[PATCH] D61749: [clang-tidy] initial version of readability-static-const-method

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 13 11:31:52 PDT 2019


JonasToth added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/readability-static-const-method.cpp:209
+void KeepLambdas() {
+  auto F = +[]() { return 0; };
+  auto F2 = []() { return 0; };
----------------
mgehre wrote:
> JonasToth wrote:
> > Does it pass here?
> > I looks a bit weird, shouldnt the lambda be called for this to work (this is the unary + right?)?
> https://stackoverflow.com/questions/18889028/a-positive-lambda-what-sorcery-is-this
Thank you C++ for showing my simple mindedness all the time :D
Its fine then and I will keep it in my mind for future test cases I check against ;)


================
Comment at: clang-tools-extra/test/clang-tidy/readability-static-const-method.cpp:312
+    return const_cast<DataPattern *>(this)->get();
+  }
+
----------------
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.


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