Skip to content

Commit

Permalink
[FOLD] treat names prefixed by 'template' as template argument lists …
Browse files Browse the repository at this point in the history
…when skipping past template arguments
  • Loading branch information
sdkrystian committed Aug 21, 2024
1 parent 58b67ae commit ec0fc1e
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions clang/lib/Parse/ParseTentative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2332,9 +2332,6 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
if (!TryConsumeToken(tok::less))
return TPResult::False;

bool IsNestedTemplateArgumentList = !GreaterThanIsOperator;
GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);

auto TrySkipTemplateArgument = [&]() {
bool NextIsTemplateId = false;
unsigned TemplateDepth = 0;
Expand All @@ -2348,76 +2345,76 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
case tok::semi:
return TPResult::False;

case tok::comma:
case tok::greater:
case tok::greatergreater:
case tok::greatergreatergreater:
if (TemplateDepth)
--TemplateDepth;
[[fallthrough]];
case tok::greatergreater:
if (TemplateDepth)
--TemplateDepth;
[[fallthrough]];
case tok::greater:
if (TemplateDepth) {
ConsumeToken();
--TemplateDepth;
break;
}
[[fallthrough]];
case tok::comma:
return TPResult::True;

case tok::l_paren:
ConsumeParen();
if (!SkipUntil(tok::r_paren, StopAtSemi))
return TPResult::Error;
break;

case tok::l_brace:
ConsumeBrace();
if (!SkipUntil(tok::r_brace, StopAtSemi))
return TPResult::Error;
break;

case tok::l_square:
ConsumeBracket();
if (!SkipUntil(tok::r_square, StopAtSemi))
return TPResult::Error;
break;

case tok::question:
ConsumeToken();
if (!SkipUntil(tok::colon, StopAtSemi))
return TPResult::Error;
break;

#if 0
case tok::kw_template:
ConsumeToken();
NextIsTemplateId = true;
continue;
#endif
case tok::kw_template:
ConsumeToken();
NextIsTemplateId = true;
continue;

case tok::identifier:
ConsumeToken();
#if 0
if (Tok.is(tok::less)) {
if (!NextIsTemplateId)
return TPResult::Ambiguous;
ConsumeToken();
if (!SkipUntil({tok::greater, tok::greatergreater, tok::greatergreatergreater}, StopAtSemi))
return TPResult::Error;
break;
}
#else
if (Tok.is(tok::less))
return TPResult::Ambiguous;
if (Tok.is(tok::less)) {
if (!NextIsTemplateId)
return TPResult::Ambiguous;
ConsumeToken();
++TemplateDepth;
}
break;
#endif

case tok::kw_operator:
if (TPResult TPR = TryParseNonConversionOperatorId();
TPR == TPResult::Error) {
return TPResult::Error;
} else if (TPR == TPResult::True) {
if (Tok.is(tok::less))
return TPResult::Ambiguous;
}
break;

#if 0
if (Tok.is(tok::less)) {
if (!NextIsTemplateId)
return TPResult::Ambiguous;
ConsumeToken();
if (!SkipUntil({tok::greater, tok::greatergreater, tok::greatergreatergreater}, StopAtSemi))
return TPResult::Error;
++TemplateDepth;
}
break;
#endif
}
break;

case tok::kw_const_cast:
case tok::kw_dynamic_cast:
Expand Down Expand Up @@ -2458,6 +2455,9 @@ Parser::TPResult Parser::isTemplateArgumentList(unsigned TokensToSkip,
}
};

bool IsNestedTemplateArgumentList = !GreaterThanIsOperator;
GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);

while (true) {
// An expression cannot be followed by a braced-init-list unless
// its the right operand of an assignment operator.
Expand Down

0 comments on commit ec0fc1e

Please sign in to comment.