/* If types have mangled ODR names and they are different, it is most
informative to output those.
This also covers types defined in different namespaces. */
- if (TYPE_NAME (mt1) && TYPE_NAME (mt2)
- && TREE_CODE (TYPE_NAME (mt1)) == TYPE_DECL
- && TREE_CODE (TYPE_NAME (mt2)) == TYPE_DECL
- && DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (mt1))
- && DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (mt2))
- && DECL_ASSEMBLER_NAME (TYPE_NAME (mt1))
- != DECL_ASSEMBLER_NAME (TYPE_NAME (mt2)))
- {
- char *name1 = xstrdup (cplus_demangle
- (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (mt1))),
- DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES));
- char *name2 = cplus_demangle
- (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (mt2))),
- DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES);
+ const char *odr1 = get_odr_name_for_type (mt1);
+ const char *odr2 = get_odr_name_for_type (mt2);
+ if (odr1 != NULL && odr2 != NULL && odr1 != odr2)
+ {
+ const int opts = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES;
+ char *name1 = xstrdup (cplus_demangle (odr1, opts));
+ char *name2 = xstrdup (cplus_demangle (odr2, opts));
if (name1 && name2 && strcmp (name1, name2))
{
inform (loc_t1,
return new pass_ipa_devirt (ctxt);
}
+/* Print ODR name of a TYPE if available.
+ Use demangler when option DEMANGLE is used. */
+
+DEBUG_FUNCTION void
+debug_tree_odr_name (tree type, bool demangle)
+{
+ const char *odr = get_odr_name_for_type (type);
+ if (demangle)
+ {
+ const int opts = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES;
+ odr = cplus_demangle (odr, opts);
+ }
+
+ fprintf (stderr, "%s\n", odr);
+}
+
#include "gt-ipa-devirt.h"
&& DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (t));
}
+/* If TYPE has mangled ODR name, return it. Otherwise return NULL.
+ The function works only when free_lang_data is run. */
+
+inline const char *
+get_odr_name_for_type (tree type)
+{
+ tree type_name = TYPE_NAME (type);
+ if (type_name == NULL_TREE
+ || !DECL_ASSEMBLER_NAME_SET_P (type_name))
+ return NULL;
+
+ return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (type_name));
+}
+
#endif /* GCC_IPA_UTILS_H */