forked from OSchip/llvm-project
Fix regression in RegionStore (from BasicStore) where static variables were not treated as being implicitly initialized to 0 (and instead were getting symbolicated).
llvm-svn: 95478
This commit is contained in:
parent
4536b9a904
commit
30fe9ecac2
|
@ -1394,11 +1394,23 @@ SVal RegionStoreManager::RetrieveVar(Store store, const VarRegion *R) {
|
|||
|
||||
// Lazily derive a value for the VarRegion.
|
||||
const VarDecl *VD = R->getDecl();
|
||||
QualType T = VD->getType();
|
||||
const MemSpaceRegion *MS = R->getMemorySpace();
|
||||
|
||||
if (isa<UnknownSpaceRegion>(MS) ||
|
||||
isa<StackArgumentsSpaceRegion>(MS))
|
||||
return ValMgr.getRegionValueSymbolVal(R, T);
|
||||
|
||||
if (R->hasGlobalsOrParametersStorage() ||
|
||||
isa<UnknownSpaceRegion>(R->getMemorySpace()))
|
||||
return ValMgr.getRegionValueSymbolVal(R, VD->getType());
|
||||
if (isa<GlobalsSpaceRegion>(MS)) {
|
||||
if (VD->isFileVarDecl())
|
||||
return ValMgr.getRegionValueSymbolVal(R, T);
|
||||
|
||||
if (T->isIntegerType())
|
||||
return ValMgr.makeIntVal(0, T);
|
||||
|
||||
return UnknownVal();
|
||||
}
|
||||
|
||||
return UndefinedVal();
|
||||
}
|
||||
|
||||
|
|
|
@ -901,3 +901,10 @@ int bar_rev95274() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void rdar7582031_test_static_init_zero() {
|
||||
static unsigned x;
|
||||
if (x == 0)
|
||||
return;
|
||||
int *p = 0;
|
||||
*p = 0xDEADBEEF;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue