[PATCH] D39375: [clang] Add PPCallbacks list to preprocessor when building a preacompiled preamble.

William Enright via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 11 12:58:43 PST 2017


Nebiroth updated this revision to Diff 126430.
Nebiroth added a comment.

Removed unique_ptr parameter in PrecompiledPreamble::Build
Added method createPPCallbacks() in PreambleCallback to be overriden


Repository:
  rC Clang

https://reviews.llvm.org/D39375

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/PrecompiledPreamble.cpp


Index: lib/Frontend/PrecompiledPreamble.cpp
===================================================================
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -351,6 +351,8 @@
   if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
     return BuildPreambleError::BeginSourceFileFailed;
 
+  if (Callbacks.createPPCallbacks())
+    Clang->getPreprocessor().addPPCallbacks(std::move(Callbacks.createPPCallbacks()));
   Act->Execute();
 
   // Run the callbacks.
@@ -709,6 +711,7 @@
 void PreambleCallbacks::HandleTopLevelDecl(DeclGroupRef DG) {}
 void PreambleCallbacks::HandleMacroDefined(const Token &MacroNameTok,
                                            const MacroDirective *MD) {}
+std::unique_ptr<PPCallbacks> PreambleCallbacks::createPPCallbacks() {return nullptr;}
 
 std::error_code clang::make_error_code(BuildPreambleError Error) {
   return std::error_code(static_cast<int>(Error), BuildPreambleErrorCategory());
Index: include/clang/Frontend/PrecompiledPreamble.h
===================================================================
--- include/clang/Frontend/PrecompiledPreamble.h
+++ include/clang/Frontend/PrecompiledPreamble.h
@@ -260,6 +260,9 @@
   /// used instead, but having only this method allows a simpler API.
   virtual void HandleMacroDefined(const Token &MacroNameTok,
                                   const MacroDirective *MD);
+  /// Adds list of Preprocessor callbacks so we can also process information
+  /// about includes that are outside of a preamble i.e in the middle of a file
+  virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
 };
 
 enum class BuildPreambleError {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39375.126430.patch
Type: text/x-patch
Size: 1682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171211/66bc55d7/attachment.bin>


More information about the cfe-commits mailing list