Skip to content

Commit cc2fe7b

Browse files
committed
[clang][Interp][NFC] Make Record::{Base,Field} member pointers const
1 parent 4136405 commit cc2fe7b

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

clang/lib/AST/Interp/Descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void moveArrayDesc(Block *B, const std::byte *Src, std::byte *Dst,
139139
static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
140140
bool IsActive, const Descriptor *D) {
141141
const bool IsUnion = D->ElemRecord->isUnion();
142-
auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase) {
142+
auto CtorSub = [=](unsigned SubOff, const Descriptor *F, bool IsBase) {
143143
auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + SubOff) - 1;
144144
Desc->Offset = SubOff;
145145
Desc->Desc = F;
@@ -161,7 +161,7 @@ static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
161161
}
162162

163163
static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
164-
auto DtorSub = [=](unsigned SubOff, Descriptor *F) {
164+
auto DtorSub = [=](unsigned SubOff, const Descriptor *F) {
165165
if (auto Fn = F->DtorFn)
166166
Fn(B, Ptr + SubOff, F);
167167
};

clang/lib/AST/Interp/Program.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
248248

249249
// Helper to get a base descriptor.
250250
auto GetBaseDesc = [this](const RecordDecl *BD,
251-
const Record *BR) -> Descriptor * {
251+
const Record *BR) -> const Descriptor * {
252252
if (!BR)
253253
return nullptr;
254254
return allocateDescriptor(BD, BR, std::nullopt, /*isConst=*/false,
@@ -268,9 +268,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
268268
// In error cases, the base might not be a RecordType.
269269
if (const auto *RT = Spec.getType()->getAs<RecordType>()) {
270270
const RecordDecl *BD = RT->getDecl();
271+
const Record *BR = getOrCreateRecord(BD);
271272

272-
Record *BR = getOrCreateRecord(BD);
273-
if (Descriptor *Desc = GetBaseDesc(BD, BR)) {
273+
if (const Descriptor *Desc = GetBaseDesc(BD, BR)) {
274274
BaseSize += align(sizeof(InlineDescriptor));
275275
Bases.push_back({BD, BaseSize, Desc, BR});
276276
BaseSize += align(BR->getSize());
@@ -284,9 +284,9 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
284284

285285
if (const auto *RT = Spec.getType()->getAs<RecordType>()) {
286286
const RecordDecl *BD = RT->getDecl();
287-
Record *BR = getOrCreateRecord(BD);
287+
const Record *BR = getOrCreateRecord(BD);
288288

289-
if (Descriptor *Desc = GetBaseDesc(BD, BR)) {
289+
if (const Descriptor *Desc = GetBaseDesc(BD, BR)) {
290290
VirtSize += align(sizeof(InlineDescriptor));
291291
VirtBases.push_back({BD, VirtSize, Desc, BR});
292292
VirtSize += align(BR->getSize());
@@ -307,7 +307,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
307307
QualType FT = FD->getType();
308308
const bool IsConst = FT.isConstQualified();
309309
const bool IsMutable = FD->isMutable();
310-
Descriptor *Desc;
310+
const Descriptor *Desc;
311311
if (std::optional<PrimType> T = Ctx.classify(FT)) {
312312
Desc = createDescriptor(FD, *T, std::nullopt, IsConst,
313313
/*isTemporary=*/false, IsMutable);

clang/lib/AST/Interp/Record.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ class Record final {
2828
struct Field {
2929
const FieldDecl *Decl;
3030
unsigned Offset;
31-
Descriptor *Desc;
31+
const Descriptor *Desc;
3232
bool isBitField() const { return Decl->isBitField(); }
3333
};
3434

3535
/// Describes a base class.
3636
struct Base {
3737
const RecordDecl *Decl;
3838
unsigned Offset;
39-
Descriptor *Desc;
40-
Record *R;
39+
const Descriptor *Desc;
40+
const Record *R;
4141
};
4242

4343
/// Mapping from identifiers to field descriptors.

0 commit comments

Comments
 (0)