27 ArgSize(0), Args(
nullptr), FrameOffset(0) {}
32 RetPC(RetPC), ArgSize(ArgSize), Args(static_cast<char *>(S.Stk.top())),
33 FrameOffset(S.Stk.size()) {
38 for (
unsigned I = 0, N = Func->getNumWrittenParams(); I != N; ++I)
39 new (argBlock(I))
Block(S.EvalID, Func->getParamDescriptor(I).Desc);
41 if (Func->getFrameSize() == 0)
45 for (auto &Local : Scope.locals()) {
46 new (localBlock(Local.Offset)) Block(S.EvalID, Local.Desc);
49 new (localInlineDesc(Local.Offset)) InlineDescriptor(Local.Desc);
56 :
InterpFrame(S, Func, S.Current, RetPC, Func->getArgSize() + VarArgSize) {
67 if (Func->hasThisPointer())
68 ThisPointerOffset = Func->hasRVO() ?
sizeof(
Pointer) : 0;
76 for (
unsigned I = 0, N = Func->getNumWrittenParams(); I != N; ++I)
77 S.deallocate(argBlock(I));
86 if (!Func || Func->getFrameSize() == 0)
88 for (
auto &
Scope : Func->scopes()) {
90 S.deallocate(localBlock(Local.Offset));
99 for (
auto &Local : Func->getScope(Idx).locals()) {
100 localBlock(Local.Offset)->invokeCtor();
112 localInlineDesc(Idx)->IsActive =
true;
116 for (
auto &Local : Func->getScope(Idx).locals_reverse()) {
117 S.deallocate(localBlock(Local.Offset));
124 if constexpr (std::is_same_v<Pointer, T>) {
126 V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
128 if (std::optional<APValue> RValue =
V.toRValue(ASTCtx, Ty))
129 RValue->printPretty(OS, ASTCtx, Ty);
134 V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
139 if (F->isLambdaStaticInvoker())
147 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
148 MD && MD->getParent()->isAnonymousStructOrUnion())
151 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
152 Ctor && Ctor->isDefaulted() && Ctor->isTrivial() &&
153 Ctor->isCopyOrMoveConstructor() && Ctor->inits().empty())
168 bool IsMemberCall =
false;
169 bool ExplicitInstanceParam =
false;
170 if (
const auto *MD = dyn_cast<CXXMethodDecl>(F)) {
172 ExplicitInstanceParam = MD->isExplicitObjectMemberFunction();
175 if (Func->hasThisPointer() && IsMemberCall) {
176 if (
const auto *MCE = dyn_cast_if_present<CXXMemberCallExpr>(
CallExpr)) {
177 const Expr *Object = MCE->getImplicitObjectArgument();
178 Object->printPretty(OS,
nullptr,
179 S.getASTContext().getPrintingPolicy(),
181 if (Object->getType()->isPointerType())
185 }
else if (
const auto *OCE =
186 dyn_cast_if_present<CXXOperatorCallExpr>(
CallExpr)) {
187 OCE->getArg(0)->printPretty(OS,
nullptr,
188 S.getASTContext().getPrintingPolicy(),
191 }
else if (
const auto *M = dyn_cast<CXXMethodDecl>(F)) {
193 S.getASTContext().getLValueReferenceType(
194 S.getASTContext().getCanonicalTagType(M->getParent())));
206 llvm::ListSeparator Comma;
208 F->
parameters().slice(ExplicitInstanceParam)) {
223 return S.EvalLocation;
231 S.getRange(
C->Caller->Func,
C->RetPC -
sizeof(
uintptr_t));
235 return S.EvalLocation;
241 return Func->getDecl();
245 assert(Offset < Func->getFrameSize() &&
"Invalid local offset.");
246 return Pointer(localBlock(Offset));
250 return localBlock(Offset);
256 Block *B = argBlock(Index);
260 unsigned ByteOffset = Func->getParamDescriptor(Index).Offset;
264 new (B->
data()) T(stackRef<T>(ByteOffset)));
274 if (F->isConstructor() || F->isDestructor())
277 return !F->getDecl()->isImplicit();
284 return Caller->getSource(RetPC);
290 return Caller->getSource(RetPC);
296 return Caller->getExpr(RetPC);
298 return S.getExpr(Func, PC);
303 return Caller->getLocation(RetPC);
305 return S.getLocation(Func, PC);
310 return Caller->getRange(RetPC);
312 return S.getRange(Func, PC);
319 if (DC->isStdNamespace())
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx, QualType Ty)
static bool shouldSkipInBacktrace(const Function *F)
static bool funcHasUsableBody(const Function *F)
#define TYPE_SWITCH(Expr, B)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
This represents one expression.
Represents a function declaration or definition.
ArrayRef< ParmVarDecl * > parameters() const
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a parameter to a function.
A (possibly-)qualified type.
Encodes a location in the source.
A trivial tuple used to represent a source range.
bool isPointerOrReferenceType() const
A memory block, either on the stack or in the heap.
std::byte * data()
Returns a pointer to the stored data.
const Descriptor * getDescriptor() const
Returns the block's descriptor.
void invokeCtor()
Invokes the constructor.
bool isInitialized() const
Returns whether the data of this block has been initialized via invoking the Ctor func.
Pointer into the code segment.
InterpFrame(InterpState &S)
Bottom Frame.
const Expr * getExpr(CodePtr PC) const
InterpFrame * Caller
The frame of the previous function.
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
SourceLocation getLocation(CodePtr PC) const
~InterpFrame()
Destroys the frame, killing all live pointers to stack slots.
const Pointer & getThis() const
Returns the 'this' pointer.
SourceRange getRange(CodePtr PC) const
bool isBottomFrame() const
Pointer getLocalPointer(unsigned Offset) const
Returns a pointer to a local variables.
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.
bool isStdFunction() const
void initScope(unsigned Idx)
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.
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.
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.
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ Result
The result type of a method or function.
for(const auto &A :T->param_types())
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool isPrimitive() const
Checks if the descriptor is of a primitive.
PrimType getPrimType() const