[clang-tools-extra] [clang-tidy] Fix `readability-container-data-pointer` check (PR #165636)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 3 05:36:35 PST 2025
================
@@ -34,7 +34,7 @@ class ContainerDataPointerCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
std::optional<TraversalKind> getCheckTraversalKind() const override {
- return TK_IgnoreUnlessSpelledInSource;
+ return TK_AsIs;
----------------
vbvictor wrote:
Can we make the check work without introducing `TK_AsIs`?
I understand that it was needed for templates but we had previously working templates in
```
template <typename T>
void m(const std::vector<T> &v) {
return &v[0];
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for accessing the data pointer instead of taking the address of the 0-th element [readability-container-data-pointer]
// CHECK-FIXES: return v.data();
}
```
https://github.com/llvm/llvm-project/pull/165636
More information about the cfe-commits
mailing list