[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
Thu Dec 14 09:43:26 PST 2017


Nebiroth updated this revision to Diff 126984.
Nebiroth marked an inline comment as done.
Nebiroth added a comment.

Minor code cleanup


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,10 @@
   if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
     return BuildPreambleError::BeginSourceFileFailed;
 
+  std::unique_ptr<PPCallbacks> DelegatedPPCallbacks = Callbacks.createPPCallbacks();
+
+  if (DelegatedPPCallbacks)
+    Clang->getPreprocessor().addPPCallbacks(std::move(DelegatedPPCallbacks));
   Act->Execute();
 
   // Run the callbacks.
@@ -709,6 +713,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);
+  /// Creates wrapper class for PPCallbacks so we can also process information
+  /// about includes that are inside of a preamble
+  virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
 };
 
 enum class BuildPreambleError {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39375.126984.patch
Type: text/x-patch
Size: 1726 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171214/4cd3f92e/attachment.bin>


More information about the cfe-commits mailing list