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

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 10:51:13 PDT 2023


aaron.ballman added a comment.

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.


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