Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

readability-static-accessed-through-instance fails to diagnose calls to member functions with out-of-class inline definitions #51486

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52519
Status NEW
Importance P enhancement
Reported by Simon Giesecke (simon.giesecke@gmail.com)
Reported on 2021-11-16 01:22:02 -0800
Last modified on 2021-11-16 01:22:02 -0800
Version unspecified
Hardware PC All
CC alexfh@google.com, djasper@google.com, klimek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

The readability-static-accessed-through-instance clang-tidy check fails to diagnose calls to member functions with out-of-class inline definitions.

A rather minimal example is on https://godbolt.org/z/8aT6xqqbx:

class Foo final { public: static Foo& getInstance(); static int getBar(); };

inline int Foo::getBar() { return 42; }

int main() { auto& params = Foo::getInstance();

params.getBar();

}

There's no clang-tidy diagnostic reported here. Note that when moving the definition of getBar into the class, a diagnostic will be reported.