diff --git a/clang/lib/AST/ByteCode/EvalEmitter.h b/clang/lib/AST/ByteCode/EvalEmitter.h index e81ea67adf97a..a9f87db5d7f8d 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.h +++ b/clang/lib/AST/ByteCode/EvalEmitter.h @@ -16,6 +16,7 @@ #include "EvaluationResult.h" #include "InterpState.h" #include "PrimType.h" +#include "Record.h" #include "Source.h" namespace clang { diff --git a/clang/lib/AST/ByteCode/InterpBlock.h b/clang/lib/AST/ByteCode/InterpBlock.h index ea9f44c38842e..9b3dadca6cc14 100644 --- a/clang/lib/AST/ByteCode/InterpBlock.h +++ b/clang/lib/AST/ByteCode/InterpBlock.h @@ -115,9 +115,10 @@ class Block final { return reinterpret_cast(this) + sizeof(Block); } - template T deref() const { + template const T &deref() const { return *reinterpret_cast(data()); } + template T &deref() { return *reinterpret_cast(data()); } /// Invokes the constructor. void invokeCtor() { diff --git a/clang/lib/AST/ByteCode/InterpFrame.h b/clang/lib/AST/ByteCode/InterpFrame.h index 3cdc164e4bdda..fa9de2e1e7c6d 100644 --- a/clang/lib/AST/ByteCode/InterpFrame.h +++ b/clang/lib/AST/ByteCode/InterpFrame.h @@ -14,7 +14,8 @@ #define LLVM_CLANG_AST_INTERP_INTERPFRAME_H #include "Frame.h" -#include "Program.h" +#include "InterpBlock.h" +#include "Pointer.h" namespace clang { namespace interp { @@ -93,7 +94,7 @@ class InterpFrame final : public Frame { auto Pt = Params.find(Offset); if (Pt == Params.end()) return stackRef(Offset); - return Pointer(reinterpret_cast(Pt->second.get())).deref(); + return reinterpret_cast(Pt->second.get())->deref(); } /// Mutates a local copy of a parameter. @@ -151,7 +152,7 @@ class InterpFrame final : public Frame { /// Returns an offset to a local. template T &localRef(unsigned Offset) const { - return getLocalPointer(Offset).deref(); + return localBlock(Offset)->deref(); } /// Returns a pointer to a local's block.