From: Trevor Saunders <tbsaunde@tbsaunde.org>
To: David Malcolm <dmalcolm@redhat.com>
Cc: Jeff Law <law@redhat.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [committed][PATCH] Convert sprintf warning code to a dominator walk
Date: Mon, 30 Oct 2017 02:03:00 -0000 [thread overview]
Message-ID: <20171030014110.bwvmymber564n7n7@ball> (raw)
In-Reply-To: <1509127439.15469.16.camel@redhat.com>
On Fri, Oct 27, 2017 at 02:03:59PM -0400, David Malcolm wrote:
> On Fri, 2017-10-27 at 10:55 -0600, Jeff Law wrote:
> > Prereq for eventually embedding range analysis into the sprintf
> > warning
> > pass. The only thing that changed since the original from a few days
> > ago was the addition of FINAL OVERRIDE to the before_dom_children
> > override function.
> >
> > Re-bootstrapped and regression tested on x86.
> >
> > Installing on the trunk. Final patch attached for archival purposes.
> >
> >
> > Jeff
>
> Sorry to be re-treading the FINAL/OVERRIDE stuff, but...
>
> [...snip...]
>
> > +class sprintf_dom_walker : public dom_walker
> > +{
> > + public:
> > + sprintf_dom_walker () : dom_walker (CDI_DOMINATORS) {}
> > + ~sprintf_dom_walker () {}
> > +
> > + virtual edge before_dom_children (basic_block) FINAL OVERRIDE;
>
> Is it just me, or is it a code smell to have both "virtual" and
> "final"/"override" on a decl?
fwiw I'm of the opinion that all decls of a virtual function should be
marked as virtual including ones also marked as final or override.
> In particular, AIUI:
> "virtual" says: "some subclass might override this method"
I'd say virtual means that the function is generally called through a
vtable not directly, and that it may be overriding a super class method
and / or allow subclasses to override this function.
> "final" says: "no subclass will override this method"
>
> so having both seems contradictory.
I guess that depends on how you interpret virtual.
> If sprintf_dom_walker is providing a implementation of a vfunc of
> dom_walker, then presumably this should just lose the "virtual" on the
> subclass, it's presumably already got the "virtual" it needs in the
> base class.
Its certainly not necessary, but I think its good to be explicit.
Especially if you mark the class as final instead of individual methods
it isn't obvious the method gets called indirectly without checking
the parent classes for declarations.
Trev
>
>
> Dave
prev parent reply other threads:[~2017-10-30 1:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 17:16 Jeff Law
2017-10-27 18:10 ` David Malcolm
2017-10-27 21:10 ` Jeff Law
2017-10-30 2:03 ` Trevor Saunders [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=20171030014110.bwvmymber564n7n7@ball \
--to=tbsaunde@tbsaunde.org \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
/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).