Skip to content

Commit ab562ed

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f50d3582b484' from llvm.org/main into next
2 parents 44e8fa2 + f50d358 commit ab562ed

13 files changed

+80
-41
lines changed

clang/lib/Basic/Module.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,9 @@ bool Module::directlyUses(const Module *Requested) {
308308
if (Requested->isSubModuleOf(Use))
309309
return true;
310310

311-
// Anyone is allowed to use our builtin stdarg.h and stddef.h and their
312-
// accompanying modules.
313-
if (Requested->getTopLevelModuleName() == "_Builtin_stdarg" ||
314-
Requested->getTopLevelModuleName() == "_Builtin_stddef")
311+
// Anyone is allowed to use our builtin stddef.h and its accompanying modules.
312+
if (Requested->fullModuleNameIs({"_Builtin_stddef", "max_align_t"}) ||
313+
Requested->fullModuleNameIs({"_Builtin_stddef_wint_t"}))
315314
return true;
316315

317316
if (NoUndeclaredIncludes)

clang/lib/Headers/__stddef_null.h

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

10-
#if !defined(NULL) || !__has_feature(modules)
10+
#if !defined(NULL) || !__building_module(_Builtin_stddef)
1111

1212
/* linux/stddef.h will define NULL to 0. glibc (and other) headers then define
1313
* __need_NULL and rely on stddef.h to redefine NULL to the correct value again.

clang/lib/Headers/__stddef_nullptr_t.h

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

10-
#ifndef _NULLPTR_T
10+
/*
11+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
12+
* and needs to behave as if it was textual.
13+
*/
14+
#if !defined(_NULLPTR_T) || \
15+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1116
#define _NULLPTR_T
1217

1318
#ifdef __cplusplus

clang/lib/Headers/__stddef_offsetof.h

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

10-
#ifndef offsetof
10+
/*
11+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
12+
* and needs to behave as if it was textual.
13+
*/
14+
#if !defined(offsetof) || \
15+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1116
#define offsetof(t, d) __builtin_offsetof(t, d)
1217
#endif

clang/lib/Headers/__stddef_ptrdiff_t.h

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

10-
#ifndef _PTRDIFF_T
10+
/*
11+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
12+
* and needs to behave as if it was textual.
13+
*/
14+
#if !defined(_PTRDIFF_T) || \
15+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1116
#define _PTRDIFF_T
1217

1318
typedef __PTRDIFF_TYPE__ ptrdiff_t;

clang/lib/Headers/__stddef_rsize_t.h

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

10-
#ifndef _RSIZE_T
10+
/*
11+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
12+
* and needs to behave as if it was textual.
13+
*/
14+
#if !defined(_RSIZE_T) || \
15+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1116
#define _RSIZE_T
1217

1318
typedef __SIZE_TYPE__ rsize_t;

clang/lib/Headers/__stddef_size_t.h

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

10-
#ifndef _SIZE_T
10+
/*
11+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
12+
* and needs to behave as if it was textual.
13+
*/
14+
#if !defined(_SIZE_T) || \
15+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1116
#define _SIZE_T
1217

1318
typedef __SIZE_TYPE__ size_t;

clang/lib/Headers/__stddef_unreachable.h

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

10-
#ifndef unreachable
10+
/*
11+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
12+
* and needs to behave as if it was textual.
13+
*/
14+
#if !defined(unreachable) || \
15+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1116
#define unreachable() __builtin_unreachable()
1217
#endif

clang/lib/Headers/__stddef_wchar_t.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
#if !defined(__cplusplus) || (defined(_MSC_VER) && !_NATIVE_WCHAR_T_DEFINED)
1111

12-
#ifndef _WCHAR_T
12+
/*
13+
* When -fbuiltin-headers-in-system-modules is set this is a non-modular header
14+
* and needs to behave as if it was textual.
15+
*/
16+
#if !defined(_WCHAR_T) || \
17+
(__has_feature(modules) && !__building_module(_Builtin_stddef))
1318
#define _WCHAR_T
1419

1520
#ifdef _MSC_EXTENSIONS

clang/lib/Headers/module.modulemap

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ module _Builtin_intrinsics [system] [extern_c] {
155155

156156
// Start -fbuiltin-headers-in-system-modules affected modules
157157

158-
// The following modules all ignore their top level headers
159-
// when -fbuiltin-headers-in-system-modules is passed, and
160-
// most of those headers join system modules when present.
158+
// The following modules all ignore their headers when
159+
// -fbuiltin-headers-in-system-modules is passed, and many of
160+
// those headers join system modules when present.
161161

162162
// e.g. if -fbuiltin-headers-in-system-modules is passed, then
163163
// float.h will not be in the _Builtin_float module (that module
@@ -190,11 +190,6 @@ module _Builtin_stdalign [system] {
190190
export *
191191
}
192192

193-
// When -fbuiltin-headers-in-system-modules is passed, only
194-
// the top level headers are removed, the implementation headers
195-
// will always be in their submodules. That means when stdarg.h
196-
// is included, it will still import this module and make the
197-
// appropriate submodules visible.
198193
module _Builtin_stdarg [system] {
199194
textual header "stdarg.h"
200195

@@ -237,6 +232,8 @@ module _Builtin_stdbool [system] {
237232
module _Builtin_stddef [system] {
238233
textual header "stddef.h"
239234

235+
// __stddef_max_align_t.h is always in this module, even if
236+
// -fbuiltin-headers-in-system-modules is passed.
240237
explicit module max_align_t {
241238
header "__stddef_max_align_t.h"
242239
export *
@@ -283,9 +280,10 @@ module _Builtin_stddef [system] {
283280
}
284281
}
285282

286-
/* wint_t is provided by <wchar.h> and not <stddef.h>. It's here
287-
* for compatibility, but must be explicitly requested. Therefore
288-
* __stddef_wint_t.h is not part of _Builtin_stddef. */
283+
// wint_t is provided by <wchar.h> and not <stddef.h>. It's here
284+
// for compatibility, but must be explicitly requested. Therefore
285+
// __stddef_wint_t.h is not part of _Builtin_stddef. It is always in
286+
// this module even if -fbuiltin-headers-in-system-modules is passed.
289287
module _Builtin_stddef_wint_t [system] {
290288
header "__stddef_wint_t.h"
291289
export *

0 commit comments

Comments
 (0)