https://github.com/XDeme updated https://github.com/llvm/llvm-project/pull/80085
>From 31936e52dd7a14f6f165ea15930f0b9d5c5a8d34 Mon Sep 17 00:00:00 2001 From: XDeme <fernando.tagawa.gamail....@gmail.com> Date: Tue, 30 Jan 2024 21:36:04 -0300 Subject: [PATCH 1/3] Handle enum elaborated type specifier --- clang/lib/Format/UnwrappedLineParser.cpp | 4 ++-- clang/unittests/Format/TokenAnnotatorTest.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) 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 >From c05543320403b1fe073885e9429c9127c0f29558 Mon Sep 17 00:00:00 2001 From: XDeme <fernando.tagawa.gamail....@gmail.com> Date: Tue, 30 Jan 2024 23:55:22 -0300 Subject: [PATCH 2/3] Addresses comments --- clang/lib/Format/UnwrappedLineParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 57669bc61749e..162d126f0f5a8 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1761,7 +1761,7 @@ void UnwrappedLineParser::parseStructuralElement( } case tok::kw_enum: // Ignore if this is part of "template <enum ..." or "... -> enum". - if (Previous && (Previous->is(tok::less) || Previous->is(tok::arrow))) { + if (Previous && Previous->isOneOf(tok::less, tok::arrow)) { nextToken(); break; } >From 61746441b75f31d53c61a26e4adb664c7894ec1a Mon Sep 17 00:00:00 2001 From: XDeme <fernando.tagawa.gamail....@gmail.com> Date: Wed, 31 Jan 2024 00:03:51 -0300 Subject: [PATCH 3/3] Add missing --- clang/unittests/Format/TokenAnnotatorTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 8924583278620..65d4a32aaae69 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2608,7 +2608,7 @@ TEST_F(TokenAnnotatorTest, StreamOperator) { TEST_F(TokenAnnotatorTest, UnderstandsElaboratedTypeSpecifier) { auto Tokens = annotate("auto foo() -> enum En {}"); - ASSERT_EQ(Tokens.size(), 10u); + ASSERT_EQ(Tokens.size(), 10u) << Tokens; EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_FunctionLBrace); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits