[PATCH] D39174: [analyzer] Fix handling of labels getLValueElement
Alexander Shaposhnikov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 22 19:39:07 PDT 2017
alexshap created this revision.
Herald added subscribers: szepet, xazax.hun.
In getLValueElement Base may represent the address of a label (as in the newly-added test case),
in this case it's not a loc::MemRegionVal and Base.castAs<loc::MemRegionVal>() triggers an assert.
Test plan: make check-all
Repository:
rL LLVM
https://reviews.llvm.org/D39174
Files:
lib/StaticAnalyzer/Core/Store.cpp
test/Analysis/ptr-arith.c
Index: test/Analysis/ptr-arith.c
===================================================================
--- test/Analysis/ptr-arith.c
+++ 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: lib/StaticAnalyzer/Core/Store.cpp
===================================================================
--- lib/StaticAnalyzer/Core/Store.cpp
+++ 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.119808.patch
Type: text/x-patch
Size: 878 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171023/279fe521/attachment.bin>
More information about the cfe-commits
mailing list