summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2015-11-09 19:50:29 +0000
committerDevin Coughlin <dcoughlin@apple.com>2015-11-09 19:50:29 +0000
commit9c76869bc33c25d07d5b4ed3eacf310e3f3537cb (patch)
treef9e1d4a8dc1e48810c8c5d88ca139925c02a9b24 /clang
parent390191dacc4e3573dcd778b6afbf42db53bc2c15 (diff)
downloadbcm5719-llvm-9c76869bc33c25d07d5b4ed3eacf310e3f3537cb.tar.gz
bcm5719-llvm-9c76869bc33c25d07d5b4ed3eacf310e3f3537cb.zip
[analyzer] Fix assertion failure invalidating on const member function calls (PR25392).
We now return early when the 'this' value cannot be converted to a MemRegion. llvm-svn: 252506
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp4
-rw-r--r--clang/test/Analysis/const-method-call.cpp19
2 files changed, 22 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 32c168819bf..a07427a57e0 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -438,7 +438,9 @@ void CXXInstanceCall::getExtraInvalidatedValues(ValueList &Values,
return;
// Preserve CXXThis.
const MemRegion *ThisRegion = ThisVal.getAsRegion();
- assert(ThisRegion && "ThisValue was not a memory region");
+ if (!ThisRegion)
+ return;
+
ETraits->setTrait(ThisRegion->getBaseRegion(),
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
}
diff --git a/clang/test/Analysis/const-method-call.cpp b/clang/test/Analysis/const-method-call.cpp
index 25909f82758..b8aaeea6c3e 100644
--- a/clang/test/Analysis/const-method-call.cpp
+++ b/clang/test/Analysis/const-method-call.cpp
@@ -204,6 +204,25 @@ void PR21606()
s2().f(0);
}
+// --- PR25392 --- //
+
+struct HasConstMemberFunction {
+public:
+ void constMemberFunction() const;
+};
+
+HasConstMemberFunction hasNoReturn() { } // expected-warning {{control reaches end of non-void function}}
+
+void testUnknownWithConstMemberFunction() {
+ hasNoReturn().constMemberFunction();
+}
+
+void testNonRegionLocWithConstMemberFunction() {
+ (*((HasConstMemberFunction *)(&&label))).constMemberFunction();
+
+ label: return;
+}
+
// FIXME
// When there is a circular reference to an object and a const method is called
// the object is not invalidated because TK_PreserveContents has already been
OpenPOWER on IntegriCloud