[CodeGen] [CodeGen] Attach function attributes to functions created in

CGBlocks.cpp.

This commit fixes a bug in clang's code-gen where it creates the
following functions but doesn't attach function attributes to them:

__copy_helper_block_
__destroy_helper_block_
__Block_byref_object_copy_
__Block_byref_object_dispose_

rdar://problem/20828324

Differential Revision: http://reviews.llvm.org/D13525

llvm-svn: 249735
This commit is contained in:
Akira Hatanaka
2015-10-08 20:26:34 +00:00
parent ab2241f1b8
commit aec6b2c20e
4 changed files with 40 additions and 28 deletions

View File

@@ -867,12 +867,12 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
void CodeGenModule::SetCommonAttributes(const Decl *D,
llvm::GlobalValue *GV) {
if (const auto *ND = dyn_cast<NamedDecl>(D))
if (const auto *ND = dyn_cast_or_null<NamedDecl>(D))
setGlobalVisibility(GV, ND);
else
GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
if (D->hasAttr<UsedAttr>())
if (D && D->hasAttr<UsedAttr>())
addUsedGlobal(GV);
}
@@ -890,8 +890,9 @@ void CodeGenModule::setNonAliasAttributes(const Decl *D,
llvm::GlobalObject *GO) {
SetCommonAttributes(D, GO);
if (const SectionAttr *SA = D->getAttr<SectionAttr>())
GO->setSection(SA->getName());
if (D)
if (const SectionAttr *SA = D->getAttr<SectionAttr>())
GO->setSection(SA->getName());
getTargetCodeGenInfo().setTargetAttributes(D, GO, *this);
}