[clang] [-Wunsafe-buffer-usage] Fold the expression "cond ? E1 : E2" when checking safe patterns, if "cond" is a constant (PR #167989)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 16 03:41:46 PST 2025


================
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -Wno-all -Wunsafe-buffer-usage -verify %s
+// RUN: %clang_cc1 -fsyntax-only -x c -Wno-all -Wunsafe-buffer-usage -verify %s
----------------
steakhal wrote:

Usually when I craft RUN lines, I tried to either, share the longest common prefix for the lines, or create a `DEFINE` to substitute to the common parts and explicitly pass what is different.
How about this?

```suggestion
// RUN: %clang_cc1 -fsyntax-only -Wno-all -Wunsafe-buffer-usage -verify %s -std=c++20
// RUN: %clang_cc1 -fsyntax-only -Wno-all -Wunsafe-buffer-usage -verify %s -x c
```

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


More information about the cfe-commits mailing list