summaryrefslogtreecommitdiff
path: root/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
-rw-r--r--lib/Frontend/FrontendAction.cpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 2e9a791c3039..6031ad2b361b 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/lib/Frontend/FrontendAction.cpp
@@ -11,8 +11,6 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclGroup.h"
-#include "clang/Lex/HeaderSearch.h"
-#include "clang/Lex/Preprocessor.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/ChainedIncludesSource.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -20,15 +18,18 @@
#include "clang/Frontend/FrontendPluginRegistry.h"
#include "clang/Frontend/LayoutOverrideSource.h"
#include "clang/Frontend/MultiplexConsumer.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/Preprocessor.h"
#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"
+#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
-#include "llvm/Support/Timer.h"
using namespace clang;
namespace {
@@ -187,6 +188,10 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
setCurrentInput(Input, AST);
+ // Inform the diagnostic client we are processing a source file.
+ CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
+ HasBegunSourceFile = true;
+
// Set the shared objects, these are reset when we finish processing the
// file, otherwise the CompilerInstance will happily destroy them.
CI.setFileManager(&AST->getFileManager());
@@ -198,7 +203,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
if (!BeginSourceFileAction(CI, InputFile))
goto failure;
- /// Create the AST consumer.
+ // Create the AST consumer.
CI.setASTConsumer(CreateWrappedASTConsumer(CI, InputFile));
if (!CI.hasASTConsumer())
goto failure;
@@ -246,16 +251,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
CI.getLangOpts(),
CI.getTargetOpts(),
CI.getPreprocessorOpts())) {
- for (unsigned I = 0, N = PPOpts.Includes.size(); I != N; ++I) {
- if (PPOpts.Includes[I] == PPOpts.ImplicitPCHInclude) {
- PPOpts.Includes[I] = Dir->path();
- PPOpts.ImplicitPCHInclude = Dir->path();
- Found = true;
- break;
- }
- }
-
- assert(Found && "Implicit PCH include not in includes list?");
+ PPOpts.ImplicitPCHInclude = Dir->path();
+ Found = true;
break;
}
}
@@ -279,8 +276,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
if (!BeginSourceFileAction(CI, InputFile))
goto failure;
- /// Create the AST context and consumer unless this is a preprocessor only
- /// action.
+ // Create the AST context and consumer unless this is a preprocessor only
+ // action.
if (!usesPreprocessorOnly()) {
CI.createASTContext();
@@ -290,8 +287,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
goto failure;
CI.getASTContext().setASTMutationListener(Consumer->GetASTMutationListener());
- CI.getPreprocessor().setPPMutationListener(
- Consumer->GetPPMutationListener());
if (!CI.getPreprocessorOpts().ChainedIncludes.empty()) {
// Convert headers to PCH and chain them.
@@ -380,6 +375,15 @@ bool FrontendAction::Execute() {
}
else ExecuteAction();
+ // If we are supposed to rebuild the global module index, do so now unless
+ // there were any module-build failures.
+ if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() &&
+ CI.hasPreprocessor()) {
+ GlobalModuleIndex::writeIndex(
+ CI.getFileManager(),
+ CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath());
+ }
+
return true;
}