[PATCH] D55051: [Analyzer] [HOTFIX!] SValBuilder crash when `aggressive-binary-operation-simplification` enabled
Balogh, Ádám via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 30 02:27:49 PST 2018
baloghadamsoftware updated this revision to Diff 176064.
baloghadamsoftware added a comment.
Test added.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55051/new/
https://reviews.llvm.org/D55051
Files:
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
test/Analysis/svalbuilder-rearrange-comparisons.c
Index: test/Analysis/svalbuilder-rearrange-comparisons.c
===================================================================
--- test/Analysis/svalbuilder-rearrange-comparisons.c
+++ test/Analysis/svalbuilder-rearrange-comparisons.c
@@ -979,3 +979,20 @@
short a = x - 1U;
return a - y;
}
+
+unsigned gu();
+unsigned fu() {
+ unsigned x = gu();
+ // Assert that no overflows occur in this test file.
+ // Assuming that concrete integers are also within that range.
+ assert(x <= ((unsigned)UINT_MAX / 4));
+ return x;
+}
+
+void unsigned_concrete_int_no_crash() {
+ unsigned x = fu() + 1U, y = fu() + 1U;
+ clang_analyzer_denote(x - 1U, "$x");
+ clang_analyzer_denote(y - 1U, "$y");
+ clang_analyzer_express(y); // expected-warning {{$y}}
+ clang_analyzer_express(x == y); // expected-warning {{$x + 1U == $y + 1U}}
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===================================================================
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -475,9 +475,6 @@
SingleTy = ResultTy;
if (LSym->getType() != SingleTy)
return None;
- // Substracting unsigned integers is a nightmare.
- if (!SingleTy->isSignedIntegerOrEnumerationType())
- return None;
} else {
// Don't rearrange other operations.
return None;
@@ -485,6 +482,10 @@
assert(!SingleTy.isNull() && "We should have figured out the type by now!");
+ // Substracting unsigned integers is a nightmare.
+ if (!SingleTy->isSignedIntegerOrEnumerationType())
+ return None;
+
SymbolRef RSym = Rhs.getAsSymbol();
if (!RSym || RSym->getType() != SingleTy)
return None;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55051.176064.patch
Type: text/x-patch
Size: 1697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181130/bf4ba256/attachment.bin>
More information about the cfe-commits
mailing list