[PATCH] D140968: [clang-tidy] Add check for passing the result of `std::string::c_str` to `strlen`

Alex Coster via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 5 02:29:30 PST 2023


acoster updated this revision to Diff 486504.
acoster added a comment.

Generlised the check to cover string_view and "string-like" classes

Removed the option of ignoring `data()`, and generalised the check to suggest
fixes if the result of `data()` or `c_str()` method of any class with a public
`length()` or `size()` method is passed to `strlen`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140968

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.cpp
  clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140968.486504.patch
Type: text/x-patch
Size: 12266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230105/4eb19f30/attachment-0001.bin>


More information about the cfe-commits mailing list