|
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 |
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. | |
| 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 | 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. | |
| 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.
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 95 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 153 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 149 of file EvalEmitter.cpp.
Definition at line 201 of file EvalEmitter.cpp.
References isActive().
|
protected |
Create a label.
Definition at line 151 of file EvalEmitter.cpp.
|
inlineoverrideprotectedvirtual |
Returns the source location of the current opcode.
Implements clang::interp::SourceMapper.
Definition at line 103 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 108 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 91 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 122 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::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 132 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 94 of file EvalEmitter.h.
Referenced by fallthrough(), jump(), jumpFalse(), jumpTrue(), and speculate().
|
protected |
Definition at line 193 of file EvalEmitter.cpp.
References isActive().
|
protected |
Definition at line 184 of file EvalEmitter.cpp.
References isActive().
|
protected |
Speculative execution.
Definition at line 208 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().
|
protectedpure virtual |
References clang::Condition, and clang::interp::This().
Referenced by interpretWithSubstitutions().
|
protected |
Local descriptors.
Definition at line 110 of file EvalEmitter.h.
|
protected |
Definition at line 111 of file EvalEmitter.h.
|
protected |