Make sure to call EndSourceFile even if we can't continue compiling.
Patch by Andy Gibbs!
llvm-svn: 161649
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index fb53c71..a4321e7 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -162,6 +162,7 @@
setCurrentInput(Input);
setCompilerInstance(&CI);
+ bool HasBegunSourceFile = false;
if (!BeginInvocation(CI))
goto failure;
@@ -214,6 +215,7 @@
// Inform the diagnostic client we are processing a source file.
CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
+ HasBegunSourceFile = true;
// Initialize the action.
if (!BeginSourceFileAction(CI, Input.File))
@@ -228,6 +230,7 @@
// Inform the diagnostic client we are processing a source file.
CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
&CI.getPreprocessor());
+ HasBegunSourceFile = true;
// Initialize the action.
if (!BeginSourceFileAction(CI, Input.File))
@@ -309,7 +312,8 @@
CI.setFileManager(0);
}
- CI.getDiagnosticClient().EndSourceFile();
+ if (HasBegunSourceFile)
+ CI.getDiagnosticClient().EndSourceFile();
setCurrentInput(FrontendInputFile());
setCompilerInstance(0);
return false;