Author: george.karpenkov Date: Wed Aug 22 16:17:02 2018 New Revision: 340474
URL: http://llvm.org/viewvc/llvm-project?rev=340474&view=rev Log: [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 Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp?rev=340474&r1=340473&r2=340474&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp Wed Aug 22 16:17:02 2018 @@ -122,6 +122,7 @@ void UndefResultChecker::checkPostStmt(c << ((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(c << ((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(c 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(c << "\', 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()) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits