Skip to content

Commit

Permalink
[clang][Interp][NFC] Return a const pointer from Pointer::getRecord()
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Jul 4, 2023
1 parent 8b9cb75 commit df5213c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/EvalEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
Ty = AT->getValueType();

if (auto *RT = Ty->getAs<RecordType>()) {
auto *Record = Ptr.getRecord();
const auto *Record = Ptr.getRecord();
assert(Record && "Missing record descriptor");

bool Ok = true;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/AST/Interp/Pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/Interp/Record.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ 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<const_virtual_iter> virtual_bases() const {
return llvm::make_range(VirtualBases.begin(), VirtualBases.end());
}

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.
Expand Down

0 comments on commit df5213c

Please sign in to comment.