clang 10.0.0git

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
clang::interp::ByteCodeExprGen< Emitter > Class Template Reference

Compilation context for expressions. More...

`#include "/work/www-prereleases/10.0.0/rc1/docsbuild/clang/lib/AST/Interp/ByteCodeExprGen.h"`

Inheritance diagram for clang::interp::ByteCodeExprGen< Emitter >:
[legend]
Collaboration diagram for clang::interp::ByteCodeExprGen< Emitter >:
[legend]

## Public Member Functions
template<typename... Tys>
| ByteCodeExprGen (Context &Ctx, Program &P, Tys &&... Args)
| Initializes the compiler and the backend emitter. More...
bool | VisitCastExpr (const CastExpr *E)
bool | VisitIntegerLiteral (const IntegerLiteral *E)
bool | VisitParenExpr (const ParenExpr *E)
bool | VisitBinaryOperator (const BinaryOperator *E)
Public Member Functions inherited from clang::StmtVisitorBase< llvm::make_const_ptr, ByteCodeExprGen< Emitter >, bool, ParamTys... >
bool | Visit (PTR(Stmt) S, ParamTys... P)
| BINOP_FALLBACK (PtrMemD) BINOP_FALLBACK(PtrMemI) BINOP_FALLBACK(Mul) BINOP_FALLBACK(Div) BINOP_FALLBACK(Rem) BINOP_FALLBACK(Add) BINOP_FALLBACK(Sub) BINOP_FALLBACK(Shl) BINOP_FALLBACK(LT) BINOP_FALLBACK(GT) BINOP_FALLBACK(LE) BINOP_FALLBACK(GE) BINOP_FALLBACK(EQ) BINOP_FALLBACK(NE) BINOP_FALLBACK(And) BINOP_FALLBACK(Xor) BINOP_FALLBACK(Or) BINOP_FALLBACK(LAnd) BINOP_FALLBACK(LOr) CAO_FALLBACK(MulAssign) CAO_FALLBACK(DivAssign) CAO_FALLBACK(RemAssign) CAO_FALLBACK(AddAssign) CAO_FALLBACK(SubAssign) CAO_FALLBACK(ShlAssign) CAO_FALLBACK(ShrAssign) CAO_FALLBACK(AndAssign) CAO_FALLBACK(OrAssign) UNARYOP_FALLBACK(PostInc) UNARYOP_FALLBACK(PostDec) UNARYOP_FALLBACK(PreInc) UNARYOP_FALLBACK(PreDec) UNARYOP_FALLBACK(AddrOf) UNARYOP_FALLBACK(Deref) UNARYOP_FALLBACK(Plus) UNARYOP_FALLBACK(Minus) UNARYOP_FALLBACK(Not) UNARYOP_FALLBACK(LNot) UNARYOP_FALLBACK(Real) UNARYOP_FALLBACK(Imag) UNARYOP_FALLBACK(Extension) UNARYOP_FALLBACK(Coawait) bool VisitStmt(PTR(Stmt) Node

## Protected Types
using | NullaryFn = bool(ByteCodeExprGen::*)(const SourceInfo &)
using | UnaryFn = bool(ByteCodeExprGen::*)(PrimType, const SourceInfo &)
using | BinaryFn = bool(ByteCodeExprGen::*)(PrimType, PrimType, const SourceInfo &)
using | LabelTy = typename Emitter::LabelTy
using | AddrTy = typename Emitter::AddrTy
using | InitFnRef = std::function< bool()>

## Protected Member Functions
bool | visitExpr (const Expr *E) override
bool | visitDecl (const VarDecl *VD) override
void | emitCleanup ()
| Emits scope cleanup instructions. More...
const RecordType * | getRecordTy (QualType Ty)
| Returns a record type from a record or pointer type. More...
Record * | getRecord (QualType Ty)
| Returns a record from a record or pointer type. More...
Record * | getRecord (const RecordDecl *RD)
unsigned | getIntWidth (QualType Ty)
| Returns the size int bits of an integer. More...
unsigned | getCharBit () const
| Returns the value of CHAR_BIT. More...
llvm::Optional< PrimType > | classify (const Expr *E) const
| Classifies a type. More...
llvm::Optional< PrimType > | classify (QualType Ty) const
bool | needsAdjust (QualType Ty) const
| Checks if a pointer needs adjustment. More...
PrimType | classifyPrim (QualType Ty) const
| Classifies a known primitive type. More...
bool | discard (const Expr *E)
| Evaluates an expression for side effects and discards the result. More...
bool | visit (const Expr *E)
| Evaluates an expression and places result on stack. More...
bool | visitInitializer (const Expr *E, InitFnRef GenPtr)
| Compiles an initializer for a local. More...
bool | visitBool (const Expr *E)
| Visits an expression and converts it to a boolean. More...
bool | visitLocalInitializer (const Expr *Init, unsigned I)
| Visits an initializer for a local. More...
bool | visitGlobalInitializer (const Expr *Init, unsigned I)
| Visits an initializer for a global. More...
bool | visitThisInitializer (const Expr *I)
| Visits a delegated initializer. More...
unsigned | allocateLocalPrimitive (DeclTy &&Decl, PrimType Ty, bool IsMutable, bool IsExtended=false)
| Creates a local primitive value. More...
llvm::Optional< unsigned > | allocateLocal (DeclTy &&Decl, bool IsExtended=false)
| Allocates a space storing a local given its type. More...

## Protected Attributes
Context & | Ctx
| Current compilation context. More...
Program & | P
| Program to link to. More...
llvm::DenseMap< const ValueDecl *, Scope::Local > | Locals
| Variable to storage mapping. More...
llvm::DenseMap< const OpaqueValueExpr *, unsigned > | OpaqueExprs
| OpaqueValueExpr to location mapping. More...
VariableScope< Emitter > * | VarScope = nullptr
| Current scope. More...
llvm::Optional< uint64_t > | ArrayIndex
| Current argument index. More...
bool | DiscardResult = false
| Flag indicating if return value is to be discarded. More...
llvm::Optional< InitFnRef > | InitFn = {}
| Expression being initialized. More...

## Friends
class | VariableScope< Emitter >
class | LocalScope< Emitter >
class | RecordScope< Emitter >
class | DeclScope< Emitter >
class | OptionScope< Emitter >

## Additional Inherited Members
Public Attributes inherited from clang::StmtVisitorBase< llvm::make_const_ptr, ByteCodeExprGen< Emitter >, bool, ParamTys... >
ParamTys | P

## Detailed Description

### template<class Emitter>
class clang::interp::ByteCodeExprGen< Emitter >

Compilation context for expressions.

Definition at line 41 of file ByteCodeExprGen.h.

## Member Typedef Documentation

## ◆ AddrTy

template<class Emitter>

using clang::interp::ByteCodeExprGen< Emitter >::AddrTy = typename Emitter::AddrTy
| protected

Definition at line 52 of file ByteCodeExprGen.h.

## ◆ BinaryFn

template<class Emitter>

using clang::interp::ByteCodeExprGen< Emitter >::BinaryFn = bool (ByteCodeExprGen::*)(PrimType, PrimType, const SourceInfo &)
| protected

Definition at line 48 of file ByteCodeExprGen.h.

## ◆ InitFnRef

template<class Emitter>

using clang::interp::ByteCodeExprGen< Emitter >::InitFnRef = std::function<bool()>
| protected

Definition at line 55 of file ByteCodeExprGen.h.

## ◆ LabelTy

template<class Emitter>

using clang::interp::ByteCodeExprGen< Emitter >::LabelTy = typename Emitter::LabelTy
| protected

Definition at line 51 of file ByteCodeExprGen.h.

## ◆ NullaryFn

template<class Emitter>

using clang::interp::ByteCodeExprGen< Emitter >::NullaryFn = bool (ByteCodeExprGen::*)(const SourceInfo &)
| protected

Definition at line 45 of file ByteCodeExprGen.h.

## ◆ UnaryFn

template<class Emitter>

using clang::interp::ByteCodeExprGen< Emitter >::UnaryFn = bool (ByteCodeExprGen::*)(PrimType, const SourceInfo &)
| protected

Definition at line 46 of file ByteCodeExprGen.h.

## Constructor & Destructor Documentation

## ◆ ByteCodeExprGen()

template<class Emitter>
template<typename... Tys>

clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen | ( | Context & | Ctx,
|  | Program & | P,
|  | Tys &&... | Args
| ) |  |
| inline

Initializes the compiler and the backend emitter.

Definition at line 65 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::emitCleanup(), clang::interp::ByteCodeExprGen< Emitter >::getRecord(), clang::interp::ByteCodeExprGen< Emitter >::getRecordTy(), clang::interp::ByteCodeExprGen< Emitter >::VisitBinaryOperator(), clang::interp::ByteCodeExprGen< Emitter >::VisitCastExpr(), clang::interp::ByteCodeExprGen< Emitter >::visitDecl(), clang::interp::ByteCodeExprGen< Emitter >::visitExpr(), clang::interp::ByteCodeExprGen< Emitter >::VisitIntegerLiteral(), and clang::interp::ByteCodeExprGen< Emitter >::VisitParenExpr().

## Member Function Documentation

## ◆ allocateLocal()

template<class Emitter >

llvm::Optional< unsigned > ByteCodeExprGen::allocateLocal | ( | DeclTy && | Decl,
|  | bool | IsExtended = `false`
| ) |  |
| protected

Allocates a space storing a local given its type.

Definition at line 437 of file ByteCodeExprGen.cpp.

References clang::Expr::getType(), clang::ValueDecl::getType(), clang::QualType::getTypePtr(), clang::QualType::isConstQualified(), clang::interp::Scope::Local::Offset, and P.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().

## ◆ allocateLocalPrimitive()

template<class Emitter >

unsigned ByteCodeExprGen::allocateLocalPrimitive | ( | DeclTy && | Decl,
|  | PrimType | Ty,
|  | bool | IsMutable,
|  | bool | IsExtended = `false`
| ) |  |
| protected

Creates a local primitive value.

Definition at line 423 of file ByteCodeExprGen.cpp.

References clang::interp::Scope::Local::Offset, and P.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().

## ◆ classify() [1/2]

template<class Emitter>

llvm::Optional<PrimType> clang::interp::ByteCodeExprGen< Emitter >::classify | ( | const Expr * | E | ) | const
| inline protected

Classifies a type.

Definition at line 102 of file ByteCodeExprGen.h.

References clang::Expr::getType(), clang::Expr::isGLValue(), and clang::interp::PT_Ptr.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().

## ◆ classify() [2/2]

template<class Emitter>

llvm::Optional<PrimType> clang::interp::ByteCodeExprGen< Emitter >::classify | ( | QualType | Ty | ) | const
| inline protected

Definition at line 105 of file ByteCodeExprGen.h.

References clang::interp::Context::classify().

## ◆ classifyPrim()

template<class Emitter>

PrimType clang::interp::ByteCodeExprGen< Emitter >::classifyPrim | ( | QualType | Ty | ) | const
| inline protected

Classifies a known primitive type.

Definition at line 115 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::classify(), clang::interp::ByteCodeExprGen< Emitter >::discard(), clang::interp::ByteCodeExprGen< Emitter >::visit(), clang::interp::ByteCodeExprGen< Emitter >::visitBool(), and clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().

## ◆ discard()

template<class Emitter >

bool ByteCodeExprGen::discard | ( | const Expr * | E | ) |
| protected

Evaluates an expression for side effects and discards the result.

Definition at line 209 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().

## ◆ emitCleanup()

template<class Emitter >

void ByteCodeExprGen::emitCleanup | ( |  | ) |
| protected

Emits scope cleanup instructions.

Definition at line 568 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ getCharBit()

template<class Emitter>

unsigned clang::interp::ByteCodeExprGen< Emitter >::getCharBit | ( |  | ) | const
| inline protected

Returns the value of CHAR_BIT.

Definition at line 96 of file ByteCodeExprGen.h.

References clang::interp::Context::getASTContext(), clang::TargetInfo::getCharWidth(), and clang::ASTContext::getTargetInfo().

## ◆ getIntWidth()

template<class Emitter>

unsigned clang::interp::ByteCodeExprGen< Emitter >::getIntWidth | ( | QualType | Ty | ) |
| inline protected

Returns the size int bits of an integer.

Definition at line 90 of file ByteCodeExprGen.h.

References clang::interp::Context::getASTContext(), and clang::ASTContext::getIntWidth().

## ◆ getRecord() [1/2]

template<class Emitter >

Record * ByteCodeExprGen::getRecord | ( | QualType | Ty | ) |
| protected

Returns a record from a record or pointer type.

Definition at line 506 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ getRecord() [2/2]

template<class Emitter >

Record * ByteCodeExprGen::getRecord | ( | const RecordDecl * | RD | ) |
| protected

Definition at line 514 of file ByteCodeExprGen.cpp.

References P.

## ◆ getRecordTy()

template<class Emitter >

const RecordType * ByteCodeExprGen::getRecordTy | ( | QualType | Ty | ) |
| protected

Returns a record type from a record or pointer type.

Definition at line 498 of file ByteCodeExprGen.cpp.

References clang::Type::getAs(), and clang::Type::getPointeeType().

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ needsAdjust()

template<class Emitter>

bool clang::interp::ByteCodeExprGen< Emitter >::needsAdjust | ( | QualType | Ty | ) | const
| inline protected

Checks if a pointer needs adjustment.

Definition at line 110 of file ByteCodeExprGen.h.

## ◆ visit()

template<class Emitter >

bool ByteCodeExprGen::visit | ( | const Expr * | E | ) |
| protected

Evaluates an expression and places result on stack.

Definition at line 215 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().

## ◆ VisitBinaryOperator()

template<class Emitter >

bool ByteCodeExprGen::VisitBinaryOperator | ( | const BinaryOperator * | E | ) |

Definition at line 146 of file ByteCodeExprGen.cpp.

References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), and clang::interp::LT().

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ visitBool()

template<class Emitter >

bool ByteCodeExprGen::visitBool | ( | const Expr * | E | ) |
| protected

Visits an expression and converts it to a boolean.

Definition at line 221 of file ByteCodeExprGen.cpp.

References clang::VarDecl::getInit(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::VarDecl::hasInit(), clang::VarDecl::hasLocalStorage(), clang::VarDecl::isConstexpr(), clang::QualType::isConstQualified(), clang::Type::isFundamentalType(), P, clang::interp::PT_Bool, clang::interp::PT_Ptr, clang::interp::PT_Sint16, clang::interp::PT_Sint32, clang::interp::PT_Sint64, clang::interp::PT_Sint8, clang::interp::PT_Uint16, clang::interp::PT_Uint32, clang::interp::PT_Uint64, clang::interp::PT_Uint8, clang::Expr::refersToBitField(), and true.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().

## ◆ VisitCastExpr()

template<class Emitter >

bool ByteCodeExprGen::VisitCastExpr | ( | const CastExpr * | E | ) |

Definition at line 90 of file ByteCodeExprGen.cpp.

References dereference(), clang::CastExpr::getCastKind(), and clang::CastExpr::getSubExpr().

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ visitDecl()

template<class Emitter >

bool ByteCodeExprGen::visitDecl | ( | const VarDecl * | VD | ) |
| override protected

Definition at line 531 of file ByteCodeExprGen.cpp.

References clang::VarDecl::getInit(), clang::ValueDecl::getType(), and P.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ visitExpr()

template<class Emitter >

bool ByteCodeExprGen::visitExpr | ( | const Expr * | E | ) |
| override protected

Definition at line 519 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ visitGlobalInitializer()

template<class Emitter>

bool clang::interp::ByteCodeExprGen< Emitter >::visitGlobalInitializer | ( | const Expr * | Init,
|  | unsigned | I
| ) |  |
| inline protected

Visits an initializer for a global.

Definition at line 140 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().

## ◆ visitInitializer()

template<class Emitter >

bool ByteCodeExprGen::visitInitializer | ( | const Expr * | E,
|  | InitFnRef | GenPtr
| ) |  |
| protected

Compiles an initializer for a local.

Definition at line 464 of file ByteCodeExprGen.cpp.

References clang::ValueDecl::getType(), clang::VarDecl::hasLocalStorage(), clang::VarDecl::isConstexpr(), clang::Type::isReferenceType(), and P.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim(), clang::interp::ByteCodeExprGen< Emitter >::visitGlobalInitializer(), clang::interp::ByteCodeExprGen< Emitter >::visitLocalInitializer(), and clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().

## ◆ VisitIntegerLiteral()

template<class Emitter >

bool ByteCodeExprGen::VisitIntegerLiteral | ( | const IntegerLiteral * | E | ) |

Definition at line 129 of file ByteCodeExprGen.cpp.

References clang::Expr::getType(), clang::APIntStorage::getValue(), and clang::interp::LE().

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ visitLocalInitializer()

template<class Emitter>

bool clang::interp::ByteCodeExprGen< Emitter >::visitLocalInitializer | ( | const Expr * | Init,
|  | unsigned | I
| ) |  |
| inline protected

Visits an initializer for a local.

Definition at line 133 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().

## ◆ VisitParenExpr()

template<class Emitter >

bool ByteCodeExprGen::VisitParenExpr | ( | const ParenExpr * | E | ) |

Definition at line 141 of file ByteCodeExprGen.cpp.

References clang::ParenExpr::getSubExpr().

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

## ◆ visitThisInitializer()

template<class Emitter>

bool clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer | ( | const Expr * | I | ) |
| inline protected

Visits a delegated initializer.

Definition at line 147 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::allocateLocal(), clang::interp::ByteCodeExprGen< Emitter >::allocateLocalPrimitive(), and clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().

## Friends And Related Function Documentation

## ◆ DeclScope< Emitter >

template<class Emitter>

friend class DeclScope< Emitter >
| friend

Definition at line 163 of file ByteCodeExprGen.h.

## ◆ LocalScope< Emitter >

template<class Emitter>

friend class LocalScope< Emitter >
| friend

Definition at line 161 of file ByteCodeExprGen.h.

## ◆ OptionScope< Emitter >

template<class Emitter>

friend class OptionScope< Emitter >
| friend

Definition at line 164 of file ByteCodeExprGen.h.

## ◆ RecordScope< Emitter >

template<class Emitter>

friend class RecordScope< Emitter >
| friend

Definition at line 162 of file ByteCodeExprGen.h.

## ◆ VariableScope< Emitter >

template<class Emitter>

friend class VariableScope< Emitter >
| friend

Definition at line 160 of file ByteCodeExprGen.h.

## Member Data Documentation

## ◆ ArrayIndex

template<class Emitter>

llvm::Optional<uint64_t> clang::interp::ByteCodeExprGen< Emitter >::ArrayIndex
| protected

Current argument index.

Definition at line 227 of file ByteCodeExprGen.h.

## ◆ Ctx

template<class Emitter>

Context& clang::interp::ByteCodeExprGen< Emitter >::Ctx
| protected

Current compilation context.

Definition at line 58 of file ByteCodeExprGen.h.

## ◆ DiscardResult

template<class Emitter>

bool clang::interp::ByteCodeExprGen< Emitter >::DiscardResult = false
| protected

Flag indicating if return value is to be discarded.

Definition at line 230 of file ByteCodeExprGen.h.

Referenced by clang::interp::OptionScope< Emitter >::OptionScope().

## ◆ InitFn

template<class Emitter>

llvm::Optional<InitFnRef> clang::interp::ByteCodeExprGen< Emitter >::InitFn = {}
| protected

Expression being initialized.

Definition at line 233 of file ByteCodeExprGen.h.

Referenced by clang::interp::OptionScope< Emitter >::OptionScope().

## ◆ Locals

template<class Emitter>

llvm::DenseMap<const ValueDecl *, Scope::Local> clang::interp::ByteCodeExprGen< Emitter >::Locals
| protected

Variable to storage mapping.

Definition at line 218 of file ByteCodeExprGen.h.

## ◆ OpaqueExprs

template<class Emitter>

llvm::DenseMap<const OpaqueValueExpr *, unsigned> clang::interp::ByteCodeExprGen< Emitter >::OpaqueExprs
| protected

OpaqueValueExpr to location mapping.

Definition at line 221 of file ByteCodeExprGen.h.

## ◆ P

template<class Emitter>

Program& clang::interp::ByteCodeExprGen< Emitter >::P
| protected

Program to link to.

Definition at line 60 of file ByteCodeExprGen.h.

## ◆ VarScope

template<class Emitter>

VariableScope<Emitter>* clang::interp::ByteCodeExprGen< Emitter >::VarScope = nullptr
| protected

Current scope.

Definition at line 224 of file ByteCodeExprGen.h.

Referenced by clang::interp::VariableScope< Emitter >::VariableScope().

The documentation for this class was generated from the following files:

- lib/AST/Interp/ByteCodeExprGen.h
- lib/AST/Interp/ByteCodeExprGen.cpp