[PATCH] D72911: clang-format: fix spacing in `operator const char*()`
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 17 04:25:54 PST 2020
krasimir updated this revision to Diff 238741.
krasimir added a comment.
- Address review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72911/new/
https://reviews.llvm.org/D72911
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15007,6 +15007,9 @@
Style.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("Foo::operator*();", Style);
verifyFormat("Foo::operator void*();", Style);
+ verifyFormat("Foo::operator/*comment*/ void*();", Style);
+ verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
+ verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
verifyFormat("Foo::operator()(void*);", Style);
verifyFormat("Foo::operator*(void*);", Style);
verifyFormat("Foo::operator*();", Style);
@@ -15014,6 +15017,9 @@
verifyFormat("Foo::operator&();", Style);
verifyFormat("Foo::operator void&();", Style);
+ verifyFormat("Foo::operator/*comment*/ void&();", Style);
+ verifyFormat("Foo::operator/*a*/ const /*b*/ void&();", Style);
+ verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&();", Style);
verifyFormat("Foo::operator()(void&);", Style);
verifyFormat("Foo::operator&(void&);", Style);
verifyFormat("Foo::operator&();", Style);
@@ -15021,6 +15027,9 @@
verifyFormat("Foo::operator&&();", Style);
verifyFormat("Foo::operator void&&();", Style);
+ verifyFormat("Foo::operator/*comment*/ void&&();", Style);
+ verifyFormat("Foo::operator/*a*/ const /*b*/ void&&();", Style);
+ verifyFormat("Foo::operator/*a*/ volatile /*b*/ void&&();", Style);
verifyFormat("Foo::operator()(void&&);", Style);
verifyFormat("Foo::operator&&(void&&);", Style);
verifyFormat("Foo::operator&&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2707,10 +2707,18 @@
return false;
if (Right.isOneOf(tok::star, tok::amp, tok::ampamp) &&
(Left.is(tok::identifier) || Left.isSimpleTypeSpecifier()) &&
- Left.Previous && Left.Previous->is(tok::kw_operator))
- // Space between the type and the *
- // operator void*(), operator char*(), operator Foo*() dependant
- // on PointerAlignment style.
+ // Space between the type and the * in:
+ // operator void*()
+ // operator void*()
+ // operator char*()
+ // operator /*comment*/ const char*()
+ // operator volatile /*comment*/ char*()
+ // operator Foo*()
+ // dependant on PointerAlignment style.
+ Left.Previous &&
+ (Left.Previous->endsSequence(tok::kw_operator) ||
+ Left.Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+ Left.Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
return (Style.PointerAlignment != FormatStyle::PAS_Left);
const auto SpaceRequiredForArrayInitializerLSquare =
[](const FormatToken &LSquareTok, const FormatStyle &Style) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72911.238741.patch
Type: text/x-patch
Size: 2939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200117/e73d19c2/attachment.bin>
More information about the cfe-commits
mailing list