Skip to content

Commit 6e547ce

Browse files
committed
[clang][Interp][NFC] Add const InterpBlock::deref() overload
1 parent 5e36c64 commit 6e547ce

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ bool SetThisField(InterpState &S, CodePtr OpPC, uint32_t I) {
10041004

10051005
template <PrimType Name, class T = typename PrimConv<Name>::T>
10061006
bool GetGlobal(InterpState &S, CodePtr OpPC, uint32_t I) {
1007-
auto *B = S.P.getGlobal(I);
1007+
const Block *B = S.P.getGlobal(I);
10081008
if (B->isExtern())
10091009
return false;
10101010
S.Stk.push<T>(B->deref<T>());

clang/lib/AST/Interp/InterpBlock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ class Block final {
9898
/// Returns a view over the data.
9999
template <typename T>
100100
T &deref() { return *reinterpret_cast<T *>(data()); }
101+
template <typename T> const T &deref() const {
102+
return *reinterpret_cast<const T *>(data());
103+
}
101104

102105
/// Invokes the constructor.
103106
void invokeCtor() {

0 commit comments

Comments
 (0)