From: Matthias Maennich <maennich@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, gprocida@google.com, kernel-team@android.com,
maennich@google.com
Subject: [PATCH] dwarf-reader: get_die_source: always initialize return value
Date: Thu, 4 Jun 2020 12:32:37 +0200 [thread overview]
Message-ID: <20200604103237.53270-1-maennich@google.com> (raw)
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 <maennich@google.com>
---
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<Dwarf_Die*>(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<Dwarf_Die*>(l)),
r_offset = dwarf_dieoffset(const_cast<Dwarf_Die*>(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<Dwarf_Die*>(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),
--
2.27.0.rc2.251.g90737beb825-goog
next reply other threads:[~2020-06-04 10:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 10:32 Matthias Maennich [this message]
2020-06-11 13:22 ` [PATCH v2] " Matthias Maennich
2020-06-15 8:53 ` Dodji Seketeli
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=20200604103237.53270-1-maennich@google.com \
--to=maennich@google.com \
--cc=dodji@seketeli.org \
--cc=gprocida@google.com \
--cc=kernel-team@android.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).