diff options
author | Timm Bäder <tbaeder@redhat.com> | 2024-02-18 08:17:36 +0100 |
---|---|---|
committer | Timm Bäder <tbaeder@redhat.com> | 2024-02-18 18:07:29 +0100 |
commit | cc2fe7b516c1dbf1f8747ade0f17891f9990dede (patch) | |
tree | 986a52f39357cb4a36c6ef4362d88ad23a189b14 | |
parent | 41364051ac9380a6b62f61c794fc5978b2e703c9 (diff) |
[clang][Interp][NFC] Make Record::{Base,Field} member pointers const
-rw-r--r-- | clang/lib/AST/Interp/Descriptor.cpp | 4 | ||||
-rw-r--r-- | clang/lib/AST/Interp/Program.cpp | 12 | ||||
-rw-r--r-- | clang/lib/AST/Interp/Record.h | 6 |
3 files changed, 11 insertions, 11 deletions
diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp index f75a9fc4b466..ce7ed9cec3db 100644 --- a/clang/lib/AST/Interp/Descriptor.cpp +++ b/clang/lib/AST/Interp/Descriptor.cpp @@ -139,7 +139,7 @@ static void moveArrayDesc(Block *B, const std::byte *Src, std::byte *Dst, static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, bool IsActive, const Descriptor *D) { const bool IsUnion = D->ElemRecord->isUnion(); - auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase) { + auto CtorSub = [=](unsigned SubOff, const Descriptor *F, bool IsBase) { auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + SubOff) - 1; Desc->Offset = SubOff; Desc->Desc = F; @@ -161,7 +161,7 @@ static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable, } static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) { - auto DtorSub = [=](unsigned SubOff, Descriptor *F) { + auto DtorSub = [=](unsigned SubOff, const Descriptor *F) { if (auto Fn = F->DtorFn) Fn(B, Ptr + SubOff, F); }; diff --git a/clang/lib/AST/Interp/Program.cpp b/clang/lib/AST/Interp/Program.cpp index 5624d5955c04..ec6cdebcd820 100644 --- a/clang/lib/AST/Interp/Program.cpp +++ b/clang/lib/AST/Interp/Program.cpp @@ -248,7 +248,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) { // Helper to get a base descriptor. auto GetBaseDesc = [this](const RecordDecl *BD, - const Record *BR) -> Descriptor * { + const Record *BR) -> const Descriptor * { if (!BR) return nullptr; return allocateDescriptor(BD, BR, std::nullopt, /*isConst=*/false, @@ -268,9 +268,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) { // In error cases, the base might not be a RecordType. if (const auto *RT = Spec.getType()->getAs<RecordType>()) { const RecordDecl *BD = RT->getDecl(); + const Record *BR = getOrCreateRecord(BD); - Record *BR = getOrCreateRecord(BD); - if (Descriptor *Desc = GetBaseDesc(BD, BR)) { + if (const Descriptor *Desc = GetBaseDesc(BD, BR)) { BaseSize += align(sizeof(InlineDescriptor)); Bases.push_back({BD, BaseSize, Desc, BR}); BaseSize += align(BR->getSize()); @@ -284,9 +284,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) { if (const auto *RT = Spec.getType()->getAs<RecordType>()) { const RecordDecl *BD = RT->getDecl(); - Record *BR = getOrCreateRecord(BD); + const Record *BR = getOrCreateRecord(BD); - if (Descriptor *Desc = GetBaseDesc(BD, BR)) { + if (const Descriptor *Desc = GetBaseDesc(BD, BR)) { VirtSize += align(sizeof(InlineDescriptor)); VirtBases.push_back({BD, VirtSize, Desc, BR}); VirtSize += align(BR->getSize()); @@ -307,7 +307,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) { QualType FT = FD->getType(); const bool IsConst = FT.isConstQualified(); const bool IsMutable = FD->isMutable(); - Descriptor *Desc; + const Descriptor *Desc; if (std::optional<PrimType> T = Ctx.classify(FT)) { Desc = createDescriptor(FD, *T, std::nullopt, IsConst, /*isTemporary=*/false, IsMutable); diff --git a/clang/lib/AST/Interp/Record.h b/clang/lib/AST/Interp/Record.h index b0952af2d1ac..284bb468d6af 100644 --- a/clang/lib/AST/Interp/Record.h +++ b/clang/lib/AST/Interp/Record.h @@ -28,7 +28,7 @@ public: struct Field { const FieldDecl *Decl; unsigned Offset; - Descriptor *Desc; + const Descriptor *Desc; bool isBitField() const { return Decl->isBitField(); } }; @@ -36,8 +36,8 @@ public: struct Base { const RecordDecl *Decl; unsigned Offset; - Descriptor *Desc; - Record *R; + const Descriptor *Desc; + const Record *R; }; /// Mapping from identifiers to field descriptors. |