clang 22.0.0git
|
An emitter which evaluates opcodes as they are emitted. More...
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/EvalEmitter.h"
Public Types | |
using | LabelTy = uint32_t |
using | AddrTy = uintptr_t |
using | Local = Scope::Local |
using | PtrCallback = llvm::function_ref<bool(const Pointer &)> |
Public Member Functions | |
EvaluationResult | interpretExpr (const Expr *E, bool ConvertResultToRValue=false, bool DestroyToplevelScope=false) |
EvaluationResult | interpretDecl (const VarDecl *VD, bool CheckFullyInitialized) |
EvaluationResult | interpretAsPointer (const Expr *E, PtrCallback PtrCB) |
Interpret the given Expr to a Pointer. | |
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 | cleanup () |
Clean up all resources. | |
Public Member Functions inherited from clang::interp::SourceMapper | |
virtual | ~SourceMapper () |
const Expr * | getExpr (const Function *F, CodePtr PC) const |
Returns the expression if an opcode belongs to one, null otherwise. | |
SourceLocation | getLocation (const Function *F, CodePtr PC) const |
Returns the location from which an opcode originates. | |
SourceRange | getRange (const Function *F, CodePtr PC) const |
Protected Member Functions | |
EvalEmitter (Context &Ctx, Program &P, State &Parent, InterpStack &Stk) | |
virtual | ~EvalEmitter () |
void | emitLabel (LabelTy Label) |
Define a label. | |
LabelTy | getLabel () |
Create a label. | |
virtual bool | visitExpr (const Expr *E, bool DestroyToplevelScope)=0 |
Methods implemented by the compiler. | |
virtual bool | visitDeclAndReturn (const VarDecl *VD, bool ConstantContext)=0 |
virtual bool | visitFunc (const FunctionDecl *F)=0 |
virtual bool | visit (const Expr *E)=0 |
virtual bool | emitBool (bool V, const Expr *E)=0 |
bool | jumpTrue (const LabelTy &Label) |
Emits jumps. | |
bool | jumpFalse (const LabelTy &Label) |
bool | jump (const LabelTy &Label) |
bool | fallthrough (const LabelTy &Label) |
bool | speculate (const CallExpr *E, const LabelTy &EndLabel) |
Speculative execution. | |
bool | isActive () const |
Since expressions can only jump forward, predicated execution is used to deal with if-else statements. | |
bool | checkingForUndefinedBehavior () const |
Local | createLocal (Descriptor *D) |
Callback for registering a local. | |
SourceInfo | getSource (const Function *F, CodePtr PC) const override |
Returns the source location of the current opcode. |
Protected Attributes | |
llvm::DenseMap< const ParmVarDecl *, ParamOffset > | Params |
Parameter indices. | |
llvm::DenseMap< const ValueDecl *, ParamOffset > | LambdaCaptures |
Lambda captures. | |
ParamOffset | LambdaThisCapture {0, false} |
Offset of the This parameter in a lambda record. | |
llvm::SmallVector< SmallVector< Local, 8 >, 2 > | Descriptors |
Local descriptors. | |
std::optional< SourceInfo > | LocOverride = std::nullopt |
An emitter which evaluates opcodes as they are emitted.
Definition at line 30 of file EvalEmitter.h.
Definition at line 33 of file EvalEmitter.h.
using clang::interp::EvalEmitter::LabelTy = uint32_t |
Definition at line 32 of file EvalEmitter.h.
Definition at line 34 of file EvalEmitter.h.
using clang::interp::EvalEmitter::PtrCallback = llvm::function_ref<bool(const Pointer &)> |
Definition at line 35 of file EvalEmitter.h.
|
protected |
Definition at line 18 of file EvalEmitter.cpp.
|
protectedvirtual |
Definition at line 22 of file EvalEmitter.cpp.
References clang::interp::Block::invokeDtor(), clang::interp::Block::isInitialized(), and V.
|
inlineprotected |
Definition at line 78 of file EvalEmitter.h.
void EvalEmitter::cleanup | ( | ) |
Clean up all resources.
Clean up all our resources.
This needs to done in failed evaluations before we call InterpStack::clear(), because there might be a Pointer on the stack pointing into a Block in the EvalEmitter.
Definition at line 33 of file EvalEmitter.cpp.
|
protected |
Callback for registering a local.
Definition at line 108 of file EvalEmitter.cpp.
References clang::interp::Block, clang::interp::InlineDescriptor::Desc, clang::interp::Descriptor::getAllocSize(), clang::interp::InlineDescriptor::IsActive, clang::interp::InlineDescriptor::IsBase, clang::interp::InlineDescriptor::IsConst, clang::interp::InlineDescriptor::IsFieldMutable, clang::interp::InlineDescriptor::IsInitialized, and clang::interp::InlineDescriptor::Offset.
References V.
Referenced by speculate().
|
protected |
Define a label.
Definition at line 104 of file EvalEmitter.cpp.
Definition at line 152 of file EvalEmitter.cpp.
References isActive().
|
protected |
Create a label.
Definition at line 106 of file EvalEmitter.cpp.
|
inlineoverrideprotectedvirtual |
Returns the source location of the current opcode.
Implements clang::interp::SourceMapper.
Definition at line 86 of file EvalEmitter.h.
References clang::interp::Function::getSource(), and clang::interp::Function::hasBody().
EvaluationResult EvalEmitter::interpretAsPointer | ( | const Expr * | E, |
PtrCallback | PtrCB ) |
Interpret the given Expr to a Pointer.
Definition at line 76 of file EvalEmitter.cpp.
References clang::Expr::getExprLoc(), and visitExpr().
bool EvalEmitter::interpretCall | ( | const FunctionDecl * | FD, |
const Expr * | E ) |
Interpret the given expression as if it was in the body of the given function, i.e.
the parameters of the function are available for use.
Definition at line 94 of file EvalEmitter.cpp.
References clang::FunctionDecl::parameters(), Params, and visitExpr().
EvaluationResult EvalEmitter::interpretDecl | ( | const VarDecl * | VD, |
bool | CheckFullyInitialized ) |
Definition at line 52 of file EvalEmitter.cpp.
References clang::VarDecl::getAnyInitializer(), clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::interp::Init(), clang::T, and visitDeclAndReturn().
EvaluationResult EvalEmitter::interpretExpr | ( | const Expr * | E, |
bool | ConvertResultToRValue = false, | ||
bool | DestroyToplevelScope = false ) |
Definition at line 35 of file EvalEmitter.cpp.
References clang::Expr::getExprLoc(), clang::isa(), and visitExpr().
|
inlineprotected |
Since expressions can only jump forward, predicated execution is used to deal with if-else statements.
Definition at line 77 of file EvalEmitter.h.
Referenced by fallthrough(), jump(), jumpFalse(), and jumpTrue().
Definition at line 146 of file EvalEmitter.cpp.
References isActive().
Definition at line 138 of file EvalEmitter.cpp.
References isActive().
Speculative execution.
Definition at line 159 of file EvalEmitter.cpp.
References clang::interp::CheckBCPResult(), emitBool(), clang::CallExpr::getArg(), clang::Expr::getType(), clang::Expr::HasSideEffects(), clang::Invalid, clang::interp::PT_Ptr, clang::T, and visit().
Referenced by speculate().
|
protectedpure virtual |
Referenced by interpretDecl().
|
protectedpure virtual |
Methods implemented by the compiler.
Referenced by interpretAsPointer(), interpretCall(), and interpretExpr().
|
protectedpure virtual |
|
protected |
Local descriptors.
Definition at line 97 of file EvalEmitter.h.
|
protected |
Lambda captures.
Definition at line 93 of file EvalEmitter.h.
|
protected |
Offset of the This parameter in a lambda record.
Definition at line 95 of file EvalEmitter.h.
|
protected |
Definition at line 98 of file EvalEmitter.h.
|
protected |