diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CodeGen/address-safety-attr.cpp | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CodeGen/address-safety-attr.cpp')
-rw-r--r-- | clang/test/CodeGen/address-safety-attr.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/CodeGen/address-safety-attr.cpp b/clang/test/CodeGen/address-safety-attr.cpp new file mode 100644 index 0000000..9d0fb95 --- /dev/null +++ b/clang/test/CodeGen/address-safety-attr.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - %s -faddress-sanitizer | FileCheck -check-prefix ASAN %s + +// The address_safety attribute should be attached to functions +// when AddressSanitizer is enabled, unless no_address_safety_analysis attribute +// is present. + +// CHECK-NOT: NoAddressSafety1{{.*}} address_safety +// ASAN-NOT: NoAddressSafety1{{.*}} address_safety +__attribute__((no_address_safety_analysis)) +int NoAddressSafety1(int *a) { return *a; } + +// CHECK-NOT: NoAddressSafety2{{.*}} address_safety +// ASAN-NOT: NoAddressSafety2{{.*}} address_safety +__attribute__((no_address_safety_analysis)) +int NoAddressSafety2(int *a); +int NoAddressSafety2(int *a) { return *a; } + +// CHECK-NOT: AddressSafetyOk{{.*}} address_safety +// ASAN: AddressSafetyOk{{.*}} address_safety +int AddressSafetyOk(int *a) { return *a; } + +// CHECK-NOT: TemplateNoAddressSafety{{.*}} address_safety +// ASAN-NOT: TemplateNoAddressSafety{{.*}} address_safety +template<int i> +__attribute__((no_address_safety_analysis)) +int TemplateNoAddressSafety() { return i; } + +// CHECK-NOT: TemplateAddressSafetyOk{{.*}} address_safety +// ASAN: TemplateAddressSafetyOk{{.*}} address_safety +template<int i> +int TemplateAddressSafetyOk() { return i; } + +int force_instance = TemplateAddressSafetyOk<42>() + + TemplateNoAddressSafety<42>(); |