@@ -267,23 +267,60 @@ class AggValueSlot {
267267 Address addr;
268268 clang::Qualifiers quals;
269269
270+ // / This is set to true if some external code is responsible for setting up a
271+ // / destructor for the slot. Otherwise the code which constructs it should
272+ // / push the appropriate cleanup.
273+ [[maybe_unused]] bool destructedFlag : 1 ;
274+
270275 // / This is set to true if the memory in the slot is known to be zero before
271276 // / the assignment into it. This means that zero fields don't need to be set.
272277 bool zeroedFlag : 1 ;
273278
279+ // / This is set to true if the slot might be aliased and it's not undefined
280+ // / behavior to access it through such an alias. Note that it's always
281+ // / undefined behavior to access a C++ object that's under construction
282+ // / through an alias derived from outside the construction process.
283+ // /
284+ // / This flag controls whether calls that produce the aggregate
285+ // / value may be evaluated directly into the slot, or whether they
286+ // / must be evaluated into an unaliased temporary and then memcpy'ed
287+ // / over. Since it's invalid in general to memcpy a non-POD C++
288+ // / object, it's important that this flag never be set when
289+ // / evaluating an expression which constructs such an object.
290+ [[maybe_unused]] bool aliasedFlag : 1 ;
291+
292+ // / This is set to true if the tail padding of this slot might overlap
293+ // / another object that may have already been initialized (and whose
294+ // / value must be preserved by this initialization). If so, we may only
295+ // / store up to the dsize of the type. Otherwise we can widen stores to
296+ // / the size of the type.
297+ [[maybe_unused]] bool overlapFlag : 1 ;
298+
274299public:
300+ enum IsDestructed_t { IsNotDestructed, IsDestructed };
275301 enum IsZeroed_t { IsNotZeroed, IsZeroed };
302+ enum IsAliased_t { IsNotAliased, IsAliased };
303+ enum Overlap_t { MayOverlap, DoesNotOverlap };
276304
277- AggValueSlot (Address addr, clang::Qualifiers quals, bool zeroedFlag)
278- : addr(addr), quals(quals), zeroedFlag(zeroedFlag) {}
305+ AggValueSlot (Address addr, clang::Qualifiers quals, bool destructedFlag,
306+ bool zeroedFlag, bool aliasedFlag, bool overlapFlag)
307+ : addr(addr), quals(quals), destructedFlag(destructedFlag),
308+ zeroedFlag (zeroedFlag), aliasedFlag(aliasedFlag),
309+ overlapFlag(overlapFlag) {}
279310
280311 static AggValueSlot forAddr (Address addr, clang::Qualifiers quals,
312+ IsDestructed_t isDestructed,
313+ IsAliased_t isAliased, Overlap_t mayOverlap,
281314 IsZeroed_t isZeroed = IsNotZeroed) {
282- return AggValueSlot (addr, quals, isZeroed);
315+ return AggValueSlot (addr, quals, isDestructed, isZeroed, isAliased,
316+ mayOverlap);
283317 }
284318
285- static AggValueSlot forLValue (const LValue &lv) {
286- return forAddr (lv.getAddress (), lv.getQuals ());
319+ static AggValueSlot forLValue (const LValue &LV, IsDestructed_t isDestructed,
320+ IsAliased_t isAliased, Overlap_t mayOverlap,
321+ IsZeroed_t isZeroed = IsNotZeroed) {
322+ return forAddr (LV.getAddress (), LV.getQuals (), isDestructed, isAliased,
323+ mayOverlap, isZeroed);
287324 }
288325
289326 clang::Qualifiers getQualifiers () const { return quals; }
0 commit comments