[PATCH] D61749: [clang-tidy] initial version of readability-static-const-method
Matthias Gehre via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 13 14:33:23 PDT 2019
mgehre marked 17 inline comments as done.
mgehre added inline comments.
================
Comment at: clang-tools-extra/test/clang-tidy/readability-static-const-method.cpp:312
+ return const_cast<DataPattern *>(this)->get();
+ }
+
----------------
JonasToth wrote:
> mgehre wrote:
> > JonasToth wrote:
> > > I think more template tests wouldn't hurt. From the other checks experience I can safely say we got burned a few times :)
> > > Instantiating the templates with builtin arrays, pointers, references and different qualifiers usually produces interesting test cases as well, that need to be handled properly.
> > >
> > > Another thing that comes to mind with templates are overloaded operators.
> > > ```
> > > template <class Foo>
> > > void bar() {
> > > Foo x1, x2;
> > > Foo y = x1 + x2;
> > > }
> > > ```
> > > Builtins are not changed by `operator+` but that can not be said about other types in general (maybe with concepts used properly).
> > The check only checks templates instantiations (so we will see no template parameters, just ordinary types). The plus here will be be function call in the AST of the instantiation when Foo has an overloaded operator+.
> > The current version will never propose to make bar() const when a method on `this` is called.
> > I can add the test to show this.
> Yes please add a test to show they are not analyzed.
I will now restrict this PR to the `static` part of the check, and I fail to come up with an example where operators could make a static looking function non-static.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61749/new/
https://reviews.llvm.org/D61749
More information about the cfe-commits
mailing list