[PATCH] D140760: [clang-tidy] Support begin/end free functions in modernize-loop-convert

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 4 13:31:33 PDT 2023


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

LGTM, things that are missing:

- some crash protection (getName)
- test for rbegin/rend



================
Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:333
 
+enum IteratorCallKind {
+  ICK_Member,
----------------
if we can, please use enum class


================
Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:363
+      return ContainerCall{TheCall->getImplicitObjectArgument(),
+                           Member->getMemberDecl()->getName(),
+                           Member->isArrow(), CallKind};
----------------
would be nice to verify if we got "name" here, same in other places


================
Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:940
+        return false;
+    } else
+      return Nodes.getNodeAs<CallExpr>(EndCallName) != nullptr;
----------------
no need for else after return


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-basic.cpp:484
 }
 
 // Tests to verify the proper use of auto where the init variable type and the
----------------
Please add test with rbegin/rend


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140760



More information about the cfe-commits mailing list