summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-06-28 13:59:24 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-06-28 13:59:24 +0000
commit6f610707cf0919effb0c18337ca45579a37b0870 (patch)
tree37f44e0b9aafa648f4f0ffe988a0d240f68db577 /clang
parentd260db1238b56d0e6f04c490e44cddace5702300 (diff)
downloadbcm5719-llvm-6f610707cf0919effb0c18337ca45579a37b0870.tar.gz
bcm5719-llvm-6f610707cf0919effb0c18337ca45579a37b0870.zip
Invalidate a field of struct type by setting its default value to conjured
symbol. llvm-svn: 74408
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Analysis/CFRefCount.cpp19
-rw-r--r--clang/test/Analysis/array-struct.c11
2 files changed, 26 insertions, 4 deletions
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<GRState>& 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.
diff --git a/clang/test/Analysis/array-struct.c b/clang/test/Analysis/array-struct.c
index 438e1ccf476..4e888c82a27 100644
--- a/clang/test/Analysis/array-struct.c
+++ b/clang/test/Analysis/array-struct.c
@@ -157,3 +157,14 @@ struct s3 p[1];
void f16(struct s3 *p) {
struct s3 a = *((struct s3*) ((char*) &p[0]));
}
+
+void inv(struct s1 *);
+
+// Invalidate the struct field.
+void f17() {
+ struct s1 t;
+ int x;
+ inv(&t);
+ if (t.e.d)
+ x = 1;
+}
OpenPOWER on IntegriCloud