[libcxx-commits] [PATCH] D92229: [libc++] Update clang-format configuration
Michael Schellenberger Costa via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 27 07:40:52 PST 2020
miscco added a comment.
In D92229#2420261 <https://reviews.llvm.org/D92229#2420261>, @mclow.lists wrote:
> Has clang-format been improved enough that it will not "wreck" `std::less<void>`? Last time I tried it on that code, it pessimized it pretty thoroughly.
> Code pasted here for reference:
>
> #if _LIBCPP_STD_VER > 11
> template <>
> struct _LIBCPP_TEMPLATE_VIS less<void>
> {
> template <class _T1, class _T2>
> _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
> auto operator()(_T1&& __t, _T2&& __u) const
> _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
> -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
> { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
> typedef void is_transparent;
> };
> #endif
I would like to note that with MSVC STL we simply work around those rare cases via `//clang-format off`. One main use case are requires clauses that are not yet supported. That said, the vast majority of the code works fine.
> Also, @missco wrote:
>
>> I really like that we get clang-format to work. Live is simply to short to worry about formatting.
>
> Writing is once, reading is many, many times.
> Formatting that reveals the underlying structure of the code is a time-saver to future you (and others).
That is true, but consistency in a code base is incredibly valuable for new contributors. Having to wonder how to indent / format complicated STL code is a really hard hurdle for a first time contributor
Also consistency helps reading a lot. and as said above the few rare cases where it is detrimental one can always simply use `// clang-format off`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92229/new/
https://reviews.llvm.org/D92229
More information about the libcxx-commits
mailing list