On Thu, Feb 2, 2012 at 3:19 PM, Chandler Carruth <[email protected]> wrote:
> No patch attached...
>
That's because I was going to commit it right away, but then it turned
out my repo is stale, so I'm now testing it with the newer Clang
version.
Index: tools/clang/test/CodeGenObjCXX/address-safety-attr.mm
===================================================================
--- tools/clang/test/CodeGenObjCXX/address-safety-attr.mm (revision 0)
+++ tools/clang/test/CodeGenObjCXX/address-safety-attr.mm (revision 0)
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s
+
+@interface MyClass
++ (int) addressSafety:(int*)a;
+@end
+
+@implementation MyClass
+
+// CHECK-NOT: +[MyClass load]{{.*}} address_safety
+// CHECK: +[MyClass load]{{.*}}
+// ASAN: +[MyClass load]{{.*}} address_safety
++(void) load { }
+
+// CHECK-NOT: +[MyClass addressSafety:]{{.*}} address_safety
+// CHECK: +[MyClass addressSafety:]{{.*}}
+// ASAN: +[MyClass addressSafety:]{{.*}} address_safety
++ (int) addressSafety:(int*)a { return *a; }
+
+@end
Property changes on: tools/clang/test/CodeGenObjCXX/address-safety-attr.mm
___________________________________________________________________
Added: svn:eol-style
+ LF
Index: tools/clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- tools/clang/lib/CodeGen/CodeGenModule.cpp (revision 149602)
+++ tools/clang/lib/CodeGen/CodeGenModule.cpp (working copy)
@@ -520,6 +520,13 @@
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 @@
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.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits