[PATCH] D54877: Update coding guidelines regarding use of `auto`

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 10:09:32 PST 2018


ruiu added a comment.

While reviewing patches for lld, I often request contributors to replace `auto` with actual types, so I'm probably conservative on using `auto` than the others. My justification of doing it is that in many situations `auto` makes easy to write code because the author of the code already know all the types they are using, but it tend to make code hard to read for those who don't know the code well. So, maybe it is a natural consequence that patch authors tend to use `auto` too frequently and reviewers point that out.

I think overall the description in the change captures my sentiment where we should use `auto` and where we shouldn't.  So overall looking good.



================
Comment at: docs/CodingStandards.rst:797
+  such as ``auto it`` instead of  ``std::vector<T>::iterator it``.
+* Range-based for loops.
+* Where the instance is only needed to perform a validity check,
----------------
jhenderson wrote:
> As others have said, I agree that Range-based for loops are not a good example in many situations. It may be appropriate in some, but not others.
I agree with James. I don't think range-based for loops are not a good example.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54877





More information about the llvm-commits mailing list