summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-08-15 17:33:34 +0000
committerJordan Rose <jordan_rose@apple.com>2012-08-15 17:33:34 +0000
commit31c3fa9c24c532f513d6f216e51f821a15ba2685 (patch)
treea8d3b04bf3241bec0602d20471e8f67ec8d7da1a /clang/lib/StaticAnalyzer/Core/CallEvent.cpp
parent1c0b3c6b84d34c1f20227c1678bf7045a79e87d4 (diff)
downloadbcm5719-llvm-31c3fa9c24c532f513d6f216e51f821a15ba2685.tar.gz
bcm5719-llvm-31c3fa9c24c532f513d6f216e51f821a15ba2685.zip
[analyzer] Only adjust the type of 'this' when we devirtualize a method call.
With reinterpret_cast, we can get completely unrelated types in a region hierarchy together; this was resulting in CXXBaseObjectRegions being layered directly on an (untyped) SymbolicRegion, whose symbol was from a completely different type hierarchy. This was what was causing the internal buildbot to fail. Reverts r161911, which merely masked the problem. llvm-svn: 161960
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index db48fba60e8..c625f24e07f 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -427,16 +427,17 @@ void CXXInstanceCall::getInitialStackFrameContents(
AnyFunctionCall::getInitialStackFrameContents(CalleeCtx, Bindings);
// Handle the binding of 'this' in the new stack frame.
- // We need to make sure we have the proper layering of CXXBaseObjectRegions.
SVal ThisVal = getCXXThisVal();
if (!ThisVal.isUnknown()) {
ProgramStateManager &StateMgr = getState()->getStateManager();
SValBuilder &SVB = StateMgr.getSValBuilder();
-
+
const CXXMethodDecl *MD = cast<CXXMethodDecl>(CalleeCtx->getDecl());
Loc ThisLoc = SVB.getCXXThis(MD, CalleeCtx);
- if (const MemRegion *ThisReg = ThisVal.getAsRegion()) {
+ // If we devirtualized to a different member function, we need to make sure
+ // we have the proper layering of CXXBaseObjectRegions.
+ if (MD->getCanonicalDecl() != getDecl()->getCanonicalDecl()) {
ASTContext &Ctx = SVB.getContext();
const CXXRecordDecl *Class = MD->getParent();
QualType Ty = Ctx.getPointerType(Ctx.getRecordType(Class));
@@ -445,13 +446,10 @@ void CXXInstanceCall::getInitialStackFrameContents(
bool Failed;
ThisVal = StateMgr.getStoreManager().evalDynamicCast(ThisVal, Ty, Failed);
assert(!Failed && "Calling an incorrectly devirtualized method");
-
- // If we couldn't build the correct cast, just strip off all casts.
- if (ThisVal.isUnknown())
- ThisVal = loc::MemRegionVal(ThisReg->StripCasts());
}
- Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
+ if (!ThisVal.isUnknown())
+ Bindings.push_back(std::make_pair(ThisLoc, ThisVal));
}
}
OpenPOWER on IntegriCloud