Don't add a symbolic region for 'this' if the member function is static.

llvm-svn: 128340
This commit is contained in:
Anders Carlsson 2011-03-26 14:30:44 +00:00
parent 8aef596dec
commit 642b03413f
2 changed files with 20 additions and 6 deletions

View File

@ -429,12 +429,15 @@ StoreRef BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
}
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(InitLoc->getDecl())) {
// For C++ methods add symbolic region for 'this' in initial stack frame.
QualType ThisT = MD->getThisType(StateMgr.getContext());
MemRegionManager &RegMgr = svalBuilder.getRegionManager();
const CXXThisRegion *ThisR = RegMgr.getCXXThisRegion(ThisT, InitLoc);
SVal ThisV = svalBuilder.getRegionValueSymbolVal(ThisR);
St = Bind(St.getStore(), svalBuilder.makeLoc(ThisR), ThisV);
// For C++ non-static member variables, add a symbolic region for 'this' in
// the initial stack frame.
if (MD->isInstance()) {
QualType ThisT = MD->getThisType(StateMgr.getContext());
MemRegionManager &RegMgr = svalBuilder.getRegionManager();
const CXXThisRegion *ThisR = RegMgr.getCXXThisRegion(ThisT, InitLoc);
SVal ThisV = svalBuilder.getRegionValueSymbolVal(ThisR);
St = Bind(St.getStore(), svalBuilder.makeLoc(ThisR), ThisV);
}
}
return St;

View File

@ -43,3 +43,14 @@ void *f(S* w) {
}
}
namespace {
struct C {
void *p;
static void f();
};
void C::f() { }
}