[PATCH] D152443: Add SpaceAfterOperatorKeyword & SpaceAfterOperatorKeywordInCall style options for clang-format
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 11:19:37 PDT 2023
HazardyKnusperkeks added a comment.
In D152443#4407331 <https://reviews.llvm.org/D152443#4407331>, @KitsuneAlex wrote:
> Applied all suggested changes and added a suiting option for aformentioned edge-case for call expressions.
> Also added the missing release notes to the apropriate section.
Please mark comments as done, if you think they are done.
================
Comment at: clang/docs/ClangFormatStyleOptions.rst:4709
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <SpaceAfterOperatorKeyword>`
+ If ``true``, a space will be inserted after the 'operator' keyword.
----------------
MyDeveloperDay wrote:
> could we use something like `SpaceAfterOperatorDeclaration` to differentiate
But it also applies to the definition?
Keyword seems to be wrong too, if we have a second option for the calls...
I currently have no recommendations for the naming.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:4206
+ if (Left.Previous &&
+ Left.Previous->isOneOf(tok::coloncolon, tok::period)) {
+ return Style.SpaceAfterOperatorKeywordInCall ||
----------------
`bool Foo::operator==() = default;`?
Please add a test. :)
================
Comment at: clang/unittests/Format/FormatTest.cpp:22915
+ verifyFormat("foo.Foo::operator==();", Style);
+ Style.SpaceAfterOperatorKeywordInCall = true;
+ verifyFormat("foo.operator ==();", Style);
----------------
Can you add an empty line, so that the 2 blocks are visually separated?
================
Comment at: clang/unittests/Format/FormatTest.cpp:22916
+ Style.SpaceAfterOperatorKeywordInCall = true;
+ verifyFormat("foo.operator ==();", Style);
+ verifyFormat("foo.Foo::operator ==();", Style);
----------------
MyDeveloperDay wrote:
> I assume I could have `foo->operator ==();`
Of course you can. :)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152443/new/
https://reviews.llvm.org/D152443
More information about the cfe-commits
mailing list