[clang][Interp][NFC] Make Record::{Base,Field} member pointers const
diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp
index f75a9fc..ce7ed9c 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -139,7 +139,7 @@
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 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 5624d59..ec6cdeb 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -248,7 +248,7 @@
// 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 @@
// 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 @@
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 @@
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 b0952af..284bb46 100644
--- a/clang/lib/AST/Interp/Record.h
+++ b/clang/lib/AST/Interp/Record.h
@@ -28,7 +28,7 @@
struct Field {
const FieldDecl *Decl;
unsigned Offset;
- Descriptor *Desc;
+ const Descriptor *Desc;
bool isBitField() const { return Decl->isBitField(); }
};
@@ -36,8 +36,8 @@
struct Base {
const RecordDecl *Decl;
unsigned Offset;
- Descriptor *Desc;
- Record *R;
+ const Descriptor *Desc;
+ const Record *R;
};
/// Mapping from identifiers to field descriptors.