Skip to content

Commit 206e7e6

Browse files
git apple-llvm automergerian-twilightcoder
git apple-llvm automerger
authored andcommitted
[cherry-pick stable/20230725] [Modules] no_undeclared_includes modules (Apple Darwin) don't work the clang modules
llvm#68241 rdar://105819340
1 parent a2d6383 commit 206e7e6

16 files changed

+203
-69
lines changed

clang/test/Modules/Inputs/System/usr/include/inttypes.h

Whitespace-only changes.

clang/test/Modules/Inputs/System/usr/include/math.h

Whitespace-only changes.

clang/test/Modules/Inputs/System/usr/include/module.map

-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
11
module cstd [system] {
2-
// Only in system headers directory
3-
module complex {
4-
header "complex.h"
5-
}
6-
72
// Only in compiler support directory
83
module float_constants {
94
header "float.h"
105
}
116

12-
// In both directories (compiler support version wins, forwards)
13-
module inttypes {
14-
header "inttypes.h"
15-
}
16-
17-
// Only in system headers directory
18-
module math {
19-
header "math.h"
20-
}
21-
227
// Only in system headers directory
238
module stdio {
249
header "stdio.h"
Original file line numberDiff line numberDiff line change
@@ -1,36 +1 @@
1-
#ifndef STDINT_H
2-
#define STDINT_H
3-
41
typedef int my_awesome_nonstandard_integer_type;
5-
6-
// types needed by stdatomic.h
7-
8-
typedef char int_least8_t;
9-
typedef short int_least16_t;
10-
typedef int int_least32_t;
11-
typedef long long int int_least64_t;
12-
typedef unsigned char uint_least8_t;
13-
typedef unsigned short uint_least16_t;
14-
typedef unsigned int uint_least32_t;
15-
typedef unsigned long long uint_least64_t;
16-
17-
typedef char int_fast8_t;
18-
typedef short int_fast16_t;
19-
typedef int int_fast32_t;
20-
typedef long long int int_fast64_t;
21-
typedef unsigned char uint_fast8_t;
22-
typedef unsigned short uint_fast16_t;
23-
typedef unsigned int uint_fast32_t;
24-
typedef unsigned long long uint_fast64_t;
25-
26-
typedef int intptr_t;
27-
typedef unsigned int uintptr_t;
28-
typedef int intmax_t;
29-
typedef unsigned int uintmax_t;
30-
31-
// additional types for unwind.h
32-
33-
typedef unsigned int uint32_t;
34-
typedef unsigned long long uint64_t;
35-
36-
#endif /* STDINT_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module c_complex [system] {
2+
header "complex.h"
3+
export *
4+
}
5+
6+
module c_float [system] {
7+
header "float.h"
8+
export *
9+
}
10+
11+
module c_inttypes [system] {
12+
header "inttypes.h"
13+
export *
14+
}
15+
16+
module c_limits [system] {
17+
header "limits.h"
18+
export *
19+
}
20+
21+
module c_math [system] {
22+
header "math.h"
23+
export *
24+
}
25+
26+
module c_stdint [system] {
27+
header "stdint.h"
28+
export *
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module cpp_stdint [system] {
2+
header "stdint.h"
3+
export *
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef CPP_STDINT_H
2+
#define CPP_STDINT_H
3+
4+
#include_next <stdint.h>
5+
6+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Required by tgmath.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef INTTYPES_H
2+
#define INTTYPES_H
3+
4+
// This creates an include cycle when inttypes.h and stdint.h
5+
// are both part of the cstd module. This include will resolve
6+
// to the C++ stdint.h, which will #include_next eventually to
7+
// the stdint.h in this directory, and thus create the cycle
8+
// cstd (inttypes.h) -> cpp_stdint (stdint.h) -> cstd (stdint.h).
9+
// This cycle is worked around by cstd using [no_undeclared_includes].
10+
#include <stdint.h>
11+
12+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Required by tgmath.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef STDINT_H
2+
#define STDINT_H
3+
4+
// types needed by stdatomic.h
5+
6+
typedef char int_least8_t;
7+
typedef short int_least16_t;
8+
typedef int int_least32_t;
9+
typedef long long int int_least64_t;
10+
typedef unsigned char uint_least8_t;
11+
typedef unsigned short uint_least16_t;
12+
typedef unsigned int uint_least32_t;
13+
typedef unsigned long long uint_least64_t;
14+
15+
typedef char int_fast8_t;
16+
typedef short int_fast16_t;
17+
typedef int int_fast32_t;
18+
typedef long long int int_fast64_t;
19+
typedef unsigned char uint_fast8_t;
20+
typedef unsigned short uint_fast16_t;
21+
typedef unsigned int uint_fast32_t;
22+
typedef unsigned long long uint_fast64_t;
23+
24+
typedef int intptr_t;
25+
typedef unsigned int uintptr_t;
26+
typedef int intmax_t;
27+
typedef unsigned int uintmax_t;
28+
29+
// additional types for unwind.h
30+
31+
typedef unsigned int uint32_t;
32+
typedef unsigned long long uint64_t;
33+
34+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module cstd [system] [no_undeclared_includes] {
2+
module complex {
3+
header "complex.h"
4+
export *
5+
}
6+
7+
module float {
8+
header "float.h"
9+
export *
10+
}
11+
12+
module inttypes {
13+
header "inttypes.h"
14+
export *
15+
}
16+
17+
module iso646 {
18+
header "iso646.h"
19+
export *
20+
}
21+
22+
module limits {
23+
header "limits.h"
24+
export *
25+
}
26+
27+
module math {
28+
header "math.h"
29+
export *
30+
}
31+
32+
module stdalign {
33+
header "stdalign.h"
34+
export *
35+
}
36+
37+
module stdarg {
38+
header "stdarg.h"
39+
export *
40+
}
41+
42+
module stdatomic {
43+
header "stdatomic.h"
44+
export *
45+
}
46+
47+
module stdbool {
48+
header "stdbool.h"
49+
export *
50+
}
51+
52+
module stddef {
53+
header "stddef.h"
54+
export *
55+
}
56+
57+
module stdint {
58+
header "stdint.h"
59+
export *
60+
}
61+
62+
module tgmath {
63+
header "tgmath.h"
64+
export *
65+
}
66+
67+
module unwind {
68+
header "unwind.h"
69+
export *
70+
}
71+
}

clang/test/Modules/builtin-headers.mm

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: rm -rf %t
2+
// RUN: %clang_cc1 -cxx-isystem %S/Inputs/builtin-headers/c++ -internal-isystem %S/Inputs/builtin-headers -fsyntax-only -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/builtin-headers/c++/module.modulemap -fmodule-map-file=%resource_dir/module.modulemap -fmodule-map-file=%S/Inputs/builtin-headers/system-modules.modulemap -fbuiltin-headers-in-system-modules -DSYSTEM_MODULES %s -verify
3+
// RUN: rm -rf %t
4+
// RUN: %clang_cc1 -cxx-isystem %S/Inputs/builtin-headers/c++ -internal-isystem %S/Inputs/builtin-headers -fsyntax-only -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/builtin-headers/c++/module.modulemap -fmodule-map-file=%resource_dir/module.modulemap -fmodule-map-file=%S/Inputs/builtin-headers/builtin-modules.modulemap %s -verify
5+
6+
// expected-no-diagnostics
7+
8+
@import cpp_stdint;
9+
10+
// The builtin modules are always available, though they're mostly
11+
// empty if -fbuiltin-headers-in-system-modules is used.
12+
@import _Builtin_float;
13+
@import _Builtin_inttypes;
14+
@import _Builtin_iso646;
15+
@import _Builtin_limits;
16+
@import _Builtin_stdalign;
17+
@import _Builtin_stdarg;
18+
@import _Builtin_stdatomic;
19+
@import _Builtin_stdbool;
20+
@import _Builtin_stddef;
21+
@import _Builtin_stdint;
22+
@import _Builtin_stdnoreturn;
23+
@import _Builtin_tgmath;
24+
@import _Builtin_unwind;
25+
26+
#ifdef SYSTEM_MODULES
27+
// system-modules.modulemap uses the "mega module" style with
28+
// -fbuiltin-headers-in-system-modules, and its modules cover
29+
// the clang builtin headers.
30+
@import cstd;
31+
#else
32+
// builtin-modules.modulemap uses top level modules for each
33+
// of its headers, which allows interleaving with the builtin
34+
// modules and libc++ modules.
35+
@import c_complex;
36+
@import c_float;
37+
@import c_inttypes;
38+
@import c_limits;
39+
@import c_math;
40+
@import c_stdint;
41+
#endif
+3-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: rm -rf %t
2-
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -internal-isystem %S/Inputs/System/usr/include -verify
3-
// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -internal-isystem %S/Inputs/System/usr/include -verify
4-
// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -DNO_SYSTEM_MODULES -verify
2+
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
3+
// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
4+
// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
55
// expected-no-diagnostics
66

77
#ifdef __SSE__
@@ -11,19 +11,3 @@
1111
#ifdef __AVX2__
1212
@import _Builtin_intrinsics.intel.avx2;
1313
#endif
14-
15-
#ifndef NO_SYSTEM_MODULES
16-
@import _Builtin_float;
17-
@import _Builtin_inttypes;
18-
@import _Builtin_iso646;
19-
@import _Builtin_limits;
20-
@import _Builtin_stdalign;
21-
@import _Builtin_stdarg;
22-
@import _Builtin_stdatomic;
23-
@import _Builtin_stdbool;
24-
@import _Builtin_stddef;
25-
@import _Builtin_stdint;
26-
@import _Builtin_stdnoreturn;
27-
@import _Builtin_tgmath;
28-
@import _Builtin_unwind;
29-
#endif

0 commit comments

Comments
 (0)