[PATCH] D151187: [doc] Add casting style preference to coding standards

Thorsten via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 11:45:34 PDT 2023


tschuett added a comment.

In D151187#4365299 <https://reviews.llvm.org/D151187#4365299>, @aaron.ballman wrote:

> In D151187#4365288 <https://reviews.llvm.org/D151187#4365288>, @mehdi_amini wrote:
>
>> In D151187#4364070 <https://reviews.llvm.org/D151187#4364070>, @barannikov88 wrote:
>>
>>> Maybe adopt this clang-tidy check? https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-type-cstyle-cast.html
>>> That is, allow C/functional-style cast when it is known to be safe (like unsigned -> int64_t or enum -> int), and prefer named casts otherwise.
>>> The check also provides fix-its, which is nice.
>>
>> This is pretty nice! If it was possible to make it a clang warning instead of a tidy check (not clear to me why this can't be?), then we could make it a Werror and actually enforce it!
>
> Someone would have to test over a large corpus of code to see what the false positive vs true positive rate looks like. My intuition is that it would have too many false positives to be enabled by default, so it wouldn't meet the bar for a clang diagnostic.

I wondering what you mean by false positives? You know the type on the left and right of the cast. There should be some rules to find fishy casts. You want to cast a struct to a bool?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151187



More information about the llvm-commits mailing list