[PATCH] D151187: [doc] Add casting style preference to coding standards
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 01:04:58 PDT 2023
jhenderson created this revision.
Herald added a project: All.
jhenderson requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
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,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<long *>(&x);
+ (void)y;
+
Do Not Use ``using namespace std``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151187.524597.patch
Type: text/x-patch
Size: 767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230523/b81c9fcc/attachment.bin>
More information about the llvm-commits
mailing list