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

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 10 09:13:48 PST 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from nits



================
Comment at: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp:83
+    return llvm::None;
+  } else if (TypeSpecifier.getEnd().getLocWithOffset(1) ==
+             ConstToken.getLocation()) {
----------------
Can drop the `else` after `return`.


================
Comment at: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp:99
+  QualType Pointee =
+      dyn_cast<AutoType>(QType->getPointeeType().getTypePtr())->desugar();
+  assert(!Pointee.isNull() && "can't have a null Pointee");
----------------
`dyn_cast<>` can return null, but you don't check for null here. Should this be using `cast<>` or should  it be checking for null?


================
Comment at: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp:169-175
+        if (!Token || Token->getLocation().isMacroID()) {
+          return true; // Disregard this VarDecl.
+        }
+        if (llvm::Optional<SourceRange> Result =
+                mergeReplacementRange(TypeSpecifier, *Token)) {
+          RemoveQualifiersRange.push_back(*Result);
+        }
----------------
Elide braces. (Same elsewhere in the patch)


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:6
+
+Adds pointer and const qualifications to auto typed variables  that are deduced
+to pointers and const pointers.
----------------
Extra whitespace between `variables` and `that`.
auto typed -> `auto`-typed (with backticks and hyphen)


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst:9
+`LLVM Coding Standards <https://llvm.org/docs/CodingStandards.html>`_ advises to
+make it obvious if a auto typed variable is a pointer, constant pointer or 
+constant reference. This check will transform ``auto`` to ``auto *`` when the 
----------------
a auto typed -> an `auto`-typed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217





More information about the cfe-commits mailing list