Skip to content

Commit 1253540

Browse files
author
git apple-llvm automerger
committed
Merge commit 'c609043dd009' from llvm.org/main into next
2 parents c239604 + c609043 commit 1253540

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,8 +1763,9 @@ void UnwrappedLineParser::parseStructuralElement(
17631763
break;
17641764
}
17651765
case tok::kw_enum:
1766-
// Ignore if this is part of "template <enum ..." or "... -> enum".
1767-
if (Previous && Previous->isOneOf(tok::less, tok::arrow)) {
1766+
// Ignore if this is part of "template <enum ..." or "... -> enum" or
1767+
// "template <..., enum ...>".
1768+
if (Previous && Previous->isOneOf(tok::less, tok::arrow, tok::comma)) {
17681769
nextToken();
17691770
break;
17701771
}

clang/unittests/Format/TokenAnnotatorTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ TEST_F(TokenAnnotatorTest, UnderstandsStructs) {
489489
EXPECT_TOKEN(Tokens[24], tok::amp, TT_UnaryOperator);
490490
EXPECT_TOKEN(Tokens[27], tok::l_square, TT_ArraySubscriptLSquare);
491491
EXPECT_TOKEN(Tokens[32], tok::r_brace, TT_StructRBrace);
492+
493+
Tokens = annotate("template <typename T, enum E e> struct S {};");
494+
ASSERT_EQ(Tokens.size(), 15u) << Tokens;
495+
EXPECT_TOKEN(Tokens[11], tok::l_brace, TT_StructLBrace);
492496
}
493497

494498
TEST_F(TokenAnnotatorTest, UnderstandsUnions) {

0 commit comments

Comments
 (0)