diff --git a/clang/lib/AST/Interp/EvalEmitter.cpp b/clang/lib/AST/Interp/EvalEmitter.cpp index 6d89bc407aad8d..f22cca90d4f412 100644 --- a/clang/lib/AST/Interp/EvalEmitter.cpp +++ b/clang/lib/AST/Interp/EvalEmitter.cpp @@ -123,7 +123,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) { Ty = AT->getValueType(); if (auto *RT = Ty->getAs()) { - auto *Record = Ptr.getRecord(); + const auto *Record = Ptr.getRecord(); assert(Record && "Missing record descriptor"); bool Ok = true; diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp index e906f65c371c27..c3503f4a078958 100644 --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -68,7 +68,7 @@ static bool CheckActive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, } // Find the active field of the union. - Record *R = U.getRecord(); + const Record *R = U.getRecord(); assert(R && R->isUnion() && "Not a union"); const FieldDecl *ActiveField = nullptr; for (unsigned I = 0, N = R->getNumFields(); I < N; ++I) { diff --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h index ab196beb93aa36..7d9e45a0a5a206 100644 --- a/clang/lib/AST/Interp/Pointer.h +++ b/clang/lib/AST/Interp/Pointer.h @@ -247,9 +247,11 @@ class Pointer { } /// Returns the record descriptor of a class. - Record *getRecord() const { return getFieldDesc()->ElemRecord; } + const Record *getRecord() const { return getFieldDesc()->ElemRecord; } /// Returns the element record type, if this is a non-primive array. - Record *getElemRecord() const { return getFieldDesc()->ElemDesc->ElemRecord; } + const Record *getElemRecord() const { + return getFieldDesc()->ElemDesc->ElemRecord; + } /// Returns the field information. const FieldDecl *getField() const { return getFieldDesc()->asFieldDecl(); } diff --git a/clang/lib/AST/Interp/Record.h b/clang/lib/AST/Interp/Record.h index 52173fffa54474..24092f57c0d941 100644 --- a/clang/lib/AST/Interp/Record.h +++ b/clang/lib/AST/Interp/Record.h @@ -87,7 +87,7 @@ class Record final { } unsigned getNumBases() const { return Bases.size(); } - Base *getBase(unsigned I) { return &Bases[I]; } + const Base *getBase(unsigned I) const { return &Bases[I]; } using const_virtual_iter = VirtualBaseList::const_iterator; llvm::iterator_range virtual_bases() const { @@ -95,7 +95,7 @@ class Record final { } unsigned getNumVirtualBases() const { return VirtualBases.size(); } - Base *getVirtualBase(unsigned I) { return &VirtualBases[I]; } + const Base *getVirtualBase(unsigned I) const { return &VirtualBases[I]; } private: /// Constructor used by Program to create record descriptors.