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