================
@@ -0,0 +1,44 @@
+// No warnings in regular compile
+// RUN: %clang_cc1 -verify=no-tsan %s
+
+// Emits warning with `-fsanitize=thread`
+// RUN: %clang_cc1 -verify=with-tsan -fsanitize=thread %s
+
+// No warnings if `-Wno-tsan` is passed
+// RUN: %clang_cc1 -verify=no-tsan -fsanitize=thread -Wno-tsan %s
+
+// Ignoring function
+// RUN: echo "fun:main" > %t
+// RUN: %clang_cc1 -verify=no-tsan -fsanitize=thread -fsanitize-ignorelist=%t 
%s
+
+// Ignoring source file
+// RUN: echo "src:%s" > %t
+// RUN: %clang_cc1 -verify=no-tsan -fsanitize=thread -fsanitize-ignorelist=%t 
%s
+
+// no-tsan-no-diagnostics
+
+namespace std {
+  enum memory_order {
+    memory_order_relaxed,
+    memory_order_consume,
+    memory_order_acquire,
+    memory_order_release,
+    memory_order_acq_rel,
+    memory_order_seq_cst,
+  };
+  void atomic_thread_fence(memory_order) {}
+};
+
+__attribute__((no_sanitize("thread")))
+void ignore_1() {
+  std::atomic_thread_fence(std::memory_order_relaxed);
+}
+
+__attribute__((no_sanitize_thread))
+void ignore_2() {
+  std::atomic_thread_fence(std::memory_order_relaxed);
+}
+
+int main() {
+  std::atomic_thread_fence(std::memory_order_relaxed); // with-tsan-warning 
{{'std::atomic_thread_fence' is not supported with '-fsanitize=thread'}}
+}
----------------
BStott6 wrote:

The lambda cases exposed another oversight in my code (it does not take into 
account the attributes applied to the lambda directly, fixed by also checking 
the attributes of `getCurFunctionDecl(/*AllowLambdas*/ true)`
Interestingly, GCC does not emit the warning in the `if (0)` case - should I 
try to match this behaviour?

https://github.com/llvm/llvm-project/pull/166542
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to