Attempt to fix null ASTContext in ASTUnit error path
We don't need the ASTContext for the diagnostics, only the language
options, which we can get from the compiler invocation. It worries me
how many categorically different states the ASTUnit class can be in
depending on how it is being constructed/used.
llvm-svn: 206909
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 240acc2..b35fcf19 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -1714,7 +1714,10 @@
}
void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) {
- // Steal the created target, context, and preprocessor.
+ // Steal the created target, context, and preprocessor if they have been
+ // created.
+ assert(CI.hasInvocation() && "missing invocation");
+ LangOpts = CI.getInvocation().getLangOpts();
TheSema.reset(CI.takeSema());
Consumer.reset(CI.takeASTConsumer());
if (CI.hasASTContext())