[03/32] cpp-callbacks

Message ID f9dccc14-fa50-de68-8b5f-c47fb67f1543@acm.org
State New
Headers show
Series
  • C++ 20 Modules
Related show

Commit Message

Nathan Sidwell Nov. 3, 2020, 9:13 p.m.
Here are the callbacks in the preprocessor itself.

a) one to handle deferred macros

b) one to handle include translation.  For every '#include <header>', 
there is the possibility of replacing that with 'import <header>'.  This 
hook determines if that happens.


-- 
Nathan Sidwell

Comments

Alexandre Oliva via Gcc-patches Nov. 6, 2020, 8:10 p.m. | #1
On 11/3/20 2:13 PM, Nathan Sidwell wrote:
> Here are the callbacks in the preprocessor itself.

>

> a) one to handle deferred macros

>

> b) one to handle include translation.  For every '#include <header>',

> there is the possibility of replacing that with 'import <header>'. 

> This hook determines if that happens.


OK

jeff

Patch

diff --git c/libcpp/include/cpplib.h w/libcpp/include/cpplib.h
index 8e398863cf6..81be6457951 100644
--- c/libcpp/include/cpplib.h
+++ w/libcpp/include/cpplib.h
@@ -680,6 +695,9 @@  struct cpp_callbacks
   /* Callback that can change a user lazy into normal macro.  */
   void (*user_lazy_macro) (cpp_reader *, cpp_macro *, unsigned);
 
+  /* Callback to handle deferred cpp_macros.  */
+  cpp_macro *(*user_deferred_macro) (cpp_reader *, location_t, cpp_hashnode *);
+
   /* Callback to parse SOURCE_DATE_EPOCH from environment.  */
   time_t (*get_source_date_epoch) (cpp_reader *);
 
@@ -698,6 +716,11 @@  struct cpp_callbacks
   /* Callback for filename remapping in __FILE__ and __BASE_FILE__ macro
      expansions.  */
   const char *(*remap_filename) (const char*);
+
+  /* Maybe translate a #include into something else.  Return a
+     cpp_buffer containing the translation if translating.  */
+  char *(*translate_include) (cpp_reader *, line_maps *, location_t,
+			      const char *path);
 };
 
 #ifdef VMS