diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index b8cffcd471e9..c5594a6d6648 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1940,11 +1940,6 @@ bool UnwrappedLineParser::tryToParseLambda() { if (!tryToParseLambdaIntroducer()) return false; - // `[something] >` is not a lambda, but an array type in a template parameter - // list. - if (FormatTok->is(tok::greater)) - return false; - bool SeenArrow = false; bool InTemplateParameterList = false; @@ -3534,7 +3529,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) { // Don't try parsing a lambda if we had a closing parenthesis before, // it was probably a pointer to an array: int (*)[]. if (!tryToParseLambda()) - continue; + break; } else { parseSquare(); continue; diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index ac0802f83717..380ec90330f1 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -98,20 +98,6 @@ TEST_F(TokenAnnotatorTest, UnderstandsStructs) { auto Tokens = annotate("struct S {};"); EXPECT_EQ(Tokens.size(), 6u) << Tokens; EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_StructLBrace); - - Tokens = annotate("template struct S {};"); - EXPECT_EQ(Tokens.size(), 18u) << Tokens; - EXPECT_TOKEN(Tokens[7], tok::less, TT_TemplateOpener); - EXPECT_TOKEN(Tokens[10], tok::l_square, TT_ArraySubscriptLSquare); - EXPECT_TOKEN(Tokens[13], tok::greater, TT_TemplateCloser); - EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_StructLBrace); - - Tokens = annotate("template struct S {};"); - EXPECT_EQ(Tokens.size(), 18u) << Tokens; - EXPECT_TOKEN(Tokens[7], tok::less, TT_TemplateOpener); - EXPECT_TOKEN(Tokens[10], tok::l_square, TT_ArraySubscriptLSquare); - EXPECT_TOKEN(Tokens[13], tok::greater, TT_TemplateCloser); - EXPECT_TOKEN(Tokens[14], tok::l_brace, TT_StructLBrace); } TEST_F(TokenAnnotatorTest, UnderstandsUnions) {