Skip to content

Commit

Permalink
[clang][Interp][NFC] Add const InterpBlock::deref() overload
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaederr committed Nov 20, 2023
1 parent 5e36c64 commit 6e547ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/AST/Interp/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ bool SetThisField(InterpState &S, CodePtr OpPC, uint32_t I) {

template <PrimType Name, class T = typename PrimConv<Name>::T>
bool GetGlobal(InterpState &S, CodePtr OpPC, uint32_t I) {
auto *B = S.P.getGlobal(I);
const Block *B = S.P.getGlobal(I);
if (B->isExtern())
return false;
S.Stk.push<T>(B->deref<T>());
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/AST/Interp/InterpBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class Block final {
/// Returns a view over the data.
template <typename T>
T &deref() { return *reinterpret_cast<T *>(data()); }
template <typename T> const T &deref() const {
return *reinterpret_cast<const T *>(data());
}

/// Invokes the constructor.
void invokeCtor() {
Expand Down

0 comments on commit 6e547ce

Please sign in to comment.