[PATCH] D39048: Dump signed integers in SymIntExpr and IntSymExpr correctly

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 05:00:32 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL316157: [analyzer] Dump signed integers in SymIntExpr and IntSymExpr correctly (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D39048?vs=119466&id=119569#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39048

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
  cfe/trunk/test/Analysis/expr-inspection.c


Index: cfe/trunk/test/Analysis/expr-inspection.c
===================================================================
--- cfe/trunk/test/Analysis/expr-inspection.c
+++ cfe/trunk/test/Analysis/expr-inspection.c
@@ -8,6 +8,7 @@
 
 void foo(int x) {
   clang_analyzer_dump(x); // expected-warning{{reg_$0<int x>}}
+  clang_analyzer_dump(x + (-1)); // expected-warning{{(reg_$0<int x>) + -1}}
   int y = 1;
   clang_analyzer_printState();
   for (; y < 3; ++y)
Index: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -31,14 +31,20 @@
   os << '(';
   getLHS()->dumpToStream(os);
   os << ") "
-     << BinaryOperator::getOpcodeStr(getOpcode()) << ' '
-     << getRHS().getZExtValue();
+     << BinaryOperator::getOpcodeStr(getOpcode()) << ' ';
+  if (getRHS().isUnsigned())
+    os << getRHS().getZExtValue();
+  else
+    os << getRHS().getSExtValue();
   if (getRHS().isUnsigned())
     os << 'U';
 }
 
 void IntSymExpr::dumpToStream(raw_ostream &os) const {
-  os << getLHS().getZExtValue();
+  if (getLHS().isUnsigned())
+    os << getLHS().getZExtValue();
+  else
+    os << getLHS().getSExtValue();
   if (getLHS().isUnsigned())
     os << 'U';
   os << ' '


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39048.119569.patch
Type: text/x-patch
Size: 1345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171019/46b1b3d1/attachment.bin>


More information about the cfe-commits mailing list