diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst --- a/llvm/docs/CodingStandards.rst +++ b/llvm/docs/CodingStandards.rst @@ -1263,6 +1263,18 @@ bool NewToSet = Myset.insert(Value); (void)NewToSet; assert(NewToSet && "The value shouldn't be in the set yet"); +Prefer C++-style casts +^^^^^^^^^^^^^^^^^^^^^^ + +When casting, use ``static_cast`` and ``reinterpret_cast`` rather than C-style +casts. The sole exception to this is when casting to void to suppress warnings +about unused variables, when C-style casts should be preferred instead: + +.. code-block:: c++ + int x = 42; + long *y = static_cast(&x); + (void)y; + Do Not Use ``using namespace std`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^