MyDeveloperDay updated this revision to Diff 260266.
MyDeveloperDay added a comment.
Need to skip over the template or we won't see this as needing to break on the
return type
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78879/new/
https://reviews.llvm.org/D78879
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
@@ -6279,7 +6279,17 @@
"void\n"
"A::operator[]() {}\n"
"void\n"
- "A::operator!() {}\n",
+ "A::operator!() {}\n"
+ "void\n"
+ "A::operator**() {}\n"
+ "void\n"
+ "A::operator<Foo> *() {}\n"
+ "void\n"
+ "A::operator<Foo> **() {}\n"
+ "void\n"
+ "A::operator<Foo> &() {}\n"
+ "void\n"
+ "A::operator void **() {}\n",
Style);
verifyFormat("constexpr auto\n"
"operator()() const -> reference {}\n"
@@ -6296,6 +6306,10 @@
"constexpr auto\n"
"operator void *() const -> reference {}\n"
"constexpr auto\n"
+ "operator void **() const -> reference {}\n"
+ "constexpr auto\n"
+ "operator void *() const -> reference {}\n"
+ "constexpr auto\n"
"operator void &() const -> reference {}\n"
"constexpr auto\n"
"operator void &&() const -> reference {}\n"
@@ -15628,9 +15642,20 @@
Style.PointerAlignment = FormatStyle::PAS_Right;
verifyFormat("Foo::operator*();", Style);
verifyFormat("Foo::operator void *();", Style);
+ verifyFormat("Foo::operator void **();", Style);
verifyFormat("Foo::operator()(void *);", Style);
verifyFormat("Foo::operator*(void *);", Style);
verifyFormat("Foo::operator*();", Style);
+ verifyFormat("Foo::operator**();", Style);
+ verifyFormat("Foo::operator&();", Style);
+ verifyFormat("Foo::operator<int> *();", Style);
+ verifyFormat("Foo::operator<Foo> *();", Style);
+ verifyFormat("Foo::operator<int> **();", Style);
+ verifyFormat("Foo::operator<Foo> **();", Style);
+ verifyFormat("Foo::operator<int> &();", Style);
+ verifyFormat("Foo::operator<Foo> &();", Style);
+ verifyFormat("Foo::operator<int> &&();", Style);
+ verifyFormat("Foo::operator<Foo> &&();", Style);
verifyFormat("operator*(int (*)(), class Foo);", Style);
verifyFormat("Foo::operator&();", Style);
@@ -15641,21 +15666,39 @@
verifyFormat("operator&(int (&)(), class Foo);", Style);
verifyFormat("Foo::operator&&();", Style);
+ verifyFormat("Foo::operator**();", Style);
verifyFormat("Foo::operator void &&();", Style);
verifyFormat("Foo::operator()(void &&);", Style);
verifyFormat("Foo::operator&&(void &&);", Style);
verifyFormat("Foo::operator&&();", Style);
verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+ verifyFormat("operator const nsTArrayRight<E> &()", Style);
+ verifyFormat("[[nodiscard]] operator const nsTArrayRight<E, Allocator> &()",
+ Style);
+ verifyFormat("operator void **()", Style);
+ verifyFormat("operator const FooRight<Object> &()", Style);
+ verifyFormat("operator const FooRight<Object> *()", Style);
+ verifyFormat("operator const FooRight<Object> **()", Style);
Style.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("Foo::operator*();", Style);
+ verifyFormat("Foo::operator**();", Style);
verifyFormat("Foo::operator void*();", 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);
+ verifyFormat("Foo::operator<int>*();", Style);
+ verifyFormat("Foo::operator<Foo>*();", Style);
+ verifyFormat("Foo::operator<int>**();", Style);
+ verifyFormat("Foo::operator<Foo>**();", Style);
+ verifyFormat("Foo::operator<int>&();", Style);
+ verifyFormat("Foo::operator<Foo>&();", Style);
+ verifyFormat("Foo::operator<int>&&();", Style);
+ verifyFormat("Foo::operator<Foo>&&();", Style);
verifyFormat("operator*(int (*)(), class Foo);", Style);
verifyFormat("Foo::operator&();", Style);
@@ -15677,9 +15720,17 @@
verifyFormat("Foo::operator&&(void&&);", Style);
verifyFormat("Foo::operator&&();", Style);
verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+ verifyFormat("operator const nsTArrayLeft<E>&()", Style);
+ verifyFormat("[[nodiscard]] operator const nsTArrayLeft<E, Allocator>&()",
+ Style);
+ verifyFormat("operator void**()", Style);
+ verifyFormat("operator const FooLeft<Object>&()", Style);
+ verifyFormat("operator const FooLeft<Object>*()", Style);
+ verifyFormat("operator const FooLeft<Object>**()", Style);
// PR45107
verifyFormat("operator Vector<String>&();", Style);
+ verifyFormat("operator const Vector<String>&();", Style);
verifyFormat("operator foo::Bar*();", Style);
verifyFormat("operator const Foo<X>::Bar<Y>*();", Style);
verifyFormat("operator/*a*/ const /*b*/ Foo /*c*/<X> /*d*/ ::Bar<Y>*();",
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2281,6 +2281,10 @@
Next = Next->Next;
continue;
}
+ if (Next->is(TT_TemplateOpener) && Next->MatchingParen) {
+ Next = Next->MatchingParen;
+ continue;
+ }
break;
}
@@ -2810,6 +2814,8 @@
tok::l_square));
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
+ if (Right.is(tok::star) && Left.is(tok::star))
+ return false;
if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {
const FormatToken *Previous = &Left;
while (Previous && !Previous->is(tok::kw_operator)) {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits