[PATCH] D79201: [clang-format] : Fix additional pointer alignment for overloaded operators
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 13 10:52:01 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc82243d0675b: [clang-format] : Fix additional pointer alignment for overloaded operators (authored by MyDeveloperDay).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79201/new/
https://reviews.llvm.org/D79201
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
@@ -15760,6 +15760,8 @@
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()(void *);", Style);
verifyFormat("Foo::operator*(void *);", Style);
verifyFormat("Foo::operator*();", Style);
@@ -15773,6 +15775,10 @@
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);
@@ -15796,12 +15802,15 @@
verifyFormat("operator const FooRight<Object> &()", Style);
verifyFormat("operator const FooRight<Object> *()", 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 void*&();", Style);
verifyFormat("Foo::operator/*comment*/ void*();", Style);
verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
@@ -15812,10 +15821,13 @@
verifyFormat("Foo::operator<Foo>*();", Style);
verifyFormat("Foo::operator<int>**();", Style);
verifyFormat("Foo::operator<Foo>**();", 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);
@@ -15844,6 +15856,8 @@
verifyFormat("operator const FooLeft<Object>&()", Style);
verifyFormat("operator const FooLeft<Object>*()", 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);
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2818,7 +2818,7 @@
tok::l_square));
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
- if (Right.is(tok::star) && Left.is(tok::star))
+ if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp))
return false;
if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {
const FormatToken *Previous = &Left;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79201.263785.patch
Type: text/x-patch
Size: 3588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200513/7d2a168a/attachment-0001.bin>
More information about the cfe-commits
mailing list