Author: rayroudc Date: 2024-03-01T21:24:13+01:00 New Revision: 76ce3c1bcf82056a61bcbdf776f67ac53d881df0
URL: https://github.com/llvm/llvm-project/commit/76ce3c1bcf82056a61bcbdf776f67ac53d881df0 DIFF: https://github.com/llvm/llvm-project/commit/76ce3c1bcf82056a61bcbdf776f67ac53d881df0.diff LOG: [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). Added: Modified: clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d9752c73e34e79..fc367a7a5a8981 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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; }"); @@ -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); @@ -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); @@ -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); @@ -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) {}", @@ -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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits