This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG1fdb3e36ff37: abseil-string-find-str-contains should not propose an edit for the three… (authored by tdl-g, committed by ymandel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D107837/new/ https://reviews.llvm.org/D107837 Files: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp Index: clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp +++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp @@ -15,6 +15,7 @@ ~basic_string(); int find(basic_string s, int pos = 0); int find(const C *s, int pos = 0); + int find(const C *s, int pos, int n); int find(char c, int pos = 0); static constexpr size_t npos = -1; }; @@ -30,6 +31,7 @@ ~basic_string_view(); int find(basic_string_view s, int pos = 0); int find(const C *s, int pos = 0); + int find(const C *s, int pos, int n); int find(char c, int pos = 0); static constexpr size_t npos = -1; }; @@ -48,6 +50,7 @@ ~string_view(); int find(string_view s, int pos = 0); int find(const char *s, int pos = 0); + int find(const char *s, int pos, int n); int find(char c, int pos = 0); static constexpr size_t npos = -1; }; @@ -263,6 +266,18 @@ asv.find("a", 3) == std::string_view::npos; } +// Confirms that it does not match when the count parameter is present. +void no_count() { + std::string ss; + ss.find("a", 0, 1) == std::string::npos; + + std::string_view ssv; + ssv.find("a", 0, 1) == std::string_view::npos; + + absl::string_view asv; + asv.find("a", 0, 1) == std::string_view::npos; +} + // Confirms that it does not match when it's compared to something other than // npos, even if the value is the same as npos. void no_non_npos() { Index: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp +++ clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp @@ -53,7 +53,7 @@ to(varDecl(hasName("npos"), hasDeclContext(StringLikeClass)))); auto StringFind = cxxMemberCallExpr( callee(cxxMethodDecl( - hasName("find"), + hasName("find"), parameterCountIs(2), hasParameter( 0, parmVarDecl(anyOf(hasType(StringType), hasType(CharStarType), hasType(CharType)))))),
Index: clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp +++ clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp @@ -15,6 +15,7 @@ ~basic_string(); int find(basic_string s, int pos = 0); int find(const C *s, int pos = 0); + int find(const C *s, int pos, int n); int find(char c, int pos = 0); static constexpr size_t npos = -1; }; @@ -30,6 +31,7 @@ ~basic_string_view(); int find(basic_string_view s, int pos = 0); int find(const C *s, int pos = 0); + int find(const C *s, int pos, int n); int find(char c, int pos = 0); static constexpr size_t npos = -1; }; @@ -48,6 +50,7 @@ ~string_view(); int find(string_view s, int pos = 0); int find(const char *s, int pos = 0); + int find(const char *s, int pos, int n); int find(char c, int pos = 0); static constexpr size_t npos = -1; }; @@ -263,6 +266,18 @@ asv.find("a", 3) == std::string_view::npos; } +// Confirms that it does not match when the count parameter is present. +void no_count() { + std::string ss; + ss.find("a", 0, 1) == std::string::npos; + + std::string_view ssv; + ssv.find("a", 0, 1) == std::string_view::npos; + + absl::string_view asv; + asv.find("a", 0, 1) == std::string_view::npos; +} + // Confirms that it does not match when it's compared to something other than // npos, even if the value is the same as npos. void no_non_npos() { Index: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp +++ clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp @@ -53,7 +53,7 @@ to(varDecl(hasName("npos"), hasDeclContext(StringLikeClass)))); auto StringFind = cxxMemberCallExpr( callee(cxxMethodDecl( - hasName("find"), + hasName("find"), parameterCountIs(2), hasParameter( 0, parmVarDecl(anyOf(hasType(StringType), hasType(CharStarType), hasType(CharType)))))),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits