owenpan created this revision. owenpan added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius. owenpan added a project: clang-format. Herald added a project: All. owenpan requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fixes https://github.com/llvm/llvm-project/issues/57160. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D132008 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -24887,7 +24887,7 @@ // the user's own fault verifyFormat("integral auto(x) = y;"); // actually a declaration, but this is // clearly the user's own fault - verifyFormat("auto(*p)() = f;"); // actually a declaration; TODO FIXME + verifyFormat("auto (*p)() = f;"); } TEST_F(FormatTest, Cpp20ModulesSupport) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3337,9 +3337,11 @@ } // trailing return type 'auto': []() -> auto {}, auto foo() -> auto {} - if (Left.is(tok::kw_auto) && - Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace)) + if (Left.is(tok::kw_auto) && Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace, + // function return type 'auto' + TT_FunctionTypeLParen)) { return true; + } // auto{x} auto(x) if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -24887,7 +24887,7 @@ // the user's own fault verifyFormat("integral auto(x) = y;"); // actually a declaration, but this is // clearly the user's own fault - verifyFormat("auto(*p)() = f;"); // actually a declaration; TODO FIXME + verifyFormat("auto (*p)() = f;"); } TEST_F(FormatTest, Cpp20ModulesSupport) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3337,9 +3337,11 @@ } // trailing return type 'auto': []() -> auto {}, auto foo() -> auto {} - if (Left.is(tok::kw_auto) && - Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace)) + if (Left.is(tok::kw_auto) && Right.isOneOf(TT_LambdaLBrace, TT_FunctionLBrace, + // function return type 'auto' + TT_FunctionTypeLParen)) { return true; + } // auto{x} auto(x) if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits