[PATCH] D96222: [clang-tidy] Simplify redundant smartptr get check

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 15 14:33:28 PST 2021


njames93 added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp:21-45
+  return expr(
+             anyOf(cxxMemberCallExpr(
+                       on(expr(anyOf(hasType(OnClass),
+                                     hasType(qualType(pointsTo(
+                                         decl(OnClass).bind("ptr_to_ptr"))))))
+                              .bind("smart_pointer")),
+                       unless(callee(
----------------
The patch says its simplifying the check, but this doesn't look like its simplifying it. Seems to be extending it to support dependent members.


================
Comment at: clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp:158
 
+  auto SR = GetCall->getSourceRange();
+  // CXXDependentScopeMemberExpr source range does not include parens
----------------
nit: Spell out the type.


================
Comment at: clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp:161
+  // Extend the source range of the get call to account for them.
+  if (isa<CXXDependentScopeMemberExpr>(GetCall)) {
+    SR.setEnd(Lexer::getLocForEndOfToken(SR.getEnd(), 0, *Result.SourceManager,
----------------
nit: Elide braces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96222



More information about the cfe-commits mailing list