Index: clang-tidy/modernize/LoopConvertUtils.cpp =================================================================== --- clang-tidy/modernize/LoopConvertUtils.cpp +++ clang-tidy/modernize/LoopConvertUtils.cpp @@ -391,8 +391,8 @@ // This check is needed because getMethodDecl can return nullptr if the // callee is a member function pointer. const auto *MDecl = MemCall->getMethodDecl(); - if (MDecl && !isa(MDecl) && MDecl->getName() == "at") { - assert(MemCall->getNumArgs() == 1); + if (MDecl && !isa(MDecl) && MDecl->getName() == "at" && + MemCall->getNumArgs() == 1) { return isIndexInSubscriptExpr(MemCall->getArg(0), IndexVar); } return false; Index: test/clang-tidy/Inputs/modernize-loop-convert/structures.h =================================================================== --- test/clang-tidy/Inputs/modernize-loop-convert/structures.h +++ test/clang-tidy/Inputs/modernize-loop-convert/structures.h @@ -98,6 +98,7 @@ ElemType & operator[](unsigned); const ElemType & operator[](unsigned) const; ElemType & at(unsigned); + ElemType & at(unsigned, unsigned); const ElemType & at(unsigned) const; // Intentionally evil. 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 @@ -251,8 +251,16 @@ // CHECK-FIXES-NEXT: const int& Idx = Other[0]; // CHECK-FIXES-NEXT: unsigned Othersize = Other.size(); + for (int i = 0; i < Other.size(); ++i) { + Other.at(i); + } + // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead + // CHECK-FIXES: for (int & i : Other) + // CHECK-FIXES: i; + for (int I = 0, E = Dep.size(); I != E; ++I) { int Idx = Other.at(I); + Other.at(I, I); // Should not trigger assert failure. } }