Skip to content

Commit 5bfa5ad

Browse files
Merge pull request #7752 from ian-twilightcoder/builtin-flag
[cherry-pick stable/20230725] [Modules] Add a flag to control builtin headers being in system modules
2 parents 38a8c52 + ec0986e commit 5bfa5ad

File tree

17 files changed

+148
-51
lines changed

17 files changed

+148
-51
lines changed

clang/include/clang/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ EXTENSION(matrix_types, LangOpts.MatrixTypes)
285285
EXTENSION(matrix_types_scalar_division, true)
286286
EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11)
287287

288+
FEATURE(builtin_headers_in_system_modules, LangOpts.BuiltinHeadersInSystemModules)
288289
FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables)
289290

290291
// CUDA/HIP Features

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ LANGOPT(MathErrno , 1, 1, "errno in math functions")
184184
BENIGN_LANGOPT(HeinousExtensions , 1, 0, "extensions that we really don't like and may be ripped out at any time")
185185
LANGOPT(Modules , 1, 0, "modules semantics")
186186
COMPATIBLE_LANGOPT(CPlusPlusModules, 1, 0, "C++ modules syntax")
187+
LANGOPT(BuiltinHeadersInSystemModules, 1, 0, "builtin headers belong to system modules, and _Builtin_ modules are ignored for cstdlib headers")
187188
BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 3, CMK_None,
188189
"compiling a module interface")
189190
BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,6 +2605,12 @@ defm modules : BoolFOption<"modules",
26052605
LangOpts<"Modules">, Default<fcxx_modules.KeyPath>,
26062606
PosFlag<SetTrue, [CC1Option], "Enable the 'modules' language feature">,
26072607
NegFlag<SetFalse>, BothFlags<[NoXarchOption, CoreOption]>>;
2608+
def fbuiltin_headers_in_system_modules : Flag <["-"], "fbuiltin-headers-in-system-modules">,
2609+
Group<f_Group>,
2610+
Flags<[NoXarchOption,CC1Option]>,
2611+
ShouldParseIf<fmodules.KeyPath>,
2612+
HelpText<"builtin headers belong to system modules, and _Builtin_ modules are ignored for cstdlib headers">,
2613+
MarshallingInfoFlag<LangOpts<"BuiltinHeadersInSystemModules">>;
26082614
def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, Alias<fimplicit_module_maps>;
26092615
def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group<f_Group>,
26102616
Flags<[NoXarchOption,CC1Option,CoreOption]>, MetaVarName<"<name>">,

clang/include/clang/Lex/ModuleMap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ class ModuleMap {
427427
}
428428

429429
/// Is this a compiler builtin header?
430-
static bool isBuiltinHeader(StringRef FileName);
431430
bool isBuiltinHeader(const FileEntry *File);
432431

433432
/// Add a module map callback.

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,6 +3023,25 @@ bool Darwin::isAlignedAllocationUnavailable() const {
30233023
return TargetVersion < alignedAllocMinVersion(OS);
30243024
}
30253025

3026+
static bool sdkSupportsBuiltinModules(const Darwin::DarwinPlatformKind &TargetPlatform, const std::optional<DarwinSDKInfo> &SDKInfo) {
3027+
if (!SDKInfo)
3028+
return false;
3029+
3030+
VersionTuple SDKVersion = SDKInfo->getVersion();
3031+
switch (TargetPlatform) {
3032+
case Darwin::MacOS:
3033+
return SDKVersion >= VersionTuple(99U);
3034+
case Darwin::IPhoneOS:
3035+
return SDKVersion >= VersionTuple(99U);
3036+
case Darwin::TvOS:
3037+
return SDKVersion >= VersionTuple(99U);
3038+
case Darwin::WatchOS:
3039+
return SDKVersion >= VersionTuple(99U);
3040+
default:
3041+
return true;
3042+
}
3043+
}
3044+
30263045
void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
30273046
llvm::opt::ArgStringList &CC1Args,
30283047
Action::OffloadKind DeviceOffloadKind) const {
@@ -3045,6 +3064,20 @@ void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
30453064
options::OPT_fvisibility_inlines_hidden_static_local_var,
30463065
options::OPT_fno_visibility_inlines_hidden_static_local_var))
30473066
CC1Args.push_back("-fvisibility-inlines-hidden-static-local-var");
3067+
3068+
// Earlier versions of the darwin SDK have the C standard library headers
3069+
// all together in the Darwin module. That leads to module cycles with
3070+
// the _Builtin_ modules. e.g. <inttypes.h> on darwin includes <stdint.h>.
3071+
// The builtin <stdint.h> include-nexts <stdint.h>. When both of those
3072+
// darwin headers are in the Darwin module, there's a module cycle Darwin ->
3073+
// _Builtin_stdint -> Darwin (i.e. inttypes.h (darwin) -> stdint.h (builtin) ->
3074+
// stdint.h (darwin)). This is fixed in later versions of the darwin SDK,
3075+
// but until then, the builtin headers need to join the system modules.
3076+
// i.e. when the builtin stdint.h is in the Darwin module too, the cycle
3077+
// goes away. Note that -fbuiltin-headers-in-system-modules does nothing
3078+
// to fix the same problem with C++ headers, and is generally fragile.
3079+
if (!sdkSupportsBuiltinModules(TargetPlatform, SDKInfo))
3080+
CC1Args.push_back("-fbuiltin-headers-in-system-modules");
30483081
}
30493082

30503083
void Darwin::addClangCC1ASTargetOptions(

clang/lib/Lex/ModuleMap.cpp

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,45 @@ OptionalFileEntryRef ModuleMap::findHeader(
253253
return NormalHdrFile;
254254
}
255255

256+
/// Determine whether the given file name is the name of a builtin
257+
/// header, supplied by Clang to replace, override, or augment existing system
258+
/// headers.
259+
static bool isBuiltinHeaderName(StringRef FileName) {
260+
return llvm::StringSwitch<bool>(FileName)
261+
.Case("float.h", true)
262+
.Case("iso646.h", true)
263+
.Case("limits.h", true)
264+
.Case("stdalign.h", true)
265+
.Case("stdarg.h", true)
266+
.Case("stdatomic.h", true)
267+
.Case("stdbool.h", true)
268+
.Case("stddef.h", true)
269+
.Case("stdint.h", true)
270+
.Case("tgmath.h", true)
271+
.Case("unwind.h", true)
272+
.Default(false);
273+
}
274+
275+
/// Determine whether the given module name is the name of a builtin
276+
/// module that is cyclic with a system module on some platforms.
277+
static bool isBuiltInModuleName(StringRef ModuleName) {
278+
return llvm::StringSwitch<bool>(ModuleName)
279+
.Case("_Builtin_float", true)
280+
.Case("_Builtin_inttypes", true)
281+
.Case("_Builtin_iso646", true)
282+
.Case("_Builtin_limits", true)
283+
.Case("_Builtin_stdalign", true)
284+
.Case("_Builtin_stdarg", true)
285+
.Case("_Builtin_stdatomic", true)
286+
.Case("_Builtin_stdbool", true)
287+
.Case("_Builtin_stddef", true)
288+
.Case("_Builtin_stdint", true)
289+
.Case("_Builtin_stdnoreturn", true)
290+
.Case("_Builtin_tgmath", true)
291+
.Case("_Builtin_unwind", true)
292+
.Default(false);
293+
}
294+
256295
void ModuleMap::resolveHeader(Module *Mod,
257296
const Module::UnresolvedHeaderDirective &Header,
258297
bool &NeedsFramework) {
@@ -297,7 +336,7 @@ bool ModuleMap::resolveAsBuiltinHeader(
297336
llvm::sys::path::is_absolute(Header.FileName) ||
298337
Mod->isPartOfFramework() || !Mod->IsSystem || Header.IsUmbrella ||
299338
!BuiltinIncludeDir || BuiltinIncludeDir == Mod->Directory ||
300-
!isBuiltinHeader(Header.FileName))
339+
!LangOpts.BuiltinHeadersInSystemModules || !isBuiltinHeaderName(Header.FileName))
301340
return false;
302341

303342
// This is a system module with a top-level header. This header
@@ -373,28 +412,9 @@ static StringRef sanitizeFilenameAsIdentifier(StringRef Name,
373412
return Name;
374413
}
375414

376-
/// Determine whether the given file name is the name of a builtin
377-
/// header, supplied by Clang to replace, override, or augment existing system
378-
/// headers.
379-
bool ModuleMap::isBuiltinHeader(StringRef FileName) {
380-
return llvm::StringSwitch<bool>(FileName)
381-
.Case("float.h", true)
382-
.Case("iso646.h", true)
383-
.Case("limits.h", true)
384-
.Case("stdalign.h", true)
385-
.Case("stdarg.h", true)
386-
.Case("stdatomic.h", true)
387-
.Case("stdbool.h", true)
388-
.Case("stddef.h", true)
389-
.Case("stdint.h", true)
390-
.Case("tgmath.h", true)
391-
.Case("unwind.h", true)
392-
.Default(false);
393-
}
394-
395415
bool ModuleMap::isBuiltinHeader(const FileEntry *File) {
396-
return File->getDir() == BuiltinIncludeDir &&
397-
ModuleMap::isBuiltinHeader(llvm::sys::path::filename(File->getName()));
416+
return File->getDir() == BuiltinIncludeDir && LangOpts.BuiltinHeadersInSystemModules &&
417+
isBuiltinHeaderName(llvm::sys::path::filename(File->getName()));
398418
}
399419

400420
ModuleMap::HeadersMap::iterator
@@ -2485,7 +2505,10 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
24852505
}
24862506

24872507
bool NeedsFramework = false;
2488-
Map.addUnresolvedHeader(ActiveModule, std::move(Header), NeedsFramework);
2508+
// Don't add the top level headers to the builtin modules if the builtin headers
2509+
// belong to the system modules.
2510+
if (!Map.LangOpts.BuiltinHeadersInSystemModules || ActiveModule->isSubModule() || !isBuiltInModuleName(ActiveModule->Name))
2511+
Map.addUnresolvedHeader(ActiveModule, std::move(Header), NeedsFramework);
24892512

24902513
if (NeedsFramework)
24912514
Diags.Report(CurrModuleDeclLoc, diag::note_mmap_add_framework_keyword)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Version":"990.0", "MaximumDeploymentTarget": "99.0.99"}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Check that darwin passes -fbuiltin-headers-in-system-modules
2+
// when expected.
3+
4+
// RUN: %clang -target x86_64-apple-darwin22.4 -### %s 2>&1 | FileCheck %s
5+
// RUN: %clang -isysroot %S/Inputs/MacOSX10.15.versioned.sdk -target x86_64-apple-macos10.15 -### %s 2>&1 | FileCheck %s
6+
// RUN: %clang -isysroot %S/Inputs/iPhoneOS13.0.sdk -target arm64-apple-ios13.0 -### %s 2>&1 | FileCheck %s
7+
// CHECK: -fbuiltin-headers-in-system-modules
8+
9+
// RUN: %clang -isysroot %S/Inputs/MacOSX99.0.sdk -target x86_64-apple-macos98.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
10+
// RUN: %clang -isysroot %S/Inputs/MacOSX99.0.sdk -target x86_64-apple-macos99.0 -### %s 2>&1 | FileCheck --check-prefix=CHECK_FUTURE %s
11+
// CHECK_FUTURE-NOT: -fbuiltin-headers-in-system-modules
12+
13+
14+
// Check that builtin_headers_in_system_modules is only set if -fbuiltin-headers-in-system-modules and -fmodules are both set.
15+
16+
// RUN: %clang -isysroot %S/Inputs/iPhoneOS13.0.sdk -target arm64-apple-ios13.0 -fsyntax-only %s -Xclang -verify=no-feature
17+
// RUN: %clang -isysroot %S/Inputs/iPhoneOS13.0.sdk -target arm64-apple-ios13.0 -fsyntax-only %s -fmodules -Xclang -verify=yes-feature
18+
// RUN: %clang -isysroot %S/Inputs/MacOSX99.0.sdk -target x86_64-apple-macos99.0 -fsyntax-only %s -Xclang -verify=no-feature
19+
// RUN: %clang -isysroot %S/Inputs/MacOSX99.0.sdk -target x86_64-apple-macos99.0 -fsyntax-only %s -fmodules -Xclang -verify=no-feature
20+
21+
#if __has_feature(builtin_headers_in_system_modules)
22+
#error "has builtin_headers_in_system_modules"
23+
// yes-feature-error@-1 {{}}
24+
#else
25+
#error "no builtin_headers_in_system_modules"
26+
// no-feature-error@-1 {{}}
27+
#endif

clang/test/Modules/Werror-Wsystem-headers.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
// RUN: mkdir %t-saved
44

55
// Initial module build
6-
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
7-
// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify
6+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules \
7+
// RUN: -fmodules-cache-path=%t -fdisable-module-hash -isystem %S/Inputs/System/usr/include \
8+
// RUN: -fsyntax-only %s -verify
89
// RUN: cp %t/cstd.pcm %t-saved/cstd.pcm
910

1011
// Even with -Werror don't rebuild a system module
11-
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
12-
// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify -Werror
12+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules \
13+
// RUN: -fmodules-cache-path=%t -fdisable-module-hash -isystem %S/Inputs/System/usr/include \
14+
// RUN: -fsyntax-only %s -verify -Werror
1315
// RUN: diff %t/cstd.pcm %t-saved/cstd.pcm
1416

1517
// Unless -Wsystem-headers is on
16-
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash \
17-
// RUN: -isystem %S/Inputs/System/usr/include -fsyntax-only %s -verify \
18-
// RUN: -Werror=unused -Wsystem-headers
18+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules \
19+
// RUN: -fmodules-cache-path=%t -fdisable-module-hash -isystem %S/Inputs/System/usr/include \
20+
// RUN: -fsyntax-only %s -verify -Werror=unused -Wsystem-headers
1921
// RUN: not diff %t/cstd.pcm %t-saved/cstd.pcm
2022

2123
// expected-no-diagnostics

clang/test/Modules/context-hash.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@
44
// RUN: rm -rf %t
55
// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
66
// RUN: %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
7-
// RUN: -fmodules-cache-path=%t %s -Rmodule-build 2> %t1
7+
// RUN: -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t %s \
8+
// RUN: -Rmodule-build 2> %t1
89
// RUN: rm -rf %t
910
// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
1011
// RUN: %S/Inputs/System/usr/include -internal-isystem %S -fmodules \
11-
// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s -Rmodule-build 2> \
12-
// RUN: %t2
12+
// RUN: -fbuiltin-headers-in-system-modules -fimplicit-module-maps \
13+
// RUN: -fmodules-cache-path=%t %s -Rmodule-build 2> %t2
1314
// RUN: rm -rf %t
1415
// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
1516
// RUN: %S/Inputs/System/usr/include -internal-isystem %S -fmodules \
16-
// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s \
17-
// RUN: -fmodules-strict-context-hash -Rmodule-build 2> %t3
17+
// RUN: -fbuiltin-headers-in-system-modules -fimplicit-module-maps \
18+
// RUN: -fmodules-cache-path=%t %s -fmodules-strict-context-hash \
19+
// RUN: -Rmodule-build 2> %t3
1820
// RUN: rm -rf %t
1921
// RUN: %clang_cc1 -fsyntax-only -Weverything -internal-isystem \
2022
// RUN: %S/Inputs/System/usr/include -fmodules -fmodules-strict-context-hash \
21-
// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s -Rmodule-build 2> \
22-
// RUN: %t4
23+
// RUN: -fbuiltin-headers-in-system-modules -fimplicit-module-maps \
24+
// RUN: -fmodules-cache-path=%t %s -Rmodule-build 2> %t4
2325
// RUN: echo %t > %t.path
2426
// RUN: cat %t.path %t1 %t2 %t3 %t4 | FileCheck %s
2527

@@ -29,16 +31,17 @@
2931
// RUN: rm -rf %t
3032
// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
3133
// RUN: %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
32-
// RUN: -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t1
34+
// RUN: -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t \
35+
// RUN: -x objective-c %s -Rmodule-build 2> %t1
3336
// RUN: rm -rf %t
3437
// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
3538
// RUN: %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
36-
// RUN: -fobjc-runtime=macosx-1.0.0.0 \
39+
// RUN: -fbuiltin-headers-in-system-modules -fobjc-runtime=macosx-1.0.0.0 \
3740
// RUN: -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t2
3841
// RUN: rm -rf %t
3942
// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
4043
// RUN: %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
41-
// RUN: -fcomment-block-commands=lp,bj \
44+
// RUN: -fbuiltin-headers-in-system-modules -fcomment-block-commands=lp,bj \
4245
// RUN: -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t3
4346
// RUN: echo %t > %t.path
4447
// RUN: cat %t.path %t1 %t2 %t3 | FileCheck --check-prefix=LANGOPTS %s

clang/test/Modules/crash-vfs-include-pch.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h \
77
// RUN: -o %t/out/pch-used.h.pch -fmodules -fimplicit-module-maps \
8-
// RUN: -fmodules-cache-path=%t/cache -O0 \
8+
// RUN: -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t/cache -O0 \
99
// RUN: -isystem %S/Inputs/System/usr/include
1010

1111
// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
1212
// RUN: not %clang %s -E -include-pch %t/out/pch-used.h.pch -fmodules -nostdlibinc \
13-
// RUN: -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 \
14-
// RUN: -Xclang -fno-validate-pch -isystem %S/Inputs/System/usr/include \
15-
// RUN: -o %t/output.E 2>&1 | FileCheck %s
13+
// RUN: -fimplicit-module-maps -fbuiltin-headers-in-system-modules \
14+
// RUN: -fmodules-cache-path=%t/cache -O0 -Xclang -fno-validate-pch \
15+
// RUN: -isystem %S/Inputs/System/usr/include -o %t/output.E 2>&1 | FileCheck %s
1616

1717
// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
1818
// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \

clang/test/Modules/cstd.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t
2-
// RUN: %clang_cc1 -fsyntax-only -internal-isystem %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
2+
// RUN: %clang_cc1 -fsyntax-only -internal-isystem %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
33

44
@import uses_other_constants;
55
const double other_value = DBL_MAX;

clang/test/Modules/pch-used.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
22
// RUN: rm -rf %t
33
// RUN: mkdir %t
4-
// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include
5-
// RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s
4+
// RUN: %clang_cc1 -x objective-c-header -emit-pch %S/Inputs/pch-used.h -o %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include
5+
// RUN: %clang_cc1 %s -include-pch %t/pch-used.h.pch -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t/cache -O0 -isystem %S/Inputs/System/usr/include -emit-llvm -o - | FileCheck %s
66

77
void f(void) { SPXTrace(); }
88
void g(void) { double x = DBL_MAX; }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t
2-
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/shadowed-submodule/Foo -I %S/Inputs/shadowed-submodule/A2 %s -verify
2+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I %S/Inputs/shadowed-submodule/Foo -I %S/Inputs/shadowed-submodule/A2 %s -verify
33

44
@import Foo; // expected-error {{module 'A' was built in directory}}
55
// [email protected]:4 {{imported by module 'Foo'}}

clang/test/Modules/stddef.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t
2-
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify -fno-modules-error-recovery
2+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify -fno-modules-error-recovery
33

44
#include "ptrdiff_t.h"
55

clang/test/Modules/stddef.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
size_t getSize(void);
44

55
// RUN: rm -rf %t
6-
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/StdDef %s -verify
6+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I %S/Inputs/StdDef %s -verify
77
// expected-no-diagnostics

lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ ClangExpressionParser::ClangExpressionParser(
576576
lang_opts.GNUMode = true;
577577
lang_opts.GNUKeywords = true;
578578
lang_opts.CPlusPlus11 = true;
579+
lang_opts.BuiltinHeadersInSystemModules = true;
579580

580581
// The Darwin libc expects this macro to be set.
581582
lang_opts.GNUCVersion = 40201;

0 commit comments

Comments
 (0)