[PATCH] D108893: clang-tidy: introduce readability-containter-data-pointer check

Saleem Abdulrasool via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 13 13:14:34 PDT 2021


compnerd marked an inline comment as done.
compnerd added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/readability-container-data-pointer.cpp:104
+  // CHECK-MESSAGES-NOT: :[[@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]
+}
----------------
aaron.ballman wrote:
> Can you add one more test for how this behaves on uninstantiated templates?
> ```
> template <typename Ty>
> void func(const std::vector<Ty> &Vec) {
>   const Ty *Ptr = &Vec[0]; // Should diagnose and provide a fix-it despite not instantiating func()
> }
> ```
Absolutely!  Thanks for the additional test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108893/new/

https://reviews.llvm.org/D108893



More information about the cfe-commits mailing list