[PATCH] D113863: [clang-tidy] Make `readability-container-data-pointer` more robust

Fabian Wolff via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 14 14:18:11 PST 2021

fwolff created this revision.
fwolff added reviewers: compnerd, alexfh, aaron.ballman.
fwolff added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes PR#52245. I've also added a few test cases beyond PR#52245 that would also fail with the current implementation, which is quite brittle in many respects (e.g. it uses the `hasDescendant()` matcher to find the container that is being accessed, which is very easy to trick, as in the example in PR#52245).

I have not been able to reproduce the second issue mentioned in PR#52245 (namely that using the `data()` member function is suggested even for containers that don't have it), but I've added a test case for it to be sure.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113863.387131.patch
Type: text/x-patch
Size: 8694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211114/ec2d5996/attachment.bin>

More information about the cfe-commits mailing list