aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/Store.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-07-06 03:41:27 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-07-06 03:41:27 +0000
commit43e2aafea1cdeca3a3fc849b41a92cc18e001ac0 (patch)
treec6519c06d3d06f5f04a153275def8e91e1232032 /lib/Analysis/Store.cpp
parent921bd2615956bda58dd71d610ed2533cc16e30cf (diff)
Start to gradually move region invalidation code into store manager.
No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74812 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Store.cpp')
-rw-r--r--lib/Analysis/Store.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index cb099862f0..c836de9940 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -109,3 +109,60 @@ StoreManager::CastRegion(const GRState* state, const MemRegion* R,
return CastResult(state, R);
}
+
+const GRState *StoreManager::InvalidateRegion(const GRState *state,
+ const TypedRegion *R,
+ const Expr *E, unsigned Count) {
+ if (!R->isBoundable())
+ return state;
+
+ ASTContext& Ctx = StateMgr.getContext();
+ QualType T = R->getValueType(Ctx);
+
+ if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
+ SVal V = ValMgr.getConjuredSymbolVal(E, T, Count);
+ return Bind(state, ValMgr.makeLoc(R), V);
+ }
+ else if (const RecordType *RT = T->getAsStructureType()) {
+ // FIXME: handle structs with default region value.
+ const RecordDecl *RD = RT->getDecl()->getDefinition(Ctx);
+
+ // No record definition. There is nothing we can do.
+ if (!RD)
+ return state;
+
+ // Iterate through the fields and construct new symbols.
+ for (RecordDecl::field_iterator FI=RD->field_begin(),
+ FE=RD->field_end(); FI!=FE; ++FI) {
+
+ // For now just handle scalar fields.
+ FieldDecl *FD = *FI;
+ QualType FT = FD->getType();
+ const FieldRegion* FR = MRMgr.getFieldRegion(FD, R);
+
+ if (Loc::IsLocType(FT) ||
+ (FT->isIntegerType() && FT->isScalarType())) {
+ SVal V = ValMgr.getConjuredSymbolVal(E, FT, Count);
+ state = state->bindLoc(ValMgr.makeLoc(FR), V);
+ }
+ else if (FT->isStructureType()) {
+ // set the default value of the struct field to conjured
+ // symbol. Note that the type of the symbol is irrelavant.
+ // We cannot use the type of the struct otherwise ValMgr won't
+ // give us the conjured symbol.
+ SVal V = ValMgr.getConjuredSymbolVal(E, Ctx.IntTy, Count);
+ state = setDefaultValue(state, FR, V);
+ }
+ }
+ } else if (const ArrayType *AT = Ctx.getAsArrayType(T)) {
+ // Set the default value of the array to conjured symbol.
+ SVal V = ValMgr.getConjuredSymbolVal(E, AT->getElementType(),
+ Count);
+ state = setDefaultValue(state, R, V);
+ } else {
+ // Just blast away other values.
+ state = Bind(state, ValMgr.makeLoc(R), UnknownVal());
+ }
+
+ return state;
+}