[clang] [clang] Don't omit null pointer checks with -fms-compatibility (PR #204658)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 9 06:00:42 PDT 2026


================
@@ -0,0 +1,35 @@
+// Check that null pointer checks are not optimized out if -fms-compatibility is set
+// RUN: %clang_cc1 -fms-kernel -O2 -triple x86_64-pc-windows-msvc %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -O2 -triple x86_64-pc-windows-msvc %s -emit-llvm -o - | FileCheck %s --check-prefix=NOCHECK
+// RUN: %clang_cc1 -fms-kernel -O2 -triple x86_64-pc-windows-msvc -fdelete-null-pointer-checks %s -emit-llvm -o - | FileCheck %s --check-prefix=NOCHECK
----------------
eleviant wrote:

Actually everything will work as expected in this case (`-fdelete-null-pointer-checks` will override `-fns-kernel`), because lang options (`-fms-kernel`) are parsed before codegen options (`-fdelete-null-pointer-checks`), so the default value of `true` of `CodeGenOptions.NullPointerIsValid` will always be overridden.

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


More information about the cfe-commits mailing list