preprocessor: new callbacks
authorNathan Sidwell <nathan@acm.org>
Tue, 17 Nov 2020 16:16:50 +0000 (08:16 -0800)
committerNathan Sidwell <nathan@acm.org>
Tue, 17 Nov 2020 16:22:02 +0000 (08:22 -0800)
These two callbacks are needed for C++ modules.  The first is for
handling macros from header-units.  These are resolved lazily.  The
second is for include-translation -- whether a #include gets turned
into a header-unit import.

libcpp/
* include/cpplib.h (struct cpp_callbacks): Add
user_deferred_macro & translate_include.

libcpp/include/cpplib.h

index ce00952bf0bb9ada7348c7dbaa7728bbb410dd50..d2324266d39188067e4ed46af5ce74462b556b54 100644 (file)
@@ -680,6 +680,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 +701,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