From patchwork Thu Jun 4 10:32:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 39471 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 4C1663851C27; Thu, 4 Jun 2020 10:32:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C1663851C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591266770; bh=Z4zVjjbLLr82ia5dXDTQ81ekYVJbGTclGGckFVg+XIo=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=tURZwyIbqjSgP8dj4z3AR4RAUjEkzvVeu7EmEkURqRatldrVQRT+o6RD9I/HV31d7 wyow0TNdXbl9TGIbL6dMB2bY/H3+eaX/LcNmyLBLXb0fPodAVKpuKgxgCrugsiBIEV fBiZkycWnyQTOFrJtlzyQ3VzadQOlnsrEhHDkGcI= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by sourceware.org (Postfix) with ESMTPS id 98A923851C27 for ; Thu, 4 Jun 2020 10:32:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 98A923851C27 Received: by mail-qt1-x84a.google.com with SMTP id e8so4552551qtq.22 for ; Thu, 04 Jun 2020 03:32:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Z4zVjjbLLr82ia5dXDTQ81ekYVJbGTclGGckFVg+XIo=; b=KaKHbiIvXXM6EkuIsIBdzB/yDhOvlO0jXZ6n73RsU14g+3B9YXF4KTcsu1LppASAQB ulqXnBLJLbIy2TdxsprgjaXz/Ajf5OzZ4kakJCRbad808UtXwLkDkyd6SKT/WWWIDPoj rieWLlAH2Wjk8dhueuErXnJKwxf4f7K4KzyEtc8clOH6DdrlmN3jgjhj7EkbAQviZ1R9 2q+ma9PaEYgKFX7WjQ2hi/fjScjHULLElGy8C1dgqI5EVFbRGK7cTIxAFn7mhLivBTkZ Y49M5D8cwXa00D0VMhk7x3lifTxQuzcJHFZH0++nIBsS7++bz33lYlGAjhHhM+g+wM6i bUaw== X-Gm-Message-State: AOAM530gzi8OC7IbFu8KD/kOAR7vkraENQsp/ITHRJFAUfBiBpn8/v3q QbuLOs/dzGYN1Fa5z/cgCGk0QOz7XtyQY+mlKuX0BCbTTVH6r/yKSCIH0K9g/IOynXY26a+HGqc Xs6jMnEdbx/H53zWj5mG/B7NBVmc02iotnwBsXCaUmXKocgdcxF/2PdQ0miELZiVhgFUUDOU= X-Google-Smtp-Source: ABdhPJwmZJclEVBejsFeLf7T7wzVMNqrxZRKJH3V5qeUmvjUJ/9bYmFlyEGrCq42JmP12C0J3imCsrdCxY/+Pw== X-Received: by 2002:a0c:9091:: with SMTP id p17mr4192733qvp.158.1591266766043; Thu, 04 Jun 2020 03:32:46 -0700 (PDT) Date: Thu, 4 Jun 2020 12:32:37 +0200 Message-Id: <20200604103237.53270-1-maennich@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.27.0.rc2.251.g90737beb825-goog Subject: [PATCH] dwarf-reader: get_die_source: always initialize return value To: libabigail@sourceware.org X-Spam-Status: No, score=-23.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Matthias Maennich via Libabigail From: =?utf-8?q?Matthias_M=C3=A4nnich?= Reply-To: Matthias Maennich Cc: maennich@google.com, gprocida@google.com, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" GCC9 with ABIGAIL_DEVEL=1 and ABIGAIL_DEBUG=1 set, regularly emits -Werror=maybe-uninitialized for the values gathered by get_die_source. As a counter measure, some of them were initialized before the call to NO_DEBUG_INFO_DIE_SOURCE, but not all of them, leading to said warning. In order to overcome this, let get_die_source always initialize the source to NO_DEBUG_INFO_DIE_SOURCE and adjust the caller to consistently not do that anymore. This solves the warning and maybe but unlikely (due to the ABG_ASSERT) avoids some UB. * src/abg-dwarf-reader.cc (read_context::get_die_source): Always initialize die_source. (read_context::ContainerType::get_container): Fix initialization of die_source. (read_context::compute_canonical_die): Likewise. (read_context::get_canonical_die): Likewise. (read_context::get_or_compute_canonical_die): Likewise. (read_context::associate_die_to_decl): Likewise. (read_context::set_canonical_die_offset): Likewise. (read_context::schedule_type_for_late_canonicalization): Likewise. (read_context::compare_dies): Likewise. (read_context::get_parent_die): Likewise. (read_context::get_scope_for_die): Likewise. (read_context::add_or_update_union_type): Likewise. (read_context::maybe_canonicalize_type): Likewise. (read_context::build_ir_node_from_die): Likewise. Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 05130730d5ec..b3cffbb7a2dd 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2106,7 +2106,7 @@ public: ContainerType& get_container(const read_context& ctxt, const Dwarf_Die *die) { - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(ctxt.get_die_source(die, source)); return get_container(source); } @@ -2891,7 +2891,7 @@ public: Dwarf_Die &canonical_die, bool die_as_type) const { - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(get_die_source(die, source)); @@ -3130,7 +3130,7 @@ public: size_t where, bool die_as_type) const { - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(get_die_source(die, source)); offset_offset_map_type &canonical_dies = @@ -3248,6 +3248,7 @@ public: bool get_die_source(const Dwarf_Die *die, die_source &source) const { + source = NO_DEBUG_INFO_DIE_SOURCE; ABG_ASSERT(die); return get_die_source(*die, source); } @@ -3353,7 +3354,7 @@ public: size_t where_offset, bool do_associate_by_repr = false) { - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(get_die_source(die, source)); die_artefact_map_type& m = @@ -3981,7 +3982,7 @@ public: Dwarf_Off canonical_die_offset, bool die_as_type) const { - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(get_die_source(die, source)); Dwarf_Off die_offset = dwarf_dieoffset(const_cast(die)); @@ -4562,7 +4563,7 @@ public: schedule_type_for_late_canonicalization(const Dwarf_Die *die) { Dwarf_Off o; - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; Dwarf_Die equiv_die; ABG_ASSERT(get_canonical_die(die, equiv_die, @@ -11397,8 +11398,7 @@ compare_dies(const read_context& ctxt, Dwarf_Off l_offset = dwarf_dieoffset(const_cast(l)), r_offset = dwarf_dieoffset(const_cast(r)); Dwarf_Off l_canonical_die_offset = 0, r_canonical_die_offset = 0; - die_source l_die_source = NO_DEBUG_INFO_DIE_SOURCE, - r_die_source = NO_DEBUG_INFO_DIE_SOURCE; + die_source l_die_source, r_die_source; ABG_ASSERT(ctxt.get_die_source(l, l_die_source)); ABG_ASSERT(ctxt.get_die_source(r, r_die_source)); @@ -11847,8 +11847,7 @@ compare_dies(const read_context& ctxt, // // In case 'r' has no canonical DIE, then compute it, and then // propagate that canonical DIE to 'r'. - die_source l_source = NO_DEBUG_INFO_DIE_SOURCE, - r_source = NO_DEBUG_INFO_DIE_SOURCE; + die_source l_source, r_source; ABG_ASSERT(ctxt.get_die_source(l, l_source)); ABG_ASSERT(ctxt.get_die_source(r, r_source)); if (!l_has_canonical_die_offset @@ -12102,7 +12101,7 @@ get_parent_die(const read_context& ctxt, { ABG_ASSERT(ctxt.dwarf()); - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(ctxt.get_die_source(die, source)); const offset_offset_map_type& m = ctxt.die_parent_map(source); @@ -12238,7 +12237,7 @@ get_scope_for_die(read_context& ctxt, bool called_for_public_decl, size_t where_offset) { - die_source source_of_die = NO_DEBUG_INFO_DIE_SOURCE; + die_source source_of_die; ABG_ASSERT(ctxt.get_die_source(die, source_of_die)); if (is_c_language(ctxt.cur_transl_unit()->get_language())) @@ -13686,7 +13685,7 @@ add_or_update_union_type(read_context& ctxt, if (tag != DW_TAG_union_type) return result; - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(ctxt.get_die_source(die, source)); { die_class_or_union_map_type::const_iterator i = @@ -15777,7 +15776,7 @@ read_debug_info_into_corpus(read_context& ctxt) static void maybe_canonicalize_type(const Dwarf_Die *die, read_context& ctxt) { - die_source source = NO_DEBUG_INFO_DIE_SOURCE; + die_source source; ABG_ASSERT(ctxt.get_die_source(die, source)); size_t die_offset = dwarf_dieoffset(const_cast(die)); @@ -15990,7 +15989,7 @@ build_ir_node_from_die(read_context& ctxt, return result; } - die_source source_of_die = NO_DEBUG_INFO_DIE_SOURCE; + die_source source_of_die; ABG_ASSERT(ctxt.get_die_source(die, source_of_die)); if ((result = ctxt.lookup_decl_from_die_offset(dwarf_dieoffset(die),