public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] abilint --show-type-use: Show results for global decls that have no symbols
Date: Tue, 01 Mar 2022 10:41:20 +0100	[thread overview]
Message-ID: <87o82qj9hb.fsf@redhat.com> (raw)

Hello,

In some abixml files, there can be global decls that don't have ELF
symbols.  We still want to see how those decls use the type that is
being used, as analyzed by abilint --show-type-use <type-id>.

	* include/abg-fwd.h (is_at_global_scope): Declare ...
	* src/abg-ir.cc (is_at_global_scope): ... new overload.
	* tools/abilint.cc (emit_artifact_use_trace): Emit the trace also
	when the decl is at global scope or has a linkage name.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 include/abg-fwd.h | 3 +++
 src/abg-ir.cc     | 9 +++++++++
 tools/abilint.cc  | 8 ++++++--
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/include/abg-fwd.h b/include/abg-fwd.h
index c5e98afe..6afaf7bc 100644
--- a/include/abg-fwd.h
+++ b/include/abg-fwd.h
@@ -349,6 +349,9 @@ is_at_global_scope(const decl_base&);
 bool
 is_at_global_scope(const decl_base_sptr);
 
+bool
+is_at_global_scope(const decl_base*);
+
 class_or_union*
 is_at_class_scope(const decl_base_sptr);
 
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 82971253..4afe2d61 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -9332,6 +9332,15 @@ bool
 is_at_global_scope(const decl_base_sptr decl)
 {return (decl && is_global_scope(decl->get_scope()));}
 
+/// Tests whether a given declaration is at global scope.
+///
+/// @param decl the decl to consider.
+///
+/// @return true iff decl is at global scope.
+bool
+is_at_global_scope(const decl_base* decl)
+{return is_at_global_scope(*decl);}
+
 /// Tests whether a given decl is at class scope.
 ///
 /// @param decl the decl to consider.
diff --git a/tools/abilint.cc b/tools/abilint.cc
index ba2de634..4883b557 100644
--- a/tools/abilint.cc
+++ b/tools/abilint.cc
@@ -398,10 +398,14 @@ emit_artifact_use_trace(const artifact_use_relation_tree& artifact_use_tree,
       if (is_decl(artifact))
 	{
 	  if (abigail::ir::var_decl* v = is_var_decl(artifact))
-	    if (v->get_symbol())
+	    if (v->get_symbol()
+		|| is_at_global_scope(v)
+		|| !v->get_linkage_name().empty())
 	      do_emit_trace = true;
 	  if (abigail::ir::function_decl* f = is_function_decl(artifact))
-	    if (f->get_symbol())
+	    if (f->get_symbol()
+		|| is_at_global_scope(f)
+		|| !f->get_linkage_name().empty())
 	      do_emit_trace = true;
 	}
 
-- 
2.35.0.rc2


-- 
		Dodji


                 reply	other threads:[~2022-03-01  9:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=87o82qj9hb.fsf@redhat.com \
    --to=dodji@redhat.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).