class CodeGenTypes

Declaration

class CodeGenTypes { /* full declaration omitted */ };

Description

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:54

Member Variables

private clang::CodeGen::CodeGenModule& CGM
private clang::ASTContext& Context
private llvm::Module& TheModule
private const clang::TargetInfo& Target
private clang::CodeGen::CGCXXABI& TheCXXABI
private const clang::CodeGen::ABIInfo& TheABIInfo
private llvm::DenseMap<const ObjCInterfaceType*, llvm::Type*> InterfaceTypes
The opaque type map for Objective-C interfaces. All direct manipulation is done by the runtime interfaces, which are responsible for coercing to the appropriate type; these opaque types are never refined.
private llvm::DenseMap<const Type*, std::unique_ptr<CGRecordLayout>> CGRecordLayouts
Maps clang struct type with corresponding record layout info.
private llvm::DenseMap<const Type*, llvm::StructType*> RecordDeclTypes
Contains the LLVM IR type for any converted RecordDecl.
private llvm::FoldingSet<CGFunctionInfo> FunctionInfos = {FunctionInfosLog2InitSize}
Hold memoized CGFunctionInfo results.
private llvm::SmallPtrSet<const Type*, 4> RecordsBeingLaidOut
This set keeps track of records that we're currently converting to an IR type. For example, when converting: struct A { struct B { int x; } } when processing 'x', the 'A' and 'B' types will be in this set.
private llvm::SmallPtrSet<const CGFunctionInfo*, 4> FunctionsBeingProcessed
private bool SkippedLayout
True if we didn't layout a function due to a being inside a recursive struct conversion, set this to true.
private SmallVector<const clang::RecordDecl*, 8> DeferredRecords
private llvm::DenseMap<const Type*, llvm::Type*> TypeCache
This map keeps cache of llvm::Types and maps clang::Type to corresponding llvm::Type.
private llvm::DenseMap<const Type*, llvm::Type*> RecordsWithOpaqueMemberPointers
private static const unsigned int FunctionInfosLog2InitSize = 9

Method Overview

Methods

unsigned int ClangCallConvToLLVMCallConv(
    clang::CallingConv CC)

Description

Convert clang calling convention to LLVM callilng convention.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:120

Parameters

clang::CallingConv CC

CodeGenTypes(clang::CodeGen::CodeGenModule& cgm)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:106

Parameters

clang::CodeGen::CodeGenModule& cgm

std::unique_ptr<CGRecordLayout>
ComputeRecordLayout(const clang::RecordDecl* D,
                    llvm::StructType* Ty)

Description

Compute a new LLVM record layout object for the given record.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:271

Parameters

const clang::RecordDecl* D
llvm::StructType* Ty

llvm::Type* ConvertFunctionTypeInternal(
    clang::QualType FT)

Description

Helper for ConvertType.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:103

Parameters

clang::QualType FT

llvm::StructType* ConvertRecordDeclType(
    const clang::RecordDecl* TD)

Description

ConvertRecordDeclType - Lay out a tagged decl type like struct or union.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:282

Parameters

const clang::RecordDecl* TD

llvm::Type* ConvertType(clang::QualType T)

Description

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:127

Parameters

clang::QualType T

llvm::Type* ConvertTypeForMem(
    clang::QualType T,
    bool ForBitField = false)

Description

ConvertTypeForMem - Convert type T into a llvm::Type. This differs from ConvertType in that it is used to convert to the memory representation for a type. For example, the scalar representation for _Bool is i1, but the memory representation is usually i8 or i32, depending on the target.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:133

Parameters

clang::QualType T
bool ForBitField = false

clang::CanQualType DeriveThisType(
    const clang::CXXRecordDecl* RD,
    const clang::CXXMethodDecl* MD)

Description

Derives the 'this' type for codegen purposes, i.e. ignoring method CVR qualification.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:124

Parameters

const clang::CXXRecordDecl* RD
const clang::CXXMethodDecl* MD

llvm::FunctionType* GetFunctionType(
    const clang::CodeGen::CGFunctionInfo& Info)

Description

GetFunctionType - Get the LLVM function type for

Declared at: clang/lib/CodeGen/CodeGenTypes.h:136

Parameters

const clang::CodeGen::CGFunctionInfo& Info

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:138

Parameters

clang::GlobalDecl GD

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

Description

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.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:154

Parameters

clang::GlobalDecl GD

void RefreshTypeCacheForClass(
    const clang::CXXRecordDecl* RD)

Description

Remove stale types from the type cache when an inheritance model gets assigned to a class.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:164

Parameters

const clang::CXXRecordDecl* RD

void UpdateCompletedType(const clang::TagDecl* TD)

Description

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:160

Parameters

const clang::TagDecl* TD

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

Description

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:276

Parameters

const clang::RecordDecl* RD
llvm::StructType* Ty
llvm::StringRef suffix

const clang::CodeGen::CGFunctionInfo&
arrangeBlockFunctionCall(
    const clang::CodeGen::CallArgList& args,
    const clang::FunctionType* type)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:231

Parameters

const clang::CodeGen::CallArgList& args
const clang::FunctionType* type

const clang::CodeGen::CGFunctionInfo&
arrangeBlockFunctionDeclaration(
    const clang::FunctionProtoType* type,
    const clang::CodeGen::FunctionArgList& args)

Description

Block invocation functions are C functions with an implicit parameter.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:228

Parameters

const clang::FunctionProtoType* type
const clang::CodeGen::FunctionArgList& args

const clang::CodeGen::CGFunctionInfo&
arrangeBuiltinFunctionCall(
    clang::QualType resultType,
    const clang::CodeGen::CallArgList& args)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:216

Parameters

clang::QualType resultType
const clang::CodeGen::CallArgList& args

const clang::CodeGen::CGFunctionInfo&
arrangeBuiltinFunctionDeclaration(
    clang::QualType resultType,
    const clang::CodeGen::FunctionArgList& args)

Description

A builtin function is a freestanding function using the default C conventions.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:211

Parameters

clang::QualType resultType
const clang::CodeGen::FunctionArgList& args

const clang::CodeGen::CGFunctionInfo&
arrangeBuiltinFunctionDeclaration(
    clang::CanQualType resultType,
    ArrayRef<clang::CanQualType> argTypes)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:214

Parameters

clang::CanQualType resultType
ArrayRef<clang::CanQualType> argTypes

const clang::CodeGen::CGFunctionInfo&
arrangeCXXConstructorCall(
    const clang::CodeGen::CallArgList& Args,
    const clang::CXXConstructorDecl* D,
    clang::CXXCtorType CtorKind,
    unsigned int ExtraPrefixArgs,
    unsigned int ExtraSuffixArgs,
    bool PassProtoArgs = true)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:237

Parameters

const clang::CodeGen::CallArgList& Args
const clang::CXXConstructorDecl* D
clang::CXXCtorType CtorKind
unsigned int ExtraPrefixArgs
unsigned int ExtraSuffixArgs
bool PassProtoArgs = true

const clang::CodeGen::CGFunctionInfo&
arrangeCXXMethodCall(
    const clang::CodeGen::CallArgList& args,
    const clang::FunctionProtoType* type,
    clang::CodeGen::RequiredArgs required,
    unsigned int numPrefixArgs)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:244

Parameters

const clang::CodeGen::CallArgList& args
const clang::FunctionProtoType* type
clang::CodeGen::RequiredArgs required
unsigned int numPrefixArgs

const clang::CodeGen::CGFunctionInfo&
arrangeCXXMethodDeclaration(
    const clang::CXXMethodDecl* MD)

Description

C++ methods have some special rules and also have implicit parameters.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:235

Parameters

const clang::CXXMethodDecl* MD

const clang::CodeGen::CGFunctionInfo&
arrangeCXXMethodType(
    const clang::CXXRecordDecl* RD,
    const clang::FunctionProtoType* FTP,
    const clang::CXXMethodDecl* MD)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:252

Parameters

const clang::CXXRecordDecl* RD
const clang::FunctionProtoType* FTP
const clang::CXXMethodDecl* MD

const clang::CodeGen::CGFunctionInfo&
arrangeCXXStructorDeclaration(
    clang::GlobalDecl GD)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:236

Parameters

clang::GlobalDecl GD

const clang::CodeGen::CGFunctionInfo& arrangeCall(
    const clang::CodeGen::CGFunctionInfo& declFI,
    const clang::CodeGen::CallArgList& args)

Description

Given a function info for a declaration, return the function info for a call with the given arguments. Often this will be able to simply return the declaration info.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:192

Parameters

const clang::CodeGen::CGFunctionInfo& declFI
const clang::CodeGen::CallArgList& args

const clang::CodeGen::CGFunctionInfo&
arrangeFreeFunctionCall(
    const clang::CodeGen::CallArgList& Args,
    const clang::FunctionType* Ty,
    bool ChainCall)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:198

Parameters

const clang::CodeGen::CallArgList& Args
const clang::FunctionType* Ty
bool ChainCall

const clang::CodeGen::CGFunctionInfo&
arrangeFreeFunctionType(
    CanQual<clang::FunctionNoProtoType> Ty)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:202

Parameters

CanQual<clang::FunctionNoProtoType> Ty

const clang::CodeGen::CGFunctionInfo&
arrangeFreeFunctionType(
    CanQual<clang::FunctionProtoType> Ty)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:201

Parameters

CanQual<clang::FunctionProtoType> Ty

const clang::CodeGen::CGFunctionInfo&
arrangeFunctionDeclaration(
    const clang::FunctionDecl* FD)

Description

Free functions are functions that are compatible with an ordinary C function pointer type.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:197

Parameters

const clang::FunctionDecl* FD

const clang::CodeGen::CGFunctionInfo&
arrangeGlobalDeclaration(clang::GlobalDecl GD)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:186

Parameters

clang::GlobalDecl GD

const clang::CodeGen::CGFunctionInfo&
arrangeLLVMFunctionInfo(
    clang::CanQualType returnType,
    bool instanceMethod,
    bool chainCall,
    ArrayRef<clang::CanQualType> argTypes,
    FunctionType::ExtInfo info,
    ArrayRef<FunctionProtoType::ExtParameterInfo>
        paramInfos,
    clang::CodeGen::RequiredArgs args)

Description

"Arrange" the LLVM information for a call or type with the given signature. This is largely an internal method; other clients should use one of the above routines, which ultimately defer to this.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:262

Parameters

clang::CanQualType returnType
bool instanceMethod
bool chainCall
ArrayRef<clang::CanQualType> argTypes
- must all actually be canonical as params
FunctionType::ExtInfo info
ArrayRef<FunctionProtoType::ExtParameterInfo> paramInfos
clang::CodeGen::RequiredArgs args

const clang::CodeGen::CGFunctionInfo&
arrangeMSCtorClosure(
    const clang::CXXConstructorDecl* CD,
    clang::CXXCtorType CT)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:250

Parameters

const clang::CXXConstructorDecl* CD
clang::CXXCtorType CT

const clang::CodeGen::CGFunctionInfo&
arrangeNullaryFunction()

Description

A nullary function is a freestanding function of type 'void ()'. This method works for both calls and declarations.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:206

const clang::CodeGen::CGFunctionInfo&
arrangeObjCMessageSendSignature(
    const clang::ObjCMethodDecl* MD,
    clang::QualType receiverType)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:221

Parameters

const clang::ObjCMethodDecl* MD
clang::QualType receiverType

const clang::CodeGen::CGFunctionInfo&
arrangeObjCMethodDeclaration(
    const clang::ObjCMethodDecl* MD)

Description

Objective-C methods are C functions with some implicit parameters.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:220

Parameters

const clang::ObjCMethodDecl* MD

const clang::CodeGen::CGFunctionInfo&
arrangeUnprototypedMustTailThunk(
    const clang::CXXMethodDecl* MD)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:249

Parameters

const clang::CXXMethodDecl* MD

const clang::CodeGen::CGFunctionInfo&
arrangeUnprototypedObjCMessageSend(
    clang::QualType returnType,
    const clang::CodeGen::CallArgList& args)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:223

Parameters

clang::QualType returnType
const clang::CodeGen::CallArgList& args

const clang::CodeGen::ABIInfo& getABIInfo() const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:113

const clang::CodeGen::CGRecordLayout&
getCGRecordLayout(const clang::RecordDecl*)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:156

Parameters

const clang::RecordDecl*

clang::CodeGen::CGCXXABI& getCXXABI() const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:115

const clang::CodeGenOptions& getCodeGenOpts()
    const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:117

clang::ASTContext& getContext() const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:112

const llvm::DataLayout& getDataLayout() const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:109

void getExpandedTypes(
    clang::QualType Ty,
    SmallVectorImpl<llvm::Type*>::iterator& TI)

Description

getExpandedTypes - Expand the type

Declared at: clang/lib/CodeGen/CodeGenTypes.h:286

Parameters

clang::QualType Ty
SmallVectorImpl<llvm::Type*>::iterator& TI

llvm::LLVMContext& getLLVMContext()

Declared at: clang/lib/CodeGen/CodeGenTypes.h:116

const clang::TargetInfo& getTarget() const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:114

bool inheritingCtorHasParams(
    const clang::InheritedConstructor& Inherited,
    clang::CXXCtorType Type)

Description

Determine if a C++ inheriting constructor should have parameters matching those of its inherited constructor.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:148

Parameters

const clang::InheritedConstructor& Inherited
clang::CXXCtorType Type

bool isFuncParamTypeConvertible(
    clang::QualType Ty)

Declared at: clang/lib/CodeGen/CodeGenTypes.h:144

Parameters

clang::QualType Ty

bool isFuncTypeConvertible(
    const clang::FunctionType* FT)

Description

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).

Declared at: clang/lib/CodeGen/CodeGenTypes.h:143

Parameters

const clang::FunctionType* FT

bool isPointerZeroInitializable(clang::QualType T)

Description

Check if the pointer type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.

Declared at: clang/lib/CodeGen/CodeGenTypes.h:295

Parameters

clang::QualType T

bool isRecordBeingLaidOut(
    const clang::Type* Ty) const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:305

Parameters

const clang::Type* Ty

bool isRecordLayoutComplete(
    const clang::Type* Ty) const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:301

Parameters

const clang::Type* Ty

bool isZeroInitializable(clang::QualType T)

Description

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:291

Parameters

clang::QualType T

bool isZeroInitializable(
    const clang::RecordDecl* RD)

Description

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

Declared at: clang/lib/CodeGen/CodeGenTypes.h:299

Parameters

const clang::RecordDecl* RD

bool noRecordsBeingLaidOut() const

Declared at: clang/lib/CodeGen/CodeGenTypes.h:302

~CodeGenTypes()

Declared at: clang/lib/CodeGen/CodeGenTypes.h:107