forked from OSchip/llvm-project
[analyzer] Use makeZeroVal in RegionStore's lazy evaluation of statics.
No functionality change. llvm-svn: 175025
This commit is contained in:
parent
bc67170056
commit
ff0dd946b1
|
|
@ -1514,19 +1514,23 @@ SVal RegionStoreManager::getBindingForVar(RegionBindingsConstRef B,
|
||||||
return svalBuilder.getRegionValueSymbolVal(R);
|
return svalBuilder.getRegionValueSymbolVal(R);
|
||||||
|
|
||||||
if (isa<GlobalsSpaceRegion>(MS)) {
|
if (isa<GlobalsSpaceRegion>(MS)) {
|
||||||
if (isa<NonStaticGlobalSpaceRegion>(MS)) {
|
// Function-scoped static variables are default-initialized to 0; if they
|
||||||
|
// have an initializer, it would have been processed by now.
|
||||||
|
if (isa<StaticGlobalSpaceRegion>(MS))
|
||||||
|
return svalBuilder.makeZeroVal(T);
|
||||||
|
|
||||||
|
// Other globals
|
||||||
// Is 'VD' declared constant? If so, retrieve the constant value.
|
// Is 'VD' declared constant? If so, retrieve the constant value.
|
||||||
QualType CT = Ctx.getCanonicalType(T);
|
QualType CT = Ctx.getCanonicalType(T);
|
||||||
if (CT.isConstQualified()) {
|
if (CT.isConstQualified()) {
|
||||||
const Expr *Init = VD->getInit();
|
if (const Expr *Init = VD->getInit()) {
|
||||||
// Do the null check first, as we want to call 'IgnoreParenCasts'.
|
|
||||||
if (Init)
|
|
||||||
if (const IntegerLiteral *IL =
|
if (const IntegerLiteral *IL =
|
||||||
dyn_cast<IntegerLiteral>(Init->IgnoreParenCasts())) {
|
dyn_cast<IntegerLiteral>(Init->IgnoreParenCasts())) {
|
||||||
const nonloc::ConcreteInt &V = svalBuilder.makeIntVal(IL);
|
const nonloc::ConcreteInt &V = svalBuilder.makeIntVal(IL);
|
||||||
return svalBuilder.evalCast(V, Init->getType(), IL->getType());
|
return svalBuilder.evalCast(V, Init->getType(), IL->getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (const Optional<SVal> &V
|
if (const Optional<SVal> &V
|
||||||
= getBindingForDerivedDefaultValue(B, MS, R, CT))
|
= getBindingForDerivedDefaultValue(B, MS, R, CT))
|
||||||
|
|
@ -1535,14 +1539,6 @@ SVal RegionStoreManager::getBindingForVar(RegionBindingsConstRef B,
|
||||||
return svalBuilder.getRegionValueSymbolVal(R);
|
return svalBuilder.getRegionValueSymbolVal(R);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (T->isIntegerType())
|
|
||||||
return svalBuilder.makeIntVal(0, T);
|
|
||||||
if (T->isPointerType())
|
|
||||||
return svalBuilder.makeNull();
|
|
||||||
|
|
||||||
return UnknownVal();
|
|
||||||
}
|
|
||||||
|
|
||||||
return UndefinedVal();
|
return UndefinedVal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue