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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 00:32:24 PDT 2023


jhenderson updated this revision to Diff 525037.
jhenderson marked 6 inline comments as done.
jhenderson added a comment.

Add `const_cast` reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151187

Files:
  llvm/docs/CodingStandards.rst


Index: llvm/docs/CodingStandards.rst
===================================================================
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -1263,6 +1263,14 @@
   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``, ``reinterpret_cast``, and ``const_cast``
+rather than C-style casts. The sole exception to this is when casting to void to
+suppress warnings about unused variables (as an alternative to
+``[[maybe_unused]]``), when C-style casts should be preferred instead.
+
 Do Not Use ``using namespace std``
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151187.525037.patch
Type: text/x-patch
Size: 741 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230524/cb7ac9ca/attachment.bin>


More information about the llvm-commits mailing list