]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
config-lang.in (gtfiles): Add cp/lex.c.
authorNathan Sidwell <nathan@acm.org>
Fri, 30 Jun 2017 18:46:01 +0000 (18:46 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Fri, 30 Jun 2017 18:46:01 +0000 (18:46 +0000)
* config-lang.in (gtfiles): Add cp/lex.c.
* cp-tree.h (mangle_convop_name_for_type): Rename ...
(make_conv_op_name): ... here.  Move to lex.
* lambda.c (maybe_add_lambda_conv_op): Update.
* parser.c (cp_parser_conversion_function_id): Update.
* pt.c (tsubst_decl, tsubst_baselink, tsubst_copy,
tsubst_copy_and_build): Update.
* semantics.c (apply_deduced_return_type): Update.
* mangle.c (conv_type_hasher, conv_type_names,
mangle_conv_op_name_for_type): Move to ...
* lex.c (conv_type_hasher, conv_type_names, make_convop_name):
... here.  Rename.

* libcp1plugin.cc (plugin_build_decl): Use make_conv_op_name.
(plugin_build_dependent_expr): Likewise.

From-SVN: r249852

gcc/cp/ChangeLog
gcc/cp/config-lang.in
gcc/cp/cp-tree.h
gcc/cp/lambda.c
gcc/cp/lex.c
gcc/cp/mangle.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/semantics.c
libcc1/ChangeLog
libcc1/libcp1plugin.cc

index 6c230a9c4c5f7739c76514e7aff3af34e9f9c7bd..ff57214535f00f6730b6d80dde9d997a6601b657 100644 (file)
@@ -1,3 +1,18 @@
+2017-06-30  Nathan Sidwell  <nathan@acm.org>
+
+       * config-lang.in (gtfiles): Add cp/lex.c.
+       * cp-tree.h (mangle_convop_name_for_type): Rename ...
+       (make_conv_op_name): ... here.  Move to lex.
+       * lambda.c (maybe_add_lambda_conv_op): Update.
+       * parser.c (cp_parser_conversion_function_id): Update.
+       * pt.c (tsubst_decl, tsubst_baselink, tsubst_copy,
+       tsubst_copy_and_build): Update.
+       * semantics.c (apply_deduced_return_type): Update.
+       * mangle.c (conv_type_hasher, conv_type_names,
+       mangle_conv_op_name_for_type): Move to ...
+       * lex.c (conv_type_hasher, conv_type_names, make_convop_name):
+       ... here.  Rename.
+
 2017-06-30  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/80014
index d0a96a07b5ab60ad1e55d0f87f812fa8fe184d6e..c009570b63dccbc5a290ca614d9c8c4f4eab27d8 100644 (file)
@@ -45,7 +45,7 @@ gtfiles="\
 \$(srcdir)/cp/except.c \
 \$(srcdir)/cp/friend.c \
 \$(srcdir)/cp/init.c \
-\$(srcdir)/cp/lambda.c \
+\$(srcdir)/cp/lambda.c \$(srcdir)/cp/lex.c \
 \$(srcdir)/cp/mangle.c \$(srcdir)/cp/method.c \
 \$(srcdir)/cp/name-lookup.c \
 \$(srcdir)/cp/parser.c \$(srcdir)/cp/pt.c \
index 4b5ff69a1a82af93fc09f428f22d6ea895a1405a..abaef68fda967fd1dc618e3036f2f435ac60be74 100644 (file)
@@ -6326,6 +6326,7 @@ extern void yyungetc                              (int, int);
 extern tree unqualified_name_lookup_error      (tree,
                                                 location_t = UNKNOWN_LOCATION);
 extern tree unqualified_fn_lookup_error                (cp_expr);
+extern tree make_conv_op_name                  (tree);
 extern tree build_lang_decl                    (enum tree_code, tree, tree);
 extern tree build_lang_decl_loc                        (location_t, enum tree_code, tree, tree);
 extern void retrofit_lang_decl                 (tree);
@@ -7180,7 +7181,6 @@ extern tree mangle_vtbl_for_type          (tree);
 extern tree mangle_vtt_for_type                        (tree);
 extern tree mangle_ctor_vtbl_for_type          (tree, tree);
 extern tree mangle_thunk                       (tree, int, tree, tree, tree);
-extern tree mangle_conv_op_name_for_type       (tree);
 extern tree mangle_guard_variable              (tree);
 extern tree mangle_tls_init_fn                 (tree);
 extern tree mangle_tls_wrapper_fn              (tree);
index 41d4921c1db49fd7a05b3135a074b2ccf30b0757..0e02375fa1b3f8382450534425965d685582ce3b 100644 (file)
@@ -1088,7 +1088,7 @@ maybe_add_lambda_conv_op (tree type)
   /* First build up the conversion op.  */
 
   tree rettype = build_pointer_type (stattype);
-  tree name = mangle_conv_op_name_for_type (rettype);
+  tree name = make_conv_op_name (rettype);
   tree thistype = cp_build_qualified_type (type, TYPE_QUAL_CONST);
   tree fntype = build_method_type_directly (thistype, rettype, void_list_node);
   tree convfn = build_lang_decl (FUNCTION_DECL, name, fntype);
index d763716bfa3067ff26aa00b99501f44e42508955..961b705a54682f4536a333fc7e6b79757cc7dba6 100644 (file)
@@ -531,6 +531,74 @@ unqualified_fn_lookup_error (cp_expr name_expr)
   return unqualified_name_lookup_error (name, loc);
 }
 
+struct conv_type_hasher : ggc_ptr_hash<tree_node>
+{
+  static hashval_t hash (tree);
+  static bool equal (tree, tree);
+};
+
+/* This hash table maps TYPEs to the IDENTIFIER for a conversion
+   operator to TYPE.  The nodes are IDENTIFIERs whose TREE_TYPE is the
+   TYPE.  */
+
+static GTY (()) hash_table<conv_type_hasher> *conv_type_names;
+
+/* Hash a node (VAL1) in the table.  */
+
+hashval_t
+conv_type_hasher::hash (tree val)
+{
+  return (hashval_t) TYPE_UID (TREE_TYPE (val));
+}
+
+/* Compare VAL1 (a node in the table) with VAL2 (a TYPE).  */
+
+bool
+conv_type_hasher::equal (tree val1, tree val2)
+{
+  return TREE_TYPE (val1) == val2;
+}
+
+/* Return an identifier for a conversion operator to TYPE.  We can
+   get from the returned identifier to the type.  */
+
+tree
+make_conv_op_name (tree type)
+{
+  tree *slot;
+  tree identifier;
+
+  if (type == error_mark_node)
+    return error_mark_node;
+
+  if (conv_type_names == NULL)
+    conv_type_names = hash_table<conv_type_hasher>::create_ggc (31);
+
+  slot = conv_type_names->find_slot_with_hash (type,
+                                              (hashval_t) TYPE_UID (type),
+                                              INSERT);
+  identifier = *slot;
+  if (!identifier)
+    {
+      char buffer[64];
+
+       /* Create a unique name corresponding to TYPE.  */
+      sprintf (buffer, "operator %lu",
+              (unsigned long) conv_type_names->elements ());
+      identifier = get_identifier (buffer);
+      *slot = identifier;
+
+      /* Hang TYPE off the identifier so it can be found easily later
+        when performing conversions.  */
+      TREE_TYPE (identifier) = type;
+
+      /* Set the identifier kind so we know later it's a conversion.  */
+      set_identifier_kind (identifier, cik_conv_op);
+    }
+
+  return identifier;
+}
+
 /* Wrapper around build_lang_decl_loc(). Should gradually move to
    build_lang_decl_loc() and then rename build_lang_decl_loc() back to
    build_lang_decl().  */
@@ -799,3 +867,5 @@ in_main_input_context (void)
   else
     return filename_cmp (main_input_filename, LOCATION_FILE (input_location)) == 0;
 }
+
+#include "gt-cp-lex.h"
index 0ba337533398dc34a55828d32d7776ed3e2c869a..8bb26a9902b46023e8162c148ec0390031e1a1a1 100644 (file)
@@ -4176,75 +4176,6 @@ mangle_thunk (tree fn_decl, const int this_adjusting, tree fixed_offset,
   return result;
 }
 
-struct conv_type_hasher : ggc_ptr_hash<tree_node>
-{
-  static hashval_t hash (tree);
-  static bool equal (tree, tree);
-};
-
-/* This hash table maps TYPEs to the IDENTIFIER for a conversion
-   operator to TYPE.  The nodes are IDENTIFIERs whose TREE_TYPE is the
-   TYPE.  */
-
-static GTY (()) hash_table<conv_type_hasher> *conv_type_names;
-
-/* Hash a node (VAL1) in the table.  */
-
-hashval_t
-conv_type_hasher::hash (tree val)
-{
-  return (hashval_t) TYPE_UID (TREE_TYPE (val));
-}
-
-/* Compare VAL1 (a node in the table) with VAL2 (a TYPE).  */
-
-bool
-conv_type_hasher::equal (tree val1, tree val2)
-{
-  return TREE_TYPE (val1) == val2;
-}
-
-/* Return an identifier for the mangled unqualified name for a
-   conversion operator to TYPE.  This mangling is not specified by the
-   ABI spec; it is only used internally.  */
-
-tree
-mangle_conv_op_name_for_type (const tree type)
-{
-  tree *slot;
-  tree identifier;
-
-  if (type == error_mark_node)
-    return error_mark_node;
-
-  if (conv_type_names == NULL)
-    conv_type_names = hash_table<conv_type_hasher>::create_ggc (31);
-
-  slot = conv_type_names->find_slot_with_hash (type,
-                                              (hashval_t) TYPE_UID (type),
-                                              INSERT);
-  identifier = *slot;
-  if (!identifier)
-    {
-      char buffer[64];
-
-       /* Create a unique name corresponding to TYPE.  */
-      sprintf (buffer, "operator %lu",
-              (unsigned long) conv_type_names->elements ());
-      identifier = get_identifier (buffer);
-      *slot = identifier;
-
-      /* Hang TYPE off the identifier so it can be found easily later
-        when performing conversions.  */
-      TREE_TYPE (identifier) = type;
-
-      /* Set the identifier kind so we know later it's a conversion.  */
-      set_identifier_kind (identifier, cik_conv_op);
-    }
-
-  return identifier;
-}
-
 /* Handle ABI backwards compatibility for past bugs where we didn't call
    check_abi_tags in places where it's needed: call check_abi_tags and warn if
    it makes a difference.  If FOR_DECL is non-null, it's the declaration
index c6a8e374d8b78b7f9094f27613a99d06f31c3c54..ea5a5103565eb3e5596f6586a9216aeb4b3815f8 100644 (file)
@@ -14081,7 +14081,7 @@ cp_parser_conversion_function_id (cp_parser* parser)
   /* If the TYPE is invalid, indicate failure.  */
   if (type == error_mark_node)
     return error_mark_node;
-  return mangle_conv_op_name_for_type (type);
+  return make_conv_op_name (type);
 }
 
 /* Parse a conversion-type-id:
index 6b6a1a694b7a958a000ddf9922229920706f3b5a..bd02951cb85136f8ef5f91d69c5439830d136c9e 100644 (file)
@@ -12385,7 +12385,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
        if (member && DECL_CONV_FN_P (r))
          /* Type-conversion operator.  Reconstruct the name, in
             case it's the name of one of the template's parameters.  */
-         DECL_NAME (r) = mangle_conv_op_name_for_type (TREE_TYPE (type));
+         DECL_NAME (r) = make_conv_op_name (TREE_TYPE (type));
 
        DECL_ARGUMENTS (r) = tsubst (DECL_ARGUMENTS (t), args,
                                     complain, t);
@@ -14242,7 +14242,7 @@ tsubst_baselink (tree baselink, tree object_type,
 
   tree name = OVL_NAME (fns);
   if (IDENTIFIER_CONV_OP_P (name))
-    name = mangle_conv_op_name_for_type (optype);
+    name = make_conv_op_name (optype);
 
   baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1);
   if (!baselink)
@@ -15032,7 +15032,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       if (IDENTIFIER_CONV_OP_P (t))
        {
          tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
-         return mangle_conv_op_name_for_type (new_type);
+         return make_conv_op_name (new_type);
        }
       else
        return t;
@@ -16665,7 +16665,7 @@ tsubst_copy_and_build (tree t,
        if (IDENTIFIER_CONV_OP_P (t))
          {
            tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
-           t = mangle_conv_op_name_for_type (new_type);
+           t = make_conv_op_name (new_type);
          }
 
        /* Look up the name.  */
index e13943aaa322aa54e813fe1ce63471647ec9f49e..f6177b32a32f72ca8768a682b54e637d6413b555 100644 (file)
@@ -9399,7 +9399,7 @@ apply_deduced_return_type (tree fco, tree return_type)
     }
 
   if (DECL_CONV_FN_P (fco))
-    DECL_NAME (fco) = mangle_conv_op_name_for_type (return_type);
+    DECL_NAME (fco) = make_conv_op_name (return_type);
 
   TREE_TYPE (fco) = change_return_type (return_type, TREE_TYPE (fco));
 
index 6a2d62380048a0ca04a98694e46078eb197e5ef5..ec795c78fcd564b5ba106d14538cc39cc294ef1f 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-30  Nathan Sidwell  <nathan@acm.org>
+
+       * libcp1plugin.cc (plugin_build_decl): Use make_conv_op_name.
+       (plugin_build_dependent_expr): Likewise.
+
 2017-06-26  Nathan Sidwell  <nathan@acm.org>
 
        * libcp1plugin.cc (plugin_build_decl): Don't set
index bbe32e38bdcc985f454b7694b3985d63da8317b8..7397888373b4a49f6178b8183abefddf7a2faaa7 100644 (file)
@@ -1321,7 +1321,7 @@ plugin_build_decl (cc1_plugin::connection *self,
              opcode = ARRAY_REF;
              break;
            case CHARS2 ('c', 'v'): // operator <T> (conversion operator)
-             identifier = mangle_conv_op_name_for_type (TREE_TYPE (sym_type));
+             identifier = make_conv_op_name (TREE_TYPE (sym_type));
              break;
              // C++11-only:
            case CHARS2 ('l', 'i'): // operator "" <id>
@@ -2622,7 +2622,7 @@ plugin_build_dependent_expr (cc1_plugin::connection *self,
          break;
        case CHARS2 ('c', 'v'): // operator <T> (conversion operator)
          convop = true;
-         identifier = mangle_conv_op_name_for_type (conv_type);
+         identifier = make_conv_op_name (conv_type);
          break;
          // C++11-only:
        case CHARS2 ('l', 'i'): // operator "" <id>