Skip to content

Commit

Permalink
[clang-format] Enable again some operator tests (#83380)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
rayroudc committed Mar 1, 2024
1 parent 617398e commit 76ce3c1
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11159,10 +11159,8 @@ TEST_F(FormatTest, UnderstandsOverloadedOperators) {
verifyFormat("void f() { a.operator*(b & b); }");
verifyFormat("void f() { a->operator&(a * b); }");
verifyFormat("void f() { NS::a.operator+(*b * *b); }");
// TODO: Calling an operator as a non-member function is hard to distinguish.
// https://llvm.org/PR50629
// verifyFormat("void f() { operator*(a & a); }");
// verifyFormat("void f() { operator&(a, b * b); }");
verifyFormat("void f() { operator*(a & a); }");
verifyFormat("void f() { operator&(a, b * b); }");

verifyFormat("void f() { return operator()(x) * b; }");
verifyFormat("void f() { return operator[](x) * b; }");
Expand Down Expand Up @@ -16551,9 +16549,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
verifyFormat("static_assert (sizeof (char) == 1, \"Impossible!\");", Space);
verifyFormat("int f () throw (Deprecated);", Space);
verifyFormat("typedef void (*cb) (int);", Space);
// FIXME these tests regressed behaviour.
// verifyFormat("T A::operator() ();", Space);
// verifyFormat("X A::operator++ (T);", Space);
verifyFormat("T A::operator() ();", Space);
verifyFormat("X A::operator++ (T);", Space);
verifyFormat("auto lambda = [] () { return 0; };", Space);
verifyFormat("int x = int (y);", Space);
verifyFormat("#define F(...) __VA_OPT__ (__VA_ARGS__)", Space);
Expand Down Expand Up @@ -16612,8 +16609,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
verifyFormat("int f() throw (Deprecated);", SomeSpace);
verifyFormat("typedef void (*cb) (int);", SomeSpace);
verifyFormat("T A::operator()();", SomeSpace);
// FIXME these tests regressed behaviour.
// verifyFormat("X A::operator++ (T);", SomeSpace);
verifyFormat("X A::operator++ (T);", SomeSpace);
verifyFormat("int x = int (y);", SomeSpace);
verifyFormat("auto lambda = []() { return 0; };", SomeSpace);

Expand Down Expand Up @@ -16671,9 +16667,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
SpaceFuncDecl);
verifyFormat("int f () throw(Deprecated);", SpaceFuncDecl);
verifyFormat("typedef void (*cb)(int);", SpaceFuncDecl);
// FIXME these tests regressed behaviour.
// verifyFormat("T A::operator() ();", SpaceFuncDecl);
// verifyFormat("X A::operator++ (T);", SpaceFuncDecl);
verifyFormat("T A::operator()();", SpaceFuncDecl);
verifyFormat("X A::operator++(T);", SpaceFuncDecl);
verifyFormat("T A::operator()() {}", SpaceFuncDecl);
verifyFormat("auto lambda = []() { return 0; };", SpaceFuncDecl);
verifyFormat("int x = int(y);", SpaceFuncDecl);
Expand Down Expand Up @@ -16710,7 +16705,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
verifyFormat("typedef void (*cb)(int);", SpaceFuncDef);
verifyFormat("T A::operator()();", SpaceFuncDef);
verifyFormat("X A::operator++(T);", SpaceFuncDef);
// verifyFormat("T A::operator() () {}", SpaceFuncDef);
verifyFormat("T A::operator()() {}", SpaceFuncDef);
verifyFormat("auto lambda = [] () { return 0; };", SpaceFuncDef);
verifyFormat("int x = int(y);", SpaceFuncDef);
verifyFormat("M(std::size_t R, std::size_t C) : C(C), data(R) {}",
Expand Down Expand Up @@ -16797,7 +16792,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
verifyFormat("int f() throw (Deprecated);", SomeSpace2);
verifyFormat("typedef void (*cb) (int);", SomeSpace2);
verifyFormat("T A::operator()();", SomeSpace2);
// verifyFormat("X A::operator++ (T);", SomeSpace2);
verifyFormat("X A::operator++ (T);", SomeSpace2);
verifyFormat("int x = int (y);", SomeSpace2);
verifyFormat("auto lambda = []() { return 0; };", SomeSpace2);

Expand Down

0 comments on commit 76ce3c1

Please sign in to comment.