aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/FrontendAction.cpp
diff options
context:
space:
mode:
authorJonathan D. Turner <jonathan.d.turner@gmail.com>2011-08-05 22:17:03 +0000
committerJonathan D. Turner <jonathan.d.turner@gmail.com>2011-08-05 22:17:03 +0000
commite735e2deb9e57d9b62c1258ee236ccfeba8e84b2 (patch)
treef26b2f682bdf2d4c7d5dea638986937a7abcf6f4 /lib/Frontend/FrontendAction.cpp
parentc25175cb1ac819fd73b33bceb43c84ca17715763 (diff)
Wire up -import-module to run ReadAST for each module loaded.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136987 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/FrontendAction.cpp')
-rw-r--r--lib/Frontend/FrontendAction.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp
index 89d95fc97d..0753686a34 100644
--- a/lib/Frontend/FrontendAction.cpp
+++ b/lib/Frontend/FrontendAction.cpp
@@ -20,6 +20,7 @@
#include "clang/Frontend/MultiplexConsumer.h"
#include "clang/Parse/ParseAST.h"
#include "clang/Serialization/ASTDeserializationListener.h"
+#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/ChainedIncludesSource.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Timer.h"
@@ -239,6 +240,30 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
DeserialListener);
if (!CI.getASTContext().getExternalSource())
goto failure;
+ } else if (!CI.getPreprocessorOpts().Modules.empty()) {
+ // Use PCH.
+ assert(hasPCHSupport() && "This action does not have PCH support!");
+ ASTDeserializationListener *DeserialListener =
+ Consumer->GetASTDeserializationListener();
+ if (CI.getPreprocessorOpts().DumpDeserializedPCHDecls)
+ DeserialListener = new DeserializedDeclsDumper(DeserialListener);
+ if (!CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn.empty())
+ DeserialListener = new DeserializedDeclsChecker(CI.getASTContext(),
+ CI.getPreprocessorOpts().DeserializedPCHDeclsToErrorOn,
+ DeserialListener);
+
+ CI.createPCHExternalASTSource(CI.getPreprocessorOpts().Modules[0],
+ true, true, DeserialListener);
+
+ for (unsigned I = 1, E = CI.getPreprocessorOpts().Modules.size(); I != E;
+ ++I) {
+
+ ASTReader *ModMgr = CI.getModuleManager();
+ ModMgr->ReadAST(CI.getPreprocessorOpts().Modules[I],
+ serialization::MK_Module);
+ }
+ if (!CI.getASTContext().getExternalSource())
+ goto failure;
}
CI.setASTConsumer(Consumer.take());
@@ -246,7 +271,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
goto failure;
}
- // Initialize builtin info as long as we aren't using an external AST
+ // Initialize built-in info as long as we aren't using an external AST
// source.
if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource()) {
Preprocessor &PP = CI.getPreprocessor();