Skip to content

Commit

Permalink
[clang-tidy] Make readability-container-data-pointer use <string> header
Browse files Browse the repository at this point in the history
This requires operator[] to be added to the std::basic_string
implementation.

Depends on D144216

Reviewed By: carlosgalvezp

Differential Revision: https://reviews.llvm.org/D145310
  • Loading branch information
mikecrowe authored and carlosgalvezp committed Mar 11, 2023
1 parent 890e6c8 commit efda335
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
Expand Up @@ -42,6 +42,9 @@ struct basic_string {
_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);
Expand Down
@@ -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;

Expand All @@ -17,22 +18,6 @@ struct vector {
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;

Expand Down

0 comments on commit efda335

Please sign in to comment.