[PATCH] D39174: [analyzer] Fix handling of labels in getLValueElement
Alexander Shaposhnikov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 23 16:47:05 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316399: [analyzer] Fix handling of labels in getLValueElement (authored by alexshap).
Changed prior to commit:
https://reviews.llvm.org/D39174?vs=119808&id=119972#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39174
Files:
cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
cfe/trunk/test/Analysis/ptr-arith.c
Index: cfe/trunk/test/Analysis/ptr-arith.c
===================================================================
--- cfe/trunk/test/Analysis/ptr-arith.c
+++ cfe/trunk/test/Analysis/ptr-arith.c
@@ -342,3 +342,8 @@
clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
}
+void test_no_crash_on_pointer_to_label() {
+ char *a = &&label;
+ a[0] = 0;
+label:;
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp
@@ -440,7 +440,10 @@
// value. See also the similar FIXME in getLValueFieldOrIvar().
if (Base.isUnknownOrUndef() || Base.getAs<loc::ConcreteInt>())
return Base;
-
+
+ if (Base.getAs<loc::GotoLabel>())
+ return UnknownVal();
+
const SubRegion *BaseRegion =
Base.castAs<loc::MemRegionVal>().getRegionAs<SubRegion>();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39174.119972.patch
Type: text/x-patch
Size: 938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171023/24e0d63e/attachment.bin>
More information about the cfe-commits
mailing list