Index: llvm/docs/CodingStandards.rst =================================================================== --- llvm/docs/CodingStandards.rst +++ llvm/docs/CodingStandards.rst @@ -590,6 +590,19 @@ This form of RTTI is opt-in and can be :doc:`added to any class `. +Prefer C++-style casts +^^^^^^^^^^^^^^^^^^^^^^ + +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 between integral types (including enums that are not strongly- + typed), functional-style casts are permitted as an alternative to + ``static_cast``. + .. _static constructor: Do not use Static Constructors