13#ifndef LLVM_CLANG_AST_INTERP_INTERPFRAME_H
14#define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
73 return localRef<T>(
Offset);
87 auto Pt = Params.find(
Offset);
88 if (Pt == Params.end()) {
89 return stackRef<T>(
Offset);
125 template <
typename T>
const T &stackRef(
unsigned Offset)
const {
127 return *
reinterpret_cast<const T *
>(Args - ArgSize +
Offset);
131 template <
typename T> T &localRef(
unsigned Offset)
const {
136 Block *localBlock(
unsigned Offset)
const {
137 return reinterpret_cast<Block *
>(Locals.get() +
Offset -
sizeof(Block));
141 InlineDescriptor *localInlineDesc(
unsigned Offset)
const {
142 return reinterpret_cast<InlineDescriptor *
>(Locals.get() +
Offset);
157 const unsigned ArgSize;
159 char *Args =
nullptr;
161 std::unique_ptr<char[]> Locals;
163 const size_t FrameOffset;
165 llvm::DenseMap<unsigned, std::unique_ptr<char[]>> Params;
This represents one expression.
Represents a function declaration or definition.
Encodes a location in the source.
A memory block, either on the stack or in the heap.
Pointer into the code segment.
Base class for stack frames, shared between VM and walker.
CodePtr getCodeBegin() const
Returns a pointer to the start of the code.
Frame storing local variables.
void popArgs()
Pops the arguments off the stack.
SourceLocation getCallLocation() const override
Returns the location of the call to the frame.
const Expr * getExpr(CodePtr PC) const
InterpFrame * Caller
The frame of the previous function.
virtual SourceInfo getSource(CodePtr PC) const
Map a location to a source.
CodePtr getRetPC() const
Returns the return address of the frame.
CodePtr getPC() const
Returns the PC of the frame's code start.
SourceLocation getLocation(CodePtr PC) const
~InterpFrame()
Destroys the frame, killing all live pointers to stack slots.
const Pointer & getThis() const
Returns the 'this' pointer.
void describe(llvm::raw_ostream &OS) override
Describes the frame with arguments for diagnostic purposes.
const Function * getFunction() const
Returns the current function.
size_t getFrameOffset() const
Returns the offset on the stack at which the frame starts.
void setLocal(unsigned Offset, const T &Value)
Mutates a local variable.
const T & getParam(unsigned Offset) const
Returns the value of an argument.
bool isRoot() const
Checks if the frame is a root frame - return should quit the interpreter.
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
Frame * getCaller() const override
Returns the parent frame object.
void setParam(unsigned Offset, const T &Value)
Mutates a local copy of a parameter.
void destroy(unsigned Idx)
Invokes the destructors for a scope.
const Pointer & getRVOPtr() const
Returns the RVO pointer, if the Function has one.
Pointer getParamPointer(unsigned Offset)
Returns a pointer to an argument - lazily creates a block.
const FunctionDecl * getCallee() const override
Returns the caller.
const T & getLocal(unsigned Offset) const
Returns the value of a local variable.
A pointer to a memory block, live or dead.
T & deref() const
Dereferences the pointer, if it's live.
Describes the statement/declaration an opcode was generated from.
unsigned IsInitialized
For primitive fields, it indicates if the field was initialized.