[PATCH] D145719: [clang-tidy] Make readability-container-data-pointer use <string> header

Mike Crowe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 9 12:31:07 PST 2023


mikecrowe created this revision.
Herald added subscribers: PiotrZSL, xazax.hun.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This requires operator[] to be added to the std::basic_string
implementation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145719

Files:
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
  clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,5 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -isystem %clang_tidy_headers -fno-delayed-template-parsing
+#include <string>
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -17,22 +18,6 @@
   const T &operator[](size_type) const;
 };
 
-template <typename T>
-struct basic_string {
-  using size_type = size_t;
-
-  basic_string();
-
-  T *data();
-  const T *data() const;
-
-  T &operator[](size_t);
-  const T &operator[](size_type) const;
-};
-
-typedef basic_string<char> string;
-typedef basic_string<wchar_t> wstring;
-
 template <typename T>
 struct is_integral;
 
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
@@ -42,6 +42,9 @@
   _Type& insert(size_type pos, const C* s);
   _Type& insert(size_type pos, const C* s, size_type n);
 
+  _Type& operator[](size_type);
+  const _Type& operator[](size_type) const;
+
   _Type& operator+=(const _Type& str);
   _Type& operator+=(const C* s);
   _Type& operator=(const _Type& str);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145719.503880.patch
Type: text/x-patch
Size: 1633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230309/0d32c0c3/attachment.bin>


More information about the cfe-commits mailing list