summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CodeGen')
-rw-r--r--clang/test/CodeGen/address-safety-attr.cpp16
-rw-r--r--clang/test/CodeGen/sanitize-thread-attr.cpp60
2 files changed, 68 insertions, 8 deletions
diff --git a/clang/test/CodeGen/address-safety-attr.cpp b/clang/test/CodeGen/address-safety-attr.cpp
index a830e23da1b..c9f6ddcab44 100644
--- a/clang/test/CodeGen/address-safety-attr.cpp
+++ b/clang/test/CodeGen/address-safety-attr.cpp
@@ -6,20 +6,20 @@
// FIXME: %t is like "src:x:\path\to\clang\test\CodeGen\address-safety-attr.cpp"
// REQUIRES: shell
-// The address_safety attribute should be attached to functions
-// when AddressSanitizer is enabled, unless no_address_safety_analysis attribute
+// The sanitize_address attribute should be attached to functions
+// when AddressSanitizer is enabled, unless no_sanitize_address attribute
// is present.
// WITHOUT: NoAddressSafety1{{.*}}) #[[NOATTR:[0-9]+]]
// BL: NoAddressSafety1{{.*}}) #[[NOATTR:[0-9]+]]
// ASAN: NoAddressSafety1{{.*}}) #[[NOATTR:[0-9]+]]
-__attribute__((no_address_safety_analysis))
+__attribute__((no_sanitize_address))
int NoAddressSafety1(int *a) { return *a; }
// WITHOUT: NoAddressSafety2{{.*}}) #[[NOATTR]]
// BL: NoAddressSafety2{{.*}}) #[[NOATTR]]
// ASAN: NoAddressSafety2{{.*}}) #[[NOATTR]]
-__attribute__((no_address_safety_analysis))
+__attribute__((no_sanitize_address))
int NoAddressSafety2(int *a);
int NoAddressSafety2(int *a) { return *a; }
@@ -38,13 +38,13 @@ int TemplateAddressSafetyOk() { return i; }
// BL: TemplateNoAddressSafety{{.*}}) #[[NOATTR]]
// ASAN: TemplateNoAddressSafety{{.*}}) #[[NOATTR]]
template<int i>
-__attribute__((no_address_safety_analysis))
+__attribute__((no_sanitize_address))
int TemplateNoAddressSafety() { return i; }
int force_instance = TemplateAddressSafetyOk<42>()
+ TemplateNoAddressSafety<42>();
-// Check that __cxx_global_var_init* get the address_safety attribute.
+// Check that __cxx_global_var_init* get the sanitize_address attribute.
int global1 = 0;
int global2 = *(int*)((char*)&global1+1);
// WITHOUT: @__cxx_global_var_init{{.*}}#[[GVI:[0-9]+]]
@@ -57,5 +57,5 @@ int global2 = *(int*)((char*)&global1+1);
// BL: attributes #[[GVI]] = { nounwind{{.*}} }
// ASAN: attributes #[[NOATTR]] = { nounwind{{.*}} }
-// ASAN: attributes #[[WITH]] = { address_safety nounwind{{.*}} }
-// ASAN: attributes #[[GVI]] = { address_safety nounwind{{.*}} }
+// ASAN: attributes #[[WITH]] = {{.*}}sanitize_address
+// ASAN: attributes #[[GVI]] = {{.*}}sanitize_address
diff --git a/clang/test/CodeGen/sanitize-thread-attr.cpp b/clang/test/CodeGen/sanitize-thread-attr.cpp
new file mode 100644
index 00000000000..09f4db57503
--- /dev/null
+++ b/clang/test/CodeGen/sanitize-thread-attr.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=thread | FileCheck -check-prefix=TSAN %s
+// RUN: echo "src:%s" > %t
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=thread -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
+
+// REQUIRES: shell
+
+// The sanitize_thread attribute should be attached to functions
+// when ThreadSanitizer is enabled, unless no_sanitize_thread attribute
+// is present.
+
+// WITHOUT: NoTSAN1{{.*}}) #[[NOATTR:[0-9]+]]
+// BL: NoTSAN1{{.*}}) #[[NOATTR:[0-9]+]]
+// TSAN: NoTSAN1{{.*}}) #[[NOATTR:[0-9]+]]
+__attribute__((no_sanitize_thread))
+int NoTSAN1(int *a) { return *a; }
+
+// WITHOUT: NoTSAN2{{.*}}) #[[NOATTR]]
+// BL: NoTSAN2{{.*}}) #[[NOATTR]]
+// TSAN: NoTSAN2{{.*}}) #[[NOATTR]]
+__attribute__((no_sanitize_thread))
+int NoTSAN2(int *a);
+int NoTSAN2(int *a) { return *a; }
+
+// WITHOUT: TSANOk{{.*}}) #[[NOATTR]]
+// BL: TSANOk{{.*}}) #[[NOATTR]]
+// TSAN: TSANOk{{.*}}) #[[WITH:[0-9]+]]
+int TSANOk(int *a) { return *a; }
+
+// WITHOUT: TemplateTSANOk{{.*}}) #[[NOATTR]]
+// BL: TemplateTSANOk{{.*}}) #[[NOATTR]]
+// TSAN: TemplateTSANOk{{.*}}) #[[WITH]]
+template<int i>
+int TemplateTSANOk() { return i; }
+
+// WITHOUT: TemplateNoTSAN{{.*}}) #[[NOATTR]]
+// BL: TemplateNoTSAN{{.*}}) #[[NOATTR]]
+// TSAN: TemplateNoTSAN{{.*}}) #[[NOATTR]]
+template<int i>
+__attribute__((no_sanitize_thread))
+int TemplateNoTSAN() { return i; }
+
+int force_instance = TemplateTSANOk<42>()
+ + TemplateNoTSAN<42>();
+
+// Check that __cxx_global_var_init* get the sanitize_thread attribute.
+int global1 = 0;
+int global2 = *(int*)((char*)&global1+1);
+// WITHOUT: @__cxx_global_var_init{{.*}}#[[GVI:[0-9]+]]
+// BL: @__cxx_global_var_init{{.*}}#[[GVI:[0-9]+]]
+// TSAN: @__cxx_global_var_init{{.*}}#[[GVI:[0-9]+]]
+
+// WITHOUT: attributes #[[NOATTR]] = { nounwind{{.*}} }
+// WITHOUT: attributes #[[GVI]] = { nounwind{{.*}} }
+// BL: attributes #[[NOATTR]] = { nounwind{{.*}} }
+// BL: attributes #[[GVI]] = { nounwind{{.*}} }
+
+// TSAN: attributes #[[NOATTR]] = { nounwind{{.*}} }
+// TSAN: attributes #[[WITH]] = { nounwind{{.*}} sanitize_thread
+// TSAN: attributes #[[GVI]] = { nounwind{{.*}} sanitize_thread
OpenPOWER on IntegriCloud