|
clang 23.0.0git
|
An emitter which evaluates opcodes as they are emitted. More...
#include "/work/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, const Expr *Init, bool CheckFullyInitialized) |
| EvaluationResult | interpretDestructor (const VarDecl *VD, const APValue &Value) |
| EvaluationResult | interpretAsPointer (const Expr *E, PtrCallback PtrCB) |
| Interpret the given Expr to a Pointer. | |
| EvaluationResult | interpretAsLValuePointer (const Expr *E, PtrCallback PtrCB) |
| 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 | visitLValueExpr (const Expr *E, bool DestroyToplevelScope)=0 |
| virtual bool | visitDeclAndReturn (const VarDecl *VD, const Expr *Init, bool ConstantContext)=0 |
| virtual bool | visitDtorCall (const VarDecl *VD, const APValue &Value)=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, SourceInfo SI) |
| Emits jumps. | |
| bool | jumpFalse (const LabelTy &Label, SourceInfo SI) |
| bool | jump (const LabelTy &Label, SourceInfo SI) |
| 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 *, FuncParam > | Params |
| Parameter indices. | |
| 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 31 of file EvalEmitter.h.
Definition at line 34 of file EvalEmitter.h.
| using clang::interp::EvalEmitter::LabelTy = uint32_t |
Definition at line 33 of file EvalEmitter.h.
Definition at line 35 of file EvalEmitter.h.
| using clang::interp::EvalEmitter::PtrCallback = llvm::function_ref<bool(const Pointer &)> |
Definition at line 36 of file EvalEmitter.h.
|
protected |
Definition at line 20 of file EvalEmitter.cpp.
|
protectedvirtual |
Definition at line 24 of file EvalEmitter.cpp.
References clang::interp::Block::invokeDtor(), clang::interp::Block::isInitialized(), and V.
|
inlineprotected |
Definition at line 85 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 35 of file EvalEmitter.cpp.
|
protected |
Callback for registering a local.
Definition at line 133 of file EvalEmitter.cpp.
References clang::interp::Block, clang::interp::InlineDescriptor::Desc, clang::interp::Descriptor::getAllocSize(), and clang::interp::Descriptor::IsConst.
References V.
Referenced by speculate().
|
protected |
Define a label.
Definition at line 129 of file EvalEmitter.cpp.
Definition at line 181 of file EvalEmitter.cpp.
References isActive().
|
protected |
Create a label.
Definition at line 131 of file EvalEmitter.cpp.
|
inlineoverrideprotectedvirtual |
Returns the source location of the current opcode.
Implements clang::interp::SourceMapper.
Definition at line 93 of file EvalEmitter.h.
References clang::interp::Function::getSource(), and clang::interp::Function::hasBody().
| EvaluationResult EvalEmitter::interpretAsLValuePointer | ( | const Expr * | E, |
| PtrCallback | PtrCB ) |
Definition at line 105 of file EvalEmitter.cpp.
References clang::Expr::getExprLoc(), and visitLValueExpr().
| EvaluationResult EvalEmitter::interpretAsPointer | ( | const Expr * | E, |
| PtrCallback | PtrCB ) |
Interpret the given Expr to a Pointer.
Definition at line 88 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 119 of file EvalEmitter.cpp.
References clang::FunctionDecl::parameters(), Params, and visitExpr().
| EvaluationResult EvalEmitter::interpretDecl | ( | const VarDecl * | VD, |
| const Expr * | Init, | ||
| bool | CheckFullyInitialized ) |
Definition at line 54 of file EvalEmitter.cpp.
References clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::interp::Init(), and visitDeclAndReturn().
| EvaluationResult EvalEmitter::interpretDestructor | ( | const VarDecl * | VD, |
| const APValue & | Value ) |
Definition at line 76 of file EvalEmitter.cpp.
References clang::Decl::getLocation(), and visitDtorCall().
| EvaluationResult EvalEmitter::interpretExpr | ( | const Expr * | E, |
| bool | ConvertResultToRValue = false, | ||
| bool | DestroyToplevelScope = false ) |
Definition at line 37 of file EvalEmitter.cpp.
References clang::Expr::getExprLoc(), clang::isa(), clang::Expr::isGLValue(), and visitExpr().
|
inlineprotected |
Since expressions can only jump forward, predicated execution is used to deal with if-else statements.
Definition at line 84 of file EvalEmitter.h.
Referenced by fallthrough(), jump(), jumpFalse(), jumpTrue(), and speculate().
|
protected |
Definition at line 173 of file EvalEmitter.cpp.
References isActive().
|
protected |
Definition at line 164 of file EvalEmitter.cpp.
References isActive().
|
protected |
Speculative execution.
Definition at line 188 of file EvalEmitter.cpp.
References clang::interp::CheckBCPResult(), emitBool(), clang::CallExpr::getArg(), clang::Expr::getType(), clang::Expr::HasSideEffects(), clang::Invalid, isActive(), clang::interp::PopIgnoreDiags(), clang::interp::PT_Ptr, clang::interp::PushIgnoreDiags(), and visit().
Referenced by speculate().
|
protectedpure virtual |
References clang::interp::Init().
Referenced by interpretDecl().
|
protectedpure virtual |
Referenced by interpretDestructor().
|
protectedpure virtual |
Methods implemented by the compiler.
Referenced by interpretAsPointer(), interpretCall(), and interpretExpr().
|
protectedpure virtual |
|
protectedpure virtual |
Referenced by interpretAsLValuePointer().
|
protected |
Local descriptors.
Definition at line 100 of file EvalEmitter.h.
|
protected |
Definition at line 101 of file EvalEmitter.h.
|
protected |