forked from OSchip/llvm-project
[Modules] Add a command line option for loading the clang builtins modulemap.
-fbuiltin-module-map loads the clang builtins modulemap file. (This is equivalent to -fmodule-map-file=<resource dir>/include/module.modulemap) Differential Revision: https://reviews.llvm.org/D25767 llvm-svn: 285548
This commit is contained in:
parent
cc012b3a37
commit
938f516424
|
@ -174,6 +174,9 @@ Command-line parameters
|
|||
``-fmodules``
|
||||
Enable the modules feature.
|
||||
|
||||
``-fbuiltin-module-map``
|
||||
Load the Clang builtins module map file. (Equivalent to ``-fmodule-map-file=<resource dir>/include/module.modulemap``)
|
||||
|
||||
``-fimplicit-module-maps``
|
||||
Enable implicit search for module map files named ``module.modulemap`` and similar. This option is implied by ``-fmodules``. If this is disabled with ``-fno-implicit-module-maps``, module map files will only be loaded if they are explicitly specified via ``-fmodule-map-file`` or transitively used by another module map file.
|
||||
|
||||
|
|
|
@ -553,6 +553,8 @@ def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group<f_Group>;
|
|||
def fborland_extensions : Flag<["-"], "fborland-extensions">, Group<f_Group>, Flags<[CC1Option]>,
|
||||
HelpText<"Accept non-standard constructs supported by the Borland compiler">;
|
||||
def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>;
|
||||
def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group<f_Group>,
|
||||
Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">;
|
||||
def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group<f_Group>;
|
||||
def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;
|
||||
def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group<f_Group>,
|
||||
|
|
|
@ -5636,6 +5636,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
// definitions.
|
||||
Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
|
||||
|
||||
// -fbuiltin-module-map can be used to load the clang
|
||||
// builtin headers modulemap file.
|
||||
if (Args.hasArg(options::OPT_fbuiltin_module_map)) {
|
||||
SmallString<128> BuiltinModuleMap(getToolChain().getDriver().ResourceDir);
|
||||
llvm::sys::path::append(BuiltinModuleMap, "include");
|
||||
llvm::sys::path::append(BuiltinModuleMap, "module.modulemap");
|
||||
if (llvm::sys::fs::exists(BuiltinModuleMap)) {
|
||||
CmdArgs.push_back(Args.MakeArgString("-fmodule-map-file=" +
|
||||
BuiltinModuleMap));
|
||||
}
|
||||
}
|
||||
|
||||
// -fmodule-file can be used to specify files containing precompiled modules.
|
||||
if (HaveAnyModules)
|
||||
Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
|
||||
|
|
|
@ -51,6 +51,10 @@
|
|||
// CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
|
||||
// CHECK-MODULE-MAP-FILES: "-fmodule-map-file=bar.map"
|
||||
|
||||
// RUN: %clang -fmodules -fbuiltin-module-map -### %s 2>&1 | FileCheck -check-prefix=CHECK-BUILTIN-MODULE-MAP %s
|
||||
// CHECK-BUILTIN-MODULE-MAP: "-fmodules"
|
||||
// CHECK-BUILTIN-MODULE-MAP: "-fmodule-map-file={{.*}}include{{/|\\\\}}module.modulemap"
|
||||
|
||||
// RUN: %clang -fmodules -fmodule-file=foo.pcm -fmodule-file=bar.pcm -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-FILES %s
|
||||
// CHECK-MODULE-FILES: "-fmodules"
|
||||
// CHECK-MODULE-FILES: "-fmodule-file=foo.pcm"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
|
||||
// RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify
|
||||
// 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
|
||||
// expected-no-diagnostics
|
||||
|
||||
#ifdef __SSE__
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
|
||||
// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding
|
||||
// expected-no-diagnostics
|
||||
|
||||
#include<x86intrin.h>
|
||||
|
|
|
@ -268,6 +268,7 @@ config.substitutions.append( ('%clang', ' ' + config.clang + ' ') )
|
|||
config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + '/utils/test_debuginfo.pl ') )
|
||||
config.substitutions.append( ('%itanium_abi_triple', makeItaniumABITriple(config.target_triple)) )
|
||||
config.substitutions.append( ('%ms_abi_triple', makeMSABITriple(config.target_triple)) )
|
||||
config.substitutions.append( ('%resource_dir', getClangBuiltinIncludeDir(config.clang)) )
|
||||
|
||||
# The host triple might not be set, at least if we're compiling clang from
|
||||
# an already installed llvm.
|
||||
|
|
Loading…
Reference in New Issue