[PATCH] D85424: [Analyzer] Crash fix for alpha.cplusplus.IteratorRange
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 10 03:36:22 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbcc662484a95: [analyzer] Crash fix for alpha.cplusplus.IteratorRange (authored by baloghadamsoftware, committed by Balazs Benics <balazsbenics at sigmatechnology.se>).
Changed prior to commit:
https://reviews.llvm.org/D85424?vs=290967&id=329600#toc
Repository:
rG LLVM Github Monorepo
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,10 @@
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; // no-crash
+ // expected-warning at -1 {{The right operand of '-' is a garbage value}}
+ // expected-note at -2 {{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,7 @@
Value = State->getRawSVal(*ValAsLoc);
}
- if (Value.isUnknown())
+ if (Value.isUnknownOrUndef())
return;
// Incremention or decremention by 0 is never a bug.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85424.329600.patch
Type: text/x-patch
Size: 1049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210310/c14b26c5/attachment.bin>
More information about the cfe-commits
mailing list