[clang-format] Handles Elaborated type specifier for enum in trailing return (#80085)

Fixes llvm/llvm-project#80062
This commit is contained in:
XDeme 2024-02-01 14:11:14 -03:00 committed by GitHub
parent 7b9bf80ab5
commit 7e7f118404
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -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->isOneOf(tok::less, tok::arrow)) {
nextToken();
break;
}

View File

@ -2644,6 +2644,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) << Tokens;
EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_FunctionLBrace);
}
} // namespace
} // namespace format
} // namespace clang