@@ -6134,7 +6134,48 @@ TEST_F(FormatTest, ReturnTypeBreakingStyle) {
6134
6134
"void\n"
6135
6135
"A::operator>>() {}\n"
6136
6136
"void\n"
6137
- "A::operator+() {}\n",
6137
+ "A::operator+() {}\n"
6138
+ "void\n"
6139
+ "A::operator*() {}\n"
6140
+ "void\n"
6141
+ "A::operator->() {}\n"
6142
+ "void\n"
6143
+ "A::operator void *() {}\n"
6144
+ "void\n"
6145
+ "A::operator void &() {}\n"
6146
+ "void\n"
6147
+ "A::operator void &&() {}\n"
6148
+ "void\n"
6149
+ "A::operator char *() {}\n"
6150
+ "void\n"
6151
+ "A::operator[]() {}\n"
6152
+ "void\n"
6153
+ "A::operator!() {}\n",
6154
+ Style);
6155
+ verifyFormat("constexpr auto\n"
6156
+ "operator()() const -> reference {}\n"
6157
+ "constexpr auto\n"
6158
+ "operator>>() const -> reference {}\n"
6159
+ "constexpr auto\n"
6160
+ "operator+() const -> reference {}\n"
6161
+ "constexpr auto\n"
6162
+ "operator*() const -> reference {}\n"
6163
+ "constexpr auto\n"
6164
+ "operator->() const -> reference {}\n"
6165
+ "constexpr auto\n"
6166
+ "operator++() const -> reference {}\n"
6167
+ "constexpr auto\n"
6168
+ "operator void *() const -> reference {}\n"
6169
+ "constexpr auto\n"
6170
+ "operator void &() const -> reference {}\n"
6171
+ "constexpr auto\n"
6172
+ "operator void &&() const -> reference {}\n"
6173
+ "constexpr auto\n"
6174
+ "operator char *() const -> reference {}\n"
6175
+ "constexpr auto\n"
6176
+ "operator!() const -> reference {}\n"
6177
+ "constexpr auto\n"
6178
+ "operator[]() const -> reference {}\n",
6138
6179
Style);
6139
6180
verifyFormat("void *operator new(std::size_t s);", // No break here.
6140
6181
Style);
@@ -14755,6 +14796,53 @@ TEST_F(FormatTest, STLWhileNotDefineChed) {
14755
14796
"#endif // while");
14756
14797
}
14757
14798
14799
+ TEST_F(FormatTest, OperatorSpacing) {
14800
+ FormatStyle Style = getLLVMStyle();
14801
+ Style.PointerAlignment = FormatStyle::PAS_Right;
14802
+ verifyFormat("Foo::operator*();", Style);
14803
+ verifyFormat("Foo::operator void *();", Style);
14804
+ verifyFormat("Foo::operator()(void *);", Style);
14805
+ verifyFormat("Foo::operator*(void *);", Style);
14806
+ verifyFormat("Foo::operator*();", Style);
14807
+ verifyFormat("operator*(int (*)(), class Foo);", Style);
14808
+
14809
+ verifyFormat("Foo::operator&();", Style);
14810
+ verifyFormat("Foo::operator void &();", Style);
14811
+ verifyFormat("Foo::operator()(void &);", Style);
14812
+ verifyFormat("Foo::operator&(void &);", Style);
14813
+ verifyFormat("Foo::operator&();", Style);
14814
+ verifyFormat("operator&(int (&)(), class Foo);", Style);
14815
+
14816
+ verifyFormat("Foo::operator&&();", Style);
14817
+ verifyFormat("Foo::operator void &&();", Style);
14818
+ verifyFormat("Foo::operator()(void &&);", Style);
14819
+ verifyFormat("Foo::operator&&(void &&);", Style);
14820
+ verifyFormat("Foo::operator&&();", Style);
14821
+ verifyFormat("operator&&(int(&&)(), class Foo);", Style);
14822
+
14823
+ Style.PointerAlignment = FormatStyle::PAS_Left;
14824
+ verifyFormat("Foo::operator*();", Style);
14825
+ verifyFormat("Foo::operator void*();", Style);
14826
+ verifyFormat("Foo::operator()(void*);", Style);
14827
+ verifyFormat("Foo::operator*(void*);", Style);
14828
+ verifyFormat("Foo::operator*();", Style);
14829
+ verifyFormat("operator*(int (*)(), class Foo);", Style);
14830
+
14831
+ verifyFormat("Foo::operator&();", Style);
14832
+ verifyFormat("Foo::operator void&();", Style);
14833
+ verifyFormat("Foo::operator()(void&);", Style);
14834
+ verifyFormat("Foo::operator&(void&);", Style);
14835
+ verifyFormat("Foo::operator&();", Style);
14836
+ verifyFormat("operator&(int (&)(), class Foo);", Style);
14837
+
14838
+ verifyFormat("Foo::operator&&();", Style);
14839
+ verifyFormat("Foo::operator void&&();", Style);
14840
+ verifyFormat("Foo::operator()(void&&);", Style);
14841
+ verifyFormat("Foo::operator&&(void&&);", Style);
14842
+ verifyFormat("Foo::operator&&();", Style);
14843
+ verifyFormat("operator&&(int(&&)(), class Foo);", Style);
14844
+ }
14845
+
14758
14846
} // namespace
14759
14847
} // namespace format
14760
14848
} // namespace clang
0 commit comments