aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-14 23:13:09 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-14 23:13:09 +0000
commitde8a9050d79d66325a18168a0994fed125a7790d (patch)
treefa30a08dc4b158d19ea488e65db8534edeec2089 /lib/Frontend/CompilerInstance.cpp
parentce835df9301d5bee7fc2c70344e05541f21a5dda (diff)
Make -E work with module imports
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139750 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
-rw-r--r--lib/Frontend/CompilerInstance.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 9a679eed24..9087ab58d6 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -736,20 +736,26 @@ ModuleKey CompilerInstance::loadModule(SourceLocation ImportLoc,
// If we don't already have an ASTReader, create one now.
if (!ModuleManager) {
+ if (!hasASTContext())
+ createASTContext();
+
std::string Sysroot = getHeaderSearchOpts().Sysroot;
const PreprocessorOptions &PPOpts = getPreprocessorOpts();
ModuleManager = new ASTReader(getPreprocessor(), *Context,
Sysroot.empty() ? "" : Sysroot.c_str(),
PPOpts.DisablePCHValidation,
PPOpts.DisableStatCache);
- ModuleManager->setDeserializationListener(
- getASTConsumer().GetASTDeserializationListener());
- getASTContext().setASTMutationListener(
- getASTConsumer().GetASTMutationListener());
+ if (hasASTConsumer()) {
+ ModuleManager->setDeserializationListener(
+ getASTConsumer().GetASTDeserializationListener());
+ getASTContext().setASTMutationListener(
+ getASTConsumer().GetASTMutationListener());
+ }
llvm::OwningPtr<ExternalASTSource> Source;
Source.reset(ModuleManager);
getASTContext().setExternalSource(Source);
- ModuleManager->InitializeSema(getSema());
+ if (hasSema())
+ ModuleManager->InitializeSema(getSema());
}
// Try to load the module we found.