llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

<details>
<summary>Changes</summary>

This PR changes the behavior of `clang::ExecuteCompilerInvocation()` so that it 
doesn't return early whenever the `DiagnosticsEngine` emitted errors **before** 
the function got called. Handling that situation is the responsibility of the 
caller. Necessary for #<!-- -->158381.

---
Full diff: https://github.com/llvm/llvm-project/pull/158695.diff


1 Files Affected:

- (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+3-1) 


``````````diff
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp 
b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 9a6844d5f7d40..f1965a4e27e07 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -210,6 +210,8 @@ CreateFrontendAction(CompilerInstance &CI) {
 }
 
 bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
+  unsigned NumErrorsBefore = Clang->getDiagnostics().getNumErrors();
+
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
     driver::getDriverOptTable().printHelp(
@@ -293,7 +295,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
 #endif
 
   // If there were errors in processing arguments, don't do anything else.
-  if (Clang->getDiagnostics().hasErrorOccurred())
+  if (Clang->getDiagnostics().getNumErrors() != NumErrorsBefore)
     return false;
   // Create and execute the frontend action.
   std::unique_ptr<FrontendAction> Act(CreateFrontendAction(*Clang));

``````````

</details>


https://github.com/llvm/llvm-project/pull/158695
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to