[clang] [clang] Implement -fstrict-bool (PR #160790)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 19:48:38 PST 2025


=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>,
=?utf-8?q?Félix?= Cloutier <fcloutier at apple.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/160790 at github.com>


================
@@ -0,0 +1,22 @@
+// RUN: %clang -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONE
+// RUN: %clang -### -fstrict-bool %s 2>&1 | FileCheck %s --check-prefix=CHECK-STRICT
+// RUN: %clang -### -fno-strict-bool %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONSTRICT
+// RUN: %clang -### -fno-strict-bool=truncate %s 2>&1 | FileCheck %s --check-prefix=CHECK-TRUNCATE
+// RUN: %clang -### -fno-strict-bool=nonzero %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONZERO
+// RUN: %clang -### -fstrict-bool -fno-strict-bool %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONSTRICT
+// RUN: %clang -### -fno-strict-bool -fno-strict-bool=nonzero %s 2>&1 | FileCheck %s --check-prefix=CHECK-NONZERO
+// RUN: %clang -### -fno-strict-bool=nonzero -fstrict-bool %s 2>&1 | FileCheck %s --check-prefix=CHECK-STRICT
+
+// RUN: %clang -### -mkernel %s 2>&1 | FileCheck %s --check-prefix=CHECK-TRUNCATE
+// RUN: %clang -### -fapple-kext %s 2>&1 | FileCheck %s --check-prefix=CHECK-TRUNCATE
+// RUN: %clang -### -mkernel -fstrict-bool %s 2>&1 | FileCheck %s --check-prefix=CHECK-STRICT
+// RUN: %clang -### -fstrict-bool -mkernel %s 2>&1 | FileCheck %s --check-prefix=CHECK-STRICT
+
+// RUN: not %clang -### -fno-strict-bool=ow-ouch %s 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID
----------------
apple-fcloutier wrote:

Do you have specific tests in mind? This already checks what happens when:

1. you do not pass any -fstrict-bool option
2. you pass -fstrict-bool
3. you pass -fno-strict-bool
4. you pass -fno-strict-bool=truncate (your concern?)
5. you pass -fno-strict-bool=nonzero (your concern?)
6. you pass -fstrict-bool then -fno-strict-bool
7. you pass -fno-strict-bool then -fstrict-bool
8. you pass -fno-strict-bool then -fno-strict-bool=nonzero
9. you pass -fno-strict-bool=nonzero then -fno-strict-bool
10. you pass -mkernel
11. you pass -fapple-kext
12. you pass -mkernel -fstrict-bool
13. you pass -fstrict-bool -mkernel
14. you pass an invalid value to -fno-strict-bool=

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


More information about the cfe-commits mailing list