mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-14 05:54:50 +00:00
Add declaration-only enums to XML reader/writer.
* src/abg-reader.cc (build_enum_type_decl): Detect a declaration-only enum and flag it as such. (build_type_decl): Support reading the "is-declaration" attribute. (build_class_decl): Adjust. * src/abg-writer.cc (write_is_declaration_only): Renamed write_class_or_union_is_declaration_only into this. (write_enum_is_declaration_only): Remove. (write_type_decl, write_enum_type_decl) (write_class_decl_opening_tag, write_union_decl_opening_tag): Use write_is_declaration_only. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Adjust. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. Signed-off-by: Giuliano Procida <gprocida@google.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
9a113ce771
commit
6295ff70ef
@ -3457,6 +3457,9 @@ build_type_decl(read_context& ctxt,
|
||||
if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "alignment-in-bits"))
|
||||
alignment_in_bits = atoi(CHAR_STR(s));
|
||||
|
||||
bool is_decl_only = false;
|
||||
read_is_declaration_only(node, is_decl_only);
|
||||
|
||||
location loc;
|
||||
read_location(ctxt, node, loc);
|
||||
|
||||
@ -3479,6 +3482,7 @@ build_type_decl(read_context& ctxt,
|
||||
type_decl_sptr decl(new type_decl(env, name, size_in_bits,
|
||||
alignment_in_bits, loc));
|
||||
decl->set_is_anonymous(is_anonymous);
|
||||
decl->set_is_declaration_only(is_decl_only);
|
||||
if (ctxt.push_and_key_type_decl(decl, id, add_to_current_scope))
|
||||
{
|
||||
ctxt.map_xml_node_to_decl(node, decl);
|
||||
@ -4161,6 +4165,9 @@ build_enum_type_decl(read_context& ctxt,
|
||||
location loc;
|
||||
read_location(ctxt, node, loc);
|
||||
|
||||
bool is_decl_only = false;
|
||||
read_is_declaration_only(node, is_decl_only);
|
||||
|
||||
bool is_anonymous = false;
|
||||
read_is_anonymous(node, is_anonymous);
|
||||
|
||||
@ -4221,6 +4228,7 @@ build_enum_type_decl(read_context& ctxt,
|
||||
enums, linkage_name));
|
||||
t->set_is_anonymous(is_anonymous);
|
||||
t->set_is_artificial(is_artificial);
|
||||
t->set_is_declaration_only(is_decl_only);
|
||||
if (ctxt.push_and_key_type_decl(t, id, add_to_current_scope))
|
||||
{
|
||||
ctxt.map_xml_node_to_decl(node, t);
|
||||
@ -4487,8 +4495,7 @@ build_class_decl(read_context& ctxt,
|
||||
|
||||
if (!def_id.empty())
|
||||
{
|
||||
class_decl_sptr d =
|
||||
dynamic_pointer_cast<class_decl>(ctxt.get_type_decl(def_id));
|
||||
decl_base_sptr d = is_decl(ctxt.get_type_decl(def_id));
|
||||
if (d && d->get_is_declaration_only())
|
||||
{
|
||||
is_def_of_decl = true;
|
||||
@ -4506,7 +4513,7 @@ build_class_decl(read_context& ctxt,
|
||||
// previous_declaration.
|
||||
//
|
||||
// Let's link them.
|
||||
decl->set_earlier_declaration(previous_declaration);
|
||||
decl->set_earlier_declaration(is_decl(previous_declaration));
|
||||
for (vector<type_base_sptr>::const_iterator i = types_ptr->begin();
|
||||
i != types_ptr->end();
|
||||
++i)
|
||||
|
@ -876,8 +876,7 @@ static void write_elf_symbol_binding(elf_symbol::binding, ostream&);
|
||||
static bool write_elf_symbol_aliases(const elf_symbol&, ostream&);
|
||||
static bool write_elf_symbol_reference(const elf_symbol&, ostream&);
|
||||
static bool write_elf_symbol_reference(const elf_symbol_sptr, ostream&);
|
||||
static void write_class_or_union_is_declaration_only(const class_or_union_sptr&,
|
||||
ostream&);
|
||||
static void write_is_declaration_only(const decl_base_sptr&, ostream&);
|
||||
static void write_is_struct(const class_decl_sptr&, ostream&);
|
||||
static void write_is_anonymous(const decl_base_sptr&, ostream&);
|
||||
static void write_naming_typedef(const class_decl_sptr&, write_context&);
|
||||
@ -1777,18 +1776,16 @@ write_cdtor_const_static(bool is_ctor,
|
||||
o << " const='yes'";
|
||||
}
|
||||
|
||||
/// Serialize the attribute "is-declaration-only", if the class or
|
||||
/// union has its 'is_declaration_only property set.
|
||||
/// Serialize the attribute "is-declaration-only", if the
|
||||
/// decl_base_sptr has its 'is_declaration_only property set.
|
||||
///
|
||||
/// @param t the pointer to instance of @ref class_or_union to
|
||||
/// consider.
|
||||
/// @param t the pointer to instance of @ref decl_base to consider.
|
||||
///
|
||||
/// @param o the output stream to serialize to.
|
||||
static void
|
||||
write_class_or_union_is_declaration_only(const class_or_union_sptr& t,
|
||||
ostream& o)
|
||||
write_is_declaration_only(const decl_base_sptr& d, ostream& o)
|
||||
{
|
||||
if (t->get_is_declaration_only())
|
||||
if (d->get_is_declaration_only())
|
||||
o << " is-declaration-only='yes'";
|
||||
}
|
||||
|
||||
@ -2459,6 +2456,8 @@ write_type_decl(const type_decl_sptr& d, write_context& ctxt, unsigned indent)
|
||||
|
||||
write_size_and_alignment(d, o);
|
||||
|
||||
write_is_declaration_only(d, o);
|
||||
|
||||
write_location(d, ctxt);
|
||||
|
||||
o << " id='" << ctxt.get_id_for_type(d) << "'" << "/>";
|
||||
@ -2938,6 +2937,7 @@ write_enum_type_decl(const enum_type_decl_sptr& decl,
|
||||
o << " linkage-name='" << decl->get_linkage_name() << "'";
|
||||
|
||||
write_location(decl, ctxt);
|
||||
write_is_declaration_only(decl, o);
|
||||
|
||||
string i = id;
|
||||
if (i.empty())
|
||||
@ -3475,7 +3475,7 @@ write_class_decl_opening_tag(const class_decl_sptr& decl,
|
||||
|
||||
write_location(decl, ctxt);
|
||||
|
||||
write_class_or_union_is_declaration_only(decl, o);
|
||||
write_is_declaration_only(decl, o);
|
||||
|
||||
if (decl->get_earlier_declaration())
|
||||
{
|
||||
@ -3549,7 +3549,7 @@ write_union_decl_opening_tag(const union_decl_sptr& decl,
|
||||
|
||||
write_location(decl, ctxt);
|
||||
|
||||
write_class_or_union_is_declaration_only(decl, o);
|
||||
write_is_declaration_only(decl, o);
|
||||
|
||||
string i = id;
|
||||
if (i.empty())
|
||||
|
@ -270,7 +270,7 @@
|
||||
<type-decl name='long long int' size-in-bits='64' id='type-id-16'/>
|
||||
<type-decl name='long long unsigned int' size-in-bits='64' id='type-id-17'/>
|
||||
<type-decl name='sizetype' size-in-bits='64' id='type-id-5'/>
|
||||
<type-decl name='unnamed-enum-underlying-type' is-anonymous='yes' id='type-id-18'/>
|
||||
<type-decl name='unnamed-enum-underlying-type' is-anonymous='yes' is-declaration-only='yes' id='type-id-18'/>
|
||||
<type-decl name='unsigned char' size-in-bits='8' id='type-id-19'/>
|
||||
<type-decl name='unsigned int' size-in-bits='32' id='type-id-20'/>
|
||||
<type-decl name='unsigned long int' size-in-bits='64' id='type-id-21'/>
|
||||
@ -500,7 +500,7 @@
|
||||
<class-decl name='basic_string<char, std::char_traits<char>, std::allocator<char> >' size-in-bits='256' visibility='default' is-declaration-only='yes' id='type-id-87'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-144'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-144'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -969,7 +969,7 @@
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-165'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-165'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
<typedef-decl name='memory_order' type-id='type-id-165' filepath='/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/atomic_base.h' line='63' column='1' id='type-id-164'/>
|
||||
@ -1140,7 +1140,7 @@
|
||||
<class-decl name='__anonymous_struct__2' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-173'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-173'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -3877,7 +3877,7 @@
|
||||
<class-decl name='__anonymous_struct__17' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-215'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-215'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -4400,7 +4400,7 @@
|
||||
<class-decl name='__anonymous_struct__6' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-230'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-230'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -5355,7 +5355,7 @@
|
||||
<class-decl name='__anonymous_struct__3' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-287'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-287'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -5408,7 +5408,7 @@
|
||||
<class-decl name='__anonymous_struct__1' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-288'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-288'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -5426,7 +5426,7 @@
|
||||
<class-decl name='__anonymous_struct__8' is-anonymous='yes' naming-typedef-id='type-id-285' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-289'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-289'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -7102,14 +7102,14 @@
|
||||
<class-decl name='__anonymous_struct__2' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-351'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-351'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
</class-decl>
|
||||
</namespace-decl>
|
||||
<namespace-decl name='FTDCBSONUtil'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-333'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-333'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</namespace-decl>
|
||||
@ -7271,7 +7271,7 @@
|
||||
<class-decl name='__anonymous_struct__19' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-352'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-352'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -7455,7 +7455,7 @@
|
||||
<class-decl name='__anonymous_struct__1' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'/>
|
||||
</member-type>
|
||||
</class-decl>
|
||||
<enum-decl name='__anonymous_enum__1' is-anonymous='yes' id='type-id-375'>
|
||||
<enum-decl name='__anonymous_enum__1' is-anonymous='yes' is-declaration-only='yes' id='type-id-375'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
<typedef-decl name='streamsize' type-id='type-id-157' filepath='/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/postypes.h' line='98' column='1' id='type-id-170'/>
|
||||
@ -7904,7 +7904,7 @@
|
||||
<class-decl name='__anonymous_struct__' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-381'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-381'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -7985,7 +7985,7 @@
|
||||
<class-decl name='__anonymous_struct__11' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-382'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-382'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
@ -8679,7 +8679,7 @@
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-408'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-408'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
<class-decl name='__anonymous_struct__14' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'/>
|
||||
@ -8808,7 +8808,7 @@
|
||||
</function-decl>
|
||||
</member-function>
|
||||
</class-decl>
|
||||
<enum-decl name='__anonymous_enum__1' is-anonymous='yes' id='type-id-409'>
|
||||
<enum-decl name='__anonymous_enum__1' is-anonymous='yes' is-declaration-only='yes' id='type-id-409'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
<class-decl name='__anonymous_struct__23' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
@ -8863,7 +8863,7 @@
|
||||
<class-decl name='__anonymous_struct__26' is-anonymous='yes' visibility='default' is-declaration-only='yes' id='type-id-24'>
|
||||
|
||||
<member-type access='private'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' id='type-id-410'>
|
||||
<enum-decl name='__anonymous_enum__' is-anonymous='yes' is-declaration-only='yes' id='type-id-410'>
|
||||
<underlying-type type-id='type-id-18'/>
|
||||
</enum-decl>
|
||||
</member-type>
|
||||
|
Loading…
Reference in New Issue
Block a user