[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange
Balogh, Ádám via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 10 07:40:26 PDT 2020
baloghadamsoftware updated this revision to Diff 290967.
baloghadamsoftware added a comment.
Test added. Thank you for the test @steakhal!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85424/new/
https://reviews.llvm.org/D85424
Files:
clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
clang/test/Analysis/iterator-range.cpp
Index: clang/test/Analysis/iterator-range.cpp
===================================================================
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -939,3 +939,9 @@
auto i0 = c.begin(), i1 = c.end();
ptrdiff_t len = i1 - i0; // no-crash
}
+
+int uninit_var(int n) {
+ int uninit; // expected-note{{'uninit' declared without an initial value}}
+ return n - uninit; // expected-warning{{The right operand of '-' is a garbage value}}
+ // expected-note at -1{{The right operand of '-' is a garbage value}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -228,7 +228,8 @@
Value = State->getRawSVal(*ValAsLoc);
}
- if (Value.isUnknown())
+ if (Value.isUnknownOrUndef())
+ // if (Value.isUnknownOrUndef())
return;
// Incremention or decremention by 0 is never a bug.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85424.290967.patch
Type: text/x-patch
Size: 1086 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200910/03341d12/attachment.bin>
More information about the cfe-commits
mailing list