diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-11-17 06:07:30 -0800 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-11-17 06:12:01 -0800 |
commit | 8a97aed0d290bc12b91091703444546d9b3edba7 (patch) | |
tree | eaa8646dd871f738feb30a5df76996329da161a6 /gcc/langhooks.h | |
parent | e3b55ce50ec294f30106947bd819f12a98069c57 (diff) | |
download | gcc-8a97aed0d290bc12b91091703444546d9b3edba7.zip gcc-8a97aed0d290bc12b91091703444546d9b3edba7.tar.gz gcc-8a97aed0d290bc12b91091703444546d9b3edba7.tar.bz2 |
langhooks: preprocessor hooks for c++ modules
This is a slightly modified version of 01-langhooks.def. I realized I
didn't need the deferred macro langhook -- that can be directly
installed into the preprocessor callbacks via preprocess_options lang
hook.
gcc/
* langhooks-def.h (LANG_HOOKS_PREPROCESS_MAIN_FILE)
(LANG_HOOKS_PREPROCESS_OPTIONS, LANG_HOOKS_PREPROCESS_UNDEF)
(LANG_HOOKS_PREPROCESS_TOKEN): New.
(LANG_HOOKS_INITIALIZER): Add them.
* langhooks.h (struct lang_hooks): Add preprocess_main_file,
preprocess_options, preprocess_undef, preprocess_token hooks. Add
enum PT_flags.
gcc/c-family/
* c-lex.c: #include "langhooks.h".
(cb_undef): Maybe call preprocess_undef lang hook.
* c-opts.c (c_common_post_options): Maybe call preprocess_options
lang hook.
(push_command_line_include): Maybe call preprocess_main_file lang
hook.
(cb_file_change): Likewise.
* c-ppoutput.c: #include "langhooks.h.
(scan_translation_unit): Maybe call preprocess_token lang hook.
(class do_streamer): New, derive from token_streamer.
(directives_only_cb): Data pointer is do_streamer, call
preprocess_token lang hook.
(scan_translation_unit_directives_only): Use do_streamer.
(print_line_1): Move src_line recording to after string output.
(cb_undef): Maybe call preprocess_undef lang hook.
Diffstat (limited to 'gcc/langhooks.h')
-rw-r--r-- | gcc/langhooks.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/langhooks.h b/gcc/langhooks.h index a35cf21..f12589e 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -356,6 +356,24 @@ struct lang_hooks global diagnostic context structure. */ void (*initialize_diagnostics) (diagnostic_context *); + /* Beginning the main source file. */ + void (*preprocess_main_file) (cpp_reader *, line_maps *, + const line_map_ordinary *); + + /* Adjust libcpp options and callbacks. */ + void (*preprocess_options) (cpp_reader *); + + /* Undefining a macro. */ + void (*preprocess_undef) (cpp_reader *, location_t, cpp_hashnode *); + + /* Observer for preprocessing stream. */ + uintptr_t (*preprocess_token) (cpp_reader *, const cpp_token *, uintptr_t); + /* Various flags it can return about the token. */ + enum PT_flags + { + PT_begin_pragma = 1 << 0 + }; + /* Register language-specific dumps. */ void (*register_dumps) (gcc::dump_manager *); |