clang  3.9.0svn
Typedefs | Functions
CGObjC.cpp File Reference
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CodeGenFunction.h"
#include "CodeGenModule.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/StmtObjC.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
Include dependency graph for CGObjC.cpp:

Go to the source code of this file.

Typedefs

typedef llvm::PointerIntPair< llvm::Value *, 1, boolTryEmitResult
 
typedef llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, llvm::Value *value)> ValueTransform
 

Functions

static TryEmitResult tryEmitARCRetainScalarExpr (CodeGenFunction &CGF, const Expr *e)
 
static RValue AdjustObjCObjectType (CodeGenFunction &CGF, QualType ExpT, RValue Result)
 Adjust the type of an Objective-C object that doesn't match up due to type erasure at various points, e.g., related result types or the use of parameterized classes. More...
 
static llvm::Constant * getNullForVariable (Address addr)
 Given the address of a variable of pointer type, find the correct null to store into it. More...
 
static bool shouldExtendReceiverForInnerPointerMessage (const ObjCMessageExpr *message)
 Decide whether to extend the lifetime of the receiver of a returns-inner-pointer message. More...
 
static const ExprfindWeakLValue (const Expr *E)
 Given an expression of ObjC pointer type, check whether it was immediately loaded from an ARC __weak l-value. More...
 
static llvm::ValueemitARCRetainLoadOfScalar (CodeGenFunction &CGF, LValue lvalue, QualType type)
 
static void emitStructGetterCall (CodeGenFunction &CGF, ObjCIvarDecl *ivar, bool isAtomic, bool hasStrong)
 emitStructGetterCall - Call the runtime function to load a property into the return value slot. More...
 
static bool hasUnalignedAtomics (llvm::Triple::ArchType arch)
 Determine whether the given architecture supports unaligned atomic accesses. More...
 
static CharUnits getMaxAtomicAccessSize (CodeGenModule &CGM, llvm::Triple::ArchType arch)
 Return the maximum size that permits atomic accesses for the given architecture. More...
 
static bool hasTrivialGetExpr (const ObjCPropertyImplDecl *propImpl)
 
static void emitCPPObjectAtomicGetterCall (CodeGenFunction &CGF, llvm::Value *returnAddr, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn)
 emitCPPObjectAtomicGetterCall - Call the runtime function to copy the ivar into the resturn slot. More...
 
static void emitStructSetterCall (CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar)
 emitStructSetterCall - Call the runtime function to store the value from the first formal parameter into the given ivar. More...
 
static void emitCPPObjectAtomicSetterCall (CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn)
 emitCPPObjectAtomicSetterCall - Call the runtime function to store the value from the first formal parameter into the given ivar, using the Cpp API for atomic Cpp objects with non-trivial copy assignment. More...
 
static bool hasTrivialSetExpr (const ObjCPropertyImplDecl *PID)
 
static bool UseOptimizedSetter (CodeGenModule &CGM)
 
static void destroyARCStrongWithStore (CodeGenFunction &CGF, Address addr, QualType type)
 Like CodeGenFunction::destroyARCStrong, but do it with a call. More...
 
static void emitCXXDestructMethod (CodeGenFunction &CGF, ObjCImplementationDecl *impl)
 
static llvm::Constant * createARCRuntimeFunction (CodeGenModule &CGM, llvm::FunctionType *type, StringRef fnName)
 
static llvm::ValueemitARCValueOperation (CodeGenFunction &CGF, llvm::Value *value, llvm::Constant *&fn, StringRef fnName, bool isTailCall=false)
 Perform an operation having the signature i8* (i8*) where a null input causes a no-op and returns null. More...
 
static llvm::ValueemitARCLoadOperation (CodeGenFunction &CGF, Address addr, llvm::Constant *&fn, StringRef fnName)
 Perform an operation having the following signature: i8* (i8**) More...
 
static llvm::ValueemitARCStoreOperation (CodeGenFunction &CGF, Address addr, llvm::Value *value, llvm::Constant *&fn, StringRef fnName, bool ignored)
 Perform an operation having the following signature: i8* (i8**, i8*) More...
 
static void emitARCCopyOperation (CodeGenFunction &CGF, Address dst, Address src, llvm::Constant *&fn, StringRef fnName)
 Perform an operation having the following signature: void (i8**, i8**) More...
 
static void emitAutoreleasedReturnValueMarker (CodeGenFunction &CGF)
 
static TryEmitResult tryEmitARCRetainLoadOfScalar (CodeGenFunction &CGF, LValue lvalue, QualType type)
 
static TryEmitResult tryEmitARCRetainLoadOfScalar (CodeGenFunction &CGF, const Expr *e)
 
static llvm::ValueemitARCOperationAfterCall (CodeGenFunction &CGF, llvm::Value *value, ValueTransform doAfterCall, ValueTransform doFallback)
 Insert code immediately after a call. More...
 
static llvm::ValueemitARCRetainCallResult (CodeGenFunction &CGF, const Expr *e)
 Given that the given expression is some sort of call (which does not return retained), emit a retain following it. More...
 
static llvm::ValueemitARCUnsafeClaimCallResult (CodeGenFunction &CGF, const Expr *e)
 Given that the given expression is some sort of call (which does not return retained), perform an unsafeClaim following it. More...
 
static bool shouldEmitSeparateBlockRetain (const Expr *e)
 Determine whether it might be important to emit a separate objc_retain_block on the result of the given expression, or whether it's okay to just emit it in a +1 context. More...
 
static llvm::ValueemitARCUnsafeUnretainedScalarExpr (CodeGenFunction &CGF, const Expr *e)
 

Typedef Documentation

typedef llvm::PointerIntPair<llvm::Value*,1,bool> TryEmitResult

Definition at line 31 of file CGObjC.cpp.

typedef llvm::function_ref<llvm::Value *(CodeGenFunction &CGF, llvm::Value *value)> ValueTransform

Definition at line 2462 of file CGObjC.cpp.

Function Documentation

static RValue AdjustObjCObjectType ( CodeGenFunction CGF,
QualType  ExpT,
RValue  Result 
)
static

Adjust the type of an Objective-C object that doesn't match up due to type erasure at various points, e.g., related result types or the use of parameterized classes.

Definition at line 251 of file CGObjC.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::ConvertType(), clang::CodeGen::CGBuilderTy::CreateBitCast(), clang::CodeGen::RValue::get(), clang::CodeGen::RValue::getScalarVal(), clang::Type::isObjCRetainableType(), and clang::CodeGen::Type.

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

static llvm::Constant* createARCRuntimeFunction ( CodeGenModule CGM,
llvm::FunctionType *  type,
StringRef  fnName 
)
static
static void destroyARCStrongWithStore ( CodeGenFunction CGF,
Address  addr,
QualType  type 
)
static

Like CodeGenFunction::destroyARCStrong, but do it with a call.

Definition at line 1359 of file CGObjC.cpp.

References clang::CodeGen::CodeGenFunction::EmitARCStoreStrongCall(), and getNullForVariable().

Referenced by emitCXXDestructMethod().

static void emitARCCopyOperation ( CodeGenFunction CGF,
Address  dst,
Address  src,
llvm::Constant *&  fn,
StringRef  fnName 
)
static
static llvm::Value* emitARCLoadOperation ( CodeGenFunction CGF,
Address  addr,
llvm::Constant *&  fn,
StringRef  fnName 
)
static
static llvm::Value* emitARCOperationAfterCall ( CodeGenFunction CGF,
llvm::Value value,
ValueTransform  doAfterCall,
ValueTransform  doFallback 
)
static

Insert code immediately after a call.

Definition at line 2465 of file CGObjC.cpp.

References clang::CodeGen::CodeGenFunction::Builder.

Referenced by emitARCRetainCallResult(), and emitARCUnsafeClaimCallResult().

static llvm::Value* emitARCRetainCallResult ( CodeGenFunction CGF,
const Expr e 
)
static
static llvm::Value * emitARCRetainLoadOfScalar ( CodeGenFunction CGF,
LValue  lvalue,
QualType  type 
)
static
static llvm::Value* emitARCStoreOperation ( CodeGenFunction CGF,
Address  addr,
llvm::Value value,
llvm::Constant *&  fn,
StringRef  fnName,
bool  ignored 
)
static
static llvm::Value* emitARCUnsafeClaimCallResult ( CodeGenFunction CGF,
const Expr e 
)
static

Given that the given expression is some sort of call (which does not return retained), perform an unsafeClaim following it.

Definition at line 2522 of file CGObjC.cpp.

References emitARCOperationAfterCall(), clang::CodeGen::CodeGenFunction::EmitARCUnsafeClaimAutoreleasedReturnValue(), and clang::CodeGen::CodeGenFunction::EmitScalarExpr().

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

static llvm::Value* emitARCUnsafeUnretainedScalarExpr ( CodeGenFunction CGF,
const Expr e 
)
static
static llvm::Value* emitARCValueOperation ( CodeGenFunction CGF,
llvm::Value value,
llvm::Constant *&  fn,
StringRef  fnName,
bool  isTailCall = false 
)
static
static void emitAutoreleasedReturnValueMarker ( CodeGenFunction CGF)
static
static void emitCPPObjectAtomicGetterCall ( CodeGenFunction CGF,
llvm::Value returnAddr,
ObjCIvarDecl ivar,
llvm::Constant *  AtomicHelperFn 
)
static
static void emitCPPObjectAtomicSetterCall ( CodeGenFunction CGF,
ObjCMethodDecl OMD,
ObjCIvarDecl ivar,
llvm::Constant *  AtomicHelperFn 
)
static
static void emitCXXDestructMethod ( CodeGenFunction CGF,
ObjCImplementationDecl impl 
)
static
static void emitStructGetterCall ( CodeGenFunction CGF,
ObjCIvarDecl ivar,
bool  isAtomic,
bool  hasStrong 
)
static
static void emitStructSetterCall ( CodeGenFunction CGF,
ObjCMethodDecl OMD,
ObjCIvarDecl ivar 
)
static
static const Expr* findWeakLValue ( const Expr E)
static

Given an expression of ObjC pointer type, check whether it was immediately loaded from an ARC __weak l-value.

Definition at line 328 of file CGObjC.cpp.

References clang::Expr::getType(), clang::Expr::IgnoreParens(), clang::Type::isObjCRetainableType(), and clang::Qualifiers::OCL_Weak.

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

static CharUnits getMaxAtomicAccessSize ( CodeGenModule CGM,
llvm::Triple::ArchType  arch 
)
static
static llvm::Constant* getNullForVariable ( Address  addr)
static
static bool hasTrivialGetExpr ( const ObjCPropertyImplDecl propImpl)
static
static bool hasTrivialSetExpr ( const ObjCPropertyImplDecl PID)
static
static bool hasUnalignedAtomics ( llvm::Triple::ArchType  arch)
static

Determine whether the given architecture supports unaligned atomic accesses.

They don't have to be fast, just faster than a function call and a mutex.

Definition at line 600 of file CGObjC.cpp.

Referenced by getMaxAtomicAccessSize().

static bool shouldEmitSeparateBlockRetain ( const Expr e)
static

Determine whether it might be important to emit a separate objc_retain_block on the result of the given expression, or whether it's okay to just emit it in a +1 context.

Definition at line 2548 of file CGObjC.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::cast(), clang::CodeGen::CodeGenFunction::ConvertType(), clang::CodeGen::CGBuilderTy::CreateBitCast(), clang::CodeGen::CodeGenFunction::EmitARCRetainBlock(), emitARCRetainCallResult(), clang::CodeGen::CodeGenFunction::EmitCheckedLValue(), clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(), clang::CodeGen::CodeGenFunction::EmitScalarExpr(), clang::CodeGen::CodeGenFunction::EmitStoreThroughLValue(), clang::CodeGen::CodeGenFunction::EnsureInsertPoint(), clang::CodeGen::RValue::get(), clang::CastExpr::getCastKind(), clang::BinaryOperator::getLHS(), clang::QualType::getObjCLifetime(), clang::BinaryOperator::getOpcode(), clang::PseudoObjectExpr::getResultExpr(), clang::BinaryOperator::getRHS(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::Type::hasPointerRepresentation(), clang::Expr::IgnoreParens(), clang::Type::isBlockPointerType(), clang::Qualifiers::OCL_Autoreleasing, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, clang::Result, clang::PseudoObjectExpr::semantics_begin(), clang::PseudoObjectExpr::semantics_end(), clang::CodeGen::CodeGenFunction::TCK_Store, tryEmitARCRetainLoadOfScalar(), and clang::CodeGen::Type.

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

static bool shouldExtendReceiverForInnerPointerMessage ( const ObjCMessageExpr message)
static
static TryEmitResult tryEmitARCRetainLoadOfScalar ( CodeGenFunction CGF,
LValue  lvalue,
QualType  type 
)
static
static TryEmitResult tryEmitARCRetainLoadOfScalar ( CodeGenFunction CGF,
const Expr e 
)
static
static TryEmitResult tryEmitARCRetainScalarExpr ( CodeGenFunction CGF,
const Expr e 
)
static
static bool UseOptimizedSetter ( CodeGenModule CGM)
static