@@ -22,7 +22,7 @@ using namespace clang;
22
22
using namespace clang ::interp;
23
23
24
24
template <typename T>
25
- static void ctorTy (Block *, std::byte *Ptr , bool , bool , bool , bool ,
25
+ static void ctorTy (Block *, std::byte *Ptr , bool , bool , bool , bool , bool ,
26
26
const Descriptor *) {
27
27
new (Ptr ) T ();
28
28
}
@@ -41,7 +41,7 @@ static void moveTy(Block *, std::byte *Src, std::byte *Dst,
41
41
}
42
42
43
43
template <typename T>
44
- static void ctorArrayTy (Block *, std::byte *Ptr , bool , bool , bool , bool ,
44
+ static void ctorArrayTy (Block *, std::byte *Ptr , bool , bool , bool , bool , bool ,
45
45
const Descriptor *D) {
46
46
new (Ptr ) InitMapPtr (std::nullopt);
47
47
@@ -82,8 +82,8 @@ static void moveArrayTy(Block *, std::byte *Src, std::byte *Dst,
82
82
}
83
83
84
84
static void ctorArrayDesc (Block *B, std::byte *Ptr , bool IsConst,
85
- bool IsMutable, bool IsActive , bool InUnion ,
86
- const Descriptor *D) {
85
+ bool IsMutable, bool IsVolatile , bool IsActive ,
86
+ bool InUnion, const Descriptor *D) {
87
87
const unsigned NumElems = D->getNumElems ();
88
88
const unsigned ElemSize =
89
89
D->ElemDesc ->getAllocSize () + sizeof (InlineDescriptor);
@@ -104,9 +104,10 @@ static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst,
104
104
Desc->IsFieldMutable = IsMutable || D->IsMutable ;
105
105
Desc->InUnion = InUnion;
106
106
Desc->IsArrayElement = true ;
107
+ Desc->IsVolatile = IsVolatile;
107
108
108
109
if (auto Fn = D->ElemDesc ->CtorFn )
109
- Fn (B, ElemLoc, Desc->IsConst , Desc->IsFieldMutable , IsActive,
110
+ Fn (B, ElemLoc, Desc->IsConst , Desc->IsFieldMutable , IsVolatile, IsActive,
110
111
Desc->InUnion || SD->isUnion (), D->ElemDesc );
111
112
}
112
113
}
@@ -149,8 +150,8 @@ static void moveArrayDesc(Block *B, std::byte *Src, std::byte *Dst,
149
150
}
150
151
151
152
static void initField (Block *B, std::byte *Ptr , bool IsConst, bool IsMutable,
152
- bool IsActive , bool IsUnionField , bool InUnion ,
153
- const Descriptor *D, unsigned FieldOffset) {
153
+ bool IsVolatile , bool IsActive , bool IsUnionField ,
154
+ bool InUnion, const Descriptor *D, unsigned FieldOffset) {
154
155
auto *Desc = reinterpret_cast <InlineDescriptor *>(Ptr + FieldOffset) - 1 ;
155
156
Desc->Offset = FieldOffset;
156
157
Desc->Desc = D;
@@ -160,15 +161,17 @@ static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
160
161
Desc->InUnion = InUnion;
161
162
Desc->IsConst = IsConst || D->IsConst ;
162
163
Desc->IsFieldMutable = IsMutable || D->IsMutable ;
164
+ Desc->IsVolatile = IsVolatile || D->IsVolatile ;
163
165
164
166
if (auto Fn = D->CtorFn )
165
167
Fn (B, Ptr + FieldOffset, Desc->IsConst , Desc->IsFieldMutable ,
166
- Desc->IsActive , InUnion || D->isUnion (), D);
168
+ Desc->IsVolatile , Desc-> IsActive , InUnion || D->isUnion (), D);
167
169
}
168
170
169
171
static void initBase (Block *B, std::byte *Ptr , bool IsConst, bool IsMutable,
170
- bool IsActive, bool InUnion, const Descriptor *D,
171
- unsigned FieldOffset, bool IsVirtualBase) {
172
+ bool IsVolatile, bool IsActive, bool InUnion,
173
+ const Descriptor *D, unsigned FieldOffset,
174
+ bool IsVirtualBase) {
172
175
assert (D);
173
176
assert (D->ElemRecord );
174
177
assert (!D->ElemRecord ->isUnion ()); // Unions cannot be base classes.
@@ -183,28 +186,32 @@ static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
183
186
Desc->IsConst = IsConst || D->IsConst ;
184
187
Desc->IsFieldMutable = IsMutable || D->IsMutable ;
185
188
Desc->InUnion = InUnion;
189
+ Desc->IsVolatile = false ;
186
190
187
191
for (const auto &V : D->ElemRecord ->bases ())
188
- initBase (B, Ptr + FieldOffset, IsConst, IsMutable, IsActive, InUnion ,
189
- V.Desc , V.Offset , false );
192
+ initBase (B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive ,
193
+ InUnion, V.Desc , V.Offset , false );
190
194
for (const auto &F : D->ElemRecord ->fields ())
191
- initField (B, Ptr + FieldOffset, IsConst, IsMutable, IsActive, InUnion ,
192
- InUnion, F.Desc , F.Offset );
195
+ initField (B, Ptr + FieldOffset, IsConst, IsMutable, IsVolatile, IsActive ,
196
+ InUnion, InUnion, F.Desc , F.Offset );
193
197
}
194
198
195
199
static void ctorRecord (Block *B, std::byte *Ptr , bool IsConst, bool IsMutable,
196
- bool IsActive, bool InUnion, const Descriptor *D) {
200
+ bool IsVolatile, bool IsActive, bool InUnion,
201
+ const Descriptor *D) {
197
202
for (const auto &V : D->ElemRecord ->bases ())
198
- initBase (B, Ptr , IsConst, IsMutable, IsActive, InUnion, V.Desc , V.Offset ,
199
- false );
203
+ initBase (B, Ptr , IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc ,
204
+ V.Offset ,
205
+ /* IsVirtualBase=*/ false );
200
206
for (const auto &F : D->ElemRecord ->fields ()) {
201
207
bool IsUnionField = D->isUnion ();
202
- initField (B, Ptr , IsConst, IsMutable, IsActive, IsUnionField,
208
+ initField (B, Ptr , IsConst, IsMutable, IsVolatile, IsActive, IsUnionField,
203
209
InUnion || IsUnionField, F.Desc , F.Offset );
204
210
}
205
211
for (const auto &V : D->ElemRecord ->virtual_bases ())
206
- initBase (B, Ptr , IsConst, IsMutable, IsActive, InUnion, V.Desc , V.Offset ,
207
- true );
212
+ initBase (B, Ptr , IsConst, IsMutable, IsVolatile, IsActive, InUnion, V.Desc ,
213
+ V.Offset ,
214
+ /* IsVirtualBase=*/ true );
208
215
}
209
216
210
217
static void destroyField (Block *B, std::byte *Ptr , const Descriptor *D,
@@ -332,12 +339,12 @@ static BlockMoveFn getMoveArrayPrim(PrimType Type) {
332
339
// / Primitives.
333
340
Descriptor::Descriptor (const DeclTy &D, const Type *SourceTy, PrimType Type,
334
341
MetadataSize MD, bool IsConst, bool IsTemporary,
335
- bool IsMutable)
342
+ bool IsMutable, bool IsVolatile )
336
343
: Source(D), SourceType(SourceTy), ElemSize(primSize(Type)), Size(ElemSize),
337
344
MDSize(MD.value_or(0 )), AllocSize(align(Size + MDSize)), PrimT(Type),
338
345
IsConst(IsConst), IsMutable(IsMutable), IsTemporary(IsTemporary),
339
- CtorFn(getCtorPrim(Type)), DtorFn(getDtorPrim (Type)),
340
- MoveFn(getMovePrim(Type)) {
346
+ IsVolatile(IsVolatile), CtorFn(getCtorPrim (Type)),
347
+ DtorFn(getDtorPrim(Type)), MoveFn(getMovePrim(Type)) {
341
348
assert (AllocSize >= Size );
342
349
assert (Source && " Missing source" );
343
350
}
@@ -396,12 +403,13 @@ Descriptor::Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
396
403
397
404
// / Composite records.
398
405
Descriptor::Descriptor (const DeclTy &D, const Record *R, MetadataSize MD,
399
- bool IsConst, bool IsTemporary, bool IsMutable)
406
+ bool IsConst, bool IsTemporary, bool IsMutable,
407
+ bool IsVolatile)
400
408
: Source(D), ElemSize(std::max<size_t >(alignof(void *), R->getFullSize())),
401
409
Size(ElemSize), MDSize(MD.value_or(0 )), AllocSize(Size + MDSize),
402
410
ElemRecord(R), IsConst(IsConst), IsMutable(IsMutable),
403
- IsTemporary(IsTemporary), CtorFn(ctorRecord ), DtorFn(dtorRecord ),
404
- MoveFn(moveRecord) {
411
+ IsTemporary(IsTemporary), IsVolatile(IsVolatile ), CtorFn(ctorRecord ),
412
+ DtorFn(dtorRecord), MoveFn(moveRecord) {
405
413
assert (Source && " Missing source" );
406
414
}
407
415
0 commit comments