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

Issue 1493813003: Convert the no-inline-virtuals rule into a constructors rule.

Created:
5 years ago by Jeffrey Yasskin
Modified:
4 years, 9 months ago
Reviewers:
Nico, dcheng
CC:
cbentzel+watch_chromium.org, cc-bugs_chromium.org, chromium-apps-reviews_chromium.org, chromium-reviews, danakj, darin-cc_chromium.org, extensions-reviews_chromium.org, jam, jbroman, rjkroege, scheib+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@lkcr
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Convert the no-inline-virtuals rule into a constructors rule. Inline virtual functions are now allowed, but if a class has too many of them, it needs an out-of-line constructor. This was discussed in https://groups.google.com/a/chromium.org/d/topic/chromium-dev/rdF1mT3V_PM/discussion. This change currently includes base classes in counting inline virtuals, but that'll make it easier to break derived classes by changing their bases. If folks are annoyed, we could revert that part (change getFinalOverriders into methods()), at the cost of reducing the accuracy of the check. CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel BUG=565523

Patch Set 1 #

Patch Set 2 : Add a flag, and make this patch just the plugin change. #

Patch Set 3 : Count longer inline virtuals as costing more object size. #

Patch Set 4 : Skip deleted constructors. #

Patch Set 5 : Fix a bug where long inheritance chains counted as expensive inline virtuals. #

Patch Set 6 : Rebase onto https://codereview.chromium.org/1504033010 #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+237 lines, -116 lines) Patch
M tools/clang/plugins/FindBadConstructsAction.cpp View 1 2 3 4 5 1 chunk +4 lines, -0 lines 0 comments Download
M tools/clang/plugins/FindBadConstructsConsumer.h View 1 chunk +1 line, -3 lines 0 comments Download
M tools/clang/plugins/FindBadConstructsConsumer.cpp View 1 2 3 4 7 chunks +79 lines, -41 lines 2 comments Download
M tools/clang/plugins/Options.h View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M tools/clang/plugins/tests/base_refcounted.h View 1 chunk +1 line, -0 lines 0 comments Download
M tools/clang/plugins/tests/overridden_methods.h View 1 chunk +1 line, -0 lines 0 comments Download
M tools/clang/plugins/tests/overridden_methods.txt View 1 chunk +10 lines, -10 lines 0 comments Download
M tools/clang/plugins/tests/test.sh View 1 2 3 4 5 1 chunk +2 lines, -0 lines 1 comment Download
M tools/clang/plugins/tests/virtual_bodies.h View 1 2 3 4 1 chunk +119 lines, -29 lines 2 comments Download
M tools/clang/plugins/tests/virtual_bodies.cpp View 1 2 1 chunk +6 lines, -29 lines 0 comments Download
M tools/clang/plugins/tests/virtual_bodies.txt View 1 2 1 chunk +13 lines, -4 lines 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 14 (9 generated)
Jeffrey Yasskin
https://codereview.chromium.org/1499003003 enables the flag. https://codereview.chromium.org/1499793003 shows some of the code that needs fixing. This currently ...
5 years ago (2015-12-04 03:37:39 UTC) #7
Jeffrey Yasskin
PTAL. If you accept this, I'll also change the Chromium style guide and inlining guide ...
5 years ago (2015-12-16 22:22:28 UTC) #8
danakj
proxy ping :)
4 years, 9 months ago (2016-03-11 21:36:57 UTC) #10
danakj
Maybe Daniel can review?
4 years, 9 months ago (2016-03-14 21:22:09 UTC) #13
dcheng
4 years, 9 months ago (2016-03-24 17:37:25 UTC) #14
https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/Fi...
File tools/clang/plugins/FindBadConstructsConsumer.cpp (right):

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/Fi...
tools/clang/plugins/FindBadConstructsConsumer.cpp:104: bool IsLeafClass(const
CXXRecordDecl& record) {
How accurate is this heuristic for determining leafiness? What were the results
when you built Chromium with your plugin changes active?

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/Fi...
tools/clang/plugins/FindBadConstructsConsumer.cpp:328: for (const
std::pair<const CXXMethodDecl*, OverridingMethods>& method :
Another way to write this might be to iterate over CXXRecordDecl::methods():
would doing that instead work here? I don't think we'd need the deduping set in
that case, and we can use CXXMethodDecl::size_overridden_methods() to determine
if it's an override or not.

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/te...
File tools/clang/plugins/tests/test.sh (right):

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/te...
tools/clang/plugins/tests/test.sh:46: flags="${flags} -Xclang
-plugin-arg-find-bad-constructs \
You might need to rebase this, since I ported the tests over to Python for
Windows coverage.

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/te...
File tools/clang/plugins/tests/virtual_bodies.h (right):

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/te...
tools/clang/plugins/tests/virtual_bodies.h:47: // Should not warn if enough
virtual methods are out-of-line.
Nit: I find this comment a bit confusing because the check is actually
implemented as # of inline virtuals > some complexity limit, and not (directly)
a count of the number of out-of-lined virtuals.

https://codereview.chromium.org/1493813003/diff/100001/tools/clang/plugins/te...
tools/clang/plugins/tests/virtual_bodies.h:92: // Complain about the inline
destructor.
Nit: non-virtual inline

Powered by Google App Engine
This is Rietveld 408576698