Skip to content

Commit 043ceb2

Browse files
committed
Reduce backtracking when parsing nested name specifiers
Signed-off-by: Roberto Raggi <[email protected]>
1 parent 49b9e65 commit 043ceb2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/parser/cxx/parser.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,14 @@ auto Parser::parse_nested_name_specifier(NestedNameSpecifierAST*& yyast)
15651565
auto lookat_decltype_nested_name_specifier = [&] {
15661566
LookaheadParser lookahead{this};
15671567

1568+
SourceLocation decltypeLoc;
1569+
if (!match(TokenKind::T_DECLTYPE, decltypeLoc)) return false;
1570+
if (!lookat(TokenKind::T_LPAREN)) return false;
1571+
if (!parse_skip_balanced()) return false;
1572+
if (!lookat(TokenKind::T_COLON_COLON)) return false;
1573+
1574+
rewind(decltypeLoc);
1575+
15681576
DecltypeSpecifierAST* decltypeSpecifier = nullptr;
15691577
if (!parse_decltype_specifier(decltypeSpecifier)) return false;
15701578

0 commit comments

Comments
 (0)