Skip to content

Commit

Permalink
[analyzer] Dump signed integers in SymIntExpr and IntSymExpr correctly
Browse files Browse the repository at this point in the history
Patch by: Adam Balogh!

Differential Revision: https://reviews.llvm.org/D39048

llvm-svn: 316157
  • Loading branch information
Xazax-hun committed Oct 19, 2017
1 parent 4f7d5ef commit d3a8570
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
Expand Up @@ -31,14 +31,20 @@ void SymIntExpr::dumpToStream(raw_ostream &os) const {
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 << ' '
Expand Down
1 change: 1 addition & 0 deletions clang/test/Analysis/expr-inspection.c
Expand Up @@ -8,6 +8,7 @@ void clang_analyzer_numTimesReached();

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)
Expand Down

0 comments on commit d3a8570

Please sign in to comment.