From patchwork Tue Mar 1 09:41:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 51465 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9AC53385802F for ; Tue, 1 Mar 2022 09:41:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9AC53385802F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1646127689; bh=erlidqsSjieZENIqCkEZKk9z3t3q2jJTQ66Cv8W0X5E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=EDoaFou7SH0ufVuaNx+zKEkO7cfo50EFICuLEzszwMGJF/l06uE5TAUbuJhQA5PAp WhZBuiPlkl55i3Hfhsax2A4uaiovrtIVWum78/kdkRD7oO52yIcQh4VP/RtokSl0Bx rZJnIxbnZoKxIVbhCzBBhOUf0jyDQTt38GJDDDnA= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 864893858C78 for ; Tue, 1 Mar 2022 09:41:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 864893858C78 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-JFdnTXB8PdW5JVNnctiymw-1; Tue, 01 Mar 2022 04:41:24 -0500 X-MC-Unique: JFdnTXB8PdW5JVNnctiymw-1 Received: by mail-qv1-f70.google.com with SMTP id p5-20020a0ccb85000000b00432db9e5021so9690346qvk.10 for ; Tue, 01 Mar 2022 01:41:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=erlidqsSjieZENIqCkEZKk9z3t3q2jJTQ66Cv8W0X5E=; b=z4+mNmbWei7QHHNJTctl9TnIbhRFqHr8lMG7W2ObEW9ERK/daUkcjPWYdiwh5dNVMc ozULqJB5zsZRzywx/ktawKVkCmGv2JSU2FYRV/dfDL1Sm2o+4J7fyYZjRiUu1dt7a5Wd /RY0Eb6uFRKP8syrkn1DjLBmZDcXUZH4EaA9Ixcuot0mWRuVg0qw2fBnruYTpc+ej8sr BAnF/B5HF3qC2rGiqcNjF9lFbJx8o6ylztLrEsRjdN7sbp++fHym41ikbvRuYpz5cLsU 9PvcypF63+6ETkaM3y9fCGz7Zoy6v5v8xvrSFgaVT3T7T/siI+DhE96vgZ/Em8JVc65J GvUQ== X-Gm-Message-State: AOAM533EUw39EEX0Jpxva5pGS4EobKwlAXjFWuQ+ATHijSo1RQ3bVVsb oLWxh36TrQ7ayqV3QtAFX+97y3+XjdjgEeH/+hJY60iGZfrs0/70CYTx+Ce8StI7PIQqcQLHU82 uTMejGAqzpKNtZYJQouIwiurU6+3DxLNySGLIr3/h5aRo5ccJ5ayOn9qtYwDCm2CdUDtn X-Received: by 2002:ac8:5a49:0:b0:2de:6fa3:f928 with SMTP id o9-20020ac85a49000000b002de6fa3f928mr19027302qta.677.1646127683633; Tue, 01 Mar 2022 01:41:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSXuP4bQLIYnSXTEYsbBiSCH2SGGw4JvQbsCyi2jZGrIDsSVU4e5Amm5SKjJU+mipGEMKVqA== X-Received: by 2002:ac8:5a49:0:b0:2de:6fa3:f928 with SMTP id o9-20020ac85a49000000b002de6fa3f928mr19027291qta.677.1646127683285; Tue, 01 Mar 2022 01:41:23 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id b1-20020a05622a020100b002de94100619sm8834067qtx.81.2022.03.01.01.41.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 01:41:22 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 03D695802B4; Tue, 1 Mar 2022 10:41:20 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH, applied] abilint --show-type-use: Show results for global decls that have no symbols Organization: Red Hat / France X-Operating-System: Fedora 36 X-URL: http://www.redhat.com Date: Tue, 01 Mar 2022 10:41:20 +0100 Message-ID: <87o82qj9hb.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" 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 . * 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 --- 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; }