Skip to content

Commit ea9f9fd

Browse files
Revert "Merge pull request swiftlang#7619 from ian-twilightcoder/cstdlib-modules"
This reverts commit 1a1fb4b, reversing changes made to c58c369.
1 parent 22c7b7d commit ea9f9fd

35 files changed

+162
-750
lines changed

clang/lib/Basic/Module.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ bool Module::directlyUses(const Module *Requested) {
308308
// Anyone is allowed to use our builtin stdarg.h and stddef.h and their
309309
// accompanying modules.
310310
if (Requested->getTopLevelModuleName() == "_Builtin_stdarg" ||
311-
Requested->getTopLevelModuleName() == "_Builtin_stddef")
311+
Requested->getTopLevelModuleName() == "_Builtin_stddef" ||
312+
(!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t"))
312313
return true;
313314

314315
if (NoUndeclaredIncludes)

clang/lib/Headers/__stddef_max_align_t.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*===---- __stddef_max_align_t.h - Definition of max_align_t ---------------===
1+
/*===---- __stddef_max_align_t.h - Definition of max_align_t for modules ---===
22
*
33
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
* See https://llvm.org/LICENSE.txt for license information.

clang/lib/Headers/__stddef_null.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,7 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#if !defined(NULL) || !__has_feature(modules)
11-
12-
/* linux/stddef.h will define NULL to 0. glibc (and other) headers then define
13-
* __need_NULL and rely on stddef.h to redefine NULL to the correct value again.
14-
* Modules don't support redefining macros like that, but support that pattern
15-
* in the non-modules case.
16-
*/
1710
#undef NULL
18-
1911
#ifdef __cplusplus
2012
#if !defined(__MINGW32__) && !defined(_MSC_VER)
2113
#define NULL __null
@@ -25,5 +17,3 @@
2517
#else
2618
#define NULL ((void *)0)
2719
#endif
28-
29-
#endif

clang/lib/Headers/__stddef_nullptr_t.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#ifndef _NULLPTR_T
10+
#if !defined(_NULLPTR_T) || __has_feature(modules)
11+
/* Always define nullptr_t when modules are available. */
12+
#if !__has_feature(modules)
1113
#define _NULLPTR_T
12-
14+
#endif
1315
#ifdef __cplusplus
1416
#if defined(_MSC_EXTENSIONS) && defined(_NATIVE_NULLPTR_SUPPORTED)
1517
namespace std {
1618
typedef decltype(nullptr) nullptr_t;
1719
}
1820
using ::std::nullptr_t;
1921
#endif
20-
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
22+
#else
2123
typedef typeof(nullptr) nullptr_t;
2224
#endif
23-
2425
#endif

clang/lib/Headers/__stddef_offsetof.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#ifndef offsetof
10+
#if !defined(offsetof) || __has_feature(modules)
11+
/* Always define offsetof when modules are available. */
1112
#define offsetof(t, d) __builtin_offsetof(t, d)
1213
#endif

clang/lib/Headers/__stddef_ptrdiff_t.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#ifndef _PTRDIFF_T
10+
#if !defined(_PTRDIFF_T) || __has_feature(modules)
11+
/* Always define ptrdiff_t when modules are available. */
12+
#if !__has_feature(modules)
1113
#define _PTRDIFF_T
12-
14+
#endif
1315
typedef __PTRDIFF_TYPE__ ptrdiff_t;
14-
1516
#endif

clang/lib/Headers/__stddef_rsize_t.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#ifndef _RSIZE_T
10+
#if !defined(_RSIZE_T) || __has_feature(modules)
11+
/* Always define rsize_t when modules are available. */
12+
#if !__has_feature(modules)
1113
#define _RSIZE_T
12-
14+
#endif
1315
typedef __SIZE_TYPE__ rsize_t;
14-
1516
#endif

clang/lib/Headers/__stddef_size_t.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#ifndef _SIZE_T
10+
#if !defined(_SIZE_T) || __has_feature(modules)
11+
/* Always define size_t when modules are available. */
12+
#if !__has_feature(modules)
1113
#define _SIZE_T
12-
14+
#endif
1315
typedef __SIZE_TYPE__ size_t;
14-
1516
#endif

clang/lib/Headers/__stddef_unreachable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*===-----------------------------------------------------------------------===
88
*/
99

10-
#ifndef unreachable
10+
#if !defined(unreachable) || __has_feature(modules)
11+
/* Always define unreachable when modules are available. */
1112
#define unreachable() __builtin_unreachable()
1213
#endif

clang/lib/Headers/__stddef_wchar_t.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
*/
99

1010
#if !defined(__cplusplus) || (defined(_MSC_VER) && !_NATIVE_WCHAR_T_DEFINED)
11-
12-
#ifndef _WCHAR_T
11+
/* Always define wchar_t when modules are available. */
12+
#if !defined(_WCHAR_T) || __has_feature(modules)
13+
#if !__has_feature(modules)
1314
#define _WCHAR_T
14-
15-
#ifdef _MSC_EXTENSIONS
15+
#if defined(_MSC_EXTENSIONS)
1616
#define _WCHAR_T_DEFINED
1717
#endif
18-
18+
#endif
1919
typedef __WCHAR_TYPE__ wchar_t;
20-
2120
#endif
22-
2321
#endif

0 commit comments

Comments
 (0)