From 87bca1152919fbf750dc942e18ed4afaecf6b73e Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 21 Mar 2016 19:06:06 +0000 Subject: [PATCH] [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 --- lib/Driver/Tools.cpp | 42 ++++++++++++++--------------- test/Modules/no-implicit-builds.cpp | 4 +++ 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index ae876a6e09..7e633bb04e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -5016,28 +5016,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 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, const JobAction &JA, 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()) { diff --git a/test/Modules/no-implicit-builds.cpp b/test/Modules/no-implicit-builds.cpp index 374ed5e418..fa4d5cb3c5 100644 --- a/test/Modules/no-implicit-builds.cpp +++ b/test/Modules/no-implicit-builds.cpp @@ -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 \ -- 2.40.0