clang 23.0.0git
clang::interp::Function Class Referencefinal

Bytecode function. More...

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/Function.h"

Classes

struct  ParamDescriptor

Public Types

enum class  FunctionKind {
  Normal , Ctor , Dtor , LambdaStaticInvoker ,
  LambdaCallOperator , CopyOrMoveOperator
}
using arg_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 BlockExprgetExpr () const
std::string getName () const
 Returns the name of the function decl this code was generated for.
ParamDescriptor getParamDescriptor (unsigned Offset) const
 Returns a parameter descriptor.
bool hasRVO () const
 Checks if the first argument is a RVO pointer.
bool hasNonNullAttr () const
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 isValid () const
 Checks if the function is valid to call.
bool isVirtual () const
 Checks if the function is virtual.
bool isImmediate () const
bool isConstexpr () const
bool isConstructor () const
 Checks if the function is a constructor.
bool isDestructor () const
 Checks if the function is a destructor.
bool isCopyOrMoveOperator () const
 Checks if the function is copy or move operator.
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.
const CXXRecordDeclgetParentDecl () const
 Returns the parent record decl, if any.
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.
bool isVariadic () const
unsigned getNumParams () const
unsigned getNumWrittenParams () const
 Returns the number of parameter this function takes when it's called, i.e excluding the instance pointer and the RVO pointer.
unsigned getWrittenArgSize () const
bool isThisPointerExplicit () const
unsigned getParamOffset (unsigned ParamIndex) const
PrimType getParamType (unsigned ParamIndex) const
void dump (CodePtr PC={}) const
 Dumps the disassembled bytecode to llvm::errs().
void dump (llvm::raw_ostream &OS, CodePtr PC={}) const

Friends

class Program
class ByteCodeEmitter
class Context

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.

The parameters saved in a clang::intepr::Function include both the instance pointer as well as the RVO pointer.

///    Stack position when calling  ─────┐
///    this Function                     │
///                                      ▼
/// ┌─────┬──────┬────────┬────────┬─────┬────────────────────┐
/// │ RVO │ This │ Param1 │ Param2 │ ... │                    │
/// └─────┴──────┴────────┴────────┴─────┴────────────────────┘
/// 

Definition at line 99 of file Function.h.

Member Typedef Documentation

◆ arg_reverse_iterator

Member Enumeration Documentation

◆ FunctionKind

Enumerator
Normal 
Ctor 
Dtor 
LambdaStaticInvoker 
LambdaCallOperator 
CopyOrMoveOperator 

Definition at line 101 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 162 of file Function.h.

◆ dump() [1/2]

LLVM_DUMP_METHOD void Function::dump ( CodePtr PC = {}) const

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

Definition at line 141 of file Disasm.cpp.

References dump(), and dump().

Referenced by dump().

◆ dump() [2/2]

void clang::interp::Function::dump ( llvm::raw_ostream & OS,
CodePtr PC = {} ) const

◆ getArgSize()

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

Returns the size of the argument stack.

Definition at line 121 of file Function.h.

◆ getCodeBegin()

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

Returns a pointer to the start of the code.

Definition at line 124 of file Function.h.

Referenced by getSource().

◆ getCodeEnd()

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

Returns a pointer to the end of the code.

Definition at line 126 of file Function.h.

Referenced by getSource().

◆ getDecl()

◆ getExpr()

const BlockExpr * clang::interp::Function::getExpr ( ) const
inline

Definition at line 132 of file Function.h.

Referenced by clang::interp::Pointer::toAPValue().

◆ getFrameSize()

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

Returns the size of the function's local stack.

Definition at line 119 of file Function.h.

◆ getName()

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

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

Definition at line 138 of file Function.h.

References getDecl(), and clang::NamedDecl::getQualifiedNameAsString().

◆ getNumParams()

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

Definition at line 223 of file Function.h.

Referenced by getNumWrittenParams().

◆ getNumWrittenParams()

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

Returns the number of parameter this function takes when it's called, i.e excluding the instance pointer and the RVO pointer.

Definition at line 227 of file Function.h.

References getNumParams(), hasRVO(), and hasThisPointer().

◆ getParamDescriptor()

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

Returns a parameter descriptor.

Definition at line 59 of file Function.cpp.

References getParamDescriptor().

Referenced by getParamDescriptor().

◆ getParamOffset()

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

Definition at line 242 of file Function.h.

◆ getParamType()

PrimType clang::interp::Function::getParamType ( unsigned ParamIndex) const
inline

Definition at line 246 of file Function.h.

◆ getParentDecl()

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

Returns the parent record decl, if any.

Definition at line 203 of file Function.h.

References clang::DeclContext::getParent().

◆ getScope() [1/2]

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

Returns a specific scope.

Definition at line 167 of file Function.h.

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

◆ getScope() [2/2]

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

Definition at line 168 of file Function.h.

◆ getSource()

SourceInfo Function::getSource ( CodePtr PC) const

Returns the source information at a given PC.

Definition at line 65 of file Function.cpp.

References getCodeBegin(), getCodeEnd(), getSource(), and hasBody().

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

◆ getWrittenArgSize()

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

◆ hasBody()

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

Checks if the function already has a body attached.

Definition at line 216 of file Function.h.

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

◆ hasNonNullAttr()

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

Definition at line 151 of file Function.h.

References getDecl(), and clang::Decl::hasAttr().

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

◆ hasRVO()

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

Checks if the first argument is a RVO pointer.

Definition at line 149 of file Function.h.

Referenced by getNumWrittenParams(), getWrittenArgSize(), clang::interp::RVOPtr(), and clang::interp::Compiler< Emitter >::VisitCXXInheritedCtorInitExpr().

◆ hasThisPointer()

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

◆ isConstexpr()

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

Definition at line 179 of file Function.h.

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

◆ isConstructor()

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

Checks if the function is a constructor.

Definition at line 182 of file Function.h.

References Ctor.

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

◆ isCopyOrMoveOperator()

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

Checks if the function is copy or move operator.

Definition at line 186 of file Function.h.

References CopyOrMoveOperator.

◆ isDefined()

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

Checks if the function is defined.

Definition at line 219 of file Function.h.

◆ isDestructor()

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

Checks if the function is a destructor.

Definition at line 184 of file Function.h.

References Dtor.

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

◆ isFullyCompiled()

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

Checks if the function is fully done compiling.

Definition at line 211 of file Function.h.

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

◆ isImmediate()

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

Definition at line 178 of file Function.h.

◆ isLambdaCallOperator()

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

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

Definition at line 198 of file Function.h.

References LambdaCallOperator.

◆ 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 192 of file Function.h.

References LambdaStaticInvoker.

Referenced by clang::interp::Call(), clang::interp::CallVar(), clang::interp::CheckCallable(), and isValid().

◆ isThisPointerExplicit()

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

Definition at line 235 of file Function.h.

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

◆ isValid()

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

Checks if the function is valid to call.

Definition at line 174 of file Function.h.

References isLambdaStaticInvoker().

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

◆ isVariadic()

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

Definition at line 221 of file Function.h.

◆ isVirtual()

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

Checks if the function is virtual.

Definition at line 177 of file Function.h.

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

◆ scopes()

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

Range over the scope blocks.

Definition at line 155 of file Function.h.

◆ ByteCodeEmitter

friend class ByteCodeEmitter
friend

Definition at line 275 of file Function.h.

References ByteCodeEmitter.

Referenced by ByteCodeEmitter.

◆ Context

friend class Context
friend

Definition at line 276 of file Function.h.

References Context, and Program.

Referenced by Context.

◆ Program

friend class Program
friend

Definition at line 274 of file Function.h.

References Program.

Referenced by Context, and Program.


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