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

Mike Crowe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 4 13:04:43 PST 2023


mikecrowe created this revision.
Herald added a subscriber: 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.


https://reviews.llvm.org/D145310

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: D145310.502386.patch
Type: text/x-patch
Size: 1633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230304/6a280598/attachment.bin>


More information about the cfe-commits mailing list