[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)

Nicolas van Kempen via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 5 10:37:35 PDT 2024


================
@@ -29,6 +29,43 @@ struct multimap {
   bool contains(const Key &K) const;
 };
 
+using size_t = decltype(sizeof(int));
+
+// Lightweight standin for std::string_view.
+template <typename C>
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const basic_string_view &);
+  basic_string_view(const C *);
+  ~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;
+};
+typedef basic_string_view<char> string_view;
+
+// Lightweight standin for std::string.
+template <typename C>
+class basic_string {
+public:
+  basic_string();
+  basic_string(const basic_string &);
+  basic_string(const C *);
+  ~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);
+  bool contains(const C *s) const;
+  bool contains(C s) const;
+  bool contains(basic_string_view<C> s) const;
+  static constexpr size_t npos = -1;
+};
+typedef basic_string<char> string;
+
----------------
nicovank wrote:

Yes IMO it's fine to change in same diff (unless it broke something, but doesn't seem to be the case here).

https://github.com/llvm/llvm-project/pull/110351


More information about the cfe-commits mailing list