From: Bruno Larsen <blarsen@redhat.com>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH] PR gdb/28480: Improve ambiguous member detection
Date: Fri, 5 Nov 2021 15:26:49 -0300 [thread overview]
Message-ID: <131933fc-d3f7-bd3c-a7a0-74d73eb22782@redhat.com> (raw)
In-Reply-To: <0e7f3dbb-ef25-9d60-42da-b01c57eb8efa@simark.ca>
On 11/5/21 14:54, Simon Marchi wrote:
> On 2021-11-04 5:04 p.m., Bruno Larsen via Gdb-patches wrote:
> snip
>> diff --git a/gdb/testsuite/gdb.cp/ambiguous.cc b/gdb/testsuite/gdb.cp/ambiguous.cc
>> index a55686547f2..b2be7297b28 100644
>> --- a/gdb/testsuite/gdb.cp/ambiguous.cc
>> +++ b/gdb/testsuite/gdb.cp/ambiguous.cc
>> @@ -1,3 +1,4 @@
>> +class empty { };
>>
>> class A1 {
>> public:
>> @@ -17,6 +18,11 @@ public:
>> int y;
>> };
>>
>> +class A4 {
>> +public:
>> + [[no_unique_address]] empty x;
>
> In theory, no_unique_address appeared in C++20. Having
> [[no_unique_address]] in the source code means that compiling this file
> with an older compiler that doesn't know about it, or in a standard mode
> where it isn't recognized, will lead to the entire test being skipped.
> In practice, it looks like older-but-not-too-old g++s cope well with it.
> For example, g++ 7 prints a warning:
>
> $ g++-7 ambiguous.cc
> ambiguous.cc:23:33: warning: ‘no_unique_address’ attribute directive ignored [-Wattributes]
> [[no_unique_address]] empty x;
> ^
>
> ... but since we disable all warnings in that tests for g++ < 10, then
> it still compiles. The no_unique_address attribute has no effect, but
> that's fine.
>
> With older g++s, like 4.8, it fails though:
>
> $ make check TESTS="gdb.cp/ambiguous.exp" RUNTESTFLAGS='CC_FOR_TARGET=gcc-4.8 CXX_FOR_TARGET=g++-4.8'
> ...
> Running /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.cp/ambiguous.exp ...
> Gdb compile failed, /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.cp/ambiguous.cc:23:5: error: expected unqualified-id before '[' token
> [[no_unique_address]] empty x;
> ^
>
> I don't know if others care about this test running with older
> compilers, but if so we could make that case optional with some
> preprocessor conditionals.
Alright, I'll wait and see if anyone says anything about this before pushing. I'll also address everything else you mentioned.
> snip
>> + {
>> + bool ambiguous = false, insert = true;
>> + for(auto finds: m_fields){
>
> Space before opening parentheses and after closing.
>
> Iterate using const-reference, to avoid copying the items as we are
> iterating. I would also use the type name instead of auto, for clarity,
> but I am ok with either. Lastly, the variable name "finds" is a bit
> strange, or I don't understand what you mean by it.
I first named it found_field, but I dont like naming variables the same as a class name, so I changed it to the plural of the noun "find". I'll rethink the variable name for sure.
>
>> + if(finds.path.back() != m_struct_path.back())
>> + {
>> + /* Same boffset points to members of different classes.
>> + We have found an ambiguity and should record it*/
>> + ambiguous = true;
>> + }
>> + else
>> + {
>> + /* we don't need to insert this value again, because a
>> + non-ambiguous path already leads to it */
>
> First letter capital, period + two spaces at the end.
>
> There are two lines above that have more than 8 spaces, that should be
> replaced with a tab. Most editors have a way to configure whitespaces
> to do that automatically.
>
>> + insert = false;
>
> Since this path makes it so that we'll definitely not insert, we can
> break the iteration.
Ah, good catch.
>
> Simon
>
Thanks for the review!
--
Cheers!
Bruno Larsen
prev parent reply other threads:[~2021-11-05 18:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 21:04 Bruno Larsen
2021-11-05 17:54 ` Simon Marchi
2021-11-05 18:26 ` Bruno Larsen [this message]
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=131933fc-d3f7-bd3c-a7a0-74d73eb22782@redhat.com \
--to=blarsen@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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).