clang  6.0.0svn
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::CodeGen::CGObjCRuntime Class Referenceabstract

Implements runtime-specific code generation functions. More...

#include "/opt/doxygen-docs/src/llvm/tools/clang/lib/CodeGen/CGObjCRuntime.h"

Collaboration diagram for clang::CodeGen::CGObjCRuntime:
Collaboration graph
[legend]

Classes

struct  MessageSendInfo
 

Public Member Functions

virtual ~CGObjCRuntime ()
 
virtual llvm::Function * ModuleInitFunction ()=0
 Generate the function required to register all Objective-C components in this compilation unit with the runtime library. More...
 
virtual llvm::ValueGetSelector (CodeGenFunction &CGF, Selector Sel)=0
 Get a selector for the specified name and type values. More...
 
virtual Address GetAddrOfSelector (CodeGenFunction &CGF, Selector Sel)=0
 Get the address of a selector for the specified name and type values. More...
 
virtual llvm::ValueGetSelector (CodeGenFunction &CGF, const ObjCMethodDecl *Method)=0
 Get a typed selector. More...
 
virtual llvm::Constant * GetEHType (QualType T)=0
 Get the type constant to catch for the given ObjC pointer type. More...
 
virtual ConstantAddress GenerateConstantString (const StringLiteral *)=0
 Generate a constant string object. More...
 
virtual void GenerateCategory (const ObjCCategoryImplDecl *OCD)=0
 Generate a category. More...
 
virtual void GenerateClass (const ObjCImplementationDecl *OID)=0
 Generate a class structure for this class. More...
 
virtual void RegisterAlias (const ObjCCompatibleAliasDecl *OAD)=0
 Register an class alias. More...
 
virtual CodeGen::RValue GenerateMessageSend (CodeGen::CodeGenFunction &CGF, ReturnValueSlot ReturnSlot, QualType ResultType, Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs, const ObjCInterfaceDecl *Class=nullptr, const ObjCMethodDecl *Method=nullptr)=0
 Generate an Objective-C message send operation. More...
 
virtual CodeGen::RValue GenerateMessageSendSuper (CodeGen::CodeGenFunction &CGF, ReturnValueSlot ReturnSlot, QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class, bool isCategoryImpl, llvm::Value *Self, bool IsClassMessage, const CallArgList &CallArgs, const ObjCMethodDecl *Method=nullptr)=0
 Generate an Objective-C message send operation to the super class initiated in a method for Class and with the given Self object. More...
 
virtual llvm::ValueGenerateProtocolRef (CodeGenFunction &CGF, const ObjCProtocolDecl *OPD)=0
 Emit the code to return the named protocol as an object, as in a @protocol expression. More...
 
virtual void GenerateProtocol (const ObjCProtocolDecl *OPD)=0
 Generate the named protocol. More...
 
virtual llvm::Function * GenerateMethod (const ObjCMethodDecl *OMD, const ObjCContainerDecl *CD)=0
 Generate a function preamble for a method with the specified types. More...
 
virtual llvm::Constant * GetPropertyGetFunction ()=0
 Return the runtime function for getting properties. More...
 
virtual llvm::Constant * GetPropertySetFunction ()=0
 Return the runtime function for setting properties. More...
 
virtual llvm::Constant * GetOptimizedPropertySetFunction (bool atomic, bool copy)=0
 Return the runtime function for optimized setting properties. More...
 
virtual llvm::Constant * GetGetStructFunction ()=0
 
virtual llvm::Constant * GetSetStructFunction ()=0
 
virtual llvm::Constant * GetCppAtomicObjectSetFunction ()=0
 API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in setter. More...
 
virtual llvm::Constant * GetCppAtomicObjectGetFunction ()=0
 API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in getter. More...
 
virtual llvm::ValueGetClass (CodeGenFunction &CGF, const ObjCInterfaceDecl *OID)=0
 GetClass - Return a reference to the class for the given interface decl. More...
 
virtual llvm::ValueEmitNSAutoreleasePoolClassRef (CodeGenFunction &CGF)
 
virtual llvm::Constant * EnumerationMutationFunction ()=0
 EnumerationMutationFunction - Return the function that's called by the compiler when a mutation is detected during foreach iteration. More...
 
virtual void EmitSynchronizedStmt (CodeGen::CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S)=0
 
virtual void EmitTryStmt (CodeGen::CodeGenFunction &CGF, const ObjCAtTryStmt &S)=0
 
virtual void EmitThrowStmt (CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, bool ClearInsertionPoint=true)=0
 
virtual llvm::ValueEmitObjCWeakRead (CodeGen::CodeGenFunction &CGF, Address AddrWeakObj)=0
 
virtual void EmitObjCWeakAssign (CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest)=0
 
virtual void EmitObjCGlobalAssign (CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest, bool threadlocal=false)=0
 
virtual void EmitObjCIvarAssign (CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest, llvm::Value *ivarOffset)=0
 
virtual void EmitObjCStrongCastAssign (CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest)=0
 
virtual LValue EmitObjCValueForIvar (CodeGen::CodeGenFunction &CGF, QualType ObjectTy, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)=0
 
virtual llvm::ValueEmitIvarOffset (CodeGen::CodeGenFunction &CGF, const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)=0
 
virtual void EmitGCMemmoveCollectable (CodeGen::CodeGenFunction &CGF, Address DestPtr, Address SrcPtr, llvm::Value *Size)=0
 
virtual llvm::Constant * BuildGCBlockLayout (CodeGen::CodeGenModule &CGM, const CodeGen::CGBlockInfo &blockInfo)=0
 
virtual llvm::Constant * BuildRCBlockLayout (CodeGen::CodeGenModule &CGM, const CodeGen::CGBlockInfo &blockInfo)=0
 
virtual llvm::Constant * BuildByrefLayout (CodeGen::CodeGenModule &CGM, QualType T)=0
 Returns an i8* which points to the byref layout information. More...
 
MessageSendInfo getMessageSendInfo (const ObjCMethodDecl *method, QualType resultType, CallArgList &callArgs)
 Compute the pointer-to-function type to which a message send should be casted in order to correctly call the given method with the given arguments. More...
 
unsigned ComputeBitfieldBitOffset (CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar)
 

Protected Member Functions

 CGObjCRuntime (CodeGen::CodeGenModule &CGM)
 
uint64_t ComputeIvarBaseOffset (CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar)
 Compute an offset to the given ivar, suitable for passing to EmitValueForIvarAtOffset. More...
 
uint64_t ComputeIvarBaseOffset (CodeGen::CodeGenModule &CGM, const ObjCImplementationDecl *OID, const ObjCIvarDecl *Ivar)
 
LValue EmitValueForIvarAtOffset (CodeGen::CodeGenFunction &CGF, const ObjCInterfaceDecl *OID, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers, llvm::Value *Offset)
 
void EmitTryCatchStmt (CodeGenFunction &CGF, const ObjCAtTryStmt &S, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *exceptionRethrowFn)
 Emits a try / catch statement. More...
 
void EmitInitOfCatchParam (CodeGenFunction &CGF, llvm::Value *exn, const VarDecl *paramDecl)
 
void EmitAtSynchronizedStmt (CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S, llvm::Function *syncEnterFn, llvm::Function *syncExitFn)
 Emits an @synchronize() statement, using the syncEnterFn and syncExitFn arguments as the functions called to lock and unlock the object. More...
 

Protected Attributes

CodeGen::CodeGenModuleCGM
 

Detailed Description

Implements runtime-specific code generation functions.

Definition at line 63 of file CGObjCRuntime.h.

Constructor & Destructor Documentation

◆ CGObjCRuntime()

clang::CodeGen::CGObjCRuntime::CGObjCRuntime ( CodeGen::CodeGenModule CGM)
inlineprotected

Definition at line 66 of file CGObjCRuntime.h.

◆ ~CGObjCRuntime()

CGObjCRuntime::~CGObjCRuntime ( )
virtual

Definition at line 3470 of file CGObjC.cpp.

Member Function Documentation

◆ BuildByrefLayout()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::BuildByrefLayout ( CodeGen::CodeGenModule CGM,
QualType  T 
)
pure virtual

Returns an i8* which points to the byref layout information.

◆ BuildGCBlockLayout()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::BuildGCBlockLayout ( CodeGen::CodeGenModule CGM,
const CodeGen::CGBlockInfo blockInfo 
)
pure virtual

Referenced by buildBlockDescriptor().

◆ BuildRCBlockLayout()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::BuildRCBlockLayout ( CodeGen::CodeGenModule CGM,
const CodeGen::CGBlockInfo blockInfo 
)
pure virtual

Referenced by buildBlockDescriptor().

◆ ComputeBitfieldBitOffset()

unsigned CGObjCRuntime::ComputeBitfieldBitOffset ( CodeGen::CodeGenModule CGM,
const ObjCInterfaceDecl ID,
const ObjCIvarDecl Ivar 
)

◆ ComputeIvarBaseOffset() [1/2]

uint64_t CGObjCRuntime::ComputeIvarBaseOffset ( CodeGen::CodeGenModule CGM,
const ObjCInterfaceDecl OID,
const ObjCIvarDecl Ivar 
)
protected

Compute an offset to the given ivar, suitable for passing to EmitValueForIvarAtOffset.

Note that the correct handling of bit-fields is carefully coordinated by these two, use caution!

The latter overload is suitable for computing the offset of a sythesized ivar.

Definition at line 29 of file CGObjCRuntime.cpp.

References clang::ASTContext::getCharWidth(), clang::CodeGen::CodeGenModule::getContext(), and clang::ASTContext::lookupFieldBitOffset().

◆ ComputeIvarBaseOffset() [2/2]

uint64_t CGObjCRuntime::ComputeIvarBaseOffset ( CodeGen::CodeGenModule CGM,
const ObjCImplementationDecl OID,
const ObjCIvarDecl Ivar 
)
protected

◆ EmitAtSynchronizedStmt()

void CGObjCRuntime::EmitAtSynchronizedStmt ( CodeGenFunction CGF,
const ObjCAtSynchronizedStmt S,
llvm::Function *  syncEnterFn,
llvm::Function *  syncExitFn 
)
protected

Emits an @synchronize() statement, using the syncEnterFn and syncExitFn arguments as the functions called to lock and unlock the object.

This function can be called by subclasses that use zero-cost exception handling.

Definition at line 285 of file CGObjCRuntime.cpp.

◆ EmitGCMemmoveCollectable()

virtual void clang::CodeGen::CGObjCRuntime::EmitGCMemmoveCollectable ( CodeGen::CodeGenFunction CGF,
Address  DestPtr,
Address  SrcPtr,
llvm::Value Size 
)
pure virtual

◆ EmitInitOfCatchParam()

void CGObjCRuntime::EmitInitOfCatchParam ( CodeGenFunction CGF,
llvm::Value exn,
const VarDecl paramDecl 
)
protected

◆ EmitIvarOffset()

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::EmitIvarOffset ( CodeGen::CodeGenFunction CGF,
const ObjCInterfaceDecl Interface,
const ObjCIvarDecl Ivar 
)
pure virtual

◆ EmitNSAutoreleasePoolClassRef()

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::EmitNSAutoreleasePoolClassRef ( CodeGenFunction CGF)
inlinevirtual

◆ EmitObjCGlobalAssign()

virtual void clang::CodeGen::CGObjCRuntime::EmitObjCGlobalAssign ( CodeGen::CodeGenFunction CGF,
llvm::Value src,
Address  dest,
bool  threadlocal = false 
)
pure virtual

◆ EmitObjCIvarAssign()

virtual void clang::CodeGen::CGObjCRuntime::EmitObjCIvarAssign ( CodeGen::CodeGenFunction CGF,
llvm::Value src,
Address  dest,
llvm::Value ivarOffset 
)
pure virtual

◆ EmitObjCStrongCastAssign()

virtual void clang::CodeGen::CGObjCRuntime::EmitObjCStrongCastAssign ( CodeGen::CodeGenFunction CGF,
llvm::Value src,
Address  dest 
)
pure virtual

◆ EmitObjCValueForIvar()

virtual LValue clang::CodeGen::CGObjCRuntime::EmitObjCValueForIvar ( CodeGen::CodeGenFunction CGF,
QualType  ObjectTy,
llvm::Value BaseValue,
const ObjCIvarDecl Ivar,
unsigned  CVRQualifiers 
)
pure virtual

◆ EmitObjCWeakAssign()

virtual void clang::CodeGen::CGObjCRuntime::EmitObjCWeakAssign ( CodeGen::CodeGenFunction CGF,
llvm::Value src,
Address  dest 
)
pure virtual

◆ EmitObjCWeakRead()

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::EmitObjCWeakRead ( CodeGen::CodeGenFunction CGF,
Address  AddrWeakObj 
)
pure virtual

◆ EmitSynchronizedStmt()

virtual void clang::CodeGen::CGObjCRuntime::EmitSynchronizedStmt ( CodeGen::CodeGenFunction CGF,
const ObjCAtSynchronizedStmt S 
)
pure virtual

◆ EmitThrowStmt()

virtual void clang::CodeGen::CGObjCRuntime::EmitThrowStmt ( CodeGen::CodeGenFunction CGF,
const ObjCAtThrowStmt S,
bool  ClearInsertionPoint = true 
)
pure virtual

◆ EmitTryCatchStmt()

void CGObjCRuntime::EmitTryCatchStmt ( CodeGenFunction CGF,
const ObjCAtTryStmt S,
llvm::Constant *  beginCatchFn,
llvm::Constant *  endCatchFn,
llvm::Constant *  exceptionRethrowFn 
)
protected

Emits a try / catch statement.

This function is intended to be called by subclasses, and provides a generic mechanism for generating these, which should be usable by all runtimes. The caller must provide the functions to call when entering and exiting a @catch() block, and the function used to rethrow exceptions. If the begin and end catch functions are NULL, then the function assumes that the EH personality function provides the thrown object directly.

Definition at line 141 of file CGObjCRuntime.cpp.

◆ EmitTryStmt()

virtual void clang::CodeGen::CGObjCRuntime::EmitTryStmt ( CodeGen::CodeGenFunction CGF,
const ObjCAtTryStmt S 
)
pure virtual

◆ EmitValueForIvarAtOffset()

LValue CGObjCRuntime::EmitValueForIvarAtOffset ( CodeGen::CodeGenFunction CGF,
const ObjCInterfaceDecl OID,
llvm::Value BaseValue,
const ObjCIvarDecl Ivar,
unsigned  CVRQualifiers,
llvm::Value Offset 
)
protected

◆ EnumerationMutationFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::EnumerationMutationFunction ( )
pure virtual

EnumerationMutationFunction - Return the function that's called by the compiler when a mutation is detected during foreach iteration.

◆ GenerateCategory()

virtual void clang::CodeGen::CGObjCRuntime::GenerateCategory ( const ObjCCategoryImplDecl OCD)
pure virtual

Generate a category.

A category contains a list of methods (and accompanying metadata) and a list of protocols.

◆ GenerateClass()

virtual void clang::CodeGen::CGObjCRuntime::GenerateClass ( const ObjCImplementationDecl OID)
pure virtual

Generate a class structure for this class.

◆ GenerateConstantString()

virtual ConstantAddress clang::CodeGen::CGObjCRuntime::GenerateConstantString ( const StringLiteral )
pure virtual

Generate a constant string object.

◆ GenerateMessageSend()

virtual CodeGen::RValue clang::CodeGen::CGObjCRuntime::GenerateMessageSend ( CodeGen::CodeGenFunction CGF,
ReturnValueSlot  ReturnSlot,
QualType  ResultType,
Selector  Sel,
llvm::Value Receiver,
const CallArgList CallArgs,
const ObjCInterfaceDecl Class = nullptr,
const ObjCMethodDecl Method = nullptr 
)
pure virtual

Generate an Objective-C message send operation.

Parameters
Method- The method being called, this may be null if synthesizing a property setter or getter.

Referenced by clang::CodeGen::CodeGenFunction::EmitBlockCopyAndAutorelease(), clang::CodeGen::CodeGenFunction::EmitObjCMRRAutoreleasePoolPop(), and clang::CodeGen::CodeGenFunction::EmitObjCMRRAutoreleasePoolPush().

◆ GenerateMessageSendSuper()

virtual CodeGen::RValue clang::CodeGen::CGObjCRuntime::GenerateMessageSendSuper ( CodeGen::CodeGenFunction CGF,
ReturnValueSlot  ReturnSlot,
QualType  ResultType,
Selector  Sel,
const ObjCInterfaceDecl Class,
bool  isCategoryImpl,
llvm::Value Self,
bool  IsClassMessage,
const CallArgList CallArgs,
const ObjCMethodDecl Method = nullptr 
)
pure virtual

Generate an Objective-C message send operation to the super class initiated in a method for Class and with the given Self object.

Parameters
Method- The method being called, this may be null if synthesizing a property setter or getter.

◆ GenerateMethod()

virtual llvm::Function* clang::CodeGen::CGObjCRuntime::GenerateMethod ( const ObjCMethodDecl OMD,
const ObjCContainerDecl CD 
)
pure virtual

Generate a function preamble for a method with the specified types.

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

◆ GenerateProtocol()

virtual void clang::CodeGen::CGObjCRuntime::GenerateProtocol ( const ObjCProtocolDecl OPD)
pure virtual

Generate the named protocol.

Protocols contain method metadata but no implementations.

◆ GenerateProtocolRef()

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::GenerateProtocolRef ( CodeGenFunction CGF,
const ObjCProtocolDecl OPD 
)
pure virtual

Emit the code to return the named protocol as an object, as in a @protocol expression.

◆ GetAddrOfSelector()

virtual Address clang::CodeGen::CGObjCRuntime::GetAddrOfSelector ( CodeGenFunction CGF,
Selector  Sel 
)
pure virtual

Get the address of a selector for the specified name and type values.

This is a rarely-used language extension, but sadly it exists.

The result should have the LLVM type for a pointer to ASTContext::getObjCSelType().

◆ GetClass()

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::GetClass ( CodeGenFunction CGF,
const ObjCInterfaceDecl OID 
)
pure virtual

GetClass - Return a reference to the class for the given interface decl.

◆ GetCppAtomicObjectGetFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetCppAtomicObjectGetFunction ( )
pure virtual

API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in getter.

Referenced by emitCPPObjectAtomicGetterCall().

◆ GetCppAtomicObjectSetFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetCppAtomicObjectSetFunction ( )
pure virtual

API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in setter.

Referenced by emitCPPObjectAtomicSetterCall().

◆ GetEHType()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetEHType ( QualType  T)
pure virtual

Get the type constant to catch for the given ObjC pointer type.

This is used externally to implement catching ObjC types in C++. Runtimes which don't support this should add the appropriate error to Sema.

◆ GetGetStructFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetGetStructFunction ( )
pure virtual

◆ getMessageSendInfo()

CGObjCRuntime::MessageSendInfo CGObjCRuntime::getMessageSendInfo ( const ObjCMethodDecl method,
QualType  resultType,
CallArgList callArgs 
)

Compute the pointer-to-function type to which a message send should be casted in order to correctly call the given method with the given arguments.

Parameters
method- may be null
resultType- the result type to use if there's no method
callArgs- the actual arguments, including implicit ones

Definition at line 321 of file CGObjCRuntime.cpp.

References clang::CodeGen::CodeGenTypes::arrangeCall(), clang::CodeGen::CodeGenTypes::arrangeObjCMessageSendSignature(), clang::CodeGen::CodeGenTypes::arrangeUnprototypedObjCMessageSend(), CGM, clang::CodeGen::CodeGenTypes::GetFunctionType(), and clang::CodeGen::CodeGenModule::getTypes().

◆ GetOptimizedPropertySetFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetOptimizedPropertySetFunction ( bool  atomic,
bool  copy 
)
pure virtual

Return the runtime function for optimized setting properties.

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

◆ GetPropertyGetFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetPropertyGetFunction ( )
pure virtual

Return the runtime function for getting properties.

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

◆ GetPropertySetFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetPropertySetFunction ( )
pure virtual

Return the runtime function for setting properties.

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

◆ GetSelector() [1/2]

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::GetSelector ( CodeGenFunction CGF,
Selector  Sel 
)
pure virtual

Get a selector for the specified name and type values.

The result should have the LLVM type for ASTContext::getObjCSelType().

◆ GetSelector() [2/2]

virtual llvm::Value* clang::CodeGen::CGObjCRuntime::GetSelector ( CodeGenFunction CGF,
const ObjCMethodDecl Method 
)
pure virtual

Get a typed selector.

◆ GetSetStructFunction()

virtual llvm::Constant* clang::CodeGen::CGObjCRuntime::GetSetStructFunction ( )
pure virtual

Referenced by emitStructSetterCall().

◆ ModuleInitFunction()

virtual llvm::Function* clang::CodeGen::CGObjCRuntime::ModuleInitFunction ( )
pure virtual

Generate the function required to register all Objective-C components in this compilation unit with the runtime library.

◆ RegisterAlias()

virtual void clang::CodeGen::CGObjCRuntime::RegisterAlias ( const ObjCCompatibleAliasDecl OAD)
pure virtual

Register an class alias.

Member Data Documentation

◆ CGM

CodeGen::CodeGenModule& clang::CodeGen::CGObjCRuntime::CGM
protected

Definition at line 65 of file CGObjCRuntime.h.

Referenced by getMessageSendInfo().


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