Author: Ian Anderson Date: 2023-08-30T11:41:12-07:00 New Revision: 680da4b5d7ec05a1e6656f2a7603a7b843268bab
URL: https://github.com/llvm/llvm-project/commit/680da4b5d7ec05a1e6656f2a7603a7b843268bab DIFF: https://github.com/llvm/llvm-project/commit/680da4b5d7ec05a1e6656f2a7603a7b843268bab.diff LOG: [Headers][Modules] Make separate headers for the stdarg.h and stddef.h pieces so that they can be modularized stdarg.h and stddef.h have to be textual headers in their upcoming modules to support their `__needs_xxx` macros. That means that they won't get precompiled into their modules' pcm, and instead their declarations will go into every other pcm that uses them. For now that's ok since the type merger can handle the declarations in these headers, but it's suboptimal at best. Make separate headers for all of the pieces so that they can be properly modularized. Reviewed By: aaron.ballman, ChuanqiXu Differential Revision: https://reviews.llvm.org/D158709 Added: clang/lib/Headers/__stdarg___gnuc_va_list.h clang/lib/Headers/__stdarg___va_copy.h clang/lib/Headers/__stdarg_va_arg.h clang/lib/Headers/__stdarg_va_copy.h clang/lib/Headers/__stdarg_va_list.h clang/lib/Headers/__stddef_null.h clang/lib/Headers/__stddef_nullptr_t.h clang/lib/Headers/__stddef_offsetof.h clang/lib/Headers/__stddef_ptrdiff_t.h clang/lib/Headers/__stddef_rsize_t.h clang/lib/Headers/__stddef_size_t.h clang/lib/Headers/__stddef_unreachable.h clang/lib/Headers/__stddef_wchar_t.h clang/lib/Headers/__stddef_wint_t.h Modified: clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp clang-tools-extra/clangd/index/CanonicalIncludes.cpp clang/lib/Headers/CMakeLists.txt clang/lib/Headers/stdarg.h clang/lib/Headers/stddef.h clang/test/Headers/stddef.c clang/test/Headers/stddefneeds.c clang/test/Modules/stddef.c compiler-rt/lib/gwp_asan/guarded_pool_allocator.h llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn Removed: ################################################################################ diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp index 5245243bac0816..df77bf7ea46da3 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp @@ -13,7 +13,21 @@ namespace find_all_symbols { const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() { static const HeaderMapCollector::RegexHeaderMap STLPostfixHeaderMap = { + {"include/__stdarg___gnuc_va_list.h$", "<cstdarg>"}, + {"include/__stdarg___va_copy.h$", "<cstdarg>"}, + {"include/__stdarg_va_arg.h$", "<cstdarg>"}, + {"include/__stdarg_va_copy.h$", "<cstdarg>"}, + {"include/__stdarg_va_list.h$", "<cstdarg>"}, {"include/__stddef_max_align_t.h$", "<cstddef>"}, + {"include/__stddef_null.h$", "<cstddef>"}, + {"include/__stddef_nullptr_t.h$", "<cstddef>"}, + {"include/__stddef_offsetof.h$", "<cstddef>"}, + {"include/__stddef_ptr diff _t.h$", "<cstddef>"}, + {"include/__stddef_rsize_t.h$", "<cstddef>"}, + {"include/__stddef_size_t.h$", "<cstddef>"}, + {"include/__stddef_unreachable.h$", "<cstddef>"}, + {"include/__stddef_wchar_t.h$", "<cstddef>"}, + {"include/__stddef_wint_t.h$", "<cstddef>"}, {"include/__wmmintrin_aes.h$", "<wmmintrin.h>"}, {"include/__wmmintrin_pclmul.h$", "<wmmintrin.h>"}, {"include/adxintrin.h$", "<immintrin.h>"}, diff --git a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp index 3e3ba4d9f2b58d..9d6c09cd2ab4b7 100644 --- a/clang-tools-extra/clangd/index/CanonicalIncludes.cpp +++ b/clang-tools-extra/clangd/index/CanonicalIncludes.cpp @@ -16,7 +16,21 @@ namespace clang { namespace clangd { namespace { const std::pair<llvm::StringRef, llvm::StringRef> IncludeMappings[] = { + {"include/__stdarg___gnuc_va_list.h", "<cstdarg>"}, + {"include/__stdarg___va_copy.h", "<cstdarg>"}, + {"include/__stdarg_va_arg.h", "<cstdarg>"}, + {"include/__stdarg_va_copy.h", "<cstdarg>"}, + {"include/__stdarg_va_list.h", "<cstdarg>"}, {"include/__stddef_max_align_t.h", "<cstddef>"}, + {"include/__stddef_null.h", "<cstddef>"}, + {"include/__stddef_nullptr_t.h", "<cstddef>"}, + {"include/__stddef_offsetof.h", "<cstddef>"}, + {"include/__stddef_ptr diff _t.h", "<cstddef>"}, + {"include/__stddef_rsize_t.h", "<cstddef>"}, + {"include/__stddef_size_t.h", "<cstddef>"}, + {"include/__stddef_unreachable.h", "<cstddef>"}, + {"include/__stddef_wchar_t.h", "<cstddef>"}, + {"include/__stddef_wint_t.h", "<cstddef>"}, {"include/__wmmintrin_aes.h", "<wmmintrin.h>"}, {"include/__wmmintrin_pclmul.h", "<wmmintrin.h>"}, {"include/adxintrin.h", "<immintrin.h>"}, diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index 05bb740f306727..e6154d7ecd80ea 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -10,10 +10,24 @@ set(core_files module.modulemap stdalign.h stdarg.h + __stdarg___gnuc_va_list.h + __stdarg___va_copy.h + __stdarg_va_arg.h + __stdarg_va_copy.h + __stdarg_va_list.h stdatomic.h stdbool.h stddef.h __stddef_max_align_t.h + __stddef_null.h + __stddef_nullptr_t.h + __stddef_offsetof.h + __stddef_ptr diff _t.h + __stddef_rsize_t.h + __stddef_size_t.h + __stddef_unreachable.h + __stddef_wchar_t.h + __stddef_wint_t.h stdint.h stdnoreturn.h tgmath.h diff --git a/clang/lib/Headers/__stdarg___gnuc_va_list.h b/clang/lib/Headers/__stdarg___gnuc_va_list.h new file mode 100644 index 00000000000000..2a0a7e8cc6c054 --- /dev/null +++ b/clang/lib/Headers/__stdarg___gnuc_va_list.h @@ -0,0 +1,13 @@ +/*===---- __stdarg___gnuc_va_list.h - Definition of __gnuc_va_list ---------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST +typedef __builtin_va_list __gnuc_va_list; +#endif diff --git a/clang/lib/Headers/__stdarg___va_copy.h b/clang/lib/Headers/__stdarg___va_copy.h new file mode 100644 index 00000000000000..e433e18a708266 --- /dev/null +++ b/clang/lib/Headers/__stdarg___va_copy.h @@ -0,0 +1,12 @@ +/*===---- __stdarg___va_copy.h - Definition of __va_copy -------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __va_copy +#define __va_copy(d, s) __builtin_va_copy(d, s) +#endif diff --git a/clang/lib/Headers/__stdarg_va_arg.h b/clang/lib/Headers/__stdarg_va_arg.h new file mode 100644 index 00000000000000..89bd2f65d3bea2 --- /dev/null +++ b/clang/lib/Headers/__stdarg_va_arg.h @@ -0,0 +1,22 @@ +/*===---- __stdarg_va_arg.h - Definitions of va_start, va_arg, va_end-------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef va_arg + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L +/* C23 does not require the second parameter for va_start. */ +#define va_start(ap, ...) __builtin_va_start(ap, 0) +#else +/* Versions before C23 do require the second parameter. */ +#define va_start(ap, param) __builtin_va_start(ap, param) +#endif +#define va_end(ap) __builtin_va_end(ap) +#define va_arg(ap, type) __builtin_va_arg(ap, type) + +#endif diff --git a/clang/lib/Headers/__stdarg_va_copy.h b/clang/lib/Headers/__stdarg_va_copy.h new file mode 100644 index 00000000000000..8645328c2c68fb --- /dev/null +++ b/clang/lib/Headers/__stdarg_va_copy.h @@ -0,0 +1,12 @@ +/*===---- __stdarg_va_copy.h - Definition of va_copy------------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef va_copy +#define va_copy(dest, src) __builtin_va_copy(dest, src) +#endif diff --git a/clang/lib/Headers/__stdarg_va_list.h b/clang/lib/Headers/__stdarg_va_list.h new file mode 100644 index 00000000000000..20c2e2cad94049 --- /dev/null +++ b/clang/lib/Headers/__stdarg_va_list.h @@ -0,0 +1,13 @@ +/*===---- __stdarg_va_list.h - Definition of va_list -----------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef _VA_LIST +#define _VA_LIST +typedef __builtin_va_list va_list; +#endif diff --git a/clang/lib/Headers/__stddef_null.h b/clang/lib/Headers/__stddef_null.h new file mode 100644 index 00000000000000..33d0ec62fd905d --- /dev/null +++ b/clang/lib/Headers/__stddef_null.h @@ -0,0 +1,19 @@ +/*===---- __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 + * + *===-----------------------------------------------------------------------=== + */ + +#undef NULL +#ifdef __cplusplus +#if !defined(__MINGW32__) && !defined(_MSC_VER) +#define NULL __null +#else +#define NULL 0 +#endif +#else +#define NULL ((void *)0) +#endif diff --git a/clang/lib/Headers/__stddef_nullptr_t.h b/clang/lib/Headers/__stddef_nullptr_t.h new file mode 100644 index 00000000000000..8d23ed6dc8c697 --- /dev/null +++ b/clang/lib/Headers/__stddef_nullptr_t.h @@ -0,0 +1,25 @@ +/*===---- __stddef_nullptr_t.h - Definition of nullptr_t -------------------=== + * + * 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(_NULLPTR_T) || __has_feature(modules) +/* Always define nullptr_t when modules are available. */ +#if !__has_feature(modules) +#define _NULLPTR_T +#endif +#ifdef __cplusplus +#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED) +namespace std { +typedef decltype(nullptr) nullptr_t; +} +using ::std::nullptr_t; +#endif +#else +typedef typeof(nullptr) nullptr_t; +#endif +#endif diff --git a/clang/lib/Headers/__stddef_offsetof.h b/clang/lib/Headers/__stddef_offsetof.h new file mode 100644 index 00000000000000..84af8357c285b5 --- /dev/null +++ b/clang/lib/Headers/__stddef_offsetof.h @@ -0,0 +1,13 @@ +/*===---- __stddef_offsetof.h - Definition of offsetof ---------------------=== + * + * 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(offsetof) || __has_feature(modules) +/* Always define offsetof when modules are available. */ +#define offsetof(t, d) __builtin_offsetof(t, d) +#endif diff --git a/clang/lib/Headers/__stddef_ptr diff _t.h b/clang/lib/Headers/__stddef_ptr diff _t.h new file mode 100644 index 00000000000000..853cee5e09799b --- /dev/null +++ b/clang/lib/Headers/__stddef_ptr diff _t.h @@ -0,0 +1,16 @@ +/*===---- __stddef_ptr diff _t.h - Definition of ptr diff _t -------------------=== + * + * 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(_PTRDIFF_T) || __has_feature(modules) +/* Always define ptr diff _t when modules are available. */ +#if !__has_feature(modules) +#define _PTRDIFF_T +#endif +typedef __PTRDIFF_TYPE__ ptr diff _t; +#endif diff --git a/clang/lib/Headers/__stddef_rsize_t.h b/clang/lib/Headers/__stddef_rsize_t.h new file mode 100644 index 00000000000000..f9c31cf8f9746a --- /dev/null +++ b/clang/lib/Headers/__stddef_rsize_t.h @@ -0,0 +1,16 @@ +/*===---- __stddef_rsize_t.h - Definition of rsize_t -----------------------=== + * + * 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(_RSIZE_T) || __has_feature(modules) +/* Always define rsize_t when modules are available. */ +#if !__has_feature(modules) +#define _RSIZE_T +#endif +typedef __SIZE_TYPE__ rsize_t; +#endif diff --git a/clang/lib/Headers/__stddef_size_t.h b/clang/lib/Headers/__stddef_size_t.h new file mode 100644 index 00000000000000..b30e245e0eb5c9 --- /dev/null +++ b/clang/lib/Headers/__stddef_size_t.h @@ -0,0 +1,16 @@ +/*===---- __stddef_size_t.h - Definition of size_t -------------------------=== + * + * 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(_SIZE_T) || __has_feature(modules) +/* Always define size_t when modules are available. */ +#if !__has_feature(modules) +#define _SIZE_T +#endif +typedef __SIZE_TYPE__ size_t; +#endif diff --git a/clang/lib/Headers/__stddef_unreachable.h b/clang/lib/Headers/__stddef_unreachable.h new file mode 100644 index 00000000000000..5252932cd27698 --- /dev/null +++ b/clang/lib/Headers/__stddef_unreachable.h @@ -0,0 +1,13 @@ +/*===---- __stddef_unreachable.h - Definition of unreachable ---------------=== + * + * 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(unreachable) || __has_feature(modules) +/* Always define unreachable when modules are available. */ +#define unreachable() __builtin_unreachable() +#endif diff --git a/clang/lib/Headers/__stddef_wchar_t.h b/clang/lib/Headers/__stddef_wchar_t.h new file mode 100644 index 00000000000000..c3f0516a4b1edf --- /dev/null +++ b/clang/lib/Headers/__stddef_wchar_t.h @@ -0,0 +1,21 @@ +/*===---- __stddef_wchar.h - Definition of wchar_t -------------------------=== + * + * 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(__cplusplus) || (defined(_MSC_VER) && !_NATIVE_WCHAR_T_DEFINED) +/* Always define wchar_t when modules are available. */ +#if !defined(_WCHAR_T) || __has_feature(modules) +#if !__has_feature(modules) +#define _WCHAR_T +#if defined(_MSC_EXTENSIONS) +#define _WCHAR_T_DEFINED +#endif +#endif +typedef __WCHAR_TYPE__ wchar_t; +#endif +#endif diff --git a/clang/lib/Headers/__stddef_wint_t.h b/clang/lib/Headers/__stddef_wint_t.h new file mode 100644 index 00000000000000..d0582ef971efda --- /dev/null +++ b/clang/lib/Headers/__stddef_wint_t.h @@ -0,0 +1,16 @@ +/*===---- __stddef_wint.h - Definition of wint_t ---------------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +/* Always define wint_t when modules are available. */ +#if !defined(_WINT_T) || __has_feature(modules) +#if !__has_feature(modules) +#define _WINT_T +#endif +typedef __WINT_TYPE__ wint_t; +#endif diff --git a/clang/lib/Headers/stdarg.h b/clang/lib/Headers/stdarg.h index 521c4733d55589..085e2bb861ceb5 100644 --- a/clang/lib/Headers/stdarg.h +++ b/clang/lib/Headers/stdarg.h @@ -30,41 +30,27 @@ #endif #ifdef __need___va_list -#ifndef __GNUC_VA_LIST -#define __GNUC_VA_LIST -typedef __builtin_va_list __gnuc_va_list; -#endif +#include <__stdarg___gnuc_va_list.h> #undef __need___va_list #endif /* defined(__need___va_list) */ #ifdef __need_va_list -#ifndef _VA_LIST -typedef __builtin_va_list va_list; -#define _VA_LIST -#endif +#include <__stdarg_va_list.h> #undef __need_va_list #endif /* defined(__need_va_list) */ #ifdef __need_va_arg -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L -/* C23 does not require the second parameter for va_start. */ -#define va_start(ap, ...) __builtin_va_start(ap, 0) -#else -/* Versions before C23 do require the second parameter. */ -#define va_start(ap, param) __builtin_va_start(ap, param) -#endif -#define va_end(ap) __builtin_va_end(ap) -#define va_arg(ap, type) __builtin_va_arg(ap, type) +#include <__stdarg_va_arg.h> #undef __need_va_arg #endif /* defined(__need_va_arg) */ #ifdef __need___va_copy -#define __va_copy(d,s) __builtin_va_copy(d,s) +#include <__stdarg___va_copy.h> #undef __need___va_copy #endif /* defined(__need___va_copy) */ #ifdef __need_va_copy -#define va_copy(dest, src) __builtin_va_copy(dest, src) +#include <__stdarg_va_copy.h> #undef __need_va_copy #endif /* defined(__need_va_copy) */ diff --git a/clang/lib/Headers/stddef.h b/clang/lib/Headers/stddef.h index dc720d44fc9b73..9c6dd0cd62dae1 100644 --- a/clang/lib/Headers/stddef.h +++ b/clang/lib/Headers/stddef.h @@ -51,107 +51,54 @@ #endif #if defined(__need_ptr diff _t) -#if !defined(_PTRDIFF_T) || __has_feature(modules) -/* Always define ptr diff _t when modules are available. */ -#if !__has_feature(modules) -#define _PTRDIFF_T -#endif -typedef __PTRDIFF_TYPE__ ptr diff _t; -#endif +#include <__stddef_ptr diff _t.h> #undef __need_ptr diff _t #endif /* defined(__need_ptr diff _t) */ #if defined(__need_size_t) -#if !defined(_SIZE_T) || __has_feature(modules) -/* Always define size_t when modules are available. */ -#if !__has_feature(modules) -#define _SIZE_T -#endif -typedef __SIZE_TYPE__ size_t; -#endif +#include <__stddef_size_t.h> #undef __need_size_t #endif /*defined(__need_size_t) */ #if defined(__need_rsize_t) -#if !defined(_RSIZE_T) || __has_feature(modules) -/* Always define rsize_t when modules are available. */ -#if !__has_feature(modules) -#define _RSIZE_T -#endif -typedef __SIZE_TYPE__ rsize_t; -#endif +#include <__stddef_rsize_t.h> #undef __need_rsize_t #endif /* defined(__need_rsize_t) */ #if defined(__need_wchar_t) -#if !defined(__cplusplus) || (defined(_MSC_VER) && !_NATIVE_WCHAR_T_DEFINED) -/* Always define wchar_t when modules are available. */ -#if !defined(_WCHAR_T) || __has_feature(modules) -#if !__has_feature(modules) -#define _WCHAR_T -#if defined(_MSC_EXTENSIONS) -#define _WCHAR_T_DEFINED -#endif -#endif -typedef __WCHAR_TYPE__ wchar_t; -#endif -#endif +#include <__stddef_wchar_t.h> #undef __need_wchar_t #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 +#include <__stddef_null.h> #undef __need_NULL #endif /* defined(__need_NULL) */ #if defined(__need_nullptr_t) -#ifdef __cplusplus -#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED) -namespace std { -typedef decltype(nullptr) nullptr_t; -} -using ::std::nullptr_t; -#endif -#else -typedef typeof(nullptr) nullptr_t; -#endif +#include <__stddef_nullptr_t.h> #undef __need_nullptr_t #endif /* defined(__need_nullptr_t) */ #if defined(__need_unreachable) -#define unreachable() __builtin_unreachable() +#include <__stddef_unreachable.h> #undef __need_unreachable #endif /* defined(__need_unreachable) */ #if defined(__need_max_align_t) -#include "__stddef_max_align_t.h" +#include <__stddef_max_align_t.h> #undef __need_max_align_t #endif /* defined(__need_max_align_t) */ #if defined(__need_offsetof) -#define offsetof(t, d) __builtin_offsetof(t, d) +#include <__stddef_offsetof.h> #undef __need_offsetof #endif /* defined(__need_offsetof) */ /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ #if defined(__need_wint_t) -/* Always define wint_t when modules are available. */ -#if !defined(_WINT_T) || __has_feature(modules) -#if !__has_feature(modules) -#define _WINT_T -#endif -typedef __WINT_TYPE__ wint_t; -#endif +#include <__stddef_wint_t.h> #undef __need_wint_t #endif /* __need_wint_t */ diff --git a/clang/test/Headers/stddef.c b/clang/test/Headers/stddef.c index 7e6d09a1b33a05..d2bceb84a0ba0b 100644 --- a/clang/test/Headers/stddef.c +++ b/clang/test/Headers/stddef.c @@ -22,7 +22,7 @@ wint_t wi0; // c99-error{{unknown type name 'wint_t'}} c11-error{{unknown type}} ptr diff _t p1; size_t s1; rsize_t r1; // c99-error{{unknown type}} c11-error{{unknown type}} c23-error{{unknown type}} - // c99-note@stddef.h:*{{'size_t' declared here}} c11-note@stddef.h:*{{'size_t' declared here}} c23-note@stddef.h:*{{'size_t' declared here}} + // c99-note@__stddef_size_t.h:*{{'size_t' declared here}} c11-note@__stddef_size_t.h:*{{'size_t' declared here}} c23-note@__stddef_size_t.h:*{{'size_t' declared here}} wchar_t wc1; void *v1 = NULL; nullptr_t n1; // c99-error{{unknown type}} c11-error{{unknown type}} diff --git a/clang/test/Headers/stddefneeds.c b/clang/test/Headers/stddefneeds.c index 4f5a443b724210..dd7ecd0e6028da 100644 --- a/clang/test/Headers/stddefneeds.c +++ b/clang/test/Headers/stddefneeds.c @@ -38,7 +38,7 @@ wint_t wi1; // c99-error{{unknown type}} c23-error{{unknown type}} ptr diff _t p2; size_t s2; rsize_t r2; // c99-error{{unknown type}} c23-error{{unknown type}} - // c99-note@stddef.h:*{{'size_t' declared here}} c23-note@stddef.h:*{{'size_t' declared here}} + // c99-note@__stddef_size_t.h:*{{'size_t' declared here}} c23-note@__stddef_size_t.h:*{{'size_t' declared here}} wchar_t wc2; // c99-error{{unknown type}} c23-error{{unknown type}} void *v2 = NULL; // c99-error{{undeclared identifier}} c23-error{{undeclared identifier}} nullptr_t n2; // c99-error{{unknown type}} c23-error{{unknown type}} @@ -96,7 +96,7 @@ wint_t wi5; // c99-error{{unknown type}} c23-error{{unknown type}} // __need_nullptr_t generates an error in <C23 because its definition // depends on nullptr. #define __need_nullptr_t -#include <stddef.h> // c99-error@stddef.h:*{{expected function body}} +#include <stddef.h> // c99-error@__stddef_nullptr_t.h:*{{expected function body}} ptr diff _t p6; size_t s6; diff --git a/clang/test/Modules/stddef.c b/clang/test/Modules/stddef.c index c33f3643112bba..dc4e41f84d9ed7 100644 --- a/clang/test/Modules/stddef.c +++ b/clang/test/Modules/stddef.c @@ -6,7 +6,7 @@ ptr diff _t pdt; size_t st; // expected-error {{missing '#include "include_again.h"'; 'size_t' must be declared before it is used}} -// expected-note@stddef.h:* {{here}} +// expected-note@__stddef_size_t.h:* {{here}} #include "include_again.h" diff --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h index de07b6798c19c6..a02a35321c2b8b 100644 --- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h +++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h @@ -20,6 +20,15 @@ #include <stddef.h> #include <stdint.h> // IWYU pragma: no_include <__stddef_max_align_t.h> +// IWYU pragma: no_include <__stddef_null.h> +// IWYU pragma: no_include <__stddef_nullptr_t.h> +// IWYU pragma: no_include <__stddef_offsetof.h> +// IWYU pragma: no_include <__stddef_ptr diff _t.h> +// IWYU pragma: no_include <__stddef_rsize_t.h> +// IWYU pragma: no_include <__stddef_size_t.h> +// IWYU pragma: no_include <__stddef_unreachable.h> +// IWYU pragma: no_include <__stddef_wchar_t.h> +// IWYU pragma: no_include <__stddef_wint_t.h> namespace gwp_asan { // This class is the primary implementation of the allocator portion of GWP- diff --git a/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn b/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn index 4047e3d3500b78..8e4660d7759577 100644 --- a/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn +++ b/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn @@ -95,7 +95,21 @@ copy("Headers") { "__clang_hip_math.h", "__clang_hip_runtime_wrapper.h", "__clang_hip_stdlib.h", + "__stdarg___gnuc_va_list.h", + "__stdarg___va_copy.h", + "__stdarg_va_arg.h", + "__stdarg_va_copy.h", + "__stdarg_va_list.h", "__stddef_max_align_t.h", + "__stddef_null.h", + "__stddef_nullptr_t.h", + "__stddef_offsetof.h", + "__stddef_ptr diff _t.h", + "__stddef_rsize_t.h", + "__stddef_size_t.h", + "__stddef_unreachable.h", + "__stddef_wchar_t.h", + "__stddef_wint_t.h", "__wmmintrin_aes.h", "__wmmintrin_pclmul.h", "adxintrin.h", _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits