[applied] abilint --show-type-use: Show results for global decls that have no symbols
Commit Message
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(-)
@@ -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);
@@ -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.
@@ -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;
}