iana updated this revision to Diff 492179.
iana added a comment.
Revert the unnecessary changes to unspecified-var-size.ll
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140250/new/
https://reviews.llvm.org/D140250
Files:
clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
clang-tools-extra/clangd/index/CanonicalIncludes.cpp
clang/docs/tools/clang-formatted-files.txt
clang/lib/Basic/Module.cpp
clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/__stddef_null.h
clang/lib/Headers/module.modulemap
clang/lib/Headers/stddef.h
clang/test/Headers/stddef_null.cpp
compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===================================================================
--- llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -88,6 +88,7 @@
"__clang_hip_runtime_wrapper.h",
"__clang_hip_stdlib.h",
"__stddef_max_align_t.h",
+ "__stddef_null.h",
"__wmmintrin_aes.h",
"__wmmintrin_pclmul.h",
"adxintrin.h",
Index: compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
===================================================================
--- compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
+++ compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
@@ -20,6 +20,7 @@
#include <stddef.h>
#include <stdint.h>
// IWYU pragma: no_include <__stddef_max_align_t.h>
+// IWYU pragma: no_include <__stddef_null.h>
namespace gwp_asan {
// This class is the primary implementation of the allocator portion of GWP-
Index: clang/test/Headers/stddef_null.cpp
===================================================================
--- /dev/null
+++ clang/test/Headers/stddef_null.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify -Wsentinel -std=c++11 %s
+
+void *v0 = NULL; // expected-error{{undeclared}}
+
+// Shouldn't bring in anything else from stddef.h
+#include <__stddef_null.h>
+void *v1 = NULL;
+ptrdiff_t p1; // expected-error{{unknown}}
+size_t s1; // expected-error{{unknown}}
+wint_t w1; // expected-error{{unknown}}
+max_align_t m1; // expected-error{{unknown}}
+
+
+// linux/stddef.h does something like this for cpp files:
+#undef NULL
+#define NULL 0
+
+// glibc (and other) headers then define __need_NULL and rely on stddef.h
+// to redefine NULL to the correct value again.
+#define __need_NULL
+#include <__stddef_null.h>
+
+// gtk headers then use __attribute__((sentinel)), which doesn't work if NULL
+// is 0.
+void f(const char* c, ...) __attribute__((sentinel));
+void g() {
+ f("", NULL); // Shouldn't warn.
+}
Index: clang/lib/Headers/stddef.h
===================================================================
--- clang/lib/Headers/stddef.h
+++ clang/lib/Headers/stddef.h
@@ -78,22 +78,7 @@
#endif /* defined(__need_wchar_t) */
#if defined(__need_NULL)
-#undef NULL
-#ifdef __cplusplus
-# if !defined(__MINGW32__) && !defined(_MSC_VER)
-# define NULL __null
-# else
-# define NULL 0
-# endif
-#else
-# define NULL ((void*)0)
-#endif
-#ifdef __cplusplus
-#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
-namespace std { typedef decltype(nullptr) nullptr_t; }
-using ::std::nullptr_t;
-#endif
-#endif
+#include <__stddef_null.h>
#undef __need_NULL
#endif /* defined(__need_NULL) */
Index: clang/lib/Headers/module.modulemap
===================================================================
--- clang/lib/Headers/module.modulemap
+++ clang/lib/Headers/module.modulemap
@@ -157,6 +157,11 @@
header "__stddef_max_align_t.h"
}
+module _Builtin_stddef_null [system] {
+ header "__stddef_null.h"
+ export *
+}
+
module opencl_c {
requires opencl
header "opencl-c.h"
Index: clang/lib/Headers/__stddef_null.h
===================================================================
--- /dev/null
+++ clang/lib/Headers/__stddef_null.h
@@ -0,0 +1,35 @@
+/*===---- __stddef_null.h - Definition of NULL -----------------------------===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#if !defined(__STDDEF_NULL_H) || defined(__need_NULL)
+
+#ifndef __STDDEF_NULL_H
+#define __STDDEF_NULL_H
+#endif
+
+#undef NULL
+#ifdef __cplusplus
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
+#define NULL __null
+#else
+#define NULL 0
+#endif
+#else
+#define NULL ((void *)0)
+#endif
+#ifdef __cplusplus
+#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
+namespace std {
+typedef decltype(nullptr) nullptr_t;
+}
+using ::std::nullptr_t;
+#endif
+#endif
+
+#endif
Index: clang/lib/Headers/CMakeLists.txt
===================================================================
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -14,6 +14,7 @@
stdbool.h
stddef.h
__stddef_max_align_t.h
+ __stddef_null.h
stdint.h
stdnoreturn.h
tgmath.h
Index: clang/lib/Basic/Module.cpp
===================================================================
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -298,8 +298,9 @@
if (Requested->isSubModuleOf(Use))
return true;
- // Anyone is allowed to use our builtin stddef.h and its accompanying module.
- if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t")
+ // Anyone is allowed to use our builtin stddef.h and its accompanying modules.
+ if (!Requested->Parent && (Requested->Name == "_Builtin_stddef_max_align_t" ||
+ Requested->Name == "_Builtin_stddef_null"))
return true;
if (NoUndeclaredIncludes)
Index: clang/docs/tools/clang-formatted-files.txt
===================================================================
--- clang/docs/tools/clang-formatted-files.txt
+++ clang/docs/tools/clang-formatted-files.txt
@@ -492,6 +492,7 @@
clang/lib/Headers/__clang_cuda_texture_intrinsics.h
clang/lib/Headers/__clang_hip_libdevice_declares.h
clang/lib/Headers/__stddef_max_align_t.h
+clang/lib/Headers/__stddef_null.h
clang/lib/Headers/openmp_wrappers/complex.h
clang/lib/Headers/openmp_wrappers/complex_cmath.h
clang/lib/Headers/openmp_wrappers/math.h
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===================================================================
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -20,6 +20,7 @@
namespace {
const std::pair<llvm::StringRef, llvm::StringRef> IncludeMappings[] = {
{"include/__stddef_max_align_t.h", "<cstddef>"},
+ {"include/__stddef_null.h", "<cstddef>"},
{"include/__wmmintrin_aes.h", "<wmmintrin.h>"},
{"include/__wmmintrin_pclmul.h", "<wmmintrin.h>"},
{"include/adxintrin.h", "<immintrin.h>"},
Index: clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
===================================================================
--- clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
+++ clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
@@ -14,6 +14,7 @@
const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
static const HeaderMapCollector::RegexHeaderMap STLPostfixHeaderMap = {
{"include/__stddef_max_align_t.h$", "<cstddef>"},
+ {"include/__stddef_null.h$", "<cstddef>"},
{"include/__wmmintrin_aes.h$", "<wmmintrin.h>"},
{"include/__wmmintrin_pclmul.h$", "<wmmintrin.h>"},
{"include/adxintrin.h$", "<immintrin.h>"},
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits