diff options
author | Gabor Horvath <xazax.hun@gmail.com> | 2018-01-22 13:32:10 +0000 |
---|---|---|
committer | Gabor Horvath <xazax.hun@gmail.com> | 2018-01-22 13:32:10 +0000 |
commit | 596fcb1b0f609ed285e27fffc273d6b4e6a56890 (patch) | |
tree | 49c866ba1c9749a6da076ea66c47e3ac0a8d8dcc /clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp | |
parent | e4d63a499d32d631041d6c1bcbd9f6e2309e690c (diff) | |
download | bcm5719-llvm-596fcb1b0f609ed285e27fffc273d6b4e6a56890.tar.gz bcm5719-llvm-596fcb1b0f609ed285e27fffc273d6b4e6a56890.zip |
[analyzer] Model and check unrepresentable left shifts
Patch by: Reka Nikolett Kovacs
Differential Revision: https://reviews.llvm.org/D41816
llvm-svn: 323115
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp b/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp index ec7a7e9e4b1..11658816ed2 100644 --- a/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp +++ b/clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp @@ -224,7 +224,6 @@ BasicValueFactory::evalAPSInt(BinaryOperator::Opcode Op, // FIXME: This logic should probably go higher up, where we can // test these conditions symbolically. - // FIXME: Expand these checks to include all undefined behavior. if (V1.isSigned() && V1.isNegative()) return nullptr; @@ -236,6 +235,9 @@ BasicValueFactory::evalAPSInt(BinaryOperator::Opcode Op, if (Amt >= V1.getBitWidth()) return nullptr; + if (V1.isSigned() && Amt > V1.countLeadingZeros()) + return nullptr; + return &getValue( V1.operator<<( (unsigned) Amt )); } @@ -244,8 +246,6 @@ BasicValueFactory::evalAPSInt(BinaryOperator::Opcode Op, // FIXME: This logic should probably go higher up, where we can // test these conditions symbolically. - // FIXME: Expand these checks to include all undefined behavior. - if (V2.isSigned() && V2.isNegative()) return nullptr; |