clang 17.0.0git
Public Member Functions | List of all members
clang::interp::Context Class Referencefinal

Holds all information required to evaluate constexpr code in a module. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/Interp/Context.h"

Public Member Functions

 Context (ASTContext &Ctx)
 Initialises the constexpr VM.
 
 ~Context ()
 Cleans up the constexpr VM.
 
bool isPotentialConstantExpr (State &Parent, const FunctionDecl *FnDecl)
 Checks if a function is a potential constant expression.
 
bool evaluateAsRValue (State &Parent, const Expr *E, APValue &Result)
 Evaluates a toplevel expression as an rvalue.
 
bool evaluateAsInitializer (State &Parent, const VarDecl *VD, APValue &Result)
 Evaluates a toplevel initializer.
 
ASTContextgetASTContext () const
 Returns the AST context.
 
const LangOptionsgetLangOpts () const
 Returns the language options.
 
InterpStackgetStack ()
 Returns the interpreter stack.
 
unsigned getCharBit () const
 Returns CHAR_BIT.
 
std::optional< PrimTypeclassify (QualType T) const
 Classifies an expression.
 

Detailed Description

Holds all information required to evaluate constexpr code in a module.

Definition at line 35 of file Context.h.

Constructor & Destructor Documentation

◆ Context()

Context::Context ( ASTContext Ctx)

Initialises the constexpr VM.

Definition at line 25 of file Context.cpp.

◆ ~Context()

Context::~Context ( )

Cleans up the constexpr VM.

Definition at line 27 of file Context.cpp.

Member Function Documentation

◆ classify()

std::optional< PrimType > Context::classify ( QualType  T) const

◆ evaluateAsInitializer()

bool Context::evaluateAsInitializer ( State Parent,
const VarDecl VD,
APValue Result 
)

Evaluates a toplevel initializer.

Definition at line 65 of file Context.cpp.

References clang::C, clang::interp::InterpStack::clear(), clang::interp::InterpStack::empty(), Parent, and clang::Result.

◆ evaluateAsRValue()

bool Context::evaluateAsRValue ( State Parent,
const Expr E,
APValue Result 
)

Evaluates a toplevel expression as an rvalue.

Definition at line 53 of file Context.cpp.

References clang::C, clang::interp::InterpStack::clear(), clang::interp::InterpStack::empty(), Parent, and clang::Result.

◆ getASTContext()

ASTContext & clang::interp::Context::getASTContext ( ) const
inline

Returns the AST context.

Definition at line 53 of file Context.h.

Referenced by clang::interp::Program::getOrCreateDummy().

◆ getCharBit()

unsigned Context::getCharBit ( ) const

Returns CHAR_BIT.

Definition at line 130 of file Context.cpp.

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

Referenced by clang::interp::Program::createGlobalString().

◆ getLangOpts()

const LangOptions & Context::getLangOpts ( ) const

Returns the language options.

Definition at line 78 of file Context.cpp.

References clang::ASTContext::getLangOpts().

◆ getStack()

InterpStack & clang::interp::Context::getStack ( )
inline

Returns the interpreter stack.

Definition at line 57 of file Context.h.

◆ isPotentialConstantExpr()

bool Context::isPotentialConstantExpr ( State Parent,
const FunctionDecl FnDecl 
)

Checks if a function is a potential constant expression.

Definition at line 29 of file Context.cpp.

References clang::interp::InterpStack::empty(), clang::interp::Function::hasBody(), clang::interp::Function::isConstexpr(), and Parent.


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