diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp index abd75a8d67bbd..2a21f60588d46 100644 --- a/clang/lib/AST/Interp/Descriptor.cpp +++ b/clang/lib/AST/Interp/Descriptor.cpp @@ -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)), diff --git a/clang/lib/AST/Interp/Descriptor.h b/clang/lib/AST/Interp/Descriptor.h index be9a380138a7b..2fd4e92082645 100644 --- a/clang/lib/AST/Interp/Descriptor.h +++ b/clang/lib/AST/Interp/Descriptor.h @@ -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. @@ -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. @@ -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. diff --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp index d1af58203bec6..e979b99b0fdd0 100644 --- a/clang/lib/AST/Interp/Pointer.cpp +++ b/clang/lib/AST/Interp/Pointer.cpp @@ -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()) diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h index 3b21290332a9d..65d710077fd1c 100644 --- a/clang/lib/AST/Interp/Pointer.h +++ b/clang/lib/AST/Interp/Pointer.h @@ -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); @@ -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. @@ -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;