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

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 06:00:15 PDT 2023


aaron.ballman added a comment.

In D151187#4420321 <https://reviews.llvm.org/D151187#4420321>, @jhenderson wrote:

> I am not at all familiar with implementing things in clang-tidy, so don't have the time or skills to implement said dirty hack.

No worries, it's a tall ask. :-)

> If we were to exclude integers and enums, then I would suggest the following wording:
>
>> When casting, use `static_cast`, `reinterpret_cast`, and `const_cast` rather than C-style casts. There are two exceptions to this:
>>
>> - When casting to void to suppress warnings about unused variables (as an alternative to ``[[maybe_unused]]``). Prefer C-style casts in this instance.
>> - When casting integral types (including enums), prefer the prevailing style in the area being worked on.

I like that phrasing, thank you! Do others have opinions on using this wording over the existing wording?


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