Author: Timm Bäder Date: 2023-11-20T17:53:30+01:00 New Revision: 6e547ce1c072f6f086a4f44fb8168df23413f597
URL: https://github.com/llvm/llvm-project/commit/6e547ce1c072f6f086a4f44fb8168df23413f597 DIFF: https://github.com/llvm/llvm-project/commit/6e547ce1c072f6f086a4f44fb8168df23413f597.diff LOG: [clang][Interp][NFC] Add const InterpBlock::deref() overload Added: Modified: clang/lib/AST/Interp/Interp.h clang/lib/AST/Interp/InterpBlock.h Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 64b376e101c8720..4f7778bdd2ff333 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -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>()); diff --git a/clang/lib/AST/Interp/InterpBlock.h b/clang/lib/AST/Interp/InterpBlock.h index 9d0c4859fd06c15..9db82567d2d5d63 100644 --- a/clang/lib/AST/Interp/InterpBlock.h +++ b/clang/lib/AST/Interp/InterpBlock.h @@ -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() { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits