Skip to content

Commit 1217a54

Browse files
committed
[clang][Interp][NFC] Make InlineDescriptor::Desc const
1 parent 547dc46 commit 1217a54

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

clang/lib/AST/Interp/Descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ Descriptor::Descriptor(const DeclTy &D, PrimType Type, bool IsTemporary,
262262
}
263263

264264
/// Arrays of composite elements.
265-
Descriptor::Descriptor(const DeclTy &D, Descriptor *Elem, MetadataSize MD,
265+
Descriptor::Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
266266
unsigned NumElems, bool IsConst, bool IsTemporary,
267267
bool IsMutable)
268268
: Source(D), ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),

clang/lib/AST/Interp/Descriptor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct InlineDescriptor {
7272
/// Flag indicating if the field is mutable (if in a record).
7373
unsigned IsFieldMutable : 1;
7474

75-
Descriptor *Desc;
75+
const Descriptor *Desc;
7676
};
7777

7878
/// Describes a memory block created by an allocation site.
@@ -102,7 +102,7 @@ struct Descriptor final {
102102
/// Pointer to the record, if block contains records.
103103
Record *const ElemRecord = nullptr;
104104
/// Descriptor of the array element.
105-
Descriptor *const ElemDesc = nullptr;
105+
const Descriptor *const ElemDesc = nullptr;
106106
/// Flag indicating if the block is mutable.
107107
const bool IsConst = false;
108108
/// Flag indicating if a field is mutable.
@@ -129,7 +129,7 @@ struct Descriptor final {
129129
Descriptor(const DeclTy &D, PrimType Type, bool IsTemporary, UnknownSize);
130130

131131
/// Allocates a descriptor for an array of composites.
132-
Descriptor(const DeclTy &D, Descriptor *Elem, MetadataSize MD,
132+
Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
133133
unsigned NumElems, bool IsConst, bool IsTemporary, bool IsMutable);
134134

135135
/// Allocates a descriptor for an array of composites of unknown size.

clang/lib/AST/Interp/Pointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ APValue Pointer::toAPValue() const {
9494
Offset = CharUnits::Zero();
9595
} else {
9696
// Build the lvalue base from the block.
97-
Descriptor *Desc = getDeclDesc();
97+
const Descriptor *Desc = getDeclDesc();
9898
if (auto *VD = Desc->asValueDecl())
9999
Base = VD;
100100
else if (auto *E = Desc->asExpr())

clang/lib/AST/Interp/Pointer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ class Pointer {
184184

185185
// Step into the containing array, if inside one.
186186
unsigned Next = Base - getInlineDesc()->Offset;
187-
Descriptor *Desc = Next == 0 ? getDeclDesc() : getDescriptor(Next)->Desc;
187+
const Descriptor *Desc =
188+
Next == 0 ? getDeclDesc() : getDescriptor(Next)->Desc;
188189
if (!Desc->IsArray)
189190
return *this;
190191
return Pointer(Pointee, Next, Offset);
@@ -198,7 +199,7 @@ class Pointer {
198199
bool isField() const { return Base != 0 && Base != RootPtrMark; }
199200

200201
/// Accessor for information about the declaration site.
201-
Descriptor *getDeclDesc() const { return Pointee->Desc; }
202+
const Descriptor *getDeclDesc() const { return Pointee->Desc; }
202203
SourceLocation getDeclLoc() const { return getDeclDesc()->getLocation(); }
203204

204205
/// Returns a pointer to the object of which this pointer is a field.
@@ -222,7 +223,7 @@ class Pointer {
222223
}
223224

224225
/// Accessors for information about the innermost field.
225-
Descriptor *getFieldDesc() const {
226+
const Descriptor *getFieldDesc() const {
226227
if (Base == 0 || Base == RootPtrMark)
227228
return getDeclDesc();
228229
return getInlineDesc()->Desc;

0 commit comments

Comments
 (0)