Open Bug 1443448 Opened 6 years ago Updated 2 years ago

[clang-tidy] Disallow non-empty inline virtual methods

Categories

(Developer Infrastructure :: Source Code Analysis, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: jwatt, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: memory-footprint)

Chromium has a checker for this:

https://www.chromium.org/developers/coding-style/chromium-style-checker-errors#TOC-Virtual-Method-Out-of-lining

It seems like they got good code size reductions. See the comments on:

https://codereview.chromium.org/5741001/

for example.
See Also: → 1443451
Version: Version 3 → Trunk
I wonder if they'd be willing to convert it to clang-tidy and upstream it?
As the code is right now, there must be some fundamental modifications in order to upstream it to clang-tidy, because the current analysis doesn't use a matcher to match a 'CXXFuncDecl' inside a 'CXXRecordDecl', it still relies on hooking up on a ASTConsumer that's why they used the clang-plugin architecture. 
TBH I'm not even sure that the code exists in the latest revisions of that folder.
While not quite the same warning, clang's -Wweak-vtable flag can report when a class's virtual functions are all inline. Without a "home" translation unit for the class's out-of-line vtable, a duplicate vtable will be emitted in every translation unit that references the class. This warning is very noisy.

https://clang.llvm.org/docs/DiagnosticsReference.html#wweak-vtables
Product: Firefox Build System → Developer Infrastructure
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.