[clang-tools-extra] [clang-tidy] Improve `container-data-pointer` check to use `c_str()` (PR #71304)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 15 09:25:17 PDT 2024
================
@@ -40,8 +40,10 @@ void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
cxxRecordDecl(
unless(matchers::matchesAnyListedName(IgnoredContainers)),
isSameOrDerivedFrom(
- namedDecl(
- has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))
+ namedDecl(anyOf(has(cxxMethodDecl(isPublic(), hasName("c_str"))
+ .bind("c_str")),
+ has(cxxMethodDecl(isPublic(), hasName("data"))
+ .bind("data"))))
----------------
5chmidti wrote:
The node bound to `data` is never retrieved, so you can remove the `.bind("data")`.
https://github.com/llvm/llvm-project/pull/71304
More information about the cfe-commits
mailing list