[1/3,V2] For WIP branch check-uapi-support: default-reporter,reporter-priv: Do not report names of anonymous enums

Message ID 87mswypsli.fsf@redhat.com
State New
Headers
Series For WIP branch check-uapi-support: Fix comparing non-reachable anonymous enums |

Commit Message

Dodji Seketeli Oct. 4, 2023, 10:52 a.m. UTC
  Hello,

When reporting changes of anonymous enums, do not try to report their
qualified name as that doesn't make any sense -- they are anonymous.

Similarly, in report_name_size_and_alignment_changes do not try to
report about changes in the name of an anonymous enum.

	* src/abg-default-reporter.cc (default_reporter::report): In the
	overload for enum_diff, do not get the qualified name of anonymous
	enums.
	* src/abg-reporter-priv.cc
	(report_name_size_and_alignment_changes): Do not report about name
	changes for anonymous enums.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-default-reporter.cc | 12 +++++++++---
 src/abg-reporter-priv.cc    |  3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)
  

Patch

diff --git a/src/abg-default-reporter.cc b/src/abg-default-reporter.cc
index b1df9300..c71f8d56 100644
--- a/src/abg-default-reporter.cc
+++ b/src/abg-default-reporter.cc
@@ -162,7 +162,9 @@  default_reporter::report(const enum_diff& d, ostream& out,
 	{
 	  out << indent
 	      << "  '"
-	      << i->get_qualified_name()
+	      << (first->get_is_anonymous()
+		  ? i->get_name()
+		  : i->get_qualified_name())
 	      << "' value '"
 	      << i->get_value()
 	      << "'";
@@ -181,7 +183,9 @@  default_reporter::report(const enum_diff& d, ostream& out,
 	{
 	  out << indent
 	      << "  '"
-	      << i->get_qualified_name()
+	      << (second->get_is_anonymous()
+		  ? i->get_name()
+		  :i->get_qualified_name())
 	      << "' value '"
 	      << i->get_value()
 	      << "'";
@@ -201,7 +205,9 @@  default_reporter::report(const enum_diff& d, ostream& out,
 	{
 	  out << indent
 	      << "  '"
-	      << i->first.get_qualified_name()
+	      << (first->get_is_anonymous()
+		  ? i->first.get_name()
+		  : i->first.get_qualified_name())
 	      << "' from value '"
 	      << i->first.get_value() << "' to '"
 	      << i->second.get_value() << "'";
diff --git a/src/abg-reporter-priv.cc b/src/abg-reporter-priv.cc
index 63a45b80..cc38f240 100644
--- a/src/abg-reporter-priv.cc
+++ b/src/abg-reporter-priv.cc
@@ -965,7 +965,8 @@  report_name_size_and_alignment_changes(decl_base_sptr		first,
   string fn = first->get_qualified_name(),
     sn = second->get_qualified_name();
 
-  if (fn != sn)
+  if (!(first->get_is_anonymous() && second->get_is_anonymous())
+      && fn != sn)
     {
       if (!(ctxt->get_allowed_category() & HARMLESS_DECL_NAME_CHANGE_CATEGORY)
 	  && filtering::has_harmless_name_change(first, second))