// BindDefault is only used to initialize a region with a default value.
StoreRef BindDefault(Store store, const MemRegion *R, SVal V) {
RegionBindingsRef B = getRegionBindings(store);
- assert(!B.lookup(R, BindingKey::Default));
assert(!B.lookup(R, BindingKey::Direct));
- return StoreRef(B.addBinding(R, BindingKey::Default, V)
- .asImmutableMap()
- .getRootWithoutRetain(), *this);
+
+ BindingKey Key = BindingKey::Make(R, BindingKey::Default);
+ if (B.lookup(Key)) {
+ const SubRegion *SR = cast<SubRegion>(R);
+ assert(SR->getAsOffset().getOffset() ==
+ SR->getSuperRegion()->getAsOffset().getOffset() &&
+ "A default value must come from a super-region");
+ B = removeSubRegionBindings(B, SR);
+ } else {
+ B = B.addBinding(Key, V);
+ }
+
+ return StoreRef(B.asImmutableMap().getRootWithoutRetain(), *this);
}
/// Attempt to extract the fields of \p LCV and bind them to the struct region
// initialized twice.
}
};
+
+ class Empty {
+ public:
+ Empty();
+ };
+
+ class PairContainer : public Empty {
+ raw_pair p;
+ public:
+ PairContainer() : Empty(), p() {
+ // This previously caused a crash because the empty base class looked
+ // like an initialization of 'p'.
+ }
+ PairContainer(int) : Empty(), p() {
+ // Test inlining something else here.
+ }
+ };
+
+ class PairContainerContainer {
+ int padding;
+ PairContainer pc;
+ public:
+ PairContainerContainer() : pc(1) {}
+ };
}
namespace InitializerList {