summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/docs/CodingStandards.rst6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/docs/CodingStandards.rst b/llvm/docs/CodingStandards.rst
index a762bf358e3..f9685d69ad5 100644
--- a/llvm/docs/CodingStandards.rst
+++ b/llvm/docs/CodingStandards.rst
@@ -747,7 +747,7 @@ is a copy. Particularly in range-based ``for`` loops, careless copies are
expensive.
As a rule of thumb, use ``const auto &`` unless you need to mutate or copy the
-result.
+result, and use ``const auto *`` when copying pointers.
.. code-block:: c++
@@ -760,6 +760,10 @@ result.
// Remove the reference if you really want a new copy.
for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
+ // Copy pointers, but make it clear that they're pointers.
+ for (const auto *Val : Container) { observe(*Val); }
+ for (auto *Val : Container) { Val->change(); }
+
Style Issues
============
OpenPOWER on IntegriCloud