Skip to content

Commit 4ebc962

Browse files
zeyi2vbvictor
andauthored
Update clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
Co-authored-by: Baranov Victor <[email protected]>
1 parent 253c39d commit 4ebc962

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,14 @@ void s(std::unique_ptr<std::vector<unsigned char>> p) {
156156
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
157157
// CHECK-FIXES: f((*p).data());
158158
}
159+
160+
void t(std::unique_ptr<container_without_data<unsigned char>> p) {
161+
// p has no "data" member function, so no warning
162+
f(&(*p)[0]);
163+
}
164+
165+
template <typename T>
166+
void u(std::unique_ptr<T> p) {
167+
// we don't know if 'T' will always have "data" member function, so no warning
168+
f(&(*p)[0]);
169+
}

0 commit comments

Comments
 (0)