diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-02-23 23:34:11 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-02-23 23:34:11 +0000 |
commit | 21206d5e3167d5e8066c005c1773afc80ff50ae6 (patch) | |
tree | b9a2cad559fadbd54e95b898570a6f1f3aea9e83 /lib/StaticAnalyzer/Checkers/CStringChecker.cpp | |
parent | 9e060ca641a1f845cecb3371b3a3018d306a5198 (diff) |
Implement a warning for known shift overflows on constant shift
expressions. Consider the code:
int64_t i = 10 << 30;
This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.
The warning is currently gated behind -Wshift-overflow.
There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.
Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126342 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/CStringChecker.cpp')
0 files changed, 0 insertions, 0 deletions