aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/StaticAnalyzer/Core/CallEvent.cpp13
-rw-r--r--test/Analysis/inlining/dyn-dispatch-bifurcate.cpp16
2 files changed, 3 insertions, 26 deletions
diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp
index 0f71a76842..09ba21173b 100644
--- a/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -433,21 +433,14 @@ RuntimeDefinition CXXInstanceCall::getRuntimeDefinition() const {
if (!RD || !RD->hasDefinition())
return RuntimeDefinition();
- const CXXMethodDecl *Result;
- if (MD->getParent()->isDerivedFrom(RD)) {
- // If our static type info is better than our dynamic type info, don't
- // bother doing a search. Just use the static method.
- Result = MD;
- } else {
- // Otherwise, find the decl for the method in the dynamic class.
- Result = MD->getCorrespondingMethodInClass(RD, true);
- }
-
+ // Find the decl for this method in that class.
+ const CXXMethodDecl *Result = MD->getCorrespondingMethodInClass(RD, true);
if (!Result) {
// We might not even get the original statically-resolved method due to
// some particularly nasty casting (e.g. casts to sister classes).
// However, we should at least be able to search up and down our own class
// hierarchy, and some real bugs have been caught by checking this.
+ assert(!MD->getParent()->isDerivedFrom(RD) && "Bad DynamicTypeInfo");
assert(!RD->isDerivedFrom(MD->getParent()) && "Couldn't find known method");
return RuntimeDefinition();
}
diff --git a/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp b/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
index 12dad79433..fa473aebce 100644
--- a/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
+++ b/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp
@@ -15,19 +15,3 @@ void testKnown() {
A a;
clang_analyzer_eval(a.get() == 0); // expected-warning{{TRUE}}
}
-
-
-namespace ReinterpretDisruptsDynamicTypeInfo {
- class Parent {};
-
- class Child : public Parent {
- public:
- virtual int foo() { return 42; }
- };
-
- void test(Parent *a) {
- Child *b = reinterpret_cast<Child *>(a);
- if (!b) return;
- clang_analyzer_eval(b->foo() == 42); // expected-warning{{TRUE}} expected-warning{{UNKNOWN}}
- }
-}