[clang] cc2fe7b - [clang][Interp][NFC] Make Record::{Base,Field} member pointers const
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 18 09:32:35 PST 2024
Author: Timm Bäder
Date: 2024-02-18T18:07:29+01:00
New Revision: cc2fe7b516c1dbf1f8747ade0f17891f9990dede
URL: https://github.com/llvm/llvm-project/commit/cc2fe7b516c1dbf1f8747ade0f17891f9990dede
DIFF: https://github.com/llvm/llvm-project/commit/cc2fe7b516c1dbf1f8747ade0f17891f9990dede.diff
LOG: [clang][Interp][NFC] Make Record::{Base,Field} member pointers const
Added:
Modified:
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Program.cpp
clang/lib/AST/Interp/Record.h
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp
index f75a9fc4b46650..ce7ed9cec3db3f 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 5624d5955c042c..ec6cdebcd820fa 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 b0952af2d1ac6c..284bb468d6af47 100644
--- a/clang/lib/AST/Interp/Record.h
+++ b/clang/lib/AST/Interp/Record.h
@@ -28,7 +28,7 @@ class Record final {
struct Field {
const FieldDecl *Decl;
unsigned Offset;
- Descriptor *Desc;
+ const Descriptor *Desc;
bool isBitField() const { return Decl->isBitField(); }
};
@@ -36,8 +36,8 @@ class Record final {
struct Base {
const RecordDecl *Decl;
unsigned Offset;
- Descriptor *Desc;
- Record *R;
+ const Descriptor *Desc;
+ const Record *R;
};
/// Mapping from identifiers to field descriptors.
More information about the cfe-commits
mailing list