-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
platform.h: fixed clang-analyzer-core.BitwiseShift
warnings and adjusted types of *_bit
members
#7271
platform.h: fixed clang-analyzer-core.BitwiseShift
warnings and adjusted types of *_bit
members
#7271
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -608,7 +608,7 @@ namespace ValueFlow | |
continue; | ||
Value v(val); | ||
v.intvalue = ~v.intvalue; | ||
int bits = 0; | ||
std::uint8_t bits = 0; | ||
if (tok->valueType() && | ||
tok->valueType()->sign == ValueType::Sign::UNSIGNED && | ||
tok->valueType()->pointer == 0) { | ||
|
@@ -618,7 +618,7 @@ namespace ValueFlow | |
bits = settings.platform.long_bit; | ||
} | ||
if (bits > 0 && bits < MathLib::bigint_bits) | ||
v.intvalue &= (((MathLib::biguint)1)<<bits) - 1; | ||
v.intvalue &= (1ULL<<bits) - 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. after your changes this would not work well the day we switch to 128-bit bigints.. however I guess there are plenty of other code that will not work perfectly that day. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually causes a compilation failure when using the 128-bit int. That's how I came across this. |
||
setTokenValue(parent, std::move(v), settings); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t
is treated as a character with stream insertion operators. This caused invalid dump files to be written.First, we should not write these files raw but using TinyXML2.
Second, I wonder if it would make sense to have a check which detects the usage of
uint8_t
in stream insertion operators. If you want it to a be an actual character you should probably use{unsigned|signed} char
orchar8_t
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spontanously that checker sounds reasonable to me.