aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-11 06:42:26 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-11 06:44:26 -0800
commit97b56dece74138398977ea53368a025ed231b35c (patch)
tree51154b245c698f740fec5c4306d30371af0c9210
parent37b242a3fbd29839ce352dfd8444c44989642a42 (diff)
downloadgcc-97b56dece74138398977ea53368a025ed231b35c.zip
gcc-97b56dece74138398977ea53368a025ed231b35c.tar.gz
gcc-97b56dece74138398977ea53368a025ed231b35c.tar.bz2
c++: Module lang hook overriding
This installs stub lang hooks for modules and creates the module dump file. gcc/cp/ * cp-lang.c (LANG_HOOKS_PREPROCESS_MAIN_FILE): Override. (LANG_HOOKS_PREPROCESS_OPTIONS): Override. (LANG_HOOKS_PREPROCESS_TOKEN): Override. * cp-objcp-common.c (cp_register_dumps): Add module dump. (cp_handle_option): New. * cp-objcp-common.h (cp_handle_option): Declare. (LANG_HOOKS_HANDLE_OPTION): Override. * cp-tree.h (module_dump_id): Declare. * module.cc (module_dump_id): Define. (module_begin_main_file, handle_module_option) (module_preproces_options): Stubs.
-rw-r--r--gcc/cp/cp-lang.c6
-rw-r--r--gcc/cp/cp-objcp-common.c15
-rw-r--r--gcc/cp/cp-objcp-common.h4
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/module.cc19
5 files changed, 44 insertions, 1 deletions
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index 9e980bc..5d2aef4 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -77,6 +77,12 @@ static tree cxx_enum_underlying_base_type (const_tree);
#define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type
#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type
+#undef LANG_HOOKS_PREPROCESS_MAIN_FILE
+#define LANG_HOOKS_PREPROCESS_MAIN_FILE module_begin_main_file
+#undef LANG_HOOKS_PREPROCESS_OPTIONS
+#define LANG_HOOKS_PREPROCESS_OPTIONS module_preprocess_options
+#undef LANG_HOOKS_PREPROCESS_TOKEN
+#define LANG_HOOKS_PREPROCESS_TOKEN module_token_pre
#if CHECKING_P
#undef LANG_HOOKS_RUN_LANG_SELFTESTS
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index 7ff4d39..84f0b59 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -438,6 +438,9 @@ cp_register_dumps (gcc::dump_manager *dumps)
class_dump_id = dumps->dump_register
(".class", "lang-class", "lang-class", DK_lang, OPTGROUP_NONE, false);
+ module_dump_id = dumps->dump_register
+ (".module", "lang-module", "lang-module", DK_lang, OPTGROUP_NONE, false);
+
raw_dump_id = dumps->dump_register
(".raw", "lang-raw", "lang-raw", DK_lang, OPTGROUP_NONE, false);
}
@@ -551,4 +554,16 @@ cp_common_init_ts (void)
c_common_init_ts ();
}
+/* Handle C++-specficic options here. Punt to c_common otherwise. */
+
+bool
+cp_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
+ int kind, location_t loc,
+ const struct cl_option_handlers *handlers)
+{
+ if (handle_module_option (unsigned (scode), arg, value))
+ return true;
+ return c_common_handle_option (scode, arg, value, kind, loc, handlers);
+}
+
#include "gt-cp-cp-objcp-common.h"
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 0936f16..4b5b96f 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -34,6 +34,8 @@ extern tree cp_unit_size_without_reusable_padding (tree);
extern tree cp_get_global_decls ();
extern tree cp_pushdecl (tree);
extern void cp_register_dumps (gcc::dump_manager *);
+extern bool cp_handle_option (size_t, const char *, HOST_WIDE_INT, int,
+ location_t, const struct cl_option_handlers *);
extern tree cxx_make_type_hook (tree_code);
extern tree cxx_simulate_enum_decl (location_t, const char *,
vec<string_int_pair>);
@@ -63,7 +65,7 @@ extern tree cxx_simulate_enum_decl (location_t, const char *,
#undef LANG_HOOKS_REGISTER_DUMPS
#define LANG_HOOKS_REGISTER_DUMPS cp_register_dumps
#undef LANG_HOOKS_HANDLE_OPTION
-#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
+#define LANG_HOOKS_HANDLE_OPTION cp_handle_option
#undef LANG_HOOKS_HANDLE_FILENAME
#define LANG_HOOKS_HANDLE_FILENAME c_common_handle_filename
#undef LANG_HOOKS_POST_OPTIONS
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5cd2999..63170fc 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6330,6 +6330,7 @@ extern cp_parameter_declarator *no_parameters;
/* Various dump ids. */
extern int class_dump_id;
+extern int module_dump_id;
extern int raw_dump_id;
/* in call.c */
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 11eb6da..02b5af8 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -65,6 +65,9 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "langhooks.h"
+/* Id for dumping module information. */
+int module_dump_id;
+
/* What the current TU is. */
unsigned module_kind;
@@ -190,6 +193,11 @@ preprocessed_module (cpp_reader *)
}
void
+module_begin_main_file (cpp_reader *, line_maps *, const line_map_ordinary *)
+{
+}
+
+void
init_modules (cpp_reader *)
{
/* Do not turn on yet. */
@@ -207,3 +215,14 @@ void
fini_modules ()
{
}
+
+bool
+handle_module_option (unsigned, const char *, int)
+{
+ return false;
+}
+
+void
+module_preprocess_options (cpp_reader *)
+{
+}