26 : Caller(Caller), S(S), Depth(Caller ? Caller->Depth + 1 : 0),
Func(
Func),
27 RetPC(RetPC), ArgSize(ArgSize), Args(static_cast<char *>(S.Stk.top())),
28 FrameOffset(S.Stk.size()) {
32 unsigned FrameSize =
Func->getFrameSize();
36 Locals = std::make_unique<char[]>(FrameSize);
39 Block *B =
new (localBlock(Local.Offset))
Block(Local.Desc);
56 RVOPtr = stackRef<Pointer>(0);
58 if (
Func->hasThisPointer()) {
60 This = stackRef<Pointer>(
sizeof(
Pointer));
62 This = stackRef<Pointer>(0);
67 for (
auto &Param : Params)
76 Block *B = localBlock(Local.Offset);
108 auto printDesc = [&OS, &Ctx](
const Descriptor *Desc) {
109 if (
const auto *D = Desc->asDecl()) {
111 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
116 if (isa<RecordDecl>(D))
120 if (
const auto *E = Desc->asExpr()) {
124 llvm_unreachable(
"Invalid descriptor type");
130 for (
Pointer F =
P; !F.isRoot(); ) {
132 F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
137 Levels.erase(Levels.begin());
139 printDesc(
P.getDeclDesc());
140 for (
const auto &It : Levels) {
142 OS <<
"[" << It.expand().getIndex() <<
"]";
145 if (
auto Index = It.getIndex()) {
146 OS <<
" + " << Index;
150 printDesc(It.getFieldDesc());
156 if (
const auto *M = dyn_cast<CXXMethodDecl>(F);
157 M && M->isInstance() && !isa<CXXConstructorDecl>(F)) {
167 for (
unsigned I = 0, N = F->
getNumParams(); I < N; ++I) {
199 assert(Offset < Func->getFrameSize() &&
"Invalid local offset.");
200 return Pointer(localBlock(Offset));
205 auto Pt = Params.find(Off);
206 if (Pt != Params.end()) {
207 return Pointer(
reinterpret_cast<Block *
>(Pt->second.get()));
212 size_t BlockSize =
sizeof(
Block) + Desc.second->getAllocSize();
213 auto Memory = std::make_unique<char[]>(BlockSize);
214 auto *B =
new (Memory.get())
Block(Desc.second);
217 TYPE_SWITCH(Desc.first, new (B->data()) T(stackRef<T>(Off)));
220 Params.insert({Off, std::move(Memory)});
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &, QualType)
#define TYPE_SWITCH(Expr, B)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getRecordType(const RecordDecl *Decl) const
const clang::PrintingPolicy & getPrintingPolicy() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
This represents one expression.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
A (possibly-)qualified type.
Encodes a location in the source.
A trivial tuple used to represent a source range.
bool isReferenceType() const
A memory block, either on the stack or in the heap.
void invokeDtor()
Invokes the Destructor.
void invokeCtor()
Invokes the constructor.
bool isInitialized() const
Pointer into the code segment.
std::optional< PrimType > classify(QualType T) const
Classifies a type.
Base class for stack frames, shared between VM and walker.
Scope & getScope(unsigned Idx)
Returns a specific scope.
const FunctionDecl * getDecl() const
Returns the original FunctionDecl.
bool hasBody() const
Checks if the function already has a body attached.
bool hasThisPointer() const
llvm::iterator_range< arg_reverse_iterator > args_reverse() const
ParamDescriptor getParamDescriptor(unsigned Offset) const
Returns a parameter descriptor.
llvm::iterator_range< llvm::SmallVector< Scope, 2 >::const_iterator > scopes() const
Range over the scope blocks.
bool hasRVO() const
Checks if the first argument is a RVO pointer.
Frame storing local variables.
void popArgs()
Pops the arguments off the stack.
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.
SourceLocation getLocation(CodePtr PC) const
~InterpFrame()
Destroys the frame, killing all live pointers to stack slots.
SourceRange getRange(CodePtr PC) const
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
Frame * getCaller() const override
Returns the parent frame object.
InterpFrame(InterpState &S, const Function *Func, InterpFrame *Caller, CodePtr RetPC, unsigned ArgSize)
Creates a new frame for a method call.
void destroy(unsigned Idx)
Invokes the destructors for a scope.
Pointer getParamPointer(unsigned Offset)
Returns a pointer to an argument - lazily creates a block.
const FunctionDecl * getCallee() const override
Returns the caller.
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.
void discard()
Discards the top value from the stack.
Context & Ctx
Interpreter Context.
SourceInfo getSource(const Function *F, CodePtr PC) const override
Delegates source mapping to the mapper.
InterpStack & Stk
Temporary stack.
void deallocate(Block *B)
Deallocates a pointer.
ASTContext & getCtx() const override
A pointer to a memory block, live or dead.
llvm::iterator_range< LocalVectorTy::const_iterator > locals() const
Describes the statement/declaration an opcode was generated from.
SourceLocation getLocation(const Function *F, CodePtr PC) const
Returns the location from which an opcode originates.
SourceRange getRange(const Function *F, CodePtr PC) const
const Expr * getExpr(const Function *F, CodePtr PC) const
Returns the expression if an opcode belongs to one, null otherwise.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
PrimType
Enumeration of the primitive types of the VM.
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
The JSON file list parser is used to communicate input to InstallAPI.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Describes a memory block created by an allocation site.
Inline descriptor embedded in structures and arrays.