clang API Documentation

Public Member Functions
clang::CodeGen::CodeGenTypes Class Reference

#include <CodeGenTypes.h>

List of all members.

Public Member Functions

 CodeGenTypes (CodeGenModule &CGM)
 ~CodeGenTypes ()
const llvm::TargetData & getTargetData () const
const TargetInfogetTarget () const
ASTContextgetContext () const
const ABIInfogetABIInfo () const
const CodeGenOptionsgetCodeGenOpts () const
CGCXXABIgetCXXABI () const
llvm::LLVMContext & getLLVMContext ()
llvm::Type * ConvertType (QualType T)
 ConvertType - Convert type T into a llvm::Type.
llvm::Type * ConvertTypeForMem (QualType T)
llvm::FunctionType * GetFunctionType (const CGFunctionInfo &Info)
 GetFunctionType - Get the LLVM function type for.
llvm::FunctionType * GetFunctionType (GlobalDecl GD)
bool isFuncTypeConvertible (const FunctionType *FT)
bool isFuncTypeArgumentConvertible (QualType Ty)
llvm::Type * GetFunctionTypeForVTable (GlobalDecl GD)
const CGRecordLayoutgetCGRecordLayout (const RecordDecl *)
 getCGRecordLayout - Return record layout info for the given record decl.
void UpdateCompletedType (const TagDecl *TD)
const CGFunctionInfoarrangeNullaryFunction ()
const CGFunctionInfoarrangeGlobalDeclaration (GlobalDecl GD)
const CGFunctionInfoarrangeFunctionDeclaration (const FunctionDecl *FD)
const CGFunctionInfoarrangeFunctionDeclaration (QualType ResTy, const FunctionArgList &Args, const FunctionType::ExtInfo &Info, bool isVariadic)
const CGFunctionInfoarrangeObjCMethodDeclaration (const ObjCMethodDecl *MD)
const CGFunctionInfoarrangeObjCMessageSendSignature (const ObjCMethodDecl *MD, QualType receiverType)
const CGFunctionInfoarrangeCXXMethodDeclaration (const CXXMethodDecl *MD)
const CGFunctionInfoarrangeCXXConstructorDeclaration (const CXXConstructorDecl *D, CXXCtorType Type)
const CGFunctionInfoarrangeCXXDestructor (const CXXDestructorDecl *D, CXXDtorType Type)
const CGFunctionInfoarrangeFunctionCall (const CallArgList &Args, const FunctionType *Ty)
const CGFunctionInfoarrangeFunctionCall (QualType ResTy, const CallArgList &args, const FunctionType::ExtInfo &info, RequiredArgs required)
const CGFunctionInfoarrangeFunctionType (CanQual< FunctionProtoType > Ty)
const CGFunctionInfoarrangeFunctionType (CanQual< FunctionNoProtoType > Ty)
const CGFunctionInfoarrangeCXXMethodType (const CXXRecordDecl *RD, const FunctionProtoType *FTP)
const CGFunctionInfoarrangeFunctionType (CanQualType returnType, ArrayRef< CanQualType > argTypes, const FunctionType::ExtInfo &info, RequiredArgs args)
CGRecordLayoutComputeRecordLayout (const RecordDecl *D, llvm::StructType *Ty)
 Compute a new LLVM record layout object for the given record.
void addRecordTypeName (const RecordDecl *RD, llvm::StructType *Ty, StringRef suffix)
llvm::StructType * ConvertRecordDeclType (const RecordDecl *TD)
 ConvertRecordDeclType - Lay out a tagged decl type like struct or union.
void GetExpandedTypes (QualType type, SmallVectorImpl< llvm::Type * > &expanded)
bool isZeroInitializable (QualType T)
bool isZeroInitializable (const CXXRecordDecl *RD)
bool isRecordLayoutComplete (const Type *Ty) const
bool noRecordsBeingLaidOut () const
bool isRecordBeingLaidOut (const Type *Ty) const

Detailed Description

CodeGenTypes - This class organizes the cross-module state that is used while lowering AST types to LLVM types.

Definition at line 60 of file CodeGenTypes.h.


Constructor & Destructor Documentation

CodeGenTypes::CodeGenTypes ( CodeGenModule CGM)

Definition at line 30 of file CodeGenTypes.cpp.

CodeGenTypes::~CodeGenTypes ( )

Definition at line 39 of file CodeGenTypes.cpp.


Member Function Documentation

void CodeGenTypes::addRecordTypeName ( const RecordDecl RD,
llvm::StructType *  Ty,
StringRef  suffix 
)

addRecordTypeName - Compute a name from the given record decl with an optional suffix and name the given LLVM type using it.

Definition at line 50 of file CodeGenTypes.cpp.

References clang::Decl::getDeclContext(), clang::NamedDecl::getIdentifier(), clang::TagDecl::getKindName(), clang::NamedDecl::getQualifiedNameAsString(), clang::TagDecl::getTypedefNameForAnonDecl(), and clang::NamedDecl::printName().

Referenced by ConvertRecordDeclType().

const CGFunctionInfo & CodeGenTypes::arrangeCXXConstructorDeclaration ( const CXXConstructorDecl D,
CXXCtorType  ctorKind 
)
const CGFunctionInfo & CodeGenTypes::arrangeCXXDestructor ( const CXXDestructorDecl D,
CXXDtorType  dtorKind 
)
const CGFunctionInfo & CodeGenTypes::arrangeCXXMethodDeclaration ( const CXXMethodDecl MD)

Arrange the argument and result information for a declaration or definition of the given C++ non-static member function. The member function must be an ordinary function, i.e. not a constructor or destructor.

Definition at line 146 of file CGCall.cpp.

References arrangeCXXMethodType(), arrangeFunctionType(), GetFormalType(), clang::CXXMethodDecl::getParent(), clang::CanQual< T >::getTypePtr(), and clang::CXXMethodDecl::isInstance().

Referenced by arrangeFunctionDeclaration(), clang::CodeGen::CodeGenFunction::EmitCXXMemberCallExpr(), clang::CodeGen::CodeGenFunction::EmitCXXOperatorMemberCallee(), and GetFunctionTypeForVTable().

const CGFunctionInfo & CodeGenTypes::arrangeCXXMethodType ( const CXXRecordDecl RD,
const FunctionProtoType FTP 
)

Arrange the argument and result information for a call to an unknown C++ non-static member function of the given abstract type. The member function must be an ordinary function, i.e. not a constructor or destructor.

Definition at line 130 of file CGCall.cpp.

References arrangeFunctionType(), clang::CanQual< T >::getAs(), clang::Type::getCanonicalTypeUnqualified(), and GetThisType().

Referenced by arrangeCXXMethodDeclaration(), and clang::CodeGen::CGCXXABI::EmitLoadOfMemberFunctionPointer().

const CGFunctionInfo & CodeGenTypes::arrangeFunctionCall ( const CallArgList args,
const FunctionType fnType 
)
const CGFunctionInfo & CodeGenTypes::arrangeFunctionCall ( QualType  ResTy,
const CallArgList args,
const FunctionType::ExtInfo info,
RequiredArgs  required 
)
const CGFunctionInfo & CodeGenTypes::arrangeFunctionDeclaration ( const FunctionDecl FD)
const CGFunctionInfo & CodeGenTypes::arrangeFunctionDeclaration ( QualType  ResTy,
const FunctionArgList Args,
const FunctionType::ExtInfo Info,
bool  isVariadic 
)
const CGFunctionInfo & CodeGenTypes::arrangeFunctionType ( CanQual< FunctionProtoType FTP)
const CGFunctionInfo & CodeGenTypes::arrangeFunctionType ( CanQual< FunctionNoProtoType FTNP)

Arrange the argument and result information for a value of the given unprototyped function type.

Definition at line 73 of file CGCall.cpp.

References arrangeFunctionType(), and clang::CanQual< T >::getUnqualifiedType().

const CGFunctionInfo & CodeGenTypes::arrangeFunctionType ( CanQualType  resultType,
ArrayRef< CanQualType argTypes,
const FunctionType::ExtInfo info,
RequiredArgs  required 
)

Retrieves the ABI information for the given function signature. This is the "core" routine to which all the others defer.

Parameters:
argTypes- must all actually be canonical as params

Arrange the argument and result information for an abstract value of a given function type. This is the method which all of the above functions ultimately defer to.

Definition at line 342 of file CGCall.cpp.

References clang::CodeGen::CGFunctionInfo::arg_begin(), clang::CodeGen::CGFunctionInfo::arg_end(), clang::ABIArgInfo::canHaveCoerceToType(), ClangCallConvToLLVMCallConv(), clang::ABIInfo::computeInfo(), ConvertType(), clang::serialized_diags::create(), getABIInfo(), clang::FunctionType::ExtInfo::getCC(), clang::ABIArgInfo::getCoerceToType(), clang::CodeGen::CGFunctionInfo::getReturnInfo(), clang::CodeGen::CGFunctionInfo::getReturnType(), clang::CodeGen::CGFunctionInfo::Profile(), and clang::ABIArgInfo::setCoerceToType().

const CGFunctionInfo & CodeGenTypes::arrangeGlobalDeclaration ( GlobalDecl  GD)
const CGFunctionInfo & CodeGenTypes::arrangeNullaryFunction ( )

getNullaryFunctionInfo - Get the function info for a void() function with standard CC.

Definition at line 333 of file CGCall.cpp.

References clang::CodeGen::RequiredArgs::All, arrangeFunctionType(), and getContext().

Referenced by createAtExitStub().

const CGFunctionInfo & CodeGenTypes::arrangeObjCMessageSendSignature ( const ObjCMethodDecl MD,
QualType  receiverType 
)

Arrange the argument and result information for the function type through which to perform a send to the given Objective-C method, using the given receiver type. The receiver type is not always the 'self' type of the method or even an Objective-C pointer type. This is *not* the right method for actually performing such a message send, due to the possibility of optional arguments.

Definition at line 243 of file CGCall.cpp.

References clang::CodeGen::RequiredArgs::All, arrangeFunctionType(), getCallingConventionForDecl(), clang::ASTContext::getCanonicalParamType(), getContext(), clang::ASTContext::getObjCSelType(), clang::ObjCMethodDecl::getResultType(), GetReturnType(), clang::Decl::hasAttr(), clang::ObjCMethodDecl::isVariadic(), clang::ObjCMethodDecl::param_begin(), clang::ObjCMethodDecl::param_end(), clang::FunctionType::ExtInfo::withCallingConv(), and clang::FunctionType::ExtInfo::withProducesResult().

Referenced by arrangeObjCMethodDeclaration(), and clang::CodeGen::CGObjCRuntime::getMessageSendInfo().

const CGFunctionInfo & CodeGenTypes::arrangeObjCMethodDeclaration ( const ObjCMethodDecl MD)

Arrange the argument and result information for the declaration or definition of an Objective-C method.

Definition at line 230 of file CGCall.cpp.

References arrangeObjCMessageSendSignature(), clang::ObjCMethodDecl::getSelfDecl(), and clang::ValueDecl::getType().

Referenced by clang::CodeGen::CodeGenFunction::StartObjCMethod().

CGRecordLayout * CodeGenTypes::ComputeRecordLayout ( const RecordDecl D,
llvm::StructType *  Ty 
)
llvm::StructType * CodeGenTypes::ConvertRecordDeclType ( const RecordDecl TD)
llvm::Type * CodeGenTypes::ConvertType ( QualType  T)

ConvertType - Convert type T into a llvm::Type.

ConvertType - Convert the specified type to its LLVM form.

Definition at line 282 of file CodeGenTypes.cpp.

References arrangeFunctionType(), clang::CodeGen::CGCXXABI::ConvertMemberPointerType(), ConvertRecordDeclType(), ConvertTypeForMem(), clang::serialized_diags::create(), clang::ASTContext::getCanonicalType(), getCXXABI(), clang::ArrayType::getElementType(), clang::VectorType::getElementType(), getElementType(), clang::ASTContext::getFloatTypeSemantics(), GetFunctionType(), clang::ArrayType::getIndexTypeCVRQualifiers(), clang::EnumDecl::getIntegerType(), getLLVMContext(), clang::VectorType::getNumElements(), clang::PointerType::getPointeeType(), clang::ReferenceType::getPointeeType(), clang::ConstantArrayType::getSize(), clang::ASTContext::getTargetAddressSpace(), clang::Type::getTypeClass(), getTypeForFormat(), clang::QualType::getTypePtr(), clang::ASTContext::getTypeSize(), clang::TagDecl::isCompleteDefinition(), clang::EnumDecl::isFixed(), isFuncTypeConvertible(), and NULL.

Referenced by arrangeFunctionType(), buildBlockDescriptor(), buildGlobalBlock(), computeBlockInfo(), clang::CodeGen::CGCXXABI::ConvertMemberPointerType(), clang::CodeGen::CodeGenFunction::ConvertType(), ConvertTypeForMem(), clang::CodeGen::CodeGenModule::EmitConstantValue(), clang::CodeGen::CodeGenFunction::EmitFunctionProlog(), clang::CodeGen::CodeGenFunction::EmitObjCCollectionLiteral(), clang::CodeGen::CodeGenFunction::EmitSynthesizedCXXCopyCtorCall(), clang::CodeGen::CodeGenFunction::GenerateObjCCtorDtorMethod(), clang::CodeGen::CodeGenFunction::generateObjCGetterBody(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(), clang::CodeGen::CodeGenModule::GetAddrOfConstantString(), clang::CodeGen::CodeGenModule::GetAddrOfFunction(), clang::CodeGen::CodeGenModule::getBlockDescriptorType(), GetBogusMemberPointer(), clang::CodeGen::CodeGenModule::GetConstantArrayFromStringLiteral(), GetExpandedTypes(), GetFunctionType(), getGuardAcquireFn(), clang::CodeGen::CodeGenModule::GetNonVirtualBaseClassOffset(), initializeForBlockHeader(), and UpdateCompletedType().

llvm::Type * CodeGenTypes::ConvertTypeForMem ( QualType  T)
const ABIInfo& clang::CodeGen::CodeGenTypes::getABIInfo ( ) const [inline]
const CGRecordLayout & CodeGenTypes::getCGRecordLayout ( const RecordDecl RD)
const CodeGenOptions& clang::CodeGen::CodeGenTypes::getCodeGenOpts ( ) const [inline]

Definition at line 115 of file CodeGenTypes.h.

Referenced by clang::CodeGen::CGBitFieldInfo::MakeInfo().

ASTContext& clang::CodeGen::CodeGenTypes::getContext ( ) const [inline]
CGCXXABI& clang::CodeGen::CodeGenTypes::getCXXABI ( ) const [inline]

Definition at line 116 of file CodeGenTypes.h.

Referenced by ConvertType(), and isZeroInitializable().

void CodeGenTypes::GetExpandedTypes ( QualType  type,
SmallVectorImpl< llvm::Type * > &  expanded 
)
llvm::FunctionType * CodeGenTypes::GetFunctionType ( const CGFunctionInfo Info)

GetFunctionType - Get the LLVM function type for.

  • Info.

Definition at line 779 of file CGCall.cpp.

References clang::CodeGen::CGFunctionInfo::arg_begin(), clang::CodeGen::CGFunctionInfo::arg_end(), ConvertType(), ConvertTypeForMem(), clang::ABIArgInfo::Direct, clang::ABIArgInfo::Expand, clang::ABIArgInfo::Extend, clang::ABIArgInfo::getCoerceToType(), GetExpandedTypes(), clang::ABIArgInfo::getIndirectAlign(), clang::ABIArgInfo::getKind(), getLLVMContext(), clang::ABIArgInfo::getPaddingType(), clang::CodeGen::CGFunctionInfo::getReturnInfo(), clang::CodeGen::CGFunctionInfo::getReturnType(), clang::ASTContext::getTargetAddressSpace(), clang::ABIArgInfo::Ignore, clang::ABIArgInfo::Indirect, and clang::CodeGen::CGFunctionInfo::isVariadic().

Referenced by clang::CodeGen::CodeGenFunction::BuildAppleKextVirtualDestructorCall(), ConvertType(), clang::CodeGen::CodeGenFunction::EmitAtomicExpr(), clang::CodeGen::CodeGenFunction::EmitCall(), clang::CodeGen::CodeGenFunction::EmitCXXMemberCallExpr(), clang::CodeGen::CodeGenFunction::EmitCXXOperatorMemberCallee(), clang::CodeGen::CodeGenFunction::EmitForwardingCallToLambda(), clang::CodeGen::CGCXXABI::EmitLoadOfMemberFunctionPointer(), EmitObjectDelete(), generateByrefCopyHelper(), generateByrefDisposeHelper(), clang::CodeGen::CodeGenFunction::generateDestroyHelper(), clang::CodeGen::CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(), clang::CodeGen::CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction(), clang::CodeGen::CodeGenFunction::GenerateThunk(), clang::CodeGen::CodeGenFunction::GenerateVarArgsThunk(), clang::CodeGen::CodeGenModule::GetAddrOfCXXConstructor(), clang::CodeGen::CodeGenModule::GetAddrOfCXXDestructor(), GetFunctionType(), GetFunctionTypeForVTable(), and clang::CodeGen::CGObjCRuntime::getMessageSendInfo().

llvm::FunctionType * CodeGenTypes::GetFunctionType ( GlobalDecl  GD)

Definition at line 773 of file CGCall.cpp.

References arrangeGlobalDeclaration(), and GetFunctionType().

llvm::Type * CodeGenTypes::GetFunctionTypeForVTable ( GlobalDecl  GD)

GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable, given a CXXMethodDecl. If the method to has an incomplete return type, and/or incomplete argument types, this will return the opaque type.

Definition at line 858 of file CGCall.cpp.

References arrangeCXXDestructor(), arrangeCXXMethodDeclaration(), clang::GlobalDecl::getDecl(), clang::GlobalDecl::getDtorType(), GetFunctionType(), getLLVMContext(), clang::ValueDecl::getType(), and isFuncTypeConvertible().

Referenced by clang::CodeGen::CodeGenModule::GetAddrOfThunk().

llvm::LLVMContext& clang::CodeGen::CodeGenTypes::getLLVMContext ( ) [inline]
const TargetInfo& clang::CodeGen::CodeGenTypes::getTarget ( ) const [inline]

Definition at line 112 of file CodeGenTypes.h.

Referenced by clang::CodeGen::CGBitFieldInfo::MakeInfo().

const llvm::TargetData& clang::CodeGen::CodeGenTypes::getTargetData ( ) const [inline]
bool CodeGenTypes::isFuncTypeArgumentConvertible ( QualType  Ty)

isFuncTypeArgumentConvertible - Return true if the specified type in a function argument or result position can be converted to an IR type at this point. This boils down to being whether it is complete, as well as whether we've temporarily deferred expanding the type because we're in a recursive context.

Definition at line 194 of file CodeGenTypes.cpp.

References clang::RecordType::getDecl(), clang::Type::isIncompleteType(), and isSafeToConvert().

Referenced by isFuncTypeConvertible().

bool CodeGenTypes::isFuncTypeConvertible ( const FunctionType FT)

isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i.e. doesn't depend on an incomplete tag type).

Code to verify a given function type is complete, i.e. the return type and all of the argument types are complete. Also check to see if we are in a RS_StructPointer context, and if so whether any struct types have been pended. If so, we don't want to ask the ABI lowering code to handle a type that cannot be converted to an IR type.

Definition at line 223 of file CodeGenTypes.cpp.

References clang::FunctionType::getResultType(), and isFuncTypeArgumentConvertible().

Referenced by ConvertType(), and GetFunctionTypeForVTable().

bool clang::CodeGen::CodeGenTypes::isRecordBeingLaidOut ( const Type Ty) const [inline]

Definition at line 245 of file CodeGenTypes.h.

Referenced by isSafeToConvert().

bool CodeGenTypes::isRecordLayoutComplete ( const Type Ty) const

isRecordLayoutComplete - Return true if the specified type is already completely laid out.

Definition at line 101 of file CodeGenTypes.cpp.

Referenced by isSafeToConvert().

bool CodeGenTypes::isZeroInitializable ( QualType  T)
bool CodeGenTypes::isZeroInitializable ( const CXXRecordDecl RD)

IsZeroInitializable - Return whether a record type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.

Definition at line 674 of file CodeGenTypes.cpp.

References getCGRecordLayout(), and clang::CodeGen::CGRecordLayout::isZeroInitializable().

bool clang::CodeGen::CodeGenTypes::noRecordsBeingLaidOut ( ) const [inline]

Definition at line 242 of file CodeGenTypes.h.

Referenced by isSafeToConvert().

void CodeGenTypes::UpdateCompletedType ( const TagDecl TD)

UpdateCompletedType - When we find the full definition for a TagDecl, replace the 'opaque' type we previously made for it if applicable.

Definition at line 237 of file CodeGenTypes.cpp.

References ConvertRecordDeclType(), ConvertType(), clang::ASTContext::getTagDeclType(), clang::QualType::getTypePtr(), and clang::TagDecl::isDependentType().

Referenced by clang::CodeGen::CodeGenModule::UpdateCompletedType().


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