Go to the documentation of this file.
17 using namespace clang;
22 : Caller(Caller), S(S), Func(Func),
This(
std::move(
This)), RetPC(RetPC),
23 ArgSize(Func ? Func->getArgSize() : 0),
24 Args(static_cast<char *>(S.Stk.top())), FrameOffset(S.Stk.size()) {
27 Locals = std::make_unique<char[]>(FrameSize);
30 Block *B =
new (localBlock(Local.Offset))
Block(Local.Desc);
41 for (
auto &Param : Params)
69 auto printDesc = [&OS, &Ctx](
Descriptor *Desc) {
70 if (
auto *D = Desc->asDecl()) {
72 if (
auto *VD = dyn_cast<ValueDecl>(D)) {
77 if (isa<RecordDecl>(D)) {
82 if (
auto *E = Desc->asExpr()) {
86 llvm_unreachable(
"Invalid descriptor type");
94 F = F.isArrayElement() ? F.getArray().expand() : F.getBase();
97 printDesc(
P.getDeclDesc());
98 for (
auto It = Levels.rbegin(); It != Levels.rend(); ++It) {
100 OS <<
"[" << It->expand().getIndex() <<
"]";
103 if (
auto Index = It->getIndex()) {
104 OS <<
" + " << Index;
108 printDesc(It->getFieldDesc());
114 auto *M = dyn_cast<CXXMethodDecl>(F);
115 if (M && M->isInstance() && !isa<CXXConstructorDecl>(F)) {
121 for (
unsigned I = 0, N = F->getNumParams(); I < N; ++I) {
122 QualType Ty = F->getParamDecl(I)->getType();
156 assert(Offset < Func->getFrameSize() &&
"Invalid local offset.");
163 auto Pt = Params.find(Off);
164 if (Pt != Params.end()) {
165 return Pointer(
reinterpret_cast<Block *
>(Pt->second.get()));
170 size_t BlockSize =
sizeof(
Block) + Desc.second->getAllocSize();
171 auto Memory = std::make_unique<char[]>(BlockSize);
172 auto *B =
new (Memory.get())
Block(Desc.second);
175 TYPE_SWITCH(Desc.first, new (B->data()) T(stackRef<T>(Off)));
178 Params.insert({Off, std::move(Memory)});
virtual SourceInfo getSource(CodePtr PC) const
Map a location to a source.
const FunctionDecl * getDecl() const
Returns the original FunctionDecl.
void discard()
Discards the top value from the stack.
Frame * getCaller() const override
Returns the parent frame object.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
llvm::iterator_range< llvm::SmallVector< Scope, 2 >::iterator > scopes()
Range over the scope blocks.
Encodes a location in the source.
A (possibly-)qualified type.
~InterpFrame()
Destroys the frame, killing all live pointers to stack slots.
void invokeCtor()
Invokes the constructor.
A pointer to a memory block, live or dead.
SourceInfo getSource(Function *F, CodePtr PC) const override
Delegates source mapping to the mapper.
bool hasRVO() const
Checks if the first argument is a RVO pointer.
Frame storing local variables.
bool isReferenceType() const
#define TYPE_SWITCH(Expr, B)
void destroy(unsigned Idx)
Invokes the destructors for a scope.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ASTContext & getCtx() const override
A memory block, either on the stack or in the heap.
void deallocate(Block *B)
Deallocates a pointer.
PrimType
Enumeration of the primitive types of the VM.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
QualType getRecordType(const RecordDecl *Decl) const
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.
llvm::iterator_range< LocalVectorTy::iterator > locals()
const FunctionDecl * getCallee() const override
Returns the caller.
size_t primSize(PrimType Type)
Returns the size of a primitive type in bytes.
SourceLocation getLocation(Function *F, CodePtr PC) const
Returns the location from which an opcode originates.
const clang::PrintingPolicy & getPrintingPolicy() const
ParamDescriptor getParamDescriptor(unsigned Offset) const
Returns a parameter descriptor.
InterpFrame * Caller
The frame of the previous function.
InterpStack & Stk
Temporary stack.
Pointer into the code segment.
bool isConstructor() const
Checks if the function is a constructor.
SourceLocation getLocation(CodePtr PC) const
Base class for stack frames, shared between VM and walker.
Describes a memory block created by an allocation site.
llvm::iterator_range< arg_reverse_iterator > args_reverse()
const Expr * getExpr(CodePtr PC) const
Scope & getScope(unsigned Idx)
Returns a specific scope.
bool This(InterpState &S, CodePtr OpPC)
Pointer getLocalPointer(unsigned Offset)
Returns a pointer to a local variables.
const Expr * getExpr(Function *F, CodePtr PC) const
Returns the expression if an opcode belongs to one, null otherwise.
void describe(llvm::raw_ostream &OS) override
Describes the frame with arguments for diagnostic purposes.
Context & Ctx
Interpreter Context.
InterpFrame(InterpState &S, Function *Func, InterpFrame *Caller, CodePtr RetPC, Pointer &&This)
Creates a new frame for a method call.
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &, QualType)
This represents one expression.
unsigned getFrameSize() const
Returns the size of the function's local stack.
Pointer getParamPointer(unsigned Offset)
Returns a pointer to an argument - lazily creates a block.
Represents a function declaration or definition.
llvm::Optional< PrimType > classify(QualType T)
Classifies an expression.