[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 15 18:29:20 PDT 2020
njames93 added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:1-2
+//===--- StringFindStrContainsCheck.cc - clang-tidy---------------*- C++
+//-*-===//
+//
----------------
Don't need the C++ specifier in a cpp file.
```
//===--- StringFindStrContainsCheck.cpp - clang-tidy ----------------------===//```
================
Comment at: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:71-72
+ binaryOperator(hasOperatorName("=="),
+ hasEitherOperand(ignoringParenImpCasts(StringNpos)),
+ hasEitherOperand(ignoringParenImpCasts(StringFind))),
+ change(cat("!absl::StrContains(", node("string_being_searched"),
----------------
This is dangerous, it will match on `std::string::npos == std::string::npos` and (more importantly) `strA.find(...) == strB.find(...)`. See D80054.
================
Comment at: clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:78-79
+ binaryOperator(hasOperatorName("!="),
+ hasEitherOperand(ignoringParenImpCasts(StringNpos)),
+ hasEitherOperand(ignoringParenImpCasts(StringFind))),
+ change(cat("absl::StrContains(", node("string_being_searched"), ", ",
----------------
Same as above.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80023/new/
https://reviews.llvm.org/D80023
More information about the cfe-commits
mailing list