[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
Mon Jan 9 04:05:43 PST 2023
acoster added a comment.
In D140968#4029072 <https://reviews.llvm.org/D140968#4029072>, @njames93 wrote:
> I don't see the appear of this check as its a situation that I doubt ever appears in code bases. If there are open source code bases where this is a known problem can you please provide links to them as well as running the run_clang_tidy script over them to verify the changes are good.
After a look at some projects, it seems like the pattern does arise, but often it's intended (eg a string buffer is set to a large size, a legacy function taking a char* writes to it, and then the string is resized to strlen(foo.c_str())). As such, I'll drop this patch, as it can introduce bugs in these cases.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140968/new/
https://reviews.llvm.org/D140968
More information about the cfe-commits
mailing list