[clang] [Clang] Warn when `std::atomic_thread_fence` is used with `fsanitize=thread` (PR #166542)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 5 07:54:48 PST 2025


================
@@ -0,0 +1,11 @@
+// RUN: %clang -std=c++17 %s 2>&1 | FileCheck %s --check-prefix=NO-TSAN --allow-empty
+// RUN: %clang -std=c++17 -fsanitize=thread %s 2>&1 | FileCheck %s --check-prefix=WITH-TSAN
+
+// WITH-TSAN: `std::atomic_thread_fence` is not supported with `-fsanitize=thread`
+// NO-TSAN-NOT: `std::atomic_thread_fence` is not supported with `-fsanitize=thread`
----------------
AaronBallman wrote:

```suggestion
// RUN: %clang -std=c++17 %s 2>&1 | FileCheck %s --check-prefix=NO-TSAN --allow-empty
// RUN: %clang -std=c++17 -fsanitize=thread %s 2>&1 | FileCheck %s --check-prefix=WITH-TSAN

// WITH-TSAN: `std::atomic_thread_fence` is not supported with `-fsanitize=thread`
// NO-TSAN-NOT: `std::atomic_thread_fence` is not supported with `-fsanitize=thread`
```
These should be running `%clang_cc1` so we're not executing the driver and the frontend. Also, please use `-verify` instead of `| FileCheck %s` to verify the diagnostics appear on the expected line. You can use `-verify=` to give different RUN lines a different prefix so you can show that the diagnostic is only emitted for some RUN lines.

https://github.com/llvm/llvm-project/pull/166542


More information about the cfe-commits mailing list