clang 10.0.0git

Enumerations | Functions
CGBlocks.cpp File Reference
`#include "CGBlocks.h"`
`#include "CGCXXABI.h"`
`#include "CGDebugInfo.h"`
`#include "CGObjCRuntime.h"`
`#include "CGOpenCLRuntime.h"`
`#include "CodeGenFunction.h"`
`#include "CodeGenModule.h"`
`#include "ConstantEmitter.h"`
`#include "TargetInfo.h"`
`#include "clang/AST/Attr.h"`
`#include "clang/AST/DeclObjC.h"`
`#include "clang/CodeGen/ConstantInitBuilder.h"`
`#include "llvm/ADT/SmallSet.h"`
`#include "llvm/IR/DataLayout.h"`
`#include "llvm/IR/Module.h"`
`#include "llvm/Support/ScopedPrinter.h"`
`#include <algorithm>`
`#include <cstdio>`
Include dependency graph for CGBlocks.cpp:

Go to the source code of this file.

## Enumerations
enum | BlockCaptureEntityKind
| Represents a type of copy/destroy operation that should be performed for an entity that's captured by a block. More...
enum | CaptureStrKind

## Functions
static llvm::Constant * | buildGlobalBlock (CodeGenModule &CGM, const CGBlockInfo &blockInfo, llvm::Constant *blockFn)
| Build the given block as a global block. More...
static llvm::Constant * | buildCopyHelper (CodeGenModule &CGM, const CGBlockInfo &blockInfo)
| Build the helper function to copy a block. More...
static llvm::Constant * | buildDisposeHelper (CodeGenModule &CGM, const CGBlockInfo &blockInfo)
| Build the helper function to dispose of a block. More...
static void | findBlockCapturedManagedEntities (const CGBlockInfo &BlockInfo, const LangOptions &LangOpts, SmallVectorImpl< BlockCaptureManagedEntity > &ManagedCaptures)
| Find the set of block captures that need to be explicitly copied or destroy. More...
static std::string | getBlockCaptureStr (const BlockCaptureManagedEntity &E, CaptureStrKind StrKind, CharUnits BlockAlignment, CodeGenModule &CGM)
static std::string | getBlockDescriptorName (const CGBlockInfo &BlockInfo, CodeGenModule &CGM)
static llvm::Constant * | buildBlockDescriptor (CodeGenModule &CGM, const CGBlockInfo &blockInfo)
| buildBlockDescriptor - Build the block descriptor meta-data for a block. More...
static bool | isSafeForCXXConstantCapture (QualType type)
| Determines if the given type is safe for constant capture in C++. More...
static llvm::Constant * | tryCaptureAsConstant (CodeGenModule &CGM, CodeGenFunction *CGF, const VarDecl *var)
| It is illegal to modify a const object after initialization. More...
static CharUnits | getLowBit (CharUnits v)
| Get the low bit of a nonzero character count. More...
static void | initializeForBlockHeader (CodeGenModule &CGM, CGBlockInfo &info, SmallVectorImpl< llvm::Type *> &elementTypes)
static QualType | getCaptureFieldType (const CodeGenFunction &CGF, const BlockDecl::Capture &CI)
static void | computeBlockInfo (CodeGenModule &CGM, CodeGenFunction *CGF, CGBlockInfo &info)
| Compute the layout of the given block. More...
static void | enterBlockScope (CodeGenFunction &CGF, BlockDecl *block)
| Enter the scope of a block. More...
static CGBlockInfo * | findAndRemoveBlockInfo (CGBlockInfo **head, const BlockDecl *block)
| Find the layout for the given block in a linked list and remove it. More...
static std::pair< BlockCaptureEntityKind, BlockFieldFlags > | computeCopyInfoForBlockCapture (const BlockDecl::Capture &CI, QualType T, const LangOptions &LangOpts)
static std::pair< BlockCaptureEntityKind, BlockFieldFlags > | computeDestroyInfoForBlockCapture (const BlockDecl::Capture &CI, QualType T, const LangOptions &LangOpts)
static std::string | getCopyDestroyHelperFuncName (const SmallVectorImpl< BlockCaptureManagedEntity > &Captures, CharUnits BlockAlignment, CaptureStrKind StrKind, CodeGenModule &CGM)
static void | pushCaptureCleanup (BlockCaptureEntityKind CaptureKind, Address Field, QualType CaptureType, BlockFieldFlags Flags, bool ForCopyHelper, VarDecl *Var, CodeGenFunction &CGF)
static void | setBlockHelperAttributesVisibility (bool CapturesNonExternalType, llvm::Function *Fn, const CGFunctionInfo &FI, CodeGenModule &CGM)
static BlockFieldFlags | getBlockFieldFlagsForObjCObjectPointer (const BlockDecl::Capture &CI, QualType T)
static llvm::Constant * | generateByrefCopyHelper (CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
static llvm::Constant * | buildByrefCopyHelper (CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
| Build the copy helper for a __block variable. More...
static llvm::Constant * | generateByrefDisposeHelper (CodeGenFunction &CGF, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
| Generate code for a __block variable's dispose helper. More...
static llvm::Constant * | buildByrefDisposeHelper (CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, BlockByrefHelpers &generator)
| Build the dispose helper for a __block variable. More...
template<class T >
static T * | buildByrefHelpers (CodeGenModule &CGM, const BlockByrefInfo &byrefInfo, T &&generator)
| Lazily build the copy and dispose helpers for a __block variable with the given information. More...
static void | configureBlocksRuntimeObject (CodeGenModule &CGM, llvm::Constant *C)
| Adjust the declaration of something from the blocks API. More...

## Enumeration Type Documentation

## ◆ BlockCaptureEntityKind

enum BlockCaptureEntityKind
| strong

Represents a type of copy/destroy operation that should be performed for an entity that's captured by a block.

Definition at line 71 of file CGBlocks.cpp.

## ◆ CaptureStrKind

enum CaptureStrKind
| strong

Definition at line 102 of file CGBlocks.cpp.

## Function Documentation

## ◆ buildBlockDescriptor()

static llvm::Constant* buildBlockDescriptor | ( | CodeGenModule & | CGM,
|  | const CGBlockInfo & | blockInfo
| ) |  |
| static

buildBlockDescriptor - Build the block descriptor meta-data for a block.

buildBlockDescriptor is accessed from 5th field of the Block_literal meta-data and contains stationary information about the block literal. Its definition will have 4 (or optionally 6) words.

struct Block_descriptor {
unsigned long reserved;
unsigned long size; // size of Block_literal metadata in bytes.
void *copy_func_helper_decl; // optional copy helper.
void *destroy_func_decl; // optional destructor helper.
void *block_method_encoding_address; // @encode for block literal signature.
void *block_layout_info; // encoding of captured block variables.
};

Definition at line 185 of file CGBlocks.cpp.

References clang::interp::align(), clang::CodeGen::ConstantInitBuilderTemplateBase< Traits >::beginStruct(), clang::CodeGen::CGBlockInfo::BlockSize, buildCopyHelper(), buildDisposeHelper(), clang::CodeGen::CGObjCRuntime::BuildGCBlockLayout(), clang::CodeGen::CGObjCRuntime::BuildRCBlockLayout(), clang::CodeGen::CGBlockInfo::Captures, clang::CodeGen::CodeGenTypes::ConvertType(), clang::CodeGen::CGBlockInfo::CXXThisIndex, clang::CodeGen::CGBlockInfo::CXXThisOffset, clang::CodeGen::CodeGenModule::GetAddrOfConstantCString(), getBlockDescriptorName(), clang::CodeGen::CodeGenModule::getBlockDescriptorType(), clang::CodeGen::CGBlockInfo::getBlockExpr(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::ASTContext::getLangOpts(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::CodeGen::CodeGenModule::getModule(), clang::ASTContext::getObjCEncodingForBlock(), clang::CodeGen::CodeGenModule::getObjCRuntime(), clang::CodeGen::ConstantAddress::getPointer(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CharUnits::getQuantity(), clang::ASTContext::getTargetAddressSpace(), clang::CodeGen::CodeGenModule::getTypes(), clang::BlockDecl::Capture::getVariable(), clang::HiddenVisibility, clang::InternalLinkage, clang::CodeGen::CGBlockInfo::Capture::makeIndex(), clang::CodeGen::CGBlockInfo::needsCopyDisposeHelpers(), clang::LangOptions::NonGC, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, clang::opencl_constant, clang::operator<(), clang::CodeGen::CodeGenModule::supportsCOMDAT(), clang::CodeGen::Type, clang::ASTContext::UnsignedLongTy, and clang::CodeGen::CodeGenTypeCache::VoidPtrTy.

Referenced by buildGlobalBlock(), and clang::CodeGen::CodeGenFunction::EmitBlockLiteral().

## ◆ buildByrefCopyHelper()

static llvm::Constant* buildByrefCopyHelper | ( | CodeGenModule & | CGM,
|  | const BlockByrefInfo & | byrefInfo,
|  | BlockByrefHelpers & | generator
| ) |  |
| static

Build the copy helper for a __block variable.

Definition at line 2511 of file CGBlocks.cpp.

References generateByrefCopyHelper().

Referenced by buildByrefHelpers().

## ◆ buildByrefDisposeHelper()

static llvm::Constant* buildByrefDisposeHelper | ( | CodeGenModule & | CGM,
|  | const BlockByrefInfo & | byrefInfo,
|  | BlockByrefHelpers & | generator
| ) |  |
| static

Build the dispose helper for a __block variable.

Definition at line 2574 of file CGBlocks.cpp.

References generateByrefDisposeHelper().

Referenced by buildByrefHelpers().

## ◆ buildByrefHelpers()

template<class T >

static T* buildByrefHelpers | ( | CodeGenModule & | CGM,
|  | const BlockByrefInfo & | byrefInfo,
|  | T && | generator
| ) |  |
| static

Lazily build the copy and dispose helpers for a __block variable with the given information.

Definition at line 2584 of file CGBlocks.cpp.

References clang::CharUnits::alignmentAtOffset(), clang::CodeGen::BLOCK_FIELD_IS_BLOCK, clang::CodeGen::BLOCK_FIELD_IS_OBJECT, clang::CodeGen::BLOCK_FIELD_IS_WEAK, buildByrefCopyHelper(), buildByrefDisposeHelper(), clang::CodeGen::CodeGenModule::ByrefHelpersCache, clang::QualType::DK_nontrivial_c_struct, clang::ASTContext::getBlockVarCopyInit(), clang::CodeGen::CodeGenModule::getContext(), clang::BlockVarCopyInit::getCopyExpr(), clang::Qualifiers::getObjCLifetime(), clang::ValueDecl::getType(), clang::VarDecl::isEscapingByref(), clang::ASTContext::isObjCNSObjectType(), clang::transformer::node(), clang::Qualifiers::OCL_Autoreleasing, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, and clang::QualType::PCK_Struct.

## ◆ buildCopyHelper()

static llvm::Constant* buildCopyHelper | ( | CodeGenModule & | CGM,
|  | const CGBlockInfo & | blockInfo
| ) |  |
| static

Build the helper function to copy a block.

Definition at line 56 of file CGBlocks.cpp.

References clang::CodeGen::CodeGenFunction::GenerateCopyHelperFunction().

Referenced by buildBlockDescriptor().

## ◆ buildDisposeHelper()

static llvm::Constant* buildDisposeHelper | ( | CodeGenModule & | CGM,
|  | const CGBlockInfo & | blockInfo
| ) |  |
| static

Build the helper function to dispose of a block.

Definition at line 62 of file CGBlocks.cpp.

References clang::CodeGen::CodeGenFunction::GenerateDestroyHelperFunction().

Referenced by buildBlockDescriptor().

## ◆ buildGlobalBlock()

static llvm::Constant * buildGlobalBlock | ( | CodeGenModule & | CGM,
|  | const CGBlockInfo & | blockInfo,
|  | llvm::Constant * | blockFn
| ) |  |
| static

Build the given block as a global block.

Definition at line 1383 of file CGBlocks.cpp.

References clang::CodeGen::CodeGenModule::addUsedGlobal(), clang::CodeGen::BLOCK_HAS_SIGNATURE, clang::CodeGen::BLOCK_IS_GLOBAL, clang::CodeGen::BLOCK_USE_STRET, clang::CodeGen::CGBlockInfo::BlockAlign, clang::CodeGen::CGBlockInfo::BlockExpression, clang::CodeGen::CGBlockInfo::BlockSize, buildBlockDescriptor(), clang::CodeGen::CGBlockInfo::CanBeGlobal, clang::CodeGen::CodeGenTypes::ConvertType(), clang::Create(), clang::CodeGen::CodeGenModule::getAddrOfGlobalBlockIfEmitted(), clang::CodeGen::BlockFlags::getBitMask(), clang::CodeGen::CGBlockInfo::getBlockExpr(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::ASTContext::getLangOpts(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::CodeGen::CodeGenModule::getModule(), clang::CodeGen::CodeGenModule::getNSConcreteGlobalBlock(), clang::CodeGen::CodeGenModule::getOpenCLRuntime(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CharUnits::getQuantity(), clang::CodeGen::CodeGenModule::getTarget(), clang::ASTContext::getTargetAddressSpace(), clang::CodeGen::CodeGenModule::getTargetCodeGenInfo(), clang::CodeGen::TargetCodeGenInfo::getTargetOpenCLBlockHelper(), clang::TargetInfo::getTriple(), clang::Expr::getType(), clang::CodeGen::CodeGenModule::getTypes(), clang::CodeGen::CodeGenTypeCache::Int8PtrPtrTy, clang::InternalLinkage, clang::CodeGen::CodeGenTypeCache::IntTy, clang::opencl_global, clang::CodeGen::CGOpenCLRuntime::recordBlockInfo(), clang::CodeGen::CodeGenModule::setAddrOfGlobalBlock(), clang::CodeGen::Type, clang::CodeGen::CGBlockInfo::UsesStret, and clang::CodeGen::CodeGenTypeCache::VoidTy.

Referenced by clang::CodeGen::CodeGenFunction::GenerateBlockFunction(), and clang::CodeGen::BlockByrefHelpers::~BlockByrefHelpers().

## ◆ computeBlockInfo()

static void computeBlockInfo | ( | CodeGenModule & | CGM,
|  | CodeGenFunction * | CGF,
|  | CGBlockInfo & | info
| ) |  |
| static

Compute the layout of the given block.

Attempts to lay the block out with minimal space requirements.

Definition at line 522 of file CGBlocks.cpp.

References clang::interp::align(), clang::CharUnits::alignTo(), clang::CodeGen::CGBlockInfo::BlockAlign, clang::CodeGen::CGBlockInfo::BlockHeaderForcedGapOffset, clang::CodeGen::CGBlockInfo::BlockHeaderForcedGapSize, clang::CodeGen::CGBlockInfo::BlockSize, clang::CodeGen::CGBlockInfo::CanBeGlobal, clang::BlockDecl::capture_begin(), clang::BlockDecl::capture_end(), clang::CodeGen::CGBlockInfo::Captures, clang::BlockDecl::captures(), clang::BlockDecl::capturesCXXThis(), clang::CodeGen::CGBlockInfo::CapturesNonExternalType, clang::CodeGen::CodeGenTypes::ConvertType(), clang::CodeGen::CodeGenTypes::ConvertTypeForMem(), clang::CodeGen::CodeGenFunction::CurFuncDecl, clang::QualType::DK_nontrivial_c_struct, clang::Type::getAsCXXRecordDecl(), clang::CodeGen::CGBlockInfo::getBlockDecl(), getCaptureFieldType(), clang::CodeGen::CodeGenModule::getContext(), clang::ASTContext::getDeclAlign(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::ASTContext::getLangOpts(), clang::CodeGen::CodeGenModule::getLLVMContext(), getLowBit(), clang::QualType::getObjCLifetime(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::CodeGen::CodeGenTypeCache::getPointerSize(), clang::CharUnits::getQuantity(), clang::CodeGen::CodeGenModule::getTargetCodeGenInfo(), clang::CodeGen::TargetCodeGenInfo::getTargetOpenCLBlockHelper(), clang::ValueDecl::getType(), clang::ASTContext::getTypeInfoInChars(), clang::CodeGen::CodeGenModule::getTypes(), clang::ASTContext::getTypeSizeInChars(), clang::CodeGen::CGBlockInfo::HasCapturedVariableLayout, clang::BlockDecl::hasCaptures(), clang::CodeGen::CGBlockInfo::HasCXXObject, initializeForBlockHeader(), clang::CodeGen::CodeGenTypeCache::Int8Ty, clang::QualType::isDestructedType(), clang::NamedDecl::isExternallyVisible(), clang::QualType::isNonTrivialToPrimitiveCopy(), clang::Type::isObjCInertUnsafeUnretainedType(), clang::Type::isObjCRetainableType(), clang::CodeGen::CGBlockInfo::Capture::makeConstant(), max(), clang::CodeGen::CGBlockInfo::NeedsCopyDispose, clang::LangOptions::NonGC, clang::Qualifiers::OCL_Autoreleasing, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Qualifiers::OCL_Weak, clang::QualType::PCK_Struct, clang::CodeGen::CGBlockInfo::StructureType, tryCaptureAsConstant(), clang::CodeGen::Type, clang::CodeGen::CodeGenTypeCache::VoidPtrTy, and clang::CharUnits::Zero().

Referenced by clang::CodeGen::CodeGenFunction::EmitBlockLiteral(), enterBlockScope(), and clang::CodeGen::CodeGenModule::GetAddrOfGlobalBlock().

## ◆ computeCopyInfoForBlockCapture()

static std::pair<BlockCaptureEntityKind, BlockFieldFlags> computeCopyInfoForBlockCapture | ( | const BlockDecl::Capture & | CI,
|  | QualType | T,
|  | const LangOptions & | LangOpts
| ) |  |
| static

Definition at line 1689 of file CGBlocks.cpp.

References clang::CodeGen::BLOCK_FIELD_IS_BLOCK, clang::CodeGen::BLOCK_FIELD_IS_BYREF, clang::CodeGen::BLOCK_FIELD_IS_OBJECT, clang::CodeGen::BLOCK_FIELD_IS_WEAK, computeDestroyInfoForBlockCapture(), clang::BlockDecl::Capture::getCopyExpr(), clang::Qualifiers::getObjCLifetime(), clang::QualType::getQualifiers(), isBlockPointer(), clang::Type::isBlockPointerType(), clang::BlockDecl::Capture::isByRef(), clang::BlockDecl::Capture::isEscapingByref(), clang::QualType::isNonTrivialToPrimitiveCopy(), clang::QualType::isObjCGCWeak(), clang::Type::isObjCRetainableType(), clang::None, clang::QualType::PCK_ARCStrong, clang::QualType::PCK_ARCWeak, clang::QualType::PCK_Struct, clang::QualType::PCK_Trivial, and clang::QualType::PCK_VolatileTrivial.

Referenced by findBlockCapturedManagedEntities().

## ◆ computeDestroyInfoForBlockCapture()

static std::pair< BlockCaptureEntityKind, BlockFieldFlags > computeDestroyInfoForBlockCapture | ( | const BlockDecl::Capture & | CI,
|  | QualType | T,
|  | const LangOptions & | LangOpts
| ) |  |
| static

Definition at line 2141 of file CGBlocks.cpp.

References clang::CodeGen::BLOCK_FIELD_IS_BYREF, clang::CodeGen::BLOCK_FIELD_IS_WEAK, clang::QualType::DK_cxx_destructor, clang::QualType::DK_none, clang::QualType::DK_nontrivial_c_struct, clang::QualType::DK_objc_strong_lifetime, clang::QualType::DK_objc_weak_lifetime, getBlockFieldFlagsForObjCObjectPointer(), clang::QualType::getQualifiers(), clang::Qualifiers::hasObjCLifetime(), clang::QualType::isDestructedType(), clang::BlockDecl::Capture::isEscapingByref(), clang::QualType::isObjCGCWeak(), clang::Type::isObjCRetainableType(), and clang::None.

Referenced by computeCopyInfoForBlockCapture(), and findBlockCapturedManagedEntities().

## ◆ configureBlocksRuntimeObject()

static void configureBlocksRuntimeObject | ( | CodeGenModule & | CGM,
|  | llvm::Constant * | C
| ) |  |
| static

Adjust the declaration of something from the blocks API.

Definition at line 2945 of file CGBlocks.cpp.

References clang::TranslationUnitDecl::castToDeclContext(), clang::ExternalLinkage, clang::IdentifierTable::get(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CodeGen::CodeGenModule::getTarget(), clang::ASTContext::getTranslationUnitDecl(), clang::TargetInfo::getTriple(), clang::ASTContext::Idents, clang::DeclContext::lookup(), and clang::CodeGen::CodeGenModule::setDSOLocal().

Referenced by clang::CodeGen::CodeGenModule::getBlockObjectAssign(), clang::CodeGen::CodeGenModule::getBlockObjectDispose(), clang::CodeGen::CodeGenModule::getNSConcreteGlobalBlock(), and clang::CodeGen::CodeGenModule::getNSConcreteStackBlock().

## ◆ enterBlockScope()

static void enterBlockScope | ( | CodeGenFunction & | CGF,
|  | BlockDecl * | block
| ) |  |
| static

Enter the scope of a block.

This should be run at the entrance to a full-expression so that the block's cleanups are pushed at the right place in the stack.

Definition at line 781 of file CGBlocks.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::BlockDecl::captures(), clang::CodeGen::CGBlockInfo::CGBlockInfo(), clang::CodeGen::CodeGenFunction::CGM, computeBlockInfo(), clang::CodeGen::CGBuilderTy::CreateStructGEP(), clang::CodeGen::CodeGenFunction::CreateTempAlloca(), clang::CodeGen::CodeGenFunction::CurFn, clang::CodeGen::CodeGenFunction::destroyARCStrongImprecise, clang::QualType::DK_none, clang::QualType::DK_objc_strong_lifetime, clang::CodeGen::CodeGenFunction::EHStack, clang::CodeGen::CodeGenFunction::emitARCIntrinsicUse, clang::CodeGen::CodeGenFunction::FirstBlockInfo, getCaptureFieldType(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenFunction::getDestroyer(), clang::CodeGen::CGBlockInfo::Capture::getIndex(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::QualType::getObjCLifetime(), clang::CodeGen::Address::getPointer(), clang::CodeGen::CodeGenFunction::HaveInsertPoint(), clang::CodeGen::InactiveNormalAndEHCleanup, clang::CodeGen::InactiveNormalCleanup, clang::CodeGen::CGBlockInfo::Capture::isConstant(), clang::QualType::isConstQualified(), clang::QualType::isDestructedType(), clang::CodeGen::CodeGenFunction::needsEHCleanup(), clang::Qualifiers::OCL_Strong, clang::CodeGen::CodeGenFunction::pushDestroy(), clang::CodeGen::CGBlockInfo::Capture::setCleanup(), and clang::CodeGen::EHScopeStack::stable_begin().

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

## ◆ findAndRemoveBlockInfo()

static CGBlockInfo* findAndRemoveBlockInfo | ( | CGBlockInfo ** | head,
|  | const BlockDecl * | block
| ) |  |
| static

Find the layout for the given block in a linked list and remove it.

Definition at line 874 of file CGBlocks.cpp.

References clang::CodeGen::CGBlockInfo::getBlockDecl(), and clang::CodeGen::CGBlockInfo::NextBlockInfo.

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

## ◆ findBlockCapturedManagedEntities()

static void findBlockCapturedManagedEntities | ( | const CGBlockInfo & | BlockInfo,
|  | const LangOptions & | LangOpts,
|  | SmallVectorImpl< BlockCaptureManagedEntity > & | ManagedCaptures
| ) |  |
| static

Find the set of block captures that need to be explicitly copied or destroy.

Definition at line 1750 of file CGBlocks.cpp.

References clang::CodeGen::CodeGenFunction::BuildBlockRelease(), clang::CodeGen::CodeGenFunction::Builder, CanThrow(), clang::BlockDecl::captures(), computeCopyInfoForBlockCapture(), computeDestroyInfoForBlockCapture(), clang::CodeGen::CGBuilderTy::CreateBitCast(), clang::CodeGen::CGBuilderTy::CreateLoad(), clang::CodeGen::CGBlockInfo::Capture::fieldType(), clang::CodeGen::CGBlockInfo::getBlockDecl(), clang::CodeGen::CGBlockInfo::getCapture(), clang::CodeGen::Address::getPointer(), clang::BlockDecl::Capture::getVariable(), clang::CodeGen::CGBlockInfo::Capture::isConstant(), clang::None, and clang::CodeGen::CodeGenTypeCache::VoidPtrTy.

Referenced by clang::CodeGen::CodeGenFunction::GenerateCopyHelperFunction(), clang::CodeGen::CodeGenFunction::GenerateDestroyHelperFunction(), and getBlockDescriptorName().

## ◆ generateByrefCopyHelper()

static llvm::Constant* generateByrefCopyHelper | ( | CodeGenFunction & | CGF,
|  | const BlockByrefInfo & | byrefInfo,
|  | BlockByrefHelpers & | generator
| ) |  |
| static

Definition at line 2443 of file CGBlocks.cpp.

Referenced by buildByrefCopyHelper().

## ◆ generateByrefDisposeHelper()

static llvm::Constant* generateByrefDisposeHelper | ( | CodeGenFunction & | CGF,
|  | const BlockByrefInfo & | byrefInfo,
|  | BlockByrefHelpers & | generator
| ) |  |
| static

Generate code for a __block variable's dispose helper.

Definition at line 2520 of file CGBlocks.cpp.

Referenced by buildByrefDisposeHelper().

## ◆ getBlockCaptureStr()

static std::string getBlockCaptureStr | ( | const BlockCaptureManagedEntity & | E,
|  | CaptureStrKind | StrKind,
|  | CharUnits | BlockAlignment,
|  | CodeGenModule & | CGM
| ) |  |
| static

Definition at line 1808 of file CGBlocks.cpp.

References clang::CharUnits::alignmentAtOffset(), clang::CodeGen::BLOCK_FIELD_IS_BLOCK, clang::CodeGen::BLOCK_FIELD_IS_BYREF, clang::CodeGen::BLOCK_FIELD_IS_OBJECT, clang::CodeGen::BLOCK_FIELD_IS_WEAK, clang::BlockVarCopyInit::canThrow(), clang::CodeGen::CodeGenFunction::cxxDestructorCanThrow(), clang::CodeGen::BlockFieldFlags::getBitMask(), clang::ASTContext::getBlockVarCopyInit(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getCXXABI(), clang::CodeGen::CGCXXABI::getMangleContext(), clang::CodeGen::CodeGenFunction::getNonTrivialCopyConstructorStr(), clang::CodeGen::CodeGenFunction::getNonTrivialDestructorStr(), clang::ValueDecl::getType(), clang::BlockDecl::Capture::getVariable(), clang::QualType::isVolatileQualified(), clang::MangleContext::mangleTypeName(), and clang::None.

Referenced by getBlockDescriptorName(), and getCopyDestroyHelperFuncName().

## ◆ getBlockDescriptorName()

static std::string getBlockDescriptorName | ( | const CGBlockInfo & | BlockInfo,
|  | CodeGenModule & | CGM
| ) |  |
| static

Replace occurrences of '@' with '\1'. '@' is reserved on ELF platforms as a separator between symbol name and symbol version.

Definition at line 122 of file CGBlocks.cpp.

References clang::CodeGen::CGBlockInfo::BlockAlign, clang::CodeGen::CGBlockInfo::BlockSize, findBlockCapturedManagedEntities(), getBlockCaptureStr(), clang::CodeGen::CGBlockInfo::getBlockExpr(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::ASTContext::getLangOpts(), clang::ASTContext::getObjCEncodingForBlock(), clang::CodeGen::CodeGenModule::getObjCRuntime(), clang::CharUnits::getQuantity(), clang::CodeGen::CGObjCRuntime::getRCBlockLayoutStr(), clang::CodeGen::CGBlockInfo::Name, clang::CodeGen::CGBlockInfo::needsCopyDisposeHelpers(), and clang::None.

Referenced by buildBlockDescriptor().

## ◆ getBlockFieldFlagsForObjCObjectPointer()

static BlockFieldFlags getBlockFieldFlagsForObjCObjectPointer | ( | const BlockDecl::Capture & | CI,
|  | QualType | T
| ) |  |
| static

Definition at line 2132 of file CGBlocks.cpp.

References clang::CodeGen::BLOCK_FIELD_IS_BLOCK, clang::CodeGen::BLOCK_FIELD_IS_OBJECT, and clang::Type::isBlockPointerType().

Referenced by computeDestroyInfoForBlockCapture().

## ◆ getCaptureFieldType()

static QualType getCaptureFieldType | ( | const CodeGenFunction & | CGF,
|  | const BlockDecl::Capture & | CI
| ) |  |
| static

Definition at line 503 of file CGBlocks.cpp.

References clang::CodeGen::CodeGenFunction::BlockInfo, clang::CodeGen::CGBlockInfo::Capture::fieldType(), clang::CodeGen::CGBlockInfo::getCapture(), clang::CodeGen::CodeGenFunction::getContext(), clang::ASTContext::getLValueReferenceType(), clang::ValueDecl::getType(), clang::BlockDecl::Capture::getVariable(), clang::BlockDecl::Capture::isNested(), clang::VarDecl::isNonEscapingByref(), and clang::CodeGen::CodeGenFunction::LambdaCaptureFields.

Referenced by computeBlockInfo(), and enterBlockScope().

## ◆ getCopyDestroyHelperFuncName()

static std::string getCopyDestroyHelperFuncName | ( | const SmallVectorImpl< BlockCaptureManagedEntity > & | Captures,
|  | CharUnits | BlockAlignment,
|  | CaptureStrKind | StrKind,
|  | CodeGenModule & | CGM
| ) |  |
| static

Definition at line 1904 of file CGBlocks.cpp.

References getBlockCaptureStr(), clang::CodeGen::CodeGenModule::getCodeGenOpts(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CharUnits::getQuantity(), and clang::CodeGen::CGBlockInfo::Name.

Referenced by clang::CodeGen::CodeGenFunction::GenerateCopyHelperFunction(), and clang::CodeGen::CodeGenFunction::GenerateDestroyHelperFunction().

## ◆ getLowBit()

static CharUnits getLowBit | ( | CharUnits | v | ) |
| static

Get the low bit of a nonzero character count.

This is the alignment of the nth byte if the 0th byte is universally aligned.

Definition at line 444 of file CGBlocks.cpp.

References clang::CharUnits::fromQuantity(), and clang::CharUnits::getQuantity().

Referenced by computeBlockInfo().

## ◆ initializeForBlockHeader()

static void initializeForBlockHeader | ( | CodeGenModule & | CGM,
|  | CGBlockInfo & | info,
|  | SmallVectorImpl< llvm::Type *> & | elementTypes
| ) |  |
| static

Definition at line 448 of file CGBlocks.cpp.

References clang::CodeGen::CGBlockInfo::BlockAlign, clang::CodeGen::CGBlockInfo::BlockSize, clang::CharUnits::fromQuantity(), clang::CodeGen::CodeGenModule::getBlockDescriptorType(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getDataLayout(), clang::CodeGen::CGOpenCLRuntime::getGenericVoidPointerType(), clang::CodeGen::CodeGenTypeCache::getIntAlign(), clang::CodeGen::CodeGenTypeCache::getIntSize(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CodeGen::CodeGenModule::getOpenCLRuntime(), clang::CodeGen::CodeGenTypeCache::getPointerAlign(), clang::TargetInfo::getPointerAlign(), clang::CodeGen::CodeGenTypeCache::getPointerSize(), clang::TargetInfo::getPointerWidth(), clang::CharUnits::getQuantity(), clang::CodeGen::CodeGenModule::getTarget(), clang::ASTContext::getTargetAddressSpace(), clang::CodeGen::CodeGenModule::getTargetCodeGenInfo(), clang::CodeGen::TargetCodeGenInfo::getTargetOpenCLBlockHelper(), clang::CodeGen::CodeGenTypeCache::IntTy, Offset, clang::opencl_generic, and clang::CodeGen::CodeGenTypeCache::VoidPtrTy.

Referenced by computeBlockInfo().

## ◆ isSafeForCXXConstantCapture()

static bool isSafeForCXXConstantCapture | ( | QualType | type | ) |
| static

Determines if the given type is safe for constant capture in C++.

Definition at line 388 of file CGBlocks.cpp.

References clang::Type::getAs(), clang::Type::getBaseElementTypeUnsafe(), clang::RecordType::getDecl(), and clang::ast_matchers::recordType.

Referenced by tryCaptureAsConstant().

## ◆ pushCaptureCleanup()

static void pushCaptureCleanup | ( | BlockCaptureEntityKind | CaptureKind,
|  | Address | Field,
|  | QualType | CaptureType,
|  | BlockFieldFlags | Flags,
|  | bool | ForCopyHelper,
|  | VarDecl * | Var,
|  | CodeGenFunction & | CGF
| ) |  |
| static

Definition at line 1927 of file CGBlocks.cpp.

References CanThrow(), clang::CodeGen::CodeGenFunction::cxxDestructorCanThrow(), clang::CodeGen::CodeGenFunction::destroyARCStrongImprecise, clang::CodeGen::EHCleanup, clang::CodeGen::CodeGenFunction::enterByrefCleanup(), clang::CodeGen::CodeGenFunction::getCleanupKind(), clang::CodeGen::CodeGenFunction::getDestroyer(), clang::CodeGen::CodeGenFunction::getLangOpts(), clang::QualType::isDestructedType(), clang::CodeGen::CodeGenFunction::needsEHCleanup(), clang::None, clang::CodeGen::NormalAndEHCleanup, and clang::CodeGen::CodeGenFunction::pushDestroy().

## ◆ setBlockHelperAttributesVisibility()

static void setBlockHelperAttributesVisibility | ( | bool | CapturesNonExternalType,
|  | llvm::Function * | Fn,
|  | const CGFunctionInfo & | FI,
|  | CodeGenModule & | CGM
| ) |  |
| static

Definition at line 1969 of file CGBlocks.cpp.

References clang::HiddenVisibility, clang::CodeGen::CodeGenModule::SetInternalFunctionAttributes(), clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributes(), and clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition().

Referenced by clang::CodeGen::CodeGenFunction::GenerateCopyHelperFunction(), and clang::CodeGen::CodeGenFunction::GenerateDestroyHelperFunction().

## ◆ tryCaptureAsConstant()

static llvm::Constant* tryCaptureAsConstant | ( | CodeGenModule & | CGM,
|  | CodeGenFunction * | CGF,
|  | const VarDecl * | var
| ) |  |
| static

It is illegal to modify a const object after initialization.

Therefore, if a const object has a constant initializer, we don't actually need to keep storage for it in the block; we'll just rematerialize it at the start of the block function. This is acceptable because we make no promises about address stability of captured variables.

Definition at line 412 of file CGBlocks.cpp.

References clang::VarDecl::getInit(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::ValueDecl::getType(), clang::QualType::isConstQualified(), isSafeForCXXConstantCapture(), and clang::CodeGen::ConstantEmitter::tryEmitAbstractForInitializer().

Referenced by computeBlockInfo().