[PATCH] D119470: [clang-tidy] Don't check decltype return types in `readability-const-return-type`

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 22 10:08:26 PST 2022


aaron.ballman added a comment.

In D119470#3312223 <https://reviews.llvm.org/D119470#3312223>, @Izaron wrote:

> I think we don't need to update the docs
> (https://clang.llvm.org/extra/clang-tidy/checks/readability-const-return-type.html)
> Because a user would expect this behaviour.
>
> //If this review is eventually approved, kindly please merge the commit on my behalf =) As I don't have merge access. My name is `Evgeny Shulgin` and email is `izaronplatz at gmail.com`. Sorry for inconvenience!//

You've submitted some quality patches already, would you be interested in obtaining commit privileges (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)?



================
Comment at: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:56-58
+AST_MATCHER(QualType, isLocalConstQualified) {
+  return Node.isLocalConstQualified();
+}
----------------
I think we might as well hit all the local qualifiers instead of just `const`, WDYT? e.g., `volatile` et al via `hasLocalQualifiers()`


================
Comment at: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:103
+  // qualified, ignoring decltype types.
+  const auto NonLocalConstDecltypeType = qualType(
+      unless(isLocalConstQualified()), anyOf(decltypeType(), autoType()));
----------------
We don't usually use top-level const qualification for locals.


================
Comment at: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:104
+  const auto NonLocalConstDecltypeType = qualType(
+      unless(isLocalConstQualified()), anyOf(decltypeType(), autoType()));
   Finder->addMatcher(
----------------
How about a `TypeOfType`? (The GCC `typeof(foo)` extension)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119470



More information about the cfe-commits mailing list