diff options
Diffstat (limited to 'lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/CallEvent.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp index 09ba21173b..0f71a76842 100644 --- a/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -433,14 +433,21 @@ RuntimeDefinition CXXInstanceCall::getRuntimeDefinition() const { if (!RD || !RD->hasDefinition()) return RuntimeDefinition(); - // Find the decl for this method in that class. - const CXXMethodDecl *Result = MD->getCorrespondingMethodInClass(RD, true); + 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); + } + 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(); } |