abilint --show-type-use: Show results for global decls that have no symbols

In some abixml file, 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>
This commit is contained in:
Dodji Seketeli 2022-02-28 17:13:47 +01:00
parent 1483f6cb49
commit 1eb3dc84f7
3 changed files with 18 additions and 2 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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;
}