diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2015-10-08 19:30:57 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2015-10-08 19:30:57 +0000 |
commit | 200500d6d3bf98212c9cad8eb564c9b9b202fb1f (patch) | |
tree | 54eaee417c7a8d59ecc633951084430b274740ec /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 8b5e7baab2327ef84d61f8cfdf4531638f80630b (diff) | |
download | llvm-200500d6d3bf98212c9cad8eb564c9b9b202fb1f.zip llvm-200500d6d3bf98212c9cad8eb564c9b9b202fb1f.tar.gz llvm-200500d6d3bf98212c9cad8eb564c9b9b202fb1f.tar.bz2 |
[CodeGen] Check if the Decl pointer passed is null, and if so, return
early.
This is needed in a patch I plan to commit later, in which a null Decl
pointer is passed to SetLLVMFunctionAttributesForDefinition.
Relevant discussion is in http://reviews.llvm.org/D13525.
llvm-svn: 249722
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 40eb678..dd8e76e 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -786,6 +786,21 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind); + if (LangOpts.getStackProtector() == LangOptions::SSPOn) + B.addAttribute(llvm::Attribute::StackProtect); + else if (LangOpts.getStackProtector() == LangOptions::SSPStrong) + B.addAttribute(llvm::Attribute::StackProtectStrong); + else if (LangOpts.getStackProtector() == LangOptions::SSPReq) + B.addAttribute(llvm::Attribute::StackProtectReq); + + if (!D) { + F->addAttributes(llvm::AttributeSet::FunctionIndex, + llvm::AttributeSet::get( + F->getContext(), + llvm::AttributeSet::FunctionIndex, B)); + return; + } + if (D->hasAttr<NakedAttr>()) { // Naked implies noinline: we should not be inlining such functions. B.addAttribute(llvm::Attribute::Naked); @@ -810,13 +825,6 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (D->hasAttr<MinSizeAttr>()) B.addAttribute(llvm::Attribute::MinSize); - if (LangOpts.getStackProtector() == LangOptions::SSPOn) - B.addAttribute(llvm::Attribute::StackProtect); - else if (LangOpts.getStackProtector() == LangOptions::SSPStrong) - B.addAttribute(llvm::Attribute::StackProtectStrong); - else if (LangOpts.getStackProtector() == LangOptions::SSPReq) - B.addAttribute(llvm::Attribute::StackProtectReq); - F->addAttributes(llvm::AttributeSet::FunctionIndex, llvm::AttributeSet::get( F->getContext(), llvm::AttributeSet::FunctionIndex, B)); |