================
@@ -0,0 +1,89 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-std-erase %t
+#include <deque>
+#include <list>
+#include <string>
+#include <vector>
+
+namespace std {
+template <class ForwardIt, class T>
+ForwardIt remove(ForwardIt first, ForwardIt last, const T& value);
+
+template <class ForwardIt, class UnaryPredicate>
+ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p);
+
+// Dummy implementation
+template <class ForwardIt, class UnaryPredicate>
+ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p) {
+ return first;
+}
+
+} // namespace std
+
+// Custom container - should be ignored
+template <typename T>
+struct MyContainer {
+ using iterator = T*;
+ iterator begin();
+ iterator end();
+ iterator erase(iterator, iterator);
+};
+
+void test_standard_remove_idiom() {
+ std::vector<int> v;
+ v.erase(std::remove(v.begin(), v.end(), 42), v.end());
+ // CHECK-MESSAGES: {{.*}}: warning: prefer std::erase over the erase-remove
idiom [modernize-use-std-erase]
----------------
vbvictor wrote:
Use real line + column numbers
https://github.com/llvm/llvm-project/pull/193407
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits