summaryrefslogtreecommitdiffstats
path: root/clang/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
commit0248f57d59a493124b378604cb084fde7b67adc7 (patch)
treefb05a86c2d15215eac202f660505fec20656b26f /clang/lib/Frontend/FrontendAction.cpp
parent3d0b3a3a50141c90acbe4ff5bc28888d1fa394cd (diff)
downloadbcm5719-llvm-0248f57d59a493124b378604cb084fde7b67adc7.tar.gz
bcm5719-llvm-0248f57d59a493124b378604cb084fde7b67adc7.zip
Wire up -import-module to run ReadAST for each module loaded.
llvm-svn: 136987
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 89d95fc97d8..0753686a347 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud