clear_type_id_map()
{m_type_id_map.clear();}
+ /// Record a given type id as belonging to a type that as been
+ /// written out to the XML output.
+ ///
+ /// @param id the ID of the type.
+ void
+ record_type_id_as_emitted(const string& id)
+ {m_emitted_type_id_map[id] = true;}
+
+ /// Flag a type as having been written out to the XML output.
+ ///
+ /// @param t the type to flag.
+ void
+ record_type_as_emitted(const type_base_sptr& t)
+ {
+ string id = get_id_for_type(t);
+ record_type_id_as_emitted(id);
+ }
+
+ /// Test if a given type ID belongs to a type that has been written
+ /// out to the XML output.
+ ///
+ /// @param id the ID of the type to test.
+ ///
+ /// @return true if the type has already been emitted, false
+ /// otherwise.
+ bool
+ type_id_is_emitted(const string& id)
+ {return m_emitted_type_id_map.find(id) != m_emitted_type_id_map.end();}
+
+ /// Test if a given type has been written out to the XML output.
+ ///
+ /// @param the type to test for.
+ ///
+ /// @return true if the type has already been emitted, false
+ /// otherwise.
+ bool
+ type_is_emitted(const type_base_sptr& t)
+ {
+ if (!type_has_existing_id(t))
+ return false;
+ string id = get_id_for_type(t);
+ return type_id_is_emitted(id);
+ }
+
+ /// Clear the map that contains the IDs of the types that has been
+ /// recorded as having been written out to the XML output.
+ void
+ clear_emitted_types_map()
+ {m_emitted_type_id_map.clear();}
+
const string_elf_symbol_sptr_map_type&
get_fun_symbol_map() const
{return m_fun_symbol_map;}
config m_config;
ostream& m_ostream;
type_ptr_map m_type_id_map;
+ unordered_map<string, bool> m_emitted_type_id_map;
fn_tmpl_shared_ptr_map m_fn_tmpl_id_map;
class_tmpl_shared_ptr_map m_class_tmpl_id_map;
string_elf_symbol_sptr_map_type m_fun_symbol_map;
ostream& o = ctxt.get_ostream();
const config& c = ctxt.get_config();
+ // In a given translation unit, we'd like to ensure that a given
+ // type is defined only once. The same type can be present in
+ // several translation units, though. They'll be canonicalized
+ // later, by the reader's code.
+ //
+ // So lets clear the map that contains the types that are emitted in
+ // the translation unit tu.
+ ctxt.clear_emitted_types_map();
+
do_indent(o, indent);
o << "<abi-instr version='"
for (const_iterator i = d.begin(); i != d.end(); ++i)
{
+ if (type_base_sptr t = is_type(*i))
+ if (ctxt.type_is_emitted(t))
+ // This type has already been written out to the current
+ // translation unit, so do not emit it again.
+ continue;
o << "\n";
write_decl(*i, ctxt, indent + c.get_xml_element_indent());
}
o << " id='" << ctxt.get_id_for_type(d) << "'" << "/>";
+ ctxt.record_type_as_emitted(d);
+
return true;
}
for (const_iterator i = d.begin(); i != d.end(); ++i)
{
+ if (type_base_sptr t = is_type(*i))
+ if (ctxt.type_is_emitted(t))
+ // This type has already been emitted to the current
+ // translation unit so do not emit it again.
+ continue;
o << "\n";
write_decl(*i, ctxt, indent + c.get_xml_element_indent());
}
o<< " id='" << i << "'/>";
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
write_location(static_pointer_cast<decl_base>(decl), o);
o << "/>";
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
write_location(static_pointer_cast<decl_base>(decl), o);
o << "/>";
+
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
o << "</array-type-def>";
}
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
do_indent(o, indent);
o << "</enum-decl>";
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
o << " id='" << i << "'/>";
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
o << "</class-decl>";
}
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
o << "/>";
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
do_indent_to_level(ctxt, indent, 0);
o << "</template-template-parameter>";
+ ctxt.record_type_as_emitted(decl);
+
return true;
}
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='25' column='1' id='type-id-48'/>
<typedef-decl name='fpos_t' type-id='type-id-48' filepath='/usr/include/stdio.h' line='110' column='1' id='type-id-49'/>
<function-decl name='fgetpos' filepath='/usr/include/stdio.h' line='798' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos64_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='30' column='1' id='type-id-200'/>
<typedef-decl name='fpos_t' type-id='type-id-200' filepath='/usr/include/stdio.h' line='112' column='1' id='type-id-201'/>
<function-decl name='fgetpos' mangled-name='fgetpos64' filepath='/usr/include/stdio.h' line='806' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='25' column='1' id='type-id-48'/>
<typedef-decl name='fpos_t' type-id='type-id-48' filepath='/usr/include/stdio.h' line='110' column='1' id='type-id-49'/>
<function-decl name='fgetpos' filepath='/usr/include/stdio.h' line='798' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='25' column='1' id='type-id-48'/>
<typedef-decl name='fpos_t' type-id='type-id-48' filepath='/usr/include/stdio.h' line='110' column='1' id='type-id-49'/>
<function-decl name='fgetpos' filepath='/usr/include/stdio.h' line='798' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='25' column='1' id='type-id-48'/>
<typedef-decl name='fpos_t' type-id='type-id-48' filepath='/usr/include/stdio.h' line='110' column='1' id='type-id-49'/>
<function-decl name='fgetpos' filepath='/usr/include/stdio.h' line='798' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='25' column='1' id='type-id-48'/>
<typedef-decl name='fpos_t' type-id='type-id-48' filepath='/usr/include/stdio.h' line='110' column='1' id='type-id-49'/>
<function-decl name='fgetpos' filepath='/usr/include/stdio.h' line='798' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='fgetc' filepath='/usr/include/stdio.h' line='531' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-3'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='_G_fpos_t' type-id='type-id-22' filepath='/usr/include/_G_config.h' line='25' column='1' id='type-id-48'/>
<typedef-decl name='fpos_t' type-id='type-id-48' filepath='/usr/include/stdio.h' line='110' column='1' id='type-id-49'/>
<function-decl name='fgetpos' filepath='/usr/include/stdio.h' line='798' column='1' visibility='default' binding='global' size-in-bits='64'>
<function-decl name='getwchar' filepath='/usr/include/wchar.h' line='752' column='1' visibility='default' binding='global' size-in-bits='64'>
<return type-id='type-id-35'/>
</function-decl>
- <class-decl name='__anonymous_struct__' is-struct='yes' visibility='default' is-declaration-only='yes' id='type-id-22'/>
<typedef-decl name='__mbstate_t' type-id='type-id-22' filepath='/usr/include/wchar.h' line='94' column='1' id='type-id-268'/>
<typedef-decl name='mbstate_t' type-id='type-id-268' filepath='/usr/include/wchar.h' line='106' column='1' id='type-id-269'/>
<function-decl name='mbrlen' filepath='/usr/include/wchar.h' line='376' column='1' visibility='default' binding='global' size-in-bits='64'>