Skip to content

Commit

Permalink
[clang][Interp][NFC] Make InlineDescriptor::Desc const
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Oct 26, 2023
1 parent 547dc46 commit 1217a54
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Descriptor::Descriptor(const DeclTy &D, PrimType Type, bool IsTemporary,
}

/// Arrays of composite elements.
Descriptor::Descriptor(const DeclTy &D, Descriptor *Elem, MetadataSize MD,
Descriptor::Descriptor(const DeclTy &D, const Descriptor *Elem, MetadataSize MD,
unsigned NumElems, bool IsConst, bool IsTemporary,
bool IsMutable)
: Source(D), ElemSize(Elem->getAllocSize() + sizeof(InlineDescriptor)),
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/Interp/Descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct InlineDescriptor {
/// Flag indicating if the field is mutable (if in a record).
unsigned IsFieldMutable : 1;

Descriptor *Desc;
const Descriptor *Desc;
};

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

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

/// Allocates a descriptor for an array of composites of unknown size.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ APValue Pointer::toAPValue() const {
Offset = CharUnits::Zero();
} else {
// Build the lvalue base from the block.
Descriptor *Desc = getDeclDesc();
const Descriptor *Desc = getDeclDesc();
if (auto *VD = Desc->asValueDecl())
Base = VD;
else if (auto *E = Desc->asExpr())
Expand Down
7 changes: 4 additions & 3 deletions clang/lib/AST/Interp/Pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ class Pointer {

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

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

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

/// Accessors for information about the innermost field.
Descriptor *getFieldDesc() const {
const Descriptor *getFieldDesc() const {
if (Base == 0 || Base == RootPtrMark)
return getDeclDesc();
return getInlineDesc()->Desc;
Expand Down

0 comments on commit 1217a54

Please sign in to comment.