summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/RegionStore.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-06-23 05:43:16 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-06-23 05:43:16 +0000
commit0442e962d997bc5022ea7d03785715f6f2041a8d (patch)
tree6c4716b42c5bc32999dba68d99621ca8cbd00061 /clang/lib/Analysis/RegionStore.cpp
parent6a42ec3e709ddb9a91e81ce821e8a10e3ed8071d (diff)
downloadbcm5719-llvm-0442e962d997bc5022ea7d03785715f6f2041a8d.tar.gz
bcm5719-llvm-0442e962d997bc5022ea7d03785715f6f2041a8d.zip
If the init list is fewer than the struct fields, bind the rest fields to 0
explicitly. Make 0 value with the field type. llvm-svn: 73949
Diffstat (limited to 'clang/lib/Analysis/RegionStore.cpp')
-rw-r--r--clang/lib/Analysis/RegionStore.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp
index ff2145e26e0..0d0f83d71c0 100644
--- a/clang/lib/Analysis/RegionStore.cpp
+++ b/clang/lib/Analysis/RegionStore.cpp
@@ -1165,20 +1165,14 @@ RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V);
nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
-
- for (RecordDecl::field_iterator FI = RD->field_begin(getContext()),
- FE = RD->field_end(getContext());
+
+ RecordDecl::field_iterator FI, FE;
+
+ for (FI = RD->field_begin(getContext()), FE = RD->field_end(getContext());
FI != FE; ++FI, ++VI) {
- // There may be fewer values than fields only when we are initializing a
- // struct decl. In this case, mark the region as having default value.
- if (VI == VE) {
- // FIXME: We should bind signed/unsigned 0 according to the sign of the
- // field type.
- const NonLoc& Idx = NonLoc::MakeIntVal(getBasicVals(), 0, false);
- state = state->set<RegionDefaultValue>(R, Idx);
+ if (VI == VE)
break;
- }
QualType FTy = (*FI)->getType();
FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
@@ -1191,6 +1185,17 @@ RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
state = BindStruct(state, FR, *VI);
}
+ // There may be fewer values in the initialize list than the fields of struct.
+ while (FI != FE) {
+ QualType FTy = (*FI)->getType();
+ if (FTy->isIntegerType()) {
+ FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
+ state = Bind(state, Loc::MakeVal(FR), ValMgr.makeZeroVal(FTy));
+ }
+
+ ++FI;
+ }
+
return state;
}
OpenPOWER on IntegriCloud