13#ifndef LLVM_CLANG_AST_INTERP_INTERPFRAME_H
14#define LLVM_CLANG_AST_INTERP_INTERPFRAME_H
37 CodePtr RetPC,
unsigned ArgSize);
44 unsigned VarArgSize = 0);
58 return "Bottom frame";
59 return Func->getName();
65 delete[]
reinterpret_cast<char *
>(F);
77 return localInlineDesc(Idx)->IsActive;
81 void describe(llvm::raw_ostream &OS)
const override;
99 template <
typename T>
const T &
getLocal(
unsigned Offset)
const {
100 return localRef<T>(Offset);
105 localRef<T>(Offset) =
Value;
106 localInlineDesc(Offset)->IsInitialized =
true;
114 template <
typename T>
const T &
getParam(
unsigned Index)
const {
115 Block *ArgBlock = argBlock(Index);
117 return stackRef<T>(Func->getParamDescriptor(Index).Offset);
118 return ArgBlock->
deref<T>();
123 argBlock(Index)->deref<T>() =
Value;
135 return stackRef<Pointer>(ThisPointerOffset);
141 assert(Func->hasRVO());
143 return stackRef<Pointer>(0);
168 void dump(llvm::raw_ostream &OS,
unsigned Indent = 0)
const;
172 template <
typename T>
const T &stackRef(
unsigned Offset)
const {
174 return *
reinterpret_cast<const T *
>(Args - ArgSize + Offset);
178 template <
typename T> T &localRef(
unsigned Offset)
const {
179 return localBlock(Offset)->
deref<T>();
183 char *locals()
const {
184 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
190 return (
reinterpret_cast<char *
>(
const_cast<InterpFrame *
>(
this))) +
195 Block *localBlock(
unsigned Offset)
const {
196 return reinterpret_cast<Block *
>(locals() + Offset -
sizeof(
Block));
200 Block *argBlock(
unsigned Index)
const {
201 unsigned ByteOffset = Func->getParamDescriptor(Index).BlockOffset;
202 return reinterpret_cast<Block *
>(args() + ByteOffset);
206 InlineDescriptor *localInlineDesc(
unsigned Offset)
const {
207 return reinterpret_cast<InlineDescriptor *
>(locals() + Offset);
218 unsigned ThisPointerOffset;
222 const unsigned ArgSize;
224 char *Args =
nullptr;
226 const size_t FrameOffset;
Expr * getExpr()
Get 'expr' part of the associated expression/statement.
This represents one expression.
Represents a function declaration or definition.
Encodes a location in the source.
A trivial tuple used to represent a source range.
A memory block, either on the stack or in the heap.
bool isInitialized() const
Returns whether the data of this block has been initialized via invoking the Ctor func.
Pointer into the code segment.
Base class for stack frames, shared between VM and walker.
unsigned getFrameSize() const
Returns the size of the function's local stack.
unsigned getNumWrittenParams() const
Returns the number of parameter this function takes when it's called, i.e excluding the instance poin...
unsigned getArgSize() const
Returns the size of the argument stack.
static void free(InterpFrame *F)
InterpFrame(InterpState &S)
Bottom Frame.
bool isLocalEnabled(unsigned Idx) const
void setParam(unsigned Index, const T &Value)
Mutates a local copy of a parameter.
InterpFrame * Caller
The frame of the previous function.
Frame * getCaller() const override
Returns the parent frame object.
SourceInfo getSource(CodePtr PC) const
Map a location to a source.
CodePtr getRetPC() const
Returns the return address of the frame.
void enableLocal(unsigned Idx)
Block * getLocalBlock(unsigned Offset) const
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.
unsigned MSVCConstexprAllowed
const Function * getFunction() const
Returns the current function.
size_t getFrameOffset() const
Returns the offset on the stack at which the frame starts.
SourceRange getRange(CodePtr PC) const
void setLocal(unsigned Offset, const T &Value)
Mutates a local variable.
bool isBottomFrame() const
bool isRoot() const
Checks if the frame is a root frame - return should quit the interpreter.
bool hasThisPointer() const
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
unsigned getDepth() const
const T & getParam(unsigned Index) const
Returns the value of an argument.
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.
std::string getName() const
bool isStdFunction() const
void initScope(unsigned Idx)
const T & getLocal(unsigned Offset) const
Returns the value of a local variable.
SourceRange getCallRange() const override
Returns the location of the call to the frame.
void describe(llvm::raw_ostream &OS) const override
Describes the frame with arguments for diagnostic purposes.
static size_t allocSize(const Function *F)
Returns the number of bytes needed to allocate an InterpFrame for the given function.
A pointer to a memory block, live or dead.
Describes the statement/declaration an opcode was generated from.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
The JSON file list parser is used to communicate input to InstallAPI.
raw_ostream & Indent(raw_ostream &Out, const unsigned int Space, bool IsDot)