r263970 - [modules] Don't invent a module cache path unless implicit module builds are enabled.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 21 12:06:07 PDT 2016


Author: rsmith
Date: Mon Mar 21 14:06:06 2016
New Revision: 263970

URL: http://llvm.org/viewvc/llvm-project?rev=263970&view=rev
Log:
[modules] Don't invent a module cache path unless implicit module builds are enabled.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Modules/no-implicit-builds.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=263970&r1=263969&r2=263970&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Mar 21 14:06:06 2016
@@ -5016,28 +5016,12 @@ void Clang::ConstructJob(Compilation &C,
   if (!Args.hasFlag(options::OPT_fimplicit_modules,
                     options::OPT_fno_implicit_modules)) {
     CmdArgs.push_back("-fno-implicit-modules");
-  }
-
-  // -fmodule-name specifies the module that is currently being built (or
-  // used for header checking by -fmodule-maps).
-  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
-
-  // -fmodule-map-file can be used to specify files containing module
-  // definitions.
-  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
-
-  // -fmodule-file can be used to specify files containing precompiled modules.
-  if (HaveModules)
-    Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
-  else
-    Args.ClaimAllArgs(options::OPT_fmodule_file);
-
-  // -fmodule-cache-path specifies where our implicitly-built module files
-  // should be written.
-  SmallString<128> Path;
-  if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
-    Path = A->getValue();
-  if (HaveModules) {
+  } else if (HaveModules) {
+    // -fmodule-cache-path specifies where our implicitly-built module files
+    // should be written.
+    SmallString<128> Path;
+    if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
+      Path = A->getValue();
     if (C.isForDiagnostics()) {
       // When generating crash reports, we want to emit the modules along with
       // the reproduction sources, so we ignore any provided module path.
@@ -5056,6 +5040,20 @@ void Clang::ConstructJob(Compilation &C,
     CmdArgs.push_back(Args.MakeArgString(Path));
   }
 
+  // -fmodule-name specifies the module that is currently being built (or
+  // used for header checking by -fmodule-maps).
+  Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);
+
+  // -fmodule-map-file can be used to specify files containing module
+  // definitions.
+  Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file);
+
+  // -fmodule-file can be used to specify files containing precompiled modules.
+  if (HaveModules)
+    Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file);
+  else
+    Args.ClaimAllArgs(options::OPT_fmodule_file);
+
   // When building modules and generating crashdumps, we need to dump a module
   // dependency VFS alongside the output.
   if (HaveModules && C.isForDiagnostics()) {

Modified: cfe/trunk/test/Modules/no-implicit-builds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/no-implicit-builds.cpp?rev=263970&r1=263969&r2=263970&view=diff
==============================================================================
--- cfe/trunk/test/Modules/no-implicit-builds.cpp (original)
+++ cfe/trunk/test/Modules/no-implicit-builds.cpp Mon Mar 21 14:06:06 2016
@@ -1,5 +1,9 @@
 // RUN: rm -rf %t
 
+// RUN: %clang -x c++ -std=c++11 -fmodules -fno-implicit-modules /dev/null -### \
+// RUN:     2>&1 | FileCheck --check-prefix=CHECK-NO-MODULE-CACHE %s
+// CHECK-NO-MODULE-CACHE-NOT: -fmodules-cache-path
+
 // Produce an error if a module is needed, but not found.
 // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
 // RUN:     -fmodule-map-file=%S/Inputs/no-implicit-builds/b.modulemap \




More information about the cfe-commits mailing list