[clang-tools-extra] [clang-tidy] support string::contains (PR #110351)
Tommy Chen via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 4 21:32:08 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;
+
----------------
dl8sd11 wrote:
The mock header does not contain the "contains" method(s). Could I modify that one in this PR or should I create a separate one?
https://github.com/llvm/llvm-project/pull/110351
More information about the cfe-commits
mailing list