static struct demangle_component *d_unnamed_type (struct d_info *);
+static struct demangle_component *
+d_clone_suffix (struct d_info *, struct demangle_component *);
+
static int
d_add_substitution (struct d_info *, struct demangle_component *);
case DEMANGLE_COMPONENT_LITERAL_NEG:
case DEMANGLE_COMPONENT_COMPOUND_NAME:
case DEMANGLE_COMPONENT_VECTOR_TYPE:
+ case DEMANGLE_COMPONENT_CLONE:
if (left == NULL || right == NULL)
return NULL;
break;
return p;
}
-/* <mangled-name> ::= _Z <encoding>
+/* <mangled-name> ::= _Z <encoding> [<clone-suffix>]*
TOP_LEVEL is non-zero when called at the top level. */
struct demangle_component *
cplus_demangle_mangled_name (struct d_info *di, int top_level)
{
+ struct demangle_component *p;
+
if (! d_check_char (di, '_')
/* Allow missing _ if not at toplevel to work around a
bug in G++ abi-version=2 mangling; see the comment in
return NULL;
if (! d_check_char (di, 'Z'))
return NULL;
- return d_encoding (di, top_level);
+ p = d_encoding (di, top_level);
+
+ /* If at top level and parsing parameters, check for a clone
+ suffix. */
+ if (top_level && (di->options & DMGL_PARAMS) != 0)
+ while (d_peek_char (di) == '.'
+ && (IS_LOWER (d_peek_next_char (di))
+ || d_peek_next_char (di) == '_'
+ || IS_DIGIT (d_peek_next_char (di))))
+ p = d_clone_suffix (di, p);
+
+ return p;
}
/* Return whether a function should have a return type. The argument
struct demangle_component *type;
char peek = d_peek_char (di);
- if (peek == '\0' || peek == 'E')
+ if (peek == '\0' || peek == 'E' || peek == '.')
break;
type = cplus_demangle_type (di);
if (type == NULL)
return ret;
}
+/* <clone-suffix> ::= [ . <clone-type-identifier> ] [ . <nonnegative number> ]*
+*/
+
+static struct demangle_component *
+d_clone_suffix (struct d_info *di, struct demangle_component *encoding)
+{
+ const char *suffix = d_str (di);
+ const char *pend = suffix;
+ struct demangle_component *n;
+
+ if (*pend == '.' && (IS_LOWER (pend[1]) || pend[1] == '_'))
+ {
+ pend += 2;
+ while (IS_LOWER (*pend) || *pend == '_')
+ ++pend;
+ }
+ while (*pend == '.' && IS_DIGIT (pend[1]))
+ {
+ pend += 2;
+ while (IS_DIGIT (*pend))
+ ++pend;
+ }
+ d_advance (di, pend - suffix);
+ n = d_make_name (di, suffix, pend - suffix);
+ return d_make_comp (di, DEMANGLE_COMPONENT_CLONE, encoding, n);
+}
+
/* Add a new substitution. */
static int
d_append_char (dpi, '}');
return;
+ case DEMANGLE_COMPONENT_CLONE:
+ d_print_comp (dpi, options, d_left (dc));
+ d_append_string (dpi, " [clone ");
+ d_print_comp (dpi, options, d_right (dc));
+ d_append_char (dpi, ']');
+ return;
+
default:
d_print_error (dpi);
return;
--format=auto
_ZN3Psi7VariantIIcPKcEE5visitIIRZN11VariantTest9TestVisit11test_methodEvEUlS2_E0_RZNS6_11test_methodEvEUlcE1_RZNS6_11test_methodEvEUlNS_4NoneEE_EEENS_13VariantDetail19SelectVisitorResultIIDpT_EE4typeEDpOSG_
Psi::VariantDetail::SelectVisitorResult<VariantTest::TestVisit::test_method()::{lambda(char const*)#2}&, VariantTest::TestVisit::test_method()::{lambda(char)#3}&, VariantTest::TestVisit::test_method()::{lambda(Psi::None)#1}&>::type Psi::Variant<char, char const*>::visit<VariantTest::TestVisit::test_method()::{lambda(char const*)#2}&, VariantTest::TestVisit::test_method()::{lambda(char)#3}&, VariantTest::TestVisit::test_method()::{lambda(Psi::None)#1}&>((VariantTest::TestVisit::test_method()::{lambda(Psi::None)#1}&)...)
+#
+# Clone suffix tests
+#
+--format=gnu-v3 --no-params
+_Z3fo5n.clone.1
+fo5(__int128) [clone .clone.1]
+fo5
+#
+--format=gnu-v3 --no-params
+_Z3fo5n.constprop.2
+fo5(__int128) [clone .constprop.2]
+fo5
+#
+--format=gnu-v3 --no-params
+_Z3fo5n.isra.3
+fo5(__int128) [clone .isra.3]
+fo5
+#
+--format=gnu-v3 --no-params
+_Z3fo5n.part.4
+fo5(__int128) [clone .part.4]
+fo5
+#
+--format=gnu-v3 --no-params
+_Z12to_be_clonediPv.clone.0
+to_be_cloned(int, void*) [clone .clone.0]
+to_be_cloned
+#
+--format=gnu-v3 --no-params
+_Z3fooi.1988
+foo(int) [clone .1988]
+foo
+#
+--format=gnu-v3 --no-params
+_Z3fooi.part.9.165493.constprop.775.31805
+foo(int) [clone .part.9.165493] [clone .constprop.775.31805]
+foo
+#
+--format=gnu-v3 --no-params
+_Z2f1IiEvT_S0_S0_._omp_fn.2
+void f1<int>(int, int, int) [clone ._omp_fn.2]
+f1<int>
+#
+--format=gnu-v3 --no-params
+_Z3fooi._omp_cpyfn.6
+foo(int) [clone ._omp_cpyfn.6]
+foo