@@ -22,7 +22,7 @@ using namespace clang;
2222using namespace clang ::interp;
2323
2424template <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 ,
2626 const Descriptor *) {
2727 new (Ptr) T ();
2828}
@@ -41,7 +41,7 @@ static void moveTy(Block *, std::byte *Src, std::byte *Dst,
4141}
4242
4343template <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 ,
4545 const Descriptor *D) {
4646 new (Ptr) InitMapPtr (std::nullopt );
4747
@@ -82,8 +82,8 @@ static void moveArrayTy(Block *, std::byte *Src, std::byte *Dst,
8282}
8383
8484static 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) {
8787 const unsigned NumElems = D->getNumElems ();
8888 const unsigned ElemSize =
8989 D->ElemDesc ->getAllocSize () + sizeof (InlineDescriptor);
@@ -104,9 +104,10 @@ static void ctorArrayDesc(Block *B, std::byte *Ptr, bool IsConst,
104104 Desc->IsFieldMutable = IsMutable || D->IsMutable ;
105105 Desc->InUnion = InUnion;
106106 Desc->IsArrayElement = true ;
107+ Desc->IsVolatile = IsVolatile;
107108
108109 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,
110111 Desc->InUnion || SD->isUnion (), D->ElemDesc );
111112 }
112113}
@@ -149,8 +150,8 @@ static void moveArrayDesc(Block *B, std::byte *Src, std::byte *Dst,
149150}
150151
151152static 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) {
154155 auto *Desc = reinterpret_cast <InlineDescriptor *>(Ptr + FieldOffset) - 1 ;
155156 Desc->Offset = FieldOffset;
156157 Desc->Desc = D;
@@ -160,15 +161,17 @@ static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
160161 Desc->InUnion = InUnion;
161162 Desc->IsConst = IsConst || D->IsConst ;
162163 Desc->IsFieldMutable = IsMutable || D->IsMutable ;
164+ Desc->IsVolatile = IsVolatile || D->IsVolatile ;
163165
164166 if (auto Fn = D->CtorFn )
165167 Fn (B, Ptr + FieldOffset, Desc->IsConst , Desc->IsFieldMutable ,
166- Desc->IsActive , InUnion || D->isUnion (), D);
168+ Desc->IsVolatile , Desc-> IsActive , InUnion || D->isUnion (), D);
167169}
168170
169171static 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) {
172175 assert (D);
173176 assert (D->ElemRecord );
174177 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,
183186 Desc->IsConst = IsConst || D->IsConst ;
184187 Desc->IsFieldMutable = IsMutable || D->IsMutable ;
185188 Desc->InUnion = InUnion;
189+ Desc->IsVolatile = false ;
186190
187191 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 );
190194 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 );
193197}
194198
195199static 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) {
197202 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 );
200206 for (const auto &F : D->ElemRecord ->fields ()) {
201207 bool IsUnionField = D->isUnion ();
202- initField (B, Ptr, IsConst, IsMutable, IsActive, IsUnionField,
208+ initField (B, Ptr, IsConst, IsMutable, IsVolatile, IsActive, IsUnionField,
203209 InUnion || IsUnionField, F.Desc , F.Offset );
204210 }
205211 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 );
208215}
209216
210217static void destroyField (Block *B, std::byte *Ptr, const Descriptor *D,
@@ -332,12 +339,12 @@ static BlockMoveFn getMoveArrayPrim(PrimType Type) {
332339// / Primitives.
333340Descriptor::Descriptor (const DeclTy &D, const Type *SourceTy, PrimType Type,
334341 MetadataSize MD, bool IsConst, bool IsTemporary,
335- bool IsMutable)
342+ bool IsMutable, bool IsVolatile )
336343 : Source(D), SourceType(SourceTy), ElemSize(primSize(Type)), Size(ElemSize),
337344 MDSize(MD.value_or(0 )), AllocSize(align(Size + MDSize)), PrimT(Type),
338345 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)) {
341348 assert (AllocSize >= Size);
342349 assert (Source && " Missing source" );
343350}
@@ -396,12 +403,13 @@ Descriptor::Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
396403
397404// / Composite records.
398405Descriptor::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)
400408 : Source(D), ElemSize(std::max<size_t >(alignof (void *), R->getFullSize())),
401409 Size(ElemSize), MDSize(MD.value_or(0 )), AllocSize(Size + MDSize),
402410 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) {
405413 assert (Source && " Missing source" );
406414}
407415
0 commit comments