r285548 - [Modules] Add a command line option for loading the clang builtins modulemap.
Elad Cohen via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 31 01:21:55 PDT 2016
Author: eladcohen
Date: Mon Oct 31 03:21:54 2016
New Revision: 285548
URL: http://llvm.org/viewvc/llvm-project?rev=285548&view=rev
Log:
[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
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/modules.m
cfe/trunk/test/Modules/compiler_builtins.m
cfe/trunk/test/Modules/compiler_builtins_x86.c
cfe/trunk/test/lit.cfg
Modified: cfe/trunk/docs/Modules.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Mon Oct 31 03:21:54 2016
@@ -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.
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 31 03:21:54 2016
@@ -553,6 +553,8 @@ def fbootclasspath_EQ : Joined<["-"], "f
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>,
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct 31 03:21:54 2016
@@ -5636,6 +5636,18 @@ void Clang::ConstructJob(Compilation &C,
// 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);
Modified: cfe/trunk/test/Driver/modules.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/modules.m?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/test/Driver/modules.m (original)
+++ cfe/trunk/test/Driver/modules.m Mon Oct 31 03:21:54 2016
@@ -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"
Modified: cfe/trunk/test/Modules/compiler_builtins.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/compiler_builtins.m?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/test/Modules/compiler_builtins.m (original)
+++ cfe/trunk/test/Modules/compiler_builtins.m Mon Oct 31 03:21:54 2016
@@ -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__
Modified: cfe/trunk/test/Modules/compiler_builtins_x86.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/compiler_builtins_x86.c?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/test/Modules/compiler_builtins_x86.c (original)
+++ cfe/trunk/test/Modules/compiler_builtins_x86.c Mon Oct 31 03:21:54 2016
@@ -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>
Modified: cfe/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=285548&r1=285547&r2=285548&view=diff
==============================================================================
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Mon Oct 31 03:21:54 2016
@@ -268,6 +268,7 @@ config.substitutions.append( ('%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.
More information about the cfe-commits
mailing list