summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-01-23 22:38:11 +0000
committerDouglas Gregor <dgregor@apple.com>2013-01-23 22:38:11 +0000
commit5e306b1233ac2281afa353c37797fd258abcd13a (patch)
tree422e1302fdf515013073aafc8ee576d01cbe352a /clang/lib/Frontend/FrontendAction.cpp
parent36293f6512a25fe312e8e54e70e64928f3771c84 (diff)
downloadbcm5719-llvm-5e306b1233ac2281afa353c37797fd258abcd13a.tar.gz
bcm5719-llvm-5e306b1233ac2281afa353c37797fd258abcd13a.zip
Implement the writer side of the global module index.
The global module index is a "global" index for all of the module files within a particular subdirectory in the module cache, which keeps track of all of the "interesting" identifiers and selectors known in each of the module files. One can perform a fast lookup in the index to determine which module files will have more information about entities with a particular name/selector. This information can help eliminate redundant lookups into module files (a serious performance problem) and help with creating auto-import/auto-include Fix-Its. The global module index is created or updated at the end of a translation unit that has triggered a (re)build of a module by scraping all of the .pcm files out of the module cache subdirectory, so it catches everything. As with module rebuilds, we use the file system's atomicity to synchronize. llvm-svn: 173301
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 742caf158ba..4b642b395cb 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -23,6 +23,7 @@
#include "clang/Parse/ParseAST.h"
#include "clang/Serialization/ASTDeserializationListener.h"
#include "clang/Serialization/ASTReader.h"
+#include "clang/Serialization/GlobalModuleIndex.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -380,6 +381,16 @@ bool FrontendAction::Execute() {
}
else ExecuteAction();
+ // If we are supposed to rebuild the global module index, do so now unless
+ // an error occurred.
+ if (CI.getBuildGlobalModuleIndex() && CI.hasFileManager() &&
+ CI.hasPreprocessor() &&
+ (!CI.hasDiagnostics() || !CI.getDiagnostics().hasErrorOccurred())) {
+ GlobalModuleIndex::writeIndex(
+ CI.getFileManager(),
+ CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath());
+ }
+
return true;
}
OpenPOWER on IntegriCloud