[PATCH] Flip the order the preprocessor and frontendaction are informed of the end of a file.

Benjamin Kramer benny.kra at gmail.com
Mon Aug 4 04:56:41 PDT 2014


Hi alexfh, klimek, djasper,

This allows using EndOfMainFile from a PPCallback to access data from the
action. The pattern of PPCallback referencing an action is common in clang-tidy.

http://reviews.llvm.org/D4773

Files:
  lib/Frontend/FrontendAction.cpp

Index: lib/Frontend/FrontendAction.cpp
===================================================================
--- lib/Frontend/FrontendAction.cpp
+++ lib/Frontend/FrontendAction.cpp
@@ -432,6 +432,10 @@
   // 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();
+
   // Finalize the action.
   EndSourceFileAction();
 
@@ -453,10 +457,6 @@
     CI.setASTConsumer(nullptr);
   }
 
-  // Inform the preprocessor we are done.
-  if (CI.hasPreprocessor())
-    CI.getPreprocessor().EndSourceFile();
-
   if (CI.getFrontendOpts().ShowStats) {
     llvm::errs() << "\nSTATISTICS FOR '" << getCurrentFile() << "':\n";
     CI.getPreprocessor().PrintStats();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4773.12153.patch
Type: text/x-patch
Size: 821 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140804/0c484efe/attachment.bin>


More information about the cfe-commits mailing list