r186870 - Make modules depend on the compiler's own module.map, as a proxy for the compiler itself.
Douglas Gregor
dgregor at apple.com
Mon Jul 22 13:48:33 PDT 2013
Author: dgregor
Date: Mon Jul 22 15:48:33 2013
New Revision: 186870
URL: http://llvm.org/viewvc/llvm-project?rev=186870&view=rev
Log:
Make modules depend on the compiler's own module.map, as a proxy for the compiler itself.
The headers in the compiler's own resource include directory are
system headers, which means we don't stat() them eagerly when loading
a module. Use module.map as a proxy for these headers and the compiler
itself. Fixes <rdar://problem/13856838>.
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=186870&r1=186869&r2=186870&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Jul 22 15:48:33 2013
@@ -424,7 +424,8 @@ private:
StringRef isysroot, const std::string &OutputFile);
void WriteInputFiles(SourceManager &SourceMgr,
HeaderSearchOptions &HSOpts,
- StringRef isysroot);
+ StringRef isysroot,
+ bool Modules);
void WriteSourceManagerBlock(SourceManager &SourceMgr,
const Preprocessor &PP,
StringRef isysroot);
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=186870&r1=186869&r2=186870&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Jul 22 15:48:33 2013
@@ -1233,7 +1233,8 @@ void ASTWriter::WriteControlBlock(Prepro
WriteInputFiles(Context.SourceMgr,
PP.getHeaderSearchInfo().getHeaderSearchOpts(),
- isysroot);
+ isysroot,
+ PP.getLangOpts().Modules);
Stream.ExitBlock();
}
@@ -1248,7 +1249,8 @@ namespace {
void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
HeaderSearchOptions &HSOpts,
- StringRef isysroot) {
+ StringRef isysroot,
+ bool Modules) {
using namespace llvm;
Stream.EnterSubblock(INPUT_FILES_BLOCK_ID, 4);
RecordData Record;
@@ -1301,6 +1303,19 @@ void ASTWriter::WriteInputFiles(SourceMa
SortedFiles.push_front(Entry);
}
}
+
+ // Add the compiler's own module.map in the set of (non-system) input files.
+ // This is a simple heuristic for detecting whether the compiler's headers
+ // have changed, because we don't want to stat() all of them.
+ if (Modules && !Chain) {
+ SmallString<128> P = StringRef(HSOpts.ResourceDir);
+ llvm::sys::path::append(P, "include");
+ llvm::sys::path::append(P, "module.map");
+ if (const FileEntry *ModuleMapFile = FileMgr.getFile(P)) {
+ InputFileEntry Entry = { ModuleMapFile, false, false };
+ SortedFiles.push_front(Entry);
+ }
+ }
unsigned UserFilesNum = 0;
// Write out all of the input files.
More information about the cfe-commits
mailing list