public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com
Subject: [PATCH 10/11] Add declaration-only enums to XML reader/writer.
Date: Wed, 10 Jun 2020 12:59:39 +0100	[thread overview]
Message-ID: <20200610115940.26035-11-gprocida@google.com> (raw)
In-Reply-To: <20200610115940.26035-1-gprocida@google.com>

Serialisation seems OK.

Deserialisation quite likely needs declaration/definition resolution
as there is logic for this for class types.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-reader.cc |  4 ++++
 src/abg-writer.cc | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index eb74659f..62eda332 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -4161,6 +4161,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 +4224,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); // TODO: more to do here!
   if (ctxt.push_and_key_type_decl(t, id, add_to_current_scope))
     {
       ctxt.map_xml_node_to_decl(node, t);
diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index bafa3024..38320867 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -840,6 +840,8 @@ 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_enum_is_declaration_only(const enum_type_decl_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&);
@@ -1754,6 +1756,20 @@ write_class_or_union_is_declaration_only(const class_or_union_sptr& t,
     o << " is-declaration-only='yes'";
 }
 
+/// Serialize the attribute "is-declaration-only", if the enum has its
+/// is_declaration_only property set.
+///
+/// @param t the pointer to instance of @ref enum_type_decl to
+/// consider.
+///
+/// @param o the output stream to serialize to.
+static void
+write_enum_is_declaration_only(const enum_type_decl_sptr& t, ostream& o)
+{
+  if (t->get_is_declaration_only())
+    o << " is-declaration-only='yes'";
+}
+
 /// Serialize the attribute "is-struct", if the current instance of
 /// class_decl is a struct.
 ///
@@ -2889,6 +2905,7 @@ write_enum_type_decl(const enum_type_decl_sptr& decl,
     o << " linkage-name='" << decl->get_linkage_name() << "'";
 
   write_location(decl, ctxt);
+  write_enum_is_declaration_only(decl, o);
 
   string i = id;
   if (i.empty())
-- 
2.27.0.278.ge193c7cf3a9-goog


  parent reply	other threads:[~2020-06-10 12:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 11:59 [PATCH 00/11] Add incomplete enum support Giuliano Procida
2020-06-10 11:59 ` [PATCH 01/11] Missing initialisation of source local variable Giuliano Procida
2020-06-10 11:59 ` [PATCH 02/11] Improve code comments and whitespace Giuliano Procida
2020-06-29  8:26   ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 03/11] Refactor d.context() as ctxt in report(enum_diff) Giuliano Procida
2020-06-29  8:54   ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 04/11] Tidy build_enum_type state variables Giuliano Procida
2020-06-29  9:08   ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 05/11] Rename declaration-definition change category Giuliano Procida
2020-06-29 16:17   ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 06/11] Support incomplete enums in core and diff code Giuliano Procida
2020-07-06 11:14   ` Dodji Seketeli
     [not found]     ` <CAGvU0HkuOc74mfL9yLttK4Riwkrj9tmtc3VXxdHAsaCbn2153A@mail.gmail.com>
2020-07-08  9:22       ` Dodji Seketeli
2020-07-08 10:39         ` Giuliano Procida
2020-07-08 15:30           ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 07/11] Add invariant to enum_type_decl::set_is_declaration_only Giuliano Procida
2020-07-06 11:15   ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 08/11] Support declaration-only enums in DWARF reader Giuliano Procida
2020-07-06 11:22   ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 09/11] Support constructing opaque types for enums Giuliano Procida
2020-07-06 11:23   ` Dodji Seketeli
2020-06-10 11:59 ` Giuliano Procida [this message]
2020-07-02 13:55   ` [PATCH 10/11] Add declaration-only enums to XML reader/writer Dodji Seketeli
2020-07-02 15:09     ` Giuliano Procida
2020-07-06 11:05       ` Dodji Seketeli
2020-07-06 11:31   ` Dodji Seketeli
2020-07-07  8:31     ` Giuliano Procida
2020-07-07 14:57       ` Dodji Seketeli
2020-06-10 11:59 ` [PATCH 11/11] Add tests for declaration-only enums Giuliano Procida
2020-07-06 11:26   ` Dodji Seketeli
2020-07-01 13:36 ` [PATCH 00/11] Add incomplete enum support Dodji Seketeli
2020-07-01 15:18   ` Giuliano Procida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200610115940.26035-11-gprocida@google.com \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).