13#ifndef LLVM_CLANG_AST_INTERP_EVALEMITTER_H
14#define LLVM_CLANG_AST_INTERP_EVALEMITTER_H
41 bool ConvertResultToRValue =
false,
42 bool DestroyToplevelScope =
false);
44 bool CheckFullyInitialized);
80 bool ConstantContext) = 0;
100 bool isActive()
const {
return CurrentLabel == ActiveLabel; }
102 return S.checkingForUndefinedBehavior();
109 llvm::DenseMap<const ParmVarDecl *, FuncParam>
Params;
124 bool ConvertResultToRValue =
false;
127 bool CheckFullyInitialized =
false;
129 std::optional<PtrCallback> PtrCB;
134 Block *getLocal(
unsigned Index)
const {
135 assert(Index < Locals.size());
136 return reinterpret_cast<Block *
>(Locals[Index]);
139 void updateGlobalTemporaries();
152#define GET_EVAL_PROTO
153#include "Opcodes.inc"
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
This represents one expression.
Represents a function declaration or definition.
Represents a variable declaration or definition.
A memory block, either on the stack or in the heap.
Pointer into the code segment.
Holds all information required to evaluate constexpr code in a module.
EvalEmitter(Context &Ctx, Program &P, State &Parent, InterpStack &Stk, FrameAllocator &FrameAlloc)
std::optional< SourceInfo > LocOverride
llvm::DenseMap< const ParmVarDecl *, FuncParam > Params
Parameter indices.
virtual bool visitFunc(const FunctionDecl *F)=0
EvaluationResult interpretDecl(const VarDecl *VD, const Expr *Init, bool CheckFullyInitialized)
EvaluationResult interpretDestructor(const VarDecl *VD, const APValue &Value)
EvaluationResult interpretExpr(const Expr *E, bool ConvertResultToRValue=false, bool DestroyToplevelScope=false)
bool jump(const LabelTy &Label, SourceInfo SI)
bool checkingForUndefinedBehavior() const
virtual bool visit(const Expr *E)=0
bool speculate(const CallExpr *E, const LabelTy &EndLabel)
Speculative execution.
Local createLocal(const Descriptor *D)
Callback for registering a local.
std::optional< bool > interpretWithSubstitutions(const FunctionDecl *Callee, ArrayRef< const Expr * > Args, const Expr *This, const Expr *Condition)
virtual bool visitDtorCall(const VarDecl *VD, const APValue &Value)=0
bool jumpFalse(const LabelTy &Label, SourceInfo SI)
bool interpretCall(const FunctionDecl *FD, const Expr *E)
Interpret the given expression as if it was in the body of the given function, i.e.
void emitLabel(LabelTy Label)
Define a label.
bool isActive() const
Since expressions can only jump forward, predicated execution is used to deal with if-else statements...
virtual bool visitWithSubstitutions(const FunctionDecl *Callee, ArrayRef< const Expr * > Args, const Expr *This, const Expr *Condition)=0
EvaluationResult interpretAsLValuePointer(const Expr *E, PtrCallback PtrCB)
virtual bool visitExpr(const Expr *E, bool DestroyToplevelScope)=0
Methods implemented by the compiler.
bool fallthrough(const LabelTy &Label)
virtual bool visitDeclAndReturn(const VarDecl *VD, const Expr *Init, bool ConstantContext)=0
void cleanup()
Clean up all resources.
LabelTy getLabel()
Create a label.
EvaluationResult interpretAsPointer(const Expr *E, PtrCallback PtrCB)
Interpret the given Expr to a Pointer.
SourceInfo getSource(CodePtr PC) const override
Returns the source location of the current opcode.
llvm::SmallVector< SmallVector< Local, 2 >, 1 > Descriptors
Local descriptors.
virtual bool emitBool(bool V, const Expr *E)=0
bool jumpTrue(const LabelTy &Label, SourceInfo SI)
Emits jumps.
virtual bool visitLValueExpr(const Expr *E, bool DestroyToplevelScope)=0
llvm::function_ref< bool(InterpState &S, CodePtr OpPC, const Pointer &)> PtrCallback
Defines the result of an evaluation.
Allocator for function frames.
Stack frame storing temporaries and parameters.
A pointer to a memory block, live or dead.
The program contains and links the bytecode for all functions.
Describes the statement/declaration an opcode was generated from.
Interface for classes which map locations to sources.
Interface for the VM to interact with the AST walker's context.
bool This(InterpState &S, CodePtr OpPC)
bool Init(InterpState &S, CodePtr OpPC)
Top level wrappers for InstallAPI frontend operations.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
EvalStatus is a struct with detailed info about an evaluation in progress.
Describes a memory block created by an allocation site.
Information about a local's storage.