[PATCH] D39048: Dump signed integers in SymIntExpr and IntSymExpr correctly
Balogh, Ádám via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 18 05:29:21 PDT 2017
baloghadamsoftware created this revision.
When dumping SymIntExpr or IntSymExpr signed numbers are dumped as unsigned, thus their two's complement is displayed. This small patch fixes this.
https://reviews.llvm.org/D39048
Files:
lib/StaticAnalyzer/Core/SymbolManager.cpp
test/Analysis/expr-inspection.c
Index: test/Analysis/expr-inspection.c
===================================================================
--- test/Analysis/expr-inspection.c
+++ 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: lib/StaticAnalyzer/Core/SymbolManager.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ 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.119466.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171018/4f8de54f/attachment.bin>
More information about the cfe-commits
mailing list