Index: test/clang-tidy/readability-container-size-empty.cpp =================================================================== --- test/clang-tidy/readability-container-size-empty.cpp +++ test/clang-tidy/readability-container-size-empty.cpp @@ -17,6 +17,7 @@ bool operator!=(const char *) const; basic_string operator+(const basic_string& other) const; unsigned long size() const; + unsigned long length() const; bool empty() const; }; @@ -106,9 +107,13 @@ std::string str2; std::wstring wstr; (void)(str.size() + 0); + (void)(str.length() + 0); (void)(str.size() - 0); + (void)(str.length() - 0); (void)(0 + str.size()); + (void)(0 + str.length()); (void)(0 - str.size()); + (void)(0 - str.length()); if (intSet.size() == 0) ; // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] @@ -125,10 +130,14 @@ // CHECK-FIXES: {{^ }}if (s_func().empty()){{$}} if (str.size() == 0) ; + if (str.length() == 0) + ; // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used // CHECK-FIXES: {{^ }}if (str.empty()){{$}} if ((str + str2).size() == 0) ; + if ((str + str2).length() == 0) + ; // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used // CHECK-FIXES: {{^ }}if ((str + str2).empty()){{$}} if (str == "") @@ -141,6 +150,8 @@ // CHECK-FIXES: {{^ }}if ((str + str2).empty()){{$}} if (wstr.size() == 0) ; + if (wstr.length() == 0) + ; // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used // CHECK-FIXES: {{^ }}if (wstr.empty()){{$}} if (wstr == "")