llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: None (XDeme) <details> <summary>Changes</summary> Fixes llvm/llvm-project#<!-- -->80062 --- Full diff: https://github.com/llvm/llvm-project/pull/80085.diff 2 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+2-2) - (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+6) ``````````diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index b904e0e56d9eb..57669bc61749e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1760,8 +1760,8 @@ void UnwrappedLineParser::parseStructuralElement( break; } case tok::kw_enum: - // Ignore if this is part of "template <enum ...". - if (Previous && Previous->is(tok::less)) { + // Ignore if this is part of "template <enum ..." or "... -> enum". + if (Previous && (Previous->is(tok::less) || Previous->is(tok::arrow))) { nextToken(); break; } diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 67678c18963b1..8924583278620 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2606,6 +2606,12 @@ TEST_F(TokenAnnotatorTest, StreamOperator) { EXPECT_TRUE(Tokens[5]->MustBreakBefore); } +TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { + auto Tokens = annotate("auto foo() -> enum En {}"); + ASSERT_EQ(Tokens.size(), 10u); + EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_FunctionLBrace); +} + } // namespace } // namespace format } // namespace clang `````````` </details> https://github.com/llvm/llvm-project/pull/80085 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits