diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-08-22 23:17:02 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-08-22 23:17:02 +0000 |
commit | 09c6b509fec80977fe35984779ffd83669b97b0f (patch) | |
tree | db1ebe1c208b8bd18fa6fb3d4fcba9a672a2ffac /clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp | |
parent | a97914243aa536495ad5eb5cc5ded5e47be921dc (diff) | |
download | bcm5719-llvm-09c6b509fec80977fe35984779ffd83669b97b0f.tar.gz bcm5719-llvm-09c6b509fec80977fe35984779ffd83669b97b0f.zip |
[analyzer] Track the problematic subexpression in UndefResultChecker
This is tested in a subsequent commit, which allows tracking those values.
Differential Revision: https://reviews.llvm.org/D51139
llvm-svn: 340474
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp index b9a93bedca2..bbf3215e4db 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -122,6 +122,7 @@ void UndefResultChecker::checkPostStmt(const BinaryOperator *B, << ((B->getOpcode() == BinaryOperatorKind::BO_Shl) ? "left" : "right") << " shift is undefined because the right operand is negative"; + Ex = B->getRHS(); } else if ((B->getOpcode() == BinaryOperatorKind::BO_Shl || B->getOpcode() == BinaryOperatorKind::BO_Shr) && isShiftOverflow(B, C)) { @@ -130,6 +131,7 @@ void UndefResultChecker::checkPostStmt(const BinaryOperator *B, << ((B->getOpcode() == BinaryOperatorKind::BO_Shl) ? "left" : "right") << " shift is undefined due to shifting by "; + Ex = B->getRHS(); SValBuilder &SB = C.getSValBuilder(); const llvm::APSInt *I = @@ -147,6 +149,7 @@ void UndefResultChecker::checkPostStmt(const BinaryOperator *B, C.isNegative(B->getLHS())) { OS << "The result of the left shift is undefined because the left " "operand is negative"; + Ex = B->getLHS(); } else if (B->getOpcode() == BinaryOperatorKind::BO_Shl && isLeftShiftResultUnrepresentable(B, C)) { ProgramStateRef State = C.getState(); @@ -160,6 +163,7 @@ void UndefResultChecker::checkPostStmt(const BinaryOperator *B, << "\', which is unrepresentable in the unsigned version of " << "the return type \'" << B->getLHS()->getType().getAsString() << "\'"; + Ex = B->getLHS(); } else { OS << "The result of the '" << BinaryOperator::getOpcodeStr(B->getOpcode()) |