From 6f610707cf0919effb0c18337ca45579a37b0870 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Sun, 28 Jun 2009 13:59:24 +0000 Subject: Invalidate a field of struct type by setting its default value to conjured symbol. llvm-svn: 74408 --- clang/lib/Analysis/CFRefCount.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'clang/lib/Analysis/CFRefCount.cpp') diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index f4a28e0c19f..1010b65209f 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -2863,14 +2863,25 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, // 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())) { - const FieldRegion* FR = MRMgr.getFieldRegion(FD, R); - SVal V = ValMgr.getConjuredSymbolVal(*I, 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. + StoreManager& StoreMgr = + Eng.getStateManager().getStoreManager(); + SVal V = ValMgr.getConjuredSymbolVal(*I, + Eng.getContext().IntTy, + Count); + state = StoreMgr.setDefaultValue(state, FR, V); + } } } else if (const ArrayType *AT = Ctx.getAsArrayType(T)) { // Set the default value of the array to conjured symbol. -- cgit v1.2.3