diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-14 23:13:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-14 23:13:09 +0000 |
commit | de8a9050d79d66325a18168a0994fed125a7790d (patch) | |
tree | fa30a08dc4b158d19ea488e65db8534edeec2089 /lib/Frontend/CompilerInstance.cpp | |
parent | ce835df9301d5bee7fc2c70344e05541f21a5dda (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.cpp | 16 |
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. |