curdeius updated this revision to Diff 397123. curdeius added a comment. This patch fixes as well https://github.com/llvm/llvm-project/issues/27146. Added a test case.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116553/new/ https://reviews.llvm.org/D116553 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -20232,6 +20232,11 @@ "};"); verifyFormat("[]() -> Void<T...> {};"); verifyFormat("[a, b]() -> Tuple<T...> { return {}; };"); + verifyFormat("SomeFunction({[]() -> int[] { return {}; }});"); + verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});"); + verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});"); + verifyFormat("SomeFunction({[]() -> ns::type<int (*)[]> { return {}; }});"); + verifyFormat("return int{[x = x]() { return x; }()};"); // Lambdas with explicit template argument lists. verifyFormat( Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1786,6 +1786,9 @@ case tok::l_paren: parseParens(); break; + case tok::l_square: + parseSquare(); + break; case tok::amp: case tok::star: case tok::kw_const:
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -20232,6 +20232,11 @@ "};"); verifyFormat("[]() -> Void<T...> {};"); verifyFormat("[a, b]() -> Tuple<T...> { return {}; };"); + verifyFormat("SomeFunction({[]() -> int[] { return {}; }});"); + verifyFormat("SomeFunction({[]() -> int *[] { return {}; }});"); + verifyFormat("SomeFunction({[]() -> int (*)[] { return {}; }});"); + verifyFormat("SomeFunction({[]() -> ns::type<int (*)[]> { return {}; }});"); + verifyFormat("return int{[x = x]() { return x; }()};"); // Lambdas with explicit template argument lists. verifyFormat( Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1786,6 +1786,9 @@ case tok::l_paren: parseParens(); break; + case tok::l_square: + parseSquare(); + break; case tok::amp: case tok::star: case tok::kw_const:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits