From eb8b3908325351011fe76b33f43fc42ded73b30b Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 9 Aug 2018 02:14:45 +0000 Subject: [PATCH] c-ppoutput.c (dump_macro): No need to check for assert here. gcc/c-family/ c-ppoutput.c (dump_macro): No need to check for assert here. libcpp/ * include/cpplib.h (cpp_user_macro_p): Check non-assertness here. (cpp_fun_like_macro_p): Make inline. * macro.c (enter_macro_context): Use it directly. (cpp_fun_like_macro_p): Remove definition here. * pch.c (save_macros): Not need to check assertness here. From-SVN: r263440 --- ChangeLog.name-lookup | 9 +++++++++ gcc/c-family/c-ppoutput.c | 4 ++-- libcpp/include/cpplib.h | 17 +++++++++++------ libcpp/macro.c | 13 ++----------- libcpp/pch.c | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ChangeLog.name-lookup b/ChangeLog.name-lookup index b642cfbd48f9..9ed2faf05958 100644 --- a/ChangeLog.name-lookup +++ b/ChangeLog.name-lookup @@ -1,5 +1,14 @@ 2018-08-08 Nathan Sidwell + gcc/c-family/ + c-ppoutput.c (dump_macro): No need to check for assert here. + libcpp/ + * include/cpplib.h (cpp_user_macro_p): Check non-assertness here. + (cpp_fun_like_macro_p): Make inline. + * macro.c (enter_macro_context): Use it directly. + (cpp_fun_like_macro_p): Remove definition here. + * pch.c (save_macros): Not need to check assertness here. + Merge trunk r263434. Fold cpp-id-data.h into cpplib.h diff --git a/gcc/c-family/c-ppoutput.c b/gcc/c-family/c-ppoutput.c index b849227df593..5b630b6e7ab4 100644 --- a/gcc/c-family/c-ppoutput.c +++ b/gcc/c-family/c-ppoutput.c @@ -20,7 +20,7 @@ #include "system.h" #include "coretypes.h" #include "c-common.h" /* For flags. */ -#include "../libcpp/internal.h" +#include "../libcpp/internal.h" /* EW! */ #include "c-pragma.h" /* For parse_in. */ #include "file-prefix-map.h" /* remap_macro_filename() */ @@ -690,7 +690,7 @@ static int dump_macro (cpp_reader *pfile, cpp_hashnode *node, void *v ATTRIBUTE_UNUSED) { /* asserts are distinguished by beginning with '#'. */ - if (cpp_user_macro_p (node) && NODE_NAME(node)[0] != '#') + if (cpp_user_macro_p (node)) { fputs ("#define ", print.outf); fputs ((const char *) cpp_macro_definition (pfile, node), diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 8fd2e4c1b692..8d224ad751e5 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -942,24 +942,29 @@ extern int cpp_avoid_paste (cpp_reader *, const cpp_token *, extern const cpp_token *cpp_get_token (cpp_reader *); extern const cpp_token *cpp_get_token_with_location (cpp_reader *, source_location *); -/* Although a macro may actually turn out to be an assert, they are - separated by namespace, in that the latter have special - '#'-starting names, that macros cannot have. We don't have to - check that. */ inline bool cpp_user_macro_p (const cpp_hashnode *node) { - return node->type == NT_USER_MACRO; + return node->type == NT_USER_MACRO && node->value.macro->kind != cmk_assert; } inline bool cpp_builtin_macro_p (const cpp_hashnode *node) { return node->type == NT_BUILTIN_MACRO; } +/* Although a macro may actually turn out to be an assert, they are + separated by namespace, in that the latter have special + '#'-starting names, that macros cannot have. We don't have to + check that here. */ inline bool cpp_macro_p (const cpp_hashnode *node) { return node->type & NT_USER_MACRO; } -extern bool cpp_fun_like_macro_p (cpp_hashnode *); +/* Returns true if NODE is a function-like user macro. */ +inline bool cpp_fun_like_macro_p (cpp_hashnode *node) +{ + return cpp_user_macro_p (node) && node->value.macro->fun_like; +} + extern const unsigned char *cpp_macro_definition (cpp_reader *, cpp_hashnode *); extern source_location cpp_macro_definition_location (cpp_hashnode *); diff --git a/libcpp/macro.c b/libcpp/macro.c index 2d830160308a..910b6dcabfd9 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -1400,10 +1400,8 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node, source_location expand_loc; if (/* The top-level macro invocation that triggered the expansion - we are looking at is with a standard macro ... */ - cpp_user_macro_p (pfile->top_most_macro_node) - /* ... and it's a function-like macro invocation, */ - && pfile->top_most_macro_node->value.macro->fun_like + we are looking at is with a function-like user macro ... */ + cpp_fun_like_macro_p (pfile->top_most_macro_node) /* ... and we are tracking the macro expansion. */ && CPP_OPTION (pfile, track_macro_expansion)) /* Then the location of the end of the macro invocation is the @@ -3639,13 +3637,6 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro, } } -/* Returns true if NODE is a function-like macro. */ -bool -cpp_fun_like_macro_p (cpp_hashnode *node) -{ - return cpp_user_macro_p (node) && node->value.macro->fun_like; -} - /* Returns the name, arguments and expansion of a macro, in a format suitable to be read back in again, and therefore also for DWARF 2 debugging info. e.g. "PASTE(X, Y) X ## Y", or "MACNAME EXPANSION". diff --git a/libcpp/pch.c b/libcpp/pch.c index de86dde1bfb7..04d7094b068f 100644 --- a/libcpp/pch.c +++ b/libcpp/pch.c @@ -755,7 +755,7 @@ save_macros (cpp_reader *r, cpp_hashnode *h, void *data_p) { struct save_macro_data *data = (struct save_macro_data *)data_p; - if (cpp_user_macro_p (h) && h->value.macro->kind != cmk_assert) + if (cpp_user_macro_p (h)) { if (data->count == data->array_size) { -- 2.47.2