MISRA rule 7.2 Require 'u' prefix when using large unsigned integer constants#2881
Conversation
danmar
left a comment
There was a problem hiding this comment.
If CI will be happy I feel this can be merged.
|
I see the failing test (Expected but not seen: 242:7.2) and will fix it. |
|
All tests are passing now so should be ready for merge. |
| if value and value.isNumber: | ||
| if variable and variable.valueType and variable.valueType.sign == 'unsigned': | ||
| if variable.valueType.type in ['char', 'short', 'int', 'long', 'long long']: | ||
| constantValue = parseUnsignedNumber(value.str, 0) |
There was a problem hiding this comment.
Instead of this parsing.. I would prefer that you use Valueflow::Value instead.
In core Cppcheck the Token class has a few utility methods: Token::hasKnownValue() , Token::hasKnownIntValue() and Token::getKnownIntValue() .. I would like that the Token class in cppcheckdata.py also had such methods and then I would like that you used these instead here.
There was a problem hiding this comment.
Ok, will look into it.
There was a problem hiding this comment.
Thanks for the advice. I am now reading values using the value flow and I could remove my custom integer parser function. Should be available in my latest commit.
MISRA rule 7.2 Require 'u' prefix when using large unsigned integer constants