r245136 - [modules] Stop dropping 'module.timestamp' files into the current directory
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 14 17:34:16 PDT 2015
Author: rsmith
Date: Fri Aug 14 19:34:15 2015
New Revision: 245136
URL: http://llvm.org/viewvc/llvm-project?rev=245136&view=rev
Log:
[modules] Stop dropping 'module.timestamp' files into the current directory
when building with implicit modules disabled.
Added:
cfe/trunk/test/Modules/explicit-build-extra-files.cpp
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=245136&r1=245135&r2=245136&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Aug 14 19:34:15 2015
@@ -331,7 +331,7 @@ void CompilerInstance::createPreprocesso
PP->setPreprocessedOutput(getPreprocessorOutputOpts().ShowCPP);
- if (PP->getLangOpts().Modules)
+ if (PP->getLangOpts().Modules && PP->getLangOpts().ImplicitModules)
PP->getHeaderSearchInfo().setModuleCachePath(getSpecificModuleCachePath());
// Handle generating dependencies, if requested.
@@ -1154,6 +1154,7 @@ static void pruneModuleCache(const Heade
struct stat StatBuf;
llvm::SmallString<128> TimestampFile;
TimestampFile = HSOpts.ModuleCachePath;
+ assert(!TimestampFile.empty());
llvm::sys::path::append(TimestampFile, "modules.timestamp");
// Try to stat() the timestamp file.
@@ -1232,8 +1233,8 @@ void CompilerInstance::createModuleManag
// If we're implicitly building modules but not currently recursively
// building a module, check whether we need to prune the module cache.
- if (getLangOpts().ImplicitModules &&
- getSourceManager().getModuleBuildStack().empty() &&
+ if (getSourceManager().getModuleBuildStack().empty() &&
+ !getPreprocessor().getHeaderSearchInfo().getModuleCachePath().empty() &&
getHeaderSearchOpts().ModuleCachePruneInterval > 0 &&
getHeaderSearchOpts().ModuleCachePruneAfter > 0) {
pruneModuleCache(getHeaderSearchOpts());
@@ -1600,6 +1601,8 @@ void CompilerInstance::makeModuleVisible
GlobalModuleIndex *CompilerInstance::loadGlobalModuleIndex(
SourceLocation TriggerLoc) {
+ if (getPreprocessor().getHeaderSearchInfo().getModuleCachePath().empty())
+ return nullptr;
if (!ModuleManager)
createModuleManager();
// Can't do anything if we don't have the module manager.
Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=245136&r1=245135&r2=245136&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Fri Aug 14 19:34:15 2015
@@ -442,9 +442,11 @@ bool FrontendAction::Execute() {
// there were any module-build failures.
if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() &&
CI.hasPreprocessor()) {
- GlobalModuleIndex::writeIndex(
- CI.getFileManager(), CI.getPCHContainerReader(),
- CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath());
+ StringRef Cache =
+ CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
+ if (!Cache.empty())
+ GlobalModuleIndex::writeIndex(CI.getFileManager(),
+ CI.getPCHContainerReader(), Cache);
}
return true;
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=245136&r1=245135&r2=245136&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Aug 14 19:34:15 2015
@@ -129,10 +129,10 @@ std::string HeaderSearch::getModuleFileN
StringRef ModuleMapPath) {
// If we don't have a module cache path or aren't supposed to use one, we
// can't do anything.
- if (ModuleCachePath.empty() || !LangOpts.ImplicitModules)
+ if (getModuleCachePath().empty())
return std::string();
- SmallString<256> Result(ModuleCachePath);
+ SmallString<256> Result(getModuleCachePath());
llvm::sys::fs::make_absolute(Result);
if (HSOpts->DisableModuleHash) {
Added: cfe/trunk/test/Modules/explicit-build-extra-files.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build-extra-files.cpp?rev=245136&view=auto
==============================================================================
--- cfe/trunk/test/Modules/explicit-build-extra-files.cpp (added)
+++ cfe/trunk/test/Modules/explicit-build-extra-files.cpp Fri Aug 14 19:34:15 2015
@@ -0,0 +1,14 @@
+// REQUIRES: shell
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+// RUN: echo 'module X {}' > %t/x
+// RUN: echo 'module Y {}' > %t/y
+//
+// RUN: %clang_cc1 -emit-module -fmodules -fmodule-name=X %t/x -x c++ -o %t/x.pcm
+// RUN: %clang_cc1 -emit-module -fmodules -fmodule-name=Y %t/y -x c++ -o %t/y.pcm
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/x.pcm -fmodule-file=%t/y.pcm -x c++ /dev/null -fsyntax-only
+//
+// RUN: not test -f %t/modules.timestamp
+// RUN: not test -f %t/modules.idx
More information about the cfe-commits
mailing list