Index: clang-tidy/modernize/LoopConvertUtils.cpp =================================================================== --- clang-tidy/modernize/LoopConvertUtils.cpp +++ clang-tidy/modernize/LoopConvertUtils.cpp @@ -368,8 +368,14 @@ break; } - case Stmt::CXXMemberCallExprClass: - return true; + case Stmt::CXXMemberCallExprClass: { + const auto *MemCall = cast(Init); + if (MemCall->getMethodDecl()->getName() == "at") { + assert(MemCall->getNumArgs() == 1); + return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar); + } + return false; + } default: break; Index: test/clang-tidy/modernize-loop-convert-extra.cpp =================================================================== --- test/clang-tidy/modernize-loop-convert-extra.cpp +++ test/clang-tidy/modernize-loop-convert-extra.cpp @@ -207,11 +207,17 @@ for (dependent::iterator it = dep.begin(), e = dep.end(); it != e; ++it) { printf("%d\n", *it); const int& idx = other[0]; + unsigned othersize = other.size(); } - // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead + // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead // CHECK-FIXES: for (auto & elem : dep) // CHECK-FIXES-NEXT: printf("%d\n", elem); // CHECK-FIXES-NEXT: const int& idx = other[0]; + // CHECK-FIXES-NEXT: unsigned othersize = other.size(); + + for (int i = 0, e = dep.size(); i != e; ++i) { + int idx = other.at(i); + } } } // namespace NamingAlias