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 << ' '
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 << ' '
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits