langhooks: preprocessor hooks for c++ modules
authorNathan Sidwell <nathan@acm.org>
Tue, 17 Nov 2020 14:07:30 +0000 (06:07 -0800)
committerNathan Sidwell <nathan@acm.org>
Tue, 17 Nov 2020 14:12:01 +0000 (06:12 -0800)
commit8a97aed0d290bc12b91091703444546d9b3edba7
treeeaa8646dd871f738feb30a5df76996329da161a6
parente3b55ce50ec294f30106947bd819f12a98069c57
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.
gcc/c-family/c-lex.c
gcc/c-family/c-opts.c
gcc/c-family/c-ppoutput.c
gcc/langhooks-def.h
gcc/langhooks.h