[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 16:12:25 PST 2020


njames93 marked 2 inline comments as done.
njames93 added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/readability-qualified-auto.cpp:183
+
+  auto LambdaTest = [] { return 0; };
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: 'auto LambdaTest' can be declared as 'auto *LambdaTest'
----------------
JonasToth wrote:
> njames93 wrote:
> > JonasToth wrote:
> > > How does that beatiful code-construct get handled?
> > > 
> > > ```
> > > auto * function_ptr = +[](int) {};
> > > ```
> > > The lambda is actually converted to a function pointer through the `+`-operator. Not sure this happens anywhere, but it can happen.
> > > So the case:
> > > ```
> > > auto unnotice_ptr = +[](int) {};
> > > ```
> > > should be transformed.
> > It gets handled the same as retty (*)(params), I should probably make function pointers in general not be converted
> Ok.
> There exist function references, too  `int (&my_reference) (int);` ( i think that was the syntax).
> They should then follow this as well (+ user-facing documentation).
You are right that there is a syntax like that, but if you try to bind one to an auto, it will decay to a pointer. If you bind one to an auto reference, then it will be just like the reference syntax above. In either case this won't trigger any replacements


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72217/new/

https://reviews.llvm.org/D72217





More information about the cfe-commits mailing list