[PATCH] D113148: Add new clang-tidy check for string_view(nullptr)
CJ Johnson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 4 09:14:19 PDT 2021
CJ-Johnson added a comment.
In D113148#3108993 <https://reviews.llvm.org/D113148#3108993>, @aaron.ballman wrote:
> Generally speaking, we prefer to improve the existing checks. I think `bugprone-string-constructor` would probably be a better place for the constructor-related functionality. But that still means we don't have a good place for things like the assignment and comparison functionality, and it seems more useful to keep all of the `string_view`-with-`nullptr` logic in one place. That said, we should be careful we're not too onerous when users enable all `bugprone` checks together.
I agree with the statement "it seems more useful to keep all of the `string_view`-with-`nullptr` logic in one place". To me, these are very logically related. The fact that some of it is constructor based is not as useful from a user perspective. The relationship between `nullptr` and `string_view` is more important, in my view.
As for "we should be careful we're not too onerous when users enable all `bugprone` checks together.", these fixes are about preventing UB. While I did put this in the "bugprone" module, perhaps "prone" is the wrong way to think about it. It's unconditionally UB in all cases, not just a potential bug. The suggested fixes are important for preventing crashes in the short term, but more importantly for allowing the code to build in the future, since the constructor overload `basic_string_view(nullptr_t) = delete;` is being added.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113148/new/
https://reviews.llvm.org/D113148
More information about the cfe-commits
mailing list