clang 18.0.0git
Public Types | Public Member Functions | Friends | List of all members
clang::interp::Function Class Referencefinal

Bytecode function. More...

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

Public Types

using ParamDescriptor = std::pair< PrimType, Descriptor * >
 
using arg_reverse_iterator = SmallVectorImpl< PrimType >::const_reverse_iterator
 Range over argument types.
 

Public Member Functions

unsigned getFrameSize () const
 Returns the size of the function's local stack.
 
unsigned getArgSize () const
 Returns the size of the argument stack.
 
CodePtr getCodeBegin () const
 Returns a pointer to the start of the code.
 
CodePtr getCodeEnd () const
 Returns a pointer to the end of the code.
 
const FunctionDeclgetDecl () const
 Returns the original FunctionDecl.
 
const std::string getName () const
 Returns the name of the function decl this code was generated for.
 
SourceLocation getLoc () const
 Returns the location.
 
ParamDescriptor getParamDescriptor (unsigned Offset) const
 Returns a parameter descriptor.
 
bool hasRVO () const
 Checks if the first argument is a RVO pointer.
 
llvm::iterator_range< llvm::SmallVector< Scope, 2 >::const_iterator > scopes () const
 Range over the scope blocks.
 
llvm::iterator_range< arg_reverse_iteratorargs_reverse () const
 
ScopegetScope (unsigned Idx)
 Returns a specific scope.
 
const ScopegetScope (unsigned Idx) const
 
SourceInfo getSource (CodePtr PC) const
 Returns the source information at a given PC.
 
bool isConstexpr () const
 Checks if the function is valid to call in constexpr.
 
bool isVirtual () const
 Checks if the function is virtual.
 
bool isConstructor () const
 Checks if the function is a constructor.
 
bool isDestructor () const
 Checks if the function is a destructor.
 
const CXXRecordDeclgetParentDecl () const
 Returns the parent record decl, if any.
 
bool isLambdaStaticInvoker () const
 Returns whether this function is a lambda static invoker, which we generate custom byte code for.
 
bool isLambdaCallOperator () const
 Returns whether this function is the call operator of a lambda record decl.
 
bool isFullyCompiled () const
 Checks if the function is fully done compiling.
 
bool hasThisPointer () const
 
bool hasBody () const
 Checks if the function already has a body attached.
 
bool isDefined () const
 Checks if the function is defined.
 
unsigned getBuiltinID () const
 
bool isBuiltin () const
 
bool needsRuntimeArgPop (const ASTContext &Ctx) const
 Does this function need its arguments to be classified at runtime rather than at bytecode-compile-time?
 
unsigned getNumParams () const
 
unsigned getParamOffset (unsigned ParamIndex) const
 
void dump () const
 Dumps the disassembled bytecode to llvm::errs().
 
void dump (llvm::raw_ostream &OS) const
 

Friends

class Program
 
class ByteCodeEmitter
 

Detailed Description

Bytecode function.

Contains links to the bytecode of the function, as well as metadata describing all arguments and stack-local variables.

Calling Convention

When calling a function, all argument values must be on the stack.

If the function has a This pointer (i.e. hasThisPointer() returns true, the argument values need to be preceeded by a Pointer for the This object.

If the function uses Return Value Optimization, the arguments (and potentially the This pointer) need to be preceeded by a Pointer pointing to the location to construct the returned value.

After the function has been called, it will remove all arguments, including RVO and This pointer, from the stack.

Definition at line 75 of file Function.h.

Member Typedef Documentation

◆ arg_reverse_iterator

Range over argument types.

Definition at line 117 of file Function.h.

◆ ParamDescriptor

Definition at line 77 of file Function.h.

Member Function Documentation

◆ args_reverse()

llvm::iterator_range< arg_reverse_iterator > clang::interp::Function::args_reverse ( ) const
inline

Definition at line 119 of file Function.h.

Referenced by clang::interp::InterpFrame::popArgs().

◆ dump() [1/2]

LLVM_DUMP_METHOD void Function::dump ( ) const

Dumps the disassembled bytecode to llvm::errs().

Definition at line 40 of file Disasm.cpp.

References dump().

◆ dump() [2/2]

LLVM_DUMP_METHOD void Function::dump ( llvm::raw_ostream &  OS) const

Definition at line 42 of file Disasm.cpp.

References getName().

◆ getArgSize()

unsigned clang::interp::Function::getArgSize ( ) const
inline

Returns the size of the argument stack.

Definition at line 82 of file Function.h.

Referenced by clang::interp::Call(), and clang::interp::CallVirt().

◆ getBuiltinID()

unsigned clang::interp::Function::getBuiltinID ( ) const
inline

Definition at line 175 of file Function.h.

References clang::FunctionDecl::getBuiltinID().

Referenced by clang::interp::InterpretBuiltin().

◆ getCodeBegin()

CodePtr clang::interp::Function::getCodeBegin ( ) const
inline

Returns a pointer to the start of the code.

Definition at line 85 of file Function.h.

Referenced by clang::interp::InterpFrame::getPC().

◆ getCodeEnd()

CodePtr clang::interp::Function::getCodeEnd ( ) const
inline

Returns a pointer to the end of the code.

Definition at line 87 of file Function.h.

◆ getDecl()

const FunctionDecl * clang::interp::Function::getDecl ( ) const
inline

◆ getFrameSize()

unsigned clang::interp::Function::getFrameSize ( ) const
inline

Returns the size of the function's local stack.

Definition at line 80 of file Function.h.

Referenced by clang::interp::InterpFrame::InterpFrame().

◆ getLoc()

SourceLocation clang::interp::Function::getLoc ( ) const
inline

Returns the location.

Definition at line 102 of file Function.h.

◆ getName()

const std::string clang::interp::Function::getName ( ) const
inline

Returns the name of the function decl this code was generated for.

Definition at line 94 of file Function.h.

References clang::NamedDecl::getQualifiedNameAsString().

Referenced by clang::interp::FunctionPointer::print().

◆ getNumParams()

unsigned clang::interp::Function::getNumParams ( ) const
inline

Definition at line 183 of file Function.h.

◆ getParamDescriptor()

Function::ParamDescriptor Function::getParamDescriptor ( unsigned  Offset) const

Returns a parameter descriptor.

Definition at line 29 of file Function.cpp.

Referenced by clang::interp::InterpFrame::getParamPointer().

◆ getParamOffset()

unsigned clang::interp::Function::getParamOffset ( unsigned  ParamIndex) const
inline

Definition at line 185 of file Function.h.

◆ getParentDecl()

const CXXRecordDecl * clang::interp::Function::getParentDecl ( ) const
inline

Returns the parent record decl, if any.

Definition at line 142 of file Function.h.

References clang::DeclContext::getParent().

Referenced by clang::interp::CallVirt().

◆ getScope() [1/2]

Scope & clang::interp::Function::getScope ( unsigned  Idx)
inline

Returns a specific scope.

Definition at line 124 of file Function.h.

Referenced by clang::interp::InterpFrame::destroy().

◆ getScope() [2/2]

const Scope & clang::interp::Function::getScope ( unsigned  Idx) const
inline

Definition at line 125 of file Function.h.

◆ getSource()

SourceInfo Function::getSource ( CodePtr  PC) const

Returns the source information at a given PC.

Definition at line 35 of file Function.cpp.

Referenced by clang::interp::EvalEmitter::getSource(), and clang::interp::InterpState::getSource().

◆ hasBody()

bool clang::interp::Function::hasBody ( ) const
inline

Checks if the function already has a body attached.

Definition at line 170 of file Function.h.

Referenced by clang::interp::EvalEmitter::getSource(), and clang::interp::Context::isPotentialConstantExpr().

◆ hasRVO()

bool clang::interp::Function::hasRVO ( ) const
inline

◆ hasThisPointer()

bool clang::interp::Function::hasThisPointer ( ) const
inline

◆ isBuiltin()

bool clang::interp::Function::isBuiltin ( ) const
inline

Definition at line 177 of file Function.h.

References clang::FunctionDecl::getBuiltinID().

◆ isConstexpr()

bool clang::interp::Function::isConstexpr ( ) const
inline

◆ isConstructor()

bool clang::interp::Function::isConstructor ( ) const
inline

Checks if the function is a constructor.

Definition at line 137 of file Function.h.

◆ isDefined()

bool clang::interp::Function::isDefined ( ) const
inline

Checks if the function is defined.

Definition at line 173 of file Function.h.

Referenced by clang::interp::Context::getOrCreateFunction().

◆ isDestructor()

bool clang::interp::Function::isDestructor ( ) const
inline

Checks if the function is a destructor.

Definition at line 139 of file Function.h.

◆ isFullyCompiled()

bool clang::interp::Function::isFullyCompiled ( ) const
inline

Checks if the function is fully done compiling.

Definition at line 165 of file Function.h.

Referenced by clang::interp::Context::getOrCreateFunction(), and clang::interp::ByteCodeExprGen< Emitter >::VisitCallExpr().

◆ isLambdaCallOperator()

bool clang::interp::Function::isLambdaCallOperator ( ) const
inline

Returns whether this function is the call operator of a lambda record decl.

Definition at line 158 of file Function.h.

References clang::isLambdaCallOperator().

Referenced by clang::interp::Call().

◆ isLambdaStaticInvoker()

bool clang::interp::Function::isLambdaStaticInvoker ( ) const
inline

Returns whether this function is a lambda static invoker, which we generate custom byte code for.

Definition at line 150 of file Function.h.

Referenced by isConstexpr().

◆ isVirtual()

bool Function::isVirtual ( ) const

Checks if the function is virtual.

Definition at line 46 of file Function.cpp.

Referenced by clang::interp::CallVirt(), and clang::interp::CheckCallable().

◆ needsRuntimeArgPop()

bool Function::needsRuntimeArgPop ( const ASTContext Ctx) const

Does this function need its arguments to be classified at runtime rather than at bytecode-compile-time?

Definition at line 52 of file Function.cpp.

References clang::ASTContext::BuiltinInfo, and clang::Builtin::Context::hasCustomTypechecking().

◆ scopes()

llvm::iterator_range< llvm::SmallVector< Scope, 2 >::const_iterator > clang::interp::Function::scopes ( ) const
inline

Range over the scope blocks.

Definition at line 112 of file Function.h.

Referenced by clang::interp::InterpFrame::InterpFrame().

Friends And Related Function Documentation

◆ ByteCodeEmitter

friend class ByteCodeEmitter
friend

Definition at line 214 of file Function.h.

◆ Program

friend class Program
friend

Definition at line 213 of file Function.h.


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