diff options
author | Alexander Potapenko <glider@google.com> | 2012-02-02 11:49:28 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2012-02-02 11:49:28 +0000 |
commit | ef41fd31d4634257224780fdc4fb4e8bc381562d (patch) | |
tree | 414d244640740ade3d8653df96560e86525fabe6 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 9df3de538bb1714df602e1438d9bb36d6deaabaa (diff) | |
download | bcm5719-llvm-ef41fd31d4634257224780fdc4fb4e8bc381562d.tar.gz bcm5719-llvm-ef41fd31d4634257224780fdc4fb4e8bc381562d.zip |
Move the code that sets the AddressSafety
attribute into CodeGenModule::SetLLVMFunctionAttributesForDefinition().
Previously it resided in CodeGenModule::GetOrCreateLLVMFunction, which
for some reason wasn't called for ObjC class methods, see
http://code.google.com/p/address-sanitizer/issues/detail?id=33
llvm-svn: 149605
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index fc1c3be39a9..ea1d94d7c2e 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -520,6 +520,13 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, else if (Features.getStackProtector() == LangOptions::SSPReq) F->addFnAttr(llvm::Attribute::StackProtectReq); + if (Features.AddressSanitizer) { + // When AddressSanitizer is enabled, set AddressSafety attribute + // unless __attribute__((no_address_safety_analysis)) is used. + if (!D->hasAttr<NoAddressSafetyAnalysisAttr>()) + F->addFnAttr(llvm::Attribute::AddressSafety); + } + unsigned alignment = D->getMaxAlignment() / Context.getCharWidth(); if (alignment) F->setAlignment(alignment); @@ -1019,14 +1026,6 @@ CodeGenModule::GetOrCreateLLVMFunction(StringRef MangledName, if (ExtraAttrs != llvm::Attribute::None) F->addFnAttr(ExtraAttrs); - if (Features.AddressSanitizer) { - // When AddressSanitizer is enabled, set AddressSafety attribute - // unless __attribute__((no_address_safety_analysis)) is used. - const FunctionDecl *FD = cast_or_null<FunctionDecl>(D.getDecl()); - if (!FD || !FD->hasAttr<NoAddressSafetyAnalysisAttr>()) - F->addFnAttr(llvm::Attribute::AddressSafety); - } - // This is the first use or definition of a mangled name. If there is a // deferred decl with this name, remember that we need to emit it at the end // of the file. |