[clang-format] Handles Elaborated type specifier for enum in trailing return (#80085)
Fixes llvm/llvm-project#80062
This commit is contained in:
parent
7b9bf80ab5
commit
7e7f118404
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user