|
clang 24.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 |
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. | |
| std::optional< bool > | interpretWithSubstitutions (const FunctionDecl *Callee, ArrayRef< const Expr * > Args, const Expr *This, const Expr *Condition) |
| void | cleanup () |
| Clean up all resources. | |
| SourceInfo | getSource (CodePtr PC) const override |
| Returns the source location of the current opcode. | |
| Public Member Functions inherited from clang::interp::SourceMapper | |
| virtual | ~SourceMapper () |
| const Expr * | getExpr (CodePtr PC) const |
| Returns the expression if an opcode belongs to one, null otherwise. | |
| SourceLocation | getLocation (CodePtr PC) const |
| Returns the location from which an opcode originates. | |
| SourceRange | getRange (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 | visitWithSubstitutions (const FunctionDecl *Callee, ArrayRef< const Expr * > Args, const Expr *This, const Expr *Condition)=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. | |
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.
Definition at line 33 of file EvalEmitter.h.
Definition at line 35 of file EvalEmitter.h.
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 98 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 152 of file EvalEmitter.cpp.
References clang::interp::Block, clang::interp::InlineDescriptor::Desc, clang::interp::Descriptor::getAllocSize(), clang::interp::Descriptor::IsConst, and clang::Off.
References V.
Referenced by speculate().
|
protected |
Define a label.
Definition at line 148 of file EvalEmitter.cpp.
Definition at line 200 of file EvalEmitter.cpp.
References isActive().
|
protected |
Create a label.
Definition at line 150 of file EvalEmitter.cpp.
|
inlineoverridevirtual |
Returns the source location of the current opcode.
Implements clang::interp::SourceMapper.
Definition at line 61 of file EvalEmitter.h.
| EvaluationResult EvalEmitter::interpretAsLValuePointer | ( | const Expr * | E, |
| PtrCallback | PtrCB ) |
Definition at line 107 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 90 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 121 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(), clang::T, and visitDeclAndReturn().
| EvaluationResult EvalEmitter::interpretDestructor | ( | const VarDecl * | VD, |
| const APValue & | Value ) |
Definition at line 75 of file EvalEmitter.cpp.
References clang::interp::Dtor, 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().
| std::optional< bool > EvalEmitter::interpretWithSubstitutions | ( | const FunctionDecl * | Callee, |
| ArrayRef< const Expr * > | Args, | ||
| const Expr * | This, | ||
| const Expr * | Condition ) |
Definition at line 131 of file EvalEmitter.cpp.
References clang::Condition, clang::Result, clang::interp::This(), and visitWithSubstitutions().
|
inlineprotected |
Since expressions can only jump forward, predicated execution is used to deal with if-else statements.
Definition at line 97 of file EvalEmitter.h.
Referenced by fallthrough(), jump(), jumpFalse(), jumpTrue(), and speculate().
|
protected |
Definition at line 192 of file EvalEmitter.cpp.
References isActive().
|
protected |
Definition at line 183 of file EvalEmitter.cpp.
References isActive().
|
protected |
Speculative execution.
Definition at line 207 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(), clang::T, 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().
|
protectedpure virtual |
References clang::Condition, and clang::interp::This().
Referenced by interpretWithSubstitutions().
|
protected |
Local descriptors.
Definition at line 108 of file EvalEmitter.h.
|
protected |
Definition at line 109 of file EvalEmitter.h.
|
protected |