On Wed, 2020-03-04 at 16:54 +0100, Bernhard Reutner-Fischer wrote: > On Mon, 2 Mar 2020 16:48:26 -0500 > David Malcolm <dmalc...@redhat.com> wrote: > > > +static inline bool > > +is_std_function_p (const_tree fndecl) > > +{ > > + tree name_decl = DECL_NAME (fndecl); > > + if (!name_decl) > > + return false; > > + if (!DECL_CONTEXT (fndecl)) > > + return false; > > + if (TREE_CODE (DECL_CONTEXT (fndecl)) != NAMESPACE_DECL) > > + return false; > > + tree ns = DECL_CONTEXT (fndecl); > > + if (!(DECL_CONTEXT (ns) == NULL_TREE > > + || TREE_CODE (DECL_CONTEXT (ns)) == TRANSLATION_UNIT_DECL)) > > + return false; > > + if (!DECL_NAME (ns)) > > + return false; > > + return id_equal ("std", DECL_NAME (ns)); > > +} > > Sounds a bit elaborate, doesn't? > I hope this is optimized to > > static inline bool > is_std_function_p (const_tree fndecl) > { > tree name_decl = DECL_NAME (fndecl); > if (!name_decl) > return false; > tree ns = DECL_CONTEXT (fndecl); > if (!ns) > return false; > if (TREE_CODE (ns) != NAMESPACE_DECL) > return false; > if (!(DECL_CONTEXT (ns) == NULL_TREE > || TREE_CODE (DECL_CONTEXT (ns)) == TRANSLATION_UNIT_DECL)) > return false; > if (!DECL_NAME (ns)) > return false; > return id_equal ("std", DECL_NAME (ns)); > } > > isn't "std" spelled out std_identifier() and is an identifier, i.e. > return DECL_NAME (ns) == std_identifier; ?
gcc/cp/ChangeLog-2019 has: 2019-10-23 Nathan Sidwell <nat...@acm.org> * cp-tree.c (CPTI_STD_IDENTIFIER): Delete. (std_identifier): Delete. (DECL_NAME_SPACE_STD_P): Compare against std_node. [...snippped...] The current ideal way to do it in gcc/cp/cp-tree.h seems to be: /* Nonzero if NODE is the std namespace. */ #define DECL_NAMESPACE_STD_P(NODE) \ ((NODE) == std_node) where: #define std_node cp_global_trees[CPTI_STD] and: extern GTY(()) tree cp_global_trees[CPTI_MAX]; However all of the above is specific to the C++ frontend, whereas the analyzer is part of the middle-end (and can be run from within lto1, where any concept of "the frontend" becomes rather abstract). I don't like the above analyzer code, but I don't see a better way to do it. Dave