Skip to content

Commit 76ce3c1

Browse files
authored
[clang-format] Enable again some operator tests (#83380)
Multiple formatting operator tests are commented. This change enables them again. [PR506629](https://llvm.org/PR50629) fixed by [D153798](https://reviews.llvm.org/D153798). Tests in `ConfigurableSpaceBeforeParens` have the same behavior as before [D110833](https://reviews.llvm.org/D110833). Update the test for function declaration and definition, as changed in [D114696](https://reviews.llvm.org/D114696).
1 parent 617398e commit 76ce3c1

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

clang/unittests/Format/FormatTest.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11159,10 +11159,8 @@ TEST_F(FormatTest, UnderstandsOverloadedOperators) {
1115911159
verifyFormat("void f() { a.operator*(b & b); }");
1116011160
verifyFormat("void f() { a->operator&(a * b); }");
1116111161
verifyFormat("void f() { NS::a.operator+(*b * *b); }");
11162-
// TODO: Calling an operator as a non-member function is hard to distinguish.
11163-
// https://llvm.org/PR50629
11164-
// verifyFormat("void f() { operator*(a & a); }");
11165-
// verifyFormat("void f() { operator&(a, b * b); }");
11162+
verifyFormat("void f() { operator*(a & a); }");
11163+
verifyFormat("void f() { operator&(a, b * b); }");
1116611164

1116711165
verifyFormat("void f() { return operator()(x) * b; }");
1116811166
verifyFormat("void f() { return operator[](x) * b; }");
@@ -16551,9 +16549,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
1655116549
verifyFormat("static_assert (sizeof (char) == 1, \"Impossible!\");", Space);
1655216550
verifyFormat("int f () throw (Deprecated);", Space);
1655316551
verifyFormat("typedef void (*cb) (int);", Space);
16554-
// FIXME these tests regressed behaviour.
16555-
// verifyFormat("T A::operator() ();", Space);
16556-
// verifyFormat("X A::operator++ (T);", Space);
16552+
verifyFormat("T A::operator() ();", Space);
16553+
verifyFormat("X A::operator++ (T);", Space);
1655716554
verifyFormat("auto lambda = [] () { return 0; };", Space);
1655816555
verifyFormat("int x = int (y);", Space);
1655916556
verifyFormat("#define F(...) __VA_OPT__ (__VA_ARGS__)", Space);
@@ -16612,8 +16609,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
1661216609
verifyFormat("int f() throw (Deprecated);", SomeSpace);
1661316610
verifyFormat("typedef void (*cb) (int);", SomeSpace);
1661416611
verifyFormat("T A::operator()();", SomeSpace);
16615-
// FIXME these tests regressed behaviour.
16616-
// verifyFormat("X A::operator++ (T);", SomeSpace);
16612+
verifyFormat("X A::operator++ (T);", SomeSpace);
1661716613
verifyFormat("int x = int (y);", SomeSpace);
1661816614
verifyFormat("auto lambda = []() { return 0; };", SomeSpace);
1661916615

@@ -16671,9 +16667,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
1667116667
SpaceFuncDecl);
1667216668
verifyFormat("int f () throw(Deprecated);", SpaceFuncDecl);
1667316669
verifyFormat("typedef void (*cb)(int);", SpaceFuncDecl);
16674-
// FIXME these tests regressed behaviour.
16675-
// verifyFormat("T A::operator() ();", SpaceFuncDecl);
16676-
// verifyFormat("X A::operator++ (T);", SpaceFuncDecl);
16670+
verifyFormat("T A::operator()();", SpaceFuncDecl);
16671+
verifyFormat("X A::operator++(T);", SpaceFuncDecl);
1667716672
verifyFormat("T A::operator()() {}", SpaceFuncDecl);
1667816673
verifyFormat("auto lambda = []() { return 0; };", SpaceFuncDecl);
1667916674
verifyFormat("int x = int(y);", SpaceFuncDecl);
@@ -16710,7 +16705,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
1671016705
verifyFormat("typedef void (*cb)(int);", SpaceFuncDef);
1671116706
verifyFormat("T A::operator()();", SpaceFuncDef);
1671216707
verifyFormat("X A::operator++(T);", SpaceFuncDef);
16713-
// verifyFormat("T A::operator() () {}", SpaceFuncDef);
16708+
verifyFormat("T A::operator()() {}", SpaceFuncDef);
1671416709
verifyFormat("auto lambda = [] () { return 0; };", SpaceFuncDef);
1671516710
verifyFormat("int x = int(y);", SpaceFuncDef);
1671616711
verifyFormat("M(std::size_t R, std::size_t C) : C(C), data(R) {}",
@@ -16797,7 +16792,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
1679716792
verifyFormat("int f() throw (Deprecated);", SomeSpace2);
1679816793
verifyFormat("typedef void (*cb) (int);", SomeSpace2);
1679916794
verifyFormat("T A::operator()();", SomeSpace2);
16800-
// verifyFormat("X A::operator++ (T);", SomeSpace2);
16795+
verifyFormat("X A::operator++ (T);", SomeSpace2);
1680116796
verifyFormat("int x = int (y);", SomeSpace2);
1680216797
verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);
1680316798

0 commit comments

Comments
 (0)