[PATCH] D65043: [Format] Add C++20 standard to style options
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 07:06:50 PDT 2019
Quuxplusone added a comment.
Peanut gallery says: A priori, I don't see any reason for clang-format's `LanguageStandard` options to diverge from Clang's own `-std=` options. It sounds like currently they're very different, and you're proposing to make them basically the same. I think that's a good thing.
GCC and Clang still treat "lack of any `-std=` option" as a synonym for "`-std=c++03`". A priori this is an absolutely terrible default, but there would be some logic in making clang-format follow their lead. The only sensible alternative, IMHO, would be for you to treat "lack of any `-std=` option" as a synonym for MSVC's `-std:c++latest`, which means "`-std=c++2a` today and `-std=c++2b` tomorrow."
================
Comment at: clang/docs/ClangFormatStyleOptions.rst:2227
+ * ``LS_Cpp20`` (in configuration: ``Cpp20``)
+ Use features of C++20 and C++2a (e.g.: treating ``co_yield`` as a keyword,
+ not an identifier, so ``co_yield++ i`` is formatted as ``co_yield ++i``).
----------------
C++2a //will// be C++20, barring any radically unforeseen events. So saying "C++20 and C++2a" is redundant. Personally I would follow GCC/Clang's lead and say "C++2a" until the standard is actually out.
================
Comment at: clang/include/clang/Format/Format.h:1878
LS_Cpp11,
+ /// Use features of C++20 and C++2a (e.g.: treating ``co_yield`` as a
+ /// keyword, not an identifier, so ``co_yield++ i`` is formatted as
----------------
Again, C++2a is likely a synonym for C++20.
Three lines earlier, you might want to change "C++1z" to "C++17" (and grep the codebase for other instances of "1z").
================
Comment at: clang/unittests/Format/FormatTest.cpp:3721
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) <= >\n"
+ " 5) {\n"
"}");
----------------
This doesn't seem to test what you set out to test, does it? `(x) <= > 5` isn't a valid C++ expression anyway. Maybe what you want to test here is that clang-format is willing to reformat pre-C++2a code
LongName<&LongerName::operator<=> x;
into
LongName<
&LongerName::operator<=
> x;
(that is, that it's willing to insert a line break between `<=` and `>`). However, if clang-format //refused// to insert a line break in that one position even in C++11 mode, would anything of value really be lost?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65043/new/
https://reviews.llvm.org/D65043
More information about the cfe-commits
mailing list