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

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 9 10:45:52 PDT 2018


Eugene.Zelenko added a comment.

GCC has -Wignored-qualifiers for long time, so may be better to implement it in Clang?



================
Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:66
+  llvm::Optional<SourceLocation> Loc = findConstToRemove(Def, Result);
+  if (!Loc) return;
+  DiagnosticBuilder Diagnostics = diag(*Loc,
----------------
Please split in two lines.


================
Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:74
+  // associate all fixes with the definition.
+  for (auto *Decl = Def->getPreviousDecl(); Decl != nullptr;
+       Decl = Decl->getPreviousDecl()) {
----------------
Please don't use auto, because type is not deducible from statement and it's not iterator over container.


================
Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`readability-const-value-return
+  <clang-tidy/checks/readability-const-value-return>` check.
----------------
Please use alphabetical order for list of new checks.


================
Comment at: docs/ReleaseNotes.rst:64
+  Checks for functions with a ``const``-qualified return type and recommends
+  removal of the `const` keyword.  Such use of ``const`` is superfluous, and
+  prevents valuable compiler optimizations.
----------------
Please enclose const in ``.

Once sentence is enough for Release Notes.


================
Comment at: docs/clang-tidy/checks/readability-const-value-return.rst:7
+Checks for functions with a ``const``-qualified return type and recommends
+removal of the `const` keyword.  Such use of ``const`` is superfluous, and
+prevents valuable compiler optimizations.
----------------
Please enclose const in ``.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025





More information about the cfe-commits mailing list