[PATCH] D51139: [analyzer] Track the problematic subexpression in UndefResultChecker

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 22 16:17:56 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC340474: [analyzer] Track the problematic subexpression in UndefResultChecker (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51139?vs=162087&id=162097#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51139

Files:
  lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp


Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -122,14 +122,16 @@
            << ((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)) {
 
         OS << "The result of the "
            << ((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 @@
                  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 @@
            << "\', 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())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51139.162097.patch
Type: text/x-patch
Size: 1749 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180822/1d9d6af7/attachment.bin>


More information about the cfe-commits mailing list