[clang] [clang-tools-extra] [clang-tidy] EndSourceFile() for preprocessor before diagnostic client (PR #145784)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 3 00:33:38 PDT 2025


================
@@ -1243,13 +1243,15 @@ llvm::Error FrontendAction::Execute() {
 void FrontendAction::EndSourceFile() {
   CompilerInstance &CI = getCompilerInstance();
 
-  // Inform the diagnostic client we are done with this source file.
-  CI.getDiagnosticClient().EndSourceFile();
-
   // Inform the preprocessor we are done.
   if (CI.hasPreprocessor())
     CI.getPreprocessor().EndSourceFile();
 
+  // Inform the diagnostic client we are done with this source file.
+  // Do this after notifying the preprocessor, so that end-of-file preprocessor
+  // callbacks can report diagnostics.
+  CI.getDiagnosticClient().EndSourceFile();
----------------
yronglin wrote:

Could you add a unittest to check this change?

https://github.com/llvm/llvm-project/pull/145784


More information about the cfe-commits mailing list