| colon_ext_only function_arglist start_opt
{ $$ = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, $2.comp);
if ($3) $$ = state->fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $3); }
+ | colon_ext_only
+ {
+ /* This production is a hack to handle
+ something like "name::operator new[]" --
+ without arguments, this ordinarily would
+ not parse, but canonicalizing it is
+ important. So we infer the "()" and then
+ remove it when converting back to string.
+ Note that this works because this
+ production is terminal. */
+ demangle_component *comp
+ = state->fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE,
+ nullptr, nullptr);
+ $$ = state->fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, $1, comp);
+ state->demangle_info->added_parens = true;
+ }
| conversion_op_name start_opt
{ $$ = $1.comp;
should_be_the_same ("Foozle<int>::fogey<Empty<int> > (Empty<int>)",
"Foozle<int>::fogey<Empty<int>> (Empty<int>)");
+
+ should_be_the_same ("something :: operator new [ ]",
+ "something::operator new[]");
+ should_be_the_same ("something :: operator new",
+ "something::operator new");
+ should_be_the_same ("operator()", "operator ()");
}
#endif
}
}
+/* A helper to strip a trailing "()" from PTR. The string is modified
+ in place. */
+
+static void
+maybe_strip_parens (char *ptr)
+{
+ size_t len = strlen (ptr);
+ if (len > 2 && ptr[len - 2] == '(' && ptr[len - 1] == ')')
+ ptr[len - 2] = '\0';
+}
+
/* Parse STRING and convert it to canonical form, resolving any
typedefs. If parsing fails, or if STRING is already canonical,
return nullptr. Otherwise return the canonical form. If
estimated_len);
gdb_assert (us);
+ if (info->added_parens)
+ maybe_strip_parens (us.get ());
+
/* Finally, compare the original string with the computed
name, returning NULL if they are the same. */
if (strcmp (us.get (), string) == 0)
return nullptr;
}
+ if (info->added_parens)
+ maybe_strip_parens (us.get ());
+
if (strcmp (us.get (), string) == 0)
return nullptr;
/* Any memory used during processing. */
auto_obstack obstack;
+ /* True if the parser had to add a dummy '()' at the end of the
+ input text to make it parse. */
+ bool added_parens = false;
+
/* Any other objects referred to by this object, and whose storage
lifetime must be linked. */
std::vector<std::unique_ptr<demangle_parse_info>> infos;