llvm-project/clang/test/CodeGen/sanitize-thread-attr.cpp
Reid Kleckner 2e1538f282 Remove 24 instances of 'REQUIRES: shell'
Tests fall into one of the following categories:

- The requirement was unnecessary

- Additional quoting was required for backslashes in paths (see "sed -e
  's/\\/\\\\/g'") in the sanitizer tests.

- OpenMP used 'REQUIRES: shell' as a proxy for the test failing on
  Windows. Those tests fail there reliably, so use XFAIL instead.

I tried not to remove shell requirements that were added to suppress
flaky test failures, but if I screwed up, we can add it back as needed.

llvm-svn: 284793
2016-10-20 23:11:45 +00:00

63 lines
2.3 KiB
C++

// 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" | sed -e 's/\\/\\\\/g' > %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s -fsanitize=thread -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
// 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: NoTSAN3{{.*}}) [[NOATTR:#[0-9]+]]
// BL: NoTSAN3{{.*}}) [[NOATTR:#[0-9]+]]
// TSAN: NoTSAN3{{.*}}) [[NOATTR:#[0-9]+]]
__attribute__((no_sanitize("thread")))
int NoTSAN3(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{{.*}}[[NOATTR:#[0-9]+]]
// BL: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
// TSAN: @__cxx_global_var_init{{.*}}[[WITH:#[0-9]+]]
// WITHOUT: attributes [[NOATTR]] = { nounwind{{.*}} }
// BL: attributes [[NOATTR]] = { nounwind{{.*}} }
// TSAN: attributes [[NOATTR]] = { nounwind{{.*}} }
// TSAN: attributes [[WITH]] = { nounwind sanitize_thread{{.*}} }