Go to the documentation of this file.
13 #ifndef LLVM_CLANG_AST_INTERP_INTERPFRAME_H
14 #define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
48 void describe(llvm::raw_ostream &OS)
override;
67 return localRef<T>(
Offset);
80 auto Pt = Params.find(
Offset);
81 if (Pt == Params.end()) {
82 return stackRef<T>(
Offset);
115 template <
typename T>
const T &stackRef(
unsigned Offset) {
116 return *
reinterpret_cast<const T *
>(Args - ArgSize +
Offset);
120 template <
typename T> T &localRef(
unsigned Offset) {
121 return *
reinterpret_cast<T *
>(Locals.get() +
Offset);
125 void *localBlock(
unsigned Offset) {
126 return Locals.get() +
Offset -
sizeof(Block);
139 const unsigned ArgSize;
141 char *Args =
nullptr;
143 std::unique_ptr<char[]> Locals;
145 const size_t FrameOffset;
147 llvm::DenseMap<unsigned, std::unique_ptr<char[]>> Params;
CodePtr getPC() const
Returns the PC of the frame's code start.
CodePtr getCodeBegin() const
Returns a pointer to the start of the code.
virtual SourceInfo getSource(CodePtr PC) const
Map a location to a source.
size_t getFrameOffset() const
Returns the offset on the stack at which the frame starts.
Frame * getCaller() const override
Returns the parent frame object.
T & deref() const
Dereferences the pointer, if it's live.
Encodes a location in the source.
~InterpFrame()
Destroys the frame, killing all live pointers to stack slots.
A pointer to a memory block, live or dead.
const Pointer & getThis() const
Returns the 'this' pointer.
Frame storing local variables.
void destroy(unsigned Idx)
Invokes the destructors for a scope.
A memory block, either on the stack or in the heap.
void setParam(unsigned Offset, const T &Value)
Mutates a local copy of a parameter.
CodePtr getRetPC() const
Returns the return address of the frame.
SourceLocation getCallLocation() const override
Returns the location of the call to the frame.
Describes the statement/declaration an opcode was generated from.
void popArgs()
Pops the arguments off the stack.
Function * getFunction() const
Returns the current function.
bool isRoot() const
Checks if the frame is a root frame - return should quit the interpreter.
const FunctionDecl * getCallee() const override
Returns the caller.
const T & getParam(unsigned Offset)
Returns the value of an argument.
const T & getLocal(unsigned Offset)
Returns the value of a local variable.
InterpFrame * Caller
The frame of the previous function.
Pointer into the code segment.
SourceLocation getLocation(CodePtr PC) const
Base class for stack frames, shared between VM and walker.
const Expr * getExpr(CodePtr PC) const
Pointer getLocalPointer(unsigned Offset)
Returns a pointer to a local variables.
void describe(llvm::raw_ostream &OS) override
Describes the frame with arguments for diagnostic purposes.
InterpFrame(InterpState &S, Function *Func, InterpFrame *Caller, CodePtr RetPC, Pointer &&This)
Creates a new frame for a method call.
void setLocal(unsigned Offset, const T &Value)
Mutates a local variable.
This represents one expression.
Pointer getParamPointer(unsigned Offset)
Returns a pointer to an argument - lazily creates a block.
Represents a function declaration or definition.