Skip to content

Commit

Permalink
Document how to comment an actual parameter.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D54446

llvm-svn: 346861
  • Loading branch information
pogo59 committed Nov 14, 2018
1 parent 02cb67d commit a6a19c0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions llvm/docs/CodingStandards.rst
Expand Up @@ -305,6 +305,21 @@ useful to use C style (``/* */``) comments however:
#. When writing a source file that is used by a tool that only accepts C style
comments.

#. When documenting the significance of constants used as actual parameters in
a call. This is most helpful for ``bool`` parameters, or passing ``0`` or
``nullptr``. Typically you add the formal parameter name, which ought to be
meaningful. For example, it's not clear what the parameter means in this call:

.. code-block:: c++

Object.emitName(nullptr);

An in-line C-style comment makes the intent obvious:

.. code-block:: c++

Object.emitName(/*Prefix=*/nullptr);

Commenting out large blocks of code is discouraged, but if you really have to do
this (for documentation purposes or as a suggestion for debug printing), use
``#if 0`` and ``#endif``. These nest properly and are better behaved in general
Expand Down

0 comments on commit a6a19c0

Please sign in to comment.