Skip to content

Commit 87bca11

Browse files
committedMar 21, 2016
[modules] Don't invent a module cache path unless implicit module builds are enabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263970 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 703ec47 commit 87bca11

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed
 

‎lib/Driver/Tools.cpp

+20-22
Original file line numberDiff line numberDiff line change
@@ -5016,28 +5016,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
50165016
if (!Args.hasFlag(options::OPT_fimplicit_modules,
50175017
options::OPT_fno_implicit_modules)) {
50185018
CmdArgs.push_back("-fno-implicit-modules");
5019-
}
5020-
5021-
// -fmodule-name specifies the module that is currently being built (or
5022-
// used for header checking by -fmodule-maps).
5023-
Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
5024-
5025-
// -fmodule-map-file can be used to specify files containing module
5026-
// definitions.
5027-
Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
5028-
5029-
// -fmodule-file can be used to specify files containing precompiled modules.
5030-
if (HaveModules)
5031-
Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
5032-
else
5033-
Args.ClaimAllArgs(options::OPT_fmodule_file);
5034-
5035-
// -fmodule-cache-path specifies where our implicitly-built module files
5036-
// should be written.
5037-
SmallString<128> Path;
5038-
if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
5039-
Path = A->getValue();
5040-
if (HaveModules) {
5019+
} else if (HaveModules) {
5020+
// -fmodule-cache-path specifies where our implicitly-built module files
5021+
// should be written.
5022+
SmallString<128> Path;
5023+
if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
5024+
Path = A->getValue();
50415025
if (C.isForDiagnostics()) {
50425026
// When generating crash reports, we want to emit the modules along with
50435027
// the reproduction sources, so we ignore any provided module path.
@@ -5056,6 +5040,20 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
50565040
CmdArgs.push_back(Args.MakeArgString(Path));
50575041
}
50585042

5043+
// -fmodule-name specifies the module that is currently being built (or
5044+
// used for header checking by -fmodule-maps).
5045+
Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
5046+
5047+
// -fmodule-map-file can be used to specify files containing module
5048+
// definitions.
5049+
Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
5050+
5051+
// -fmodule-file can be used to specify files containing precompiled modules.
5052+
if (HaveModules)
5053+
Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
5054+
else
5055+
Args.ClaimAllArgs(options::OPT_fmodule_file);
5056+
50595057
// When building modules and generating crashdumps, we need to dump a module
50605058
// dependency VFS alongside the output.
50615059
if (HaveModules && C.isForDiagnostics()) {

‎test/Modules/no-implicit-builds.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// RUN: rm -rf %t
22

3+
// RUN: %clang -x c++ -std=c++11 -fmodules -fno-implicit-modules /dev/null -### \
4+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-MODULE-CACHE %s
5+
// CHECK-NO-MODULE-CACHE-NOT: -fmodules-cache-path
6+
37
// Produce an error if a module is needed, but not found.
48
// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
59
// RUN: -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \

0 commit comments

Comments
 (0)