summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-31 06:26:43 +0000
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-31 06:26:43 +0000
commitd30446fd773e9571a287bb2c3e5d06ab86f7e18b (patch)
tree33333cfa1ff0bf4559655240ddc861f4c9ee9147 /clang/lib/Frontend/CompilerInvocation.cpp
parentb8198f02e689b2234c09c1171539ecfa3a0f59b2 (diff)
downloadbcm5719-llvm-d30446fd773e9571a287bb2c3e5d06ab86f7e18b.tar.gz
bcm5719-llvm-d30446fd773e9571a287bb2c3e5d06ab86f7e18b.zip
[modules] Add ability to specify module name to module file mapping (reapply)
Extend the -fmodule-file option to support the [<name>=]<file> value format. If the name is omitted, then the old semantics is preserved (the module file is loaded whether needed or not). If the name is specified, then the mapping is treated as just another prebuilt module search mechanism, similar to -fprebuilt-module-path, and the module file is only loaded if actually used (e.g., via import). With one exception: this mapping also overrides module file references embedded in other modules (which can be useful if module files are moved/renamed as often happens during remote compilation). This override semantics requires some extra work: we now store the module name in addition to the file name in the serialized AST representation. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35020 llvm-svn: 312220
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 2cc93c1f13d..f9dafbb88ea 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1009,9 +1009,12 @@ static void ParseDependencyOutputArgs(DependencyOutputOptions &Opts,
// They won't be discovered by the regular preprocessor, so
// we let make / ninja to know about this implicit dependency.
Opts.ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry);
- auto ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);
- Opts.ExtraDeps.insert(Opts.ExtraDeps.end(), ModuleFiles.begin(),
- ModuleFiles.end());
+ // Only the -fmodule-file=<file> form.
+ for (const Arg *A : Args.filtered(OPT_fmodule_file)) {
+ StringRef Val = A->getValue();
+ if (Val.find('=') == StringRef::npos)
+ Opts.ExtraDeps.push_back(Val);
+ }
}
static bool parseShowColorsArgs(const ArgList &Args, bool DefaultColor) {
@@ -1340,7 +1343,12 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.UseGlobalModuleIndex = !Args.hasArg(OPT_fno_modules_global_index);
Opts.GenerateGlobalModuleIndex = Opts.UseGlobalModuleIndex;
Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
- Opts.ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);
+ // Only the -fmodule-file=<file> form.
+ for (const Arg *A : Args.filtered(OPT_fmodule_file)) {
+ StringRef Val = A->getValue();
+ if (Val.find('=') == StringRef::npos)
+ Opts.ModuleFiles.push_back(Val);
+ }
Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
@@ -1544,6 +1552,12 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args,
Opts.ModuleCachePath = P.str();
Opts.ModuleUserBuildPath = Args.getLastArgValue(OPT_fmodules_user_build_path);
+ // Only the -fmodule-file=<name>=<file> form.
+ for (const Arg *A : Args.filtered(OPT_fmodule_file)) {
+ StringRef Val = A->getValue();
+ if (Val.find('=') != StringRef::npos)
+ Opts.PrebuiltModuleFiles.insert(Val.split('='));
+ }
for (const Arg *A : Args.filtered(OPT_fprebuilt_module_path))
Opts.AddPrebuiltModulePath(A->getValue());
Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
OpenPOWER on IntegriCloud