Browse Source

Make sure to call EndSourceFile even if we can't continue compiling.

Patch by Andy Gibbs!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161649 91177308-0d34-0410-b5e6-96231b3b80d8
Jordan Rose 13 years ago
parent
commit
af6cf431ea
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lib/Frontend/FrontendAction.cpp

+ 5 - 1
lib/Frontend/FrontendAction.cpp

@@ -162,6 +162,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
   setCurrentInput(Input);
   setCurrentInput(Input);
   setCompilerInstance(&CI);
   setCompilerInstance(&CI);
 
 
+  bool HasBegunSourceFile = false;
   if (!BeginInvocation(CI))
   if (!BeginInvocation(CI))
     goto failure;
     goto failure;
 
 
@@ -214,6 +215,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
 
 
     // Inform the diagnostic client we are processing a source file.
     // Inform the diagnostic client we are processing a source file.
     CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
     CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), 0);
+    HasBegunSourceFile = true;
 
 
     // Initialize the action.
     // Initialize the action.
     if (!BeginSourceFileAction(CI, Input.File))
     if (!BeginSourceFileAction(CI, Input.File))
@@ -228,6 +230,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
   // Inform the diagnostic client we are processing a source file.
   // Inform the diagnostic client we are processing a source file.
   CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
   CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
                                            &CI.getPreprocessor());
                                            &CI.getPreprocessor());
+  HasBegunSourceFile = true;
 
 
   // Initialize the action.
   // Initialize the action.
   if (!BeginSourceFileAction(CI, Input.File))
   if (!BeginSourceFileAction(CI, Input.File))
@@ -309,7 +312,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
     CI.setFileManager(0);
     CI.setFileManager(0);
   }
   }
 
 
-  CI.getDiagnosticClient().EndSourceFile();
+  if (HasBegunSourceFile)
+    CI.getDiagnosticClient().EndSourceFile();
   setCurrentInput(FrontendInputFile());
   setCurrentInput(FrontendInputFile());
   setCompilerInstance(0);
   setCompilerInstance(0);
   return false;
   return false;