aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/Store.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-07-06 06:01:24 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-07-06 06:01:24 +0000
commit313b6dab9efcce465b68da0fed7bf422b6e5c375 (patch)
tree2dcc7e1a73b0fe9ab18fc049a1922319f9c8e785 /lib/Analysis/Store.cpp
parent9852b5bf94d4934de63da6356c651c61e81f58d9 (diff)
Further cleanup of region invalidation code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Store.cpp')
-rw-r--r--lib/Analysis/Store.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index c836de9940..deb546ae6a 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -111,17 +111,28 @@ StoreManager::CastRegion(const GRState* state, const MemRegion* R,
}
const GRState *StoreManager::InvalidateRegion(const GRState *state,
- const TypedRegion *R,
+ const MemRegion *R,
const Expr *E, unsigned Count) {
+ ASTContext& Ctx = StateMgr.getContext();
+
if (!R->isBoundable())
return state;
- ASTContext& Ctx = StateMgr.getContext();
- QualType T = R->getValueType(Ctx);
+ if (isa<AllocaRegion>(R) || isa<SymbolicRegion>(R)) {
+ // Invalidate the alloca region by setting its default value to
+ // conjured symbol. The type of the symbol is irrelavant.
+ SVal V = ValMgr.getConjuredSymbolVal(E, Ctx.IntTy, Count);
+ state = setDefaultValue(state, R, V);
+ return state;
+ }
+
+ const TypedRegion *TR = cast<TypedRegion>(R);
+
+ QualType T = TR->getValueType(Ctx);
if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
SVal V = ValMgr.getConjuredSymbolVal(E, T, Count);
- return Bind(state, ValMgr.makeLoc(R), V);
+ return Bind(state, ValMgr.makeLoc(TR), V);
}
else if (const RecordType *RT = T->getAsStructureType()) {
// FIXME: handle structs with default region value.
@@ -138,7 +149,7 @@ const GRState *StoreManager::InvalidateRegion(const GRState *state,
// For now just handle scalar fields.
FieldDecl *FD = *FI;
QualType FT = FD->getType();
- const FieldRegion* FR = MRMgr.getFieldRegion(FD, R);
+ const FieldRegion* FR = MRMgr.getFieldRegion(FD, TR);
if (Loc::IsLocType(FT) ||
(FT->isIntegerType() && FT->isScalarType())) {
@@ -158,10 +169,10 @@ const GRState *StoreManager::InvalidateRegion(const GRState *state,
// Set the default value of the array to conjured symbol.
SVal V = ValMgr.getConjuredSymbolVal(E, AT->getElementType(),
Count);
- state = setDefaultValue(state, R, V);
+ state = setDefaultValue(state, TR, V);
} else {
// Just blast away other values.
- state = Bind(state, ValMgr.makeLoc(R), UnknownVal());
+ state = Bind(state, ValMgr.makeLoc(TR), UnknownVal());
}
return state;