https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/158695
>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 1/2] [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)); >From 5200d1af7a3faec47e3012ba503383c0a037a932 Mon Sep 17 00:00:00 2001 From: Jan Svoboda <jan_svob...@apple.com> Date: Mon, 15 Sep 2025 14:07:50 -0700 Subject: [PATCH 2/2] Add comment --- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index f1965a4e27e07..8b0ab2eb37189 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -294,9 +294,12 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) { } #endif - // If there were errors in processing arguments, don't do anything else. + // If there were errors in the above, don't do anything else. + // This intentionally ignores errors emitted before this function to + // accommodate lenient callers that decided to make progress despite errors. if (Clang->getDiagnostics().getNumErrors() != NumErrorsBefore) return false; + // Create and execute the frontend action. std::unique_ptr<FrontendAction> Act(CreateFrontendAction(*Clang)); if (!Act) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits