[PATCH] D53025: [clang-tidy] implement new check for const return types.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 12 11:04:31 PDT 2018


ymandel marked 5 inline comments as done.
ymandel added inline comments.


================
Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:60
+    diag(Def->getInnerLocStart(),
+         "return type is 'const'-qualifed (possibly behind a type alias), "
+         "which hinders compiler optimizations");
----------------
JonasToth wrote:
> This diagnostic is nice, but including the type would make it even better. This will resolve typedefs as well (like "'uint32_t (a.k.a. 'unsigned int')").
> 
> Necessary code (more info in the cfe-internals manual)
> ```
> diag(Location, "return type %0 is 'const'-qualified hindering compiler optimizations") << Def->getReturnType();
> ```
> The value passed in with `<<` must be a `QualType`.
> Also diagnostics don't have punctuation and are not full sentences and should be as short as possible (but still clear).
Thanks, this is a significant improvement.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025





More information about the cfe-commits mailing list