r330605 - [analyzer] Don't crash on printing ConcreteInt of size >64 bits
Aleksei Sidorin via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 23 08:41:44 PDT 2018
Author: a.sidorin
Date: Mon Apr 23 08:41:44 2018
New Revision: 330605
URL: http://llvm.org/viewvc/llvm-project?rev=330605&view=rev
Log:
[analyzer] Don't crash on printing ConcreteInt of size >64 bits
Printing of ConcreteInts with size >64 bits resulted in assertion failure
in get[Z|S]ExtValue() because these methods are only allowed to be used
with integers of 64 max bit width. This patch fixes the issue.
Added:
cfe/trunk/test/Analysis/sval-dump-int128.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp?rev=330605&r1=330604&r2=330605&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp Mon Apr 23 08:41:44 2018
@@ -300,13 +300,9 @@ void SVal::dumpToStream(raw_ostream &os)
void NonLoc::dumpToStream(raw_ostream &os) const {
switch (getSubKind()) {
case nonloc::ConcreteIntKind: {
- const nonloc::ConcreteInt& C = castAs<nonloc::ConcreteInt>();
- if (C.getValue().isUnsigned())
- os << C.getValue().getZExtValue();
- else
- os << C.getValue().getSExtValue();
- os << ' ' << (C.getValue().isUnsigned() ? 'U' : 'S')
- << C.getValue().getBitWidth() << 'b';
+ const auto &Value = castAs<nonloc::ConcreteInt>().getValue();
+ os << Value << ' ' << (Value.isSigned() ? 'S' : 'U')
+ << Value.getBitWidth() << 'b';
break;
}
case nonloc::SymbolValKind:
Added: cfe/trunk/test/Analysis/sval-dump-int128.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/sval-dump-int128.c?rev=330605&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/sval-dump-int128.c (added)
+++ cfe/trunk/test/Analysis/sval-dump-int128.c Mon Apr 23 08:41:44 2018
@@ -0,0 +1,7 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection %s -verify
+
+void clang_analyzer_dump(unsigned __int128 x);
+
+void testDumpInt128() {
+ clang_analyzer_dump((unsigned __int128)5 << 64); // expected-warning{{92233720368547758080 U128b}}
+}
More information about the cfe-commits
mailing list