diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2014-01-16 18:02:23 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2014-01-16 18:02:23 +0000 |
| commit | 5e21db7130f81fdcb219c31bba8a25153ce47ab8 (patch) | |
| tree | 546c2a4773766c3987f06d4531ee0896e631d1f5 /lib/StaticAnalyzer/Core/BasicValueFactory.cpp | |
| parent | f6e50b28981f58e39ea6996db1d4359107d0b92d (diff) | |
| download | clang-5e21db7130f81fdcb219c31bba8a25153ce47ab8.tar.gz clang-5e21db7130f81fdcb219c31bba8a25153ce47ab8.tar.bz2 clang-5e21db7130f81fdcb219c31bba8a25153ce47ab8.tar.xz | |
[analyzer] Shitfing a constant value by its bit width is undefined.
Citation: C++11 [expr.shift]p1 (and the equivalent text in C11).
This fixes PR18073, but the right thing to do (as noted in the FIXME) is to
have a real checker for too-large shifts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199405 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BasicValueFactory.cpp')
| -rw-r--r-- | lib/StaticAnalyzer/Core/BasicValueFactory.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/StaticAnalyzer/Core/BasicValueFactory.cpp b/lib/StaticAnalyzer/Core/BasicValueFactory.cpp index a6c400f370..8f93cee626 100644 --- a/lib/StaticAnalyzer/Core/BasicValueFactory.cpp +++ b/lib/StaticAnalyzer/Core/BasicValueFactory.cpp @@ -177,7 +177,7 @@ BasicValueFactory::evalAPSInt(BinaryOperator::Opcode Op, uint64_t Amt = V2.getZExtValue(); - if (Amt > V1.getBitWidth()) + if (Amt >= V1.getBitWidth()) return NULL; return &getValue( V1.operator<<( (unsigned) Amt )); @@ -195,7 +195,7 @@ BasicValueFactory::evalAPSInt(BinaryOperator::Opcode Op, uint64_t Amt = V2.getZExtValue(); - if (Amt > V1.getBitWidth()) + if (Amt >= V1.getBitWidth()) return NULL; return &getValue( V1.operator>>( (unsigned) Amt )); |
