Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Issue 667143003: Standardize usage of virtual/override/final in tools/gn/ (Closed)

Created:
6 years, 2 months ago by dcheng
Modified:
6 years, 2 months ago
CC:
chromium-reviews, tfarina
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Project:
chromium
Visibility:
Public.

Description

Standardize usage of virtual/override/final in tools/gn/ The Google C++ style guide states: Explicitly annotate overrides of virtual functions or virtual destructors with an override or (less frequently) final specifier. Older (pre-C++11) code will use the virtual keyword as an inferior alternative annotation. For clarity, use exactly one of override, final, or virtual when declaring an override. To better conform to these guidelines, the following constructs have been rewritten: - if a base class has a virtual destructor, then: virtual ~Foo(); -> ~Foo() override; - virtual void Foo() override; -> void Foo() override; - virtual void Foo() override final; -> void Foo() final; This patch was automatically generated. The clang plugin can generate fixit hints, which are suggested edits when it is 100% sure it knows how to fix a problem. The hints from the clang plugin were applied to the source tree using the tool in https://codereview.chromium.org/598073004. BUG=417463 R=brettw@chromium.org

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+108 lines, -114 lines) Patch
M tools/gn/action_target_generator.h View 1 chunk +1 line, -1 line 3 comments Download
M tools/gn/binary_target_generator.h View 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/builder_unittest.cc View 2 chunks +7 lines, -11 lines 0 comments Download
M tools/gn/config.h View 1 chunk +3 lines, -3 lines 0 comments Download
M tools/gn/copy_target_generator.h View 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/group_target_generator.h View 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/loader.h View 2 chunks +7 lines, -8 lines 0 comments Download
M tools/gn/ninja_action_target_writer.h View 1 chunk +2 lines, -2 lines 0 comments Download
M tools/gn/ninja_binary_target_writer.h View 1 chunk +2 lines, -2 lines 0 comments Download
M tools/gn/ninja_copy_target_writer.h View 1 chunk +2 lines, -2 lines 0 comments Download
M tools/gn/ninja_group_target_writer.h View 1 chunk +2 lines, -2 lines 0 comments Download
M tools/gn/ninja_target_writer_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M tools/gn/parse_tree.h View 11 chunks +66 lines, -66 lines 0 comments Download
M tools/gn/scope_per_file_provider.h View 1 chunk +1 line, -2 lines 0 comments Download
M tools/gn/setup.h View 3 chunks +4 lines, -4 lines 0 comments Download
M tools/gn/target.h View 1 chunk +4 lines, -4 lines 0 comments Download
M tools/gn/toolchain.h View 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 8 (2 generated)
dcheng
6 years, 2 months ago (2014-10-21 20:56:29 UTC) #1
brettw
lgtm
6 years, 2 months ago (2014-10-21 21:03:27 UTC) #2
Peter Kasting
This seems to overlap with https://codereview.chromium.org/643063004/ . The comment below is only from looking at ...
6 years, 2 months ago (2014-10-21 22:47:51 UTC) #4
dcheng
https://codereview.chromium.org/667143003/diff/1/tools/gn/action_target_generator.h File tools/gn/action_target_generator.h (right): https://codereview.chromium.org/667143003/diff/1/tools/gn/action_target_generator.h#newcode19 tools/gn/action_target_generator.h:19: virtual ~ActionTargetGenerator(); On 2014/10/21 22:47:51, Peter Kasting wrote: > ...
6 years, 2 months ago (2014-10-21 22:57:15 UTC) #5
viettrungluu
https://codereview.chromium.org/667143003/diff/1/tools/gn/action_target_generator.h File tools/gn/action_target_generator.h (right): https://codereview.chromium.org/667143003/diff/1/tools/gn/action_target_generator.h#newcode19 tools/gn/action_target_generator.h:19: virtual ~ActionTargetGenerator(); On 2014/10/21 22:57:15, dcheng wrote: > On ...
6 years, 2 months ago (2014-10-22 00:42:14 UTC) #7
dcheng
6 years, 2 months ago (2014-10-22 00:47:10 UTC) #8
On 2014/10/22 at 00:42:14, viettrungluu wrote:
>
https://codereview.chromium.org/667143003/diff/1/tools/gn/action_target_gener...
> File tools/gn/action_target_generator.h (right):
> 
>
https://codereview.chromium.org/667143003/diff/1/tools/gn/action_target_gener...
> tools/gn/action_target_generator.h:19: virtual ~ActionTargetGenerator();
> On 2014/10/21 22:57:15, dcheng wrote:
> > On 2014/10/21 22:47:51, Peter Kasting wrote:
> > > Shouldn't this be "override" instead of "virtual"?
> > 
> > Yeah. I'm not sure why, but the plugin is currently missing some cases. =/
> > 
> > I'm going to be investigating this--I'm guessing one of the early returns is
> > somehow getting triggered, but I'm not yet sure how.
> 
> It's not missing it: the base class's dtor isn't virtual, so this is really a
bug in the code.
> 
> (Quite possibly, we should have a warning/error when a subclass has a virtual
dtor but the superclass doesn't.[*])
> 
> [*] At least when the superclass has an explicitly-declared dtor. Sometimes we
declare interfaces without providing dtors, which is somewhat debatable.[**]
> 
> [**] Arguably, in such cases, the interface should have a protected, but
possibly non-virtual dtor.

I think you're right in this instance, but
https://codereview.chromium.org/665323004 also had some instances where it
appears the plugin missed stuff.

(Also I don't plan on committing this patch. Given the size of the original
patch, I didn't want to bother with fixing up OVERRIDE/FINAL, while it looks
like your patch updates them as well.)

Powered by Google App Engine
This is Rietveld 408576698