https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/158695
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. >From 827307ddefb5e25c41406e736574a230a396b9cc Mon Sep 17 00:00:00 2001 From: Jan Svoboda <jan_svob...@apple.com> Date: Mon, 15 Sep 2025 09:55:11 -0700 Subject: [PATCH] [clang] Don't fail `clang::ExecuteCompilerInvocation()` for unrelated errors --- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits