23 #include "llvm/Support/TimeProfiler.h"
24 using namespace clang;
38 Decl *Parser::ParseDeclarationStartingWithTemplate(
43 if (Tok.
is(tok::kw_template) &&
NextToken().isNot(tok::less)) {
45 DeclEnd, AccessAttrs, AS);
47 return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AccessAttrs,
75 Decl *Parser::ParseTemplateDeclarationOrSpecialization(
78 assert(Tok.
isOneOf(tok::kw_export, tok::kw_template) &&
79 "Token does not start a template declaration.");
81 MultiParseScope TemplateParamScopes(*
this);
109 bool isSpecialization =
true;
110 bool LastParamListWasEmpty =
false;
112 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
129 if (ParseTemplateParameters(TemplateParamScopes,
130 CurTemplateDepthTracker.getDepth(),
131 TemplateParams, LAngleLoc, RAngleLoc)) {
138 ExprResult OptionalRequiresClauseConstraintER;
139 if (!TemplateParams.empty()) {
140 isSpecialization =
false;
141 ++CurTemplateDepthTracker;
144 OptionalRequiresClauseConstraintER =
147 if (!OptionalRequiresClauseConstraintER.
isUsable()) {
155 LastParamListWasEmpty =
true;
159 CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
160 TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.
get()));
161 }
while (Tok.
isOneOf(tok::kw_export, tok::kw_template));
164 if (Tok.
is(tok::kw_concept))
165 return ParseConceptDefinition(
166 ParsedTemplateInfo(&ParamLists, isSpecialization,
167 LastParamListWasEmpty),
170 return ParseSingleDeclarationAfterTemplate(
172 ParsedTemplateInfo(&ParamLists, isSpecialization, LastParamListWasEmpty),
173 ParsingTemplateParams, DeclEnd, AccessAttrs, AS);
186 Decl *Parser::ParseSingleDeclarationAfterTemplate(
190 assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
191 "Template information required");
193 if (Tok.
is(tok::kw_static_assert)) {
196 << TemplateInfo.getSourceRange();
198 return ParseStaticAssertDeclaration(DeclEnd);
204 AS, AccessAttrs, TemplateInfo, &DiagsFromTParams);
206 if (!D || !D.get().isSingleDecl())
208 return D.get().getSingleDecl();
212 MaybeParseCXX11Attributes(prefixAttrs);
214 if (Tok.
is(tok::kw_using)) {
215 auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
217 if (!usingDeclPtr || !usingDeclPtr.get().isSingleDecl())
219 return usingDeclPtr.get().getSingleDecl();
226 ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
227 getDeclSpecContextFromDeclaratorContext(Context));
229 if (Tok.
is(tok::semi)) {
230 ProhibitAttributes(prefixAttrs);
235 TemplateInfo.TemplateParams ? *TemplateInfo.TemplateParams
237 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation,
239 assert(!AnonRecord &&
240 "Anonymous unions/structs should not be valid with template");
246 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
247 ProhibitAttributes(prefixAttrs);
249 DS.takeAttributesFrom(prefixAttrs);
253 if (TemplateInfo.TemplateParams)
254 DeclaratorInfo.setTemplateParameterLists(*TemplateInfo.TemplateParams);
266 bool IsTemplateSpecOrInst =
267 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
268 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
271 ParseDeclarator(DeclaratorInfo);
273 if (IsTemplateSpecOrInst)
277 if (!DeclaratorInfo.hasName()) {
280 if (Tok.
is(tok::semi))
285 llvm::TimeTraceScope TimeScope(
"ParseTemplate", [&]() {
286 return std::string(DeclaratorInfo.getIdentifier() !=
nullptr
287 ? DeclaratorInfo.getIdentifier()->getName()
291 LateParsedAttrList LateParsedAttrs(
true);
292 if (DeclaratorInfo.isFunctionDeclarator()) {
293 if (Tok.
is(tok::kw_requires))
294 ParseTrailingRequiresClause(DeclaratorInfo);
296 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
299 if (DeclaratorInfo.isFunctionDeclarator() &&
300 isStartOfFunctionDefinition(DeclaratorInfo)) {
306 Diag(Tok, diag::err_function_definition_not_allowed);
315 Diag(DS.getStorageClassSpecLoc(), diag::err_function_declared_typedef)
317 DS.ClearStorageClassSpecs();
320 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
321 if (DeclaratorInfo.getName().getKind() !=
325 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
326 return ParseFunctionDefinition(DeclaratorInfo, ParsedTemplateInfo(),
331 Diag(DeclaratorInfo.getIdentifierLoc(),
332 diag::err_explicit_instantiation_with_definition)
340 LAngleLoc,
nullptr));
342 return ParseFunctionDefinition(
343 DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
349 return ParseFunctionDefinition(DeclaratorInfo, TemplateInfo,
354 Decl *ThisDecl = ParseDeclarationAfterDeclarator(DeclaratorInfo,
357 if (Tok.
is(tok::comma)) {
358 Diag(Tok, diag::err_multiple_template_declarators)
359 << (
int)TemplateInfo.Kind;
365 ExpectAndConsumeSemi(diag::err_expected_semi_declaration);
366 if (LateParsedAttrs.size() > 0)
367 ParseLexedAttributeList(LateParsedAttrs, ThisDecl,
true,
false);
368 DeclaratorInfo.complete(ThisDecl);
379 Parser::ParseConceptDefinition(
const ParsedTemplateInfo &TemplateInfo,
381 assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
382 "Template information required");
383 assert(Tok.
is(tok::kw_concept) &&
384 "ParseConceptDefinition must be called when at a 'concept' keyword");
393 DiagnoseAndSkipCXX11Attributes();
396 if (ParseOptionalCXXScopeSpecifier(
400 false,
nullptr,
true) ||
408 diag::err_concept_definition_not_identifier);
422 Diag(Result.
getBeginLoc(), diag::err_concept_definition_not_identifier);
430 DiagnoseAndSkipCXX11Attributes();
446 ExpectAndConsumeSemi(diag::err_expected_semi_declaration);
447 Expr *ConstraintExpr = ConstraintExprResult.
get();
449 *TemplateInfo.TemplateParams,
450 Id, IdLoc, ConstraintExpr);
462 bool Parser::ParseTemplateParameters(
463 MultiParseScope &TemplateScopes,
unsigned Depth,
475 if (!Tok.
is(tok::greater) && !Tok.
is(tok::greatergreater)) {
477 Failed = ParseTemplateParameterList(
Depth, TemplateParams);
480 if (Tok.
is(tok::greatergreater)) {
505 Parser::ParseTemplateParameterList(
const unsigned Depth,
510 = ParseTemplateParameter(
Depth, TemplateParams.size())) {
511 TemplateParams.push_back(TmpParam);
515 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
520 if (Tok.
is(tok::comma)) {
522 }
else if (Tok.
isOneOf(tok::greater, tok::greatergreater)) {
530 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
540 Parser::TPResult Parser::isStartOfTemplateTypeParameter() {
541 if (Tok.
is(tok::kw_class)) {
548 case tok::greatergreater:
550 return TPResult::True;
552 case tok::identifier:
558 return TPResult::False;
561 switch (GetLookAheadToken(2).
getKind()) {
565 case tok::greatergreater:
566 return TPResult::True;
569 return TPResult::False;
573 if (TryAnnotateTypeConstraint())
574 return TPResult::Error;
576 if (isTypeConstraintAnnotation() &&
580 !GetLookAheadToken(Tok.
is(tok::annot_cxxscope) ? 2 : 1)
581 .
isOneOf(tok::kw_auto, tok::kw_decltype))
582 return TPResult::True;
586 if (Tok.
isNot(tok::kw_typename) && Tok.
isNot(tok::kw_typedef))
587 return TPResult::False;
598 if (Next.getKind() == tok::identifier)
599 Next = GetLookAheadToken(2);
601 switch (Next.getKind()) {
605 case tok::greatergreater:
607 return TPResult::True;
609 case tok::kw_typename:
610 case tok::kw_typedef:
614 return TPResult::True;
617 return TPResult::False;
641 NamedDecl *Parser::ParseTemplateParameter(
unsigned Depth,
unsigned Position) {
643 switch (isStartOfTemplateTypeParameter()) {
647 if (Tok.
is(tok::kw_typedef)) {
659 return ParseTypeParameter(
Depth, Position);
660 case TPResult::False:
663 case TPResult::Error: {
671 DS.SetTypeSpecError();
674 D.setInvalidType(
true);
679 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
684 case TPResult::Ambiguous:
685 llvm_unreachable(
"template param classification can't be ambiguous");
688 if (Tok.
is(tok::kw_template))
689 return ParseTemplateTemplateParameter(
Depth, Position);
694 return ParseNonTypeTemplateParameter(
Depth, Position);
699 bool Parser::isTypeConstraintAnnotation() {
701 if (T.
isNot(tok::annot_template_id))
703 const auto *ExistingAnnot =
716 bool Parser::TryAnnotateTypeConstraint() {
720 bool WasScopeAnnotation = Tok.
is(tok::annot_cxxscope);
721 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
736 if (Tok.
is(tok::identifier)) {
742 bool MemberOfUnknownSpecialization =
false;
749 MemberOfUnknownSpecialization,
751 if (MemberOfUnknownSpecialization || !PossibleConcept ||
754 AnnotateScopeToken(SS, !WasScopeAnnotation);
761 if (AnnotateTemplateIdToken(PossibleConcept, TNK, SS,
770 AnnotateScopeToken(SS, !WasScopeAnnotation);
783 NamedDecl *Parser::ParseTypeParameter(
unsigned Depth,
unsigned Position) {
784 assert((Tok.
isOneOf(tok::kw_class, tok::kw_typename) ||
785 isTypeConstraintAnnotation()) &&
786 "A type-parameter starts with 'class', 'typename' or a "
791 bool TypenameKeyword =
false;
793 ParseOptionalCXXScopeSpecifier(TypeConstraintSS,
nullptr,
796 if (Tok.
is(tok::annot_template_id)) {
801 "stray non-concept template-id annotation");
802 KeyLoc = ConsumeAnnotationToken();
804 assert(TypeConstraintSS.
isEmpty() &&
805 "expected type constraint after scope specifier");
808 TypenameKeyword = Tok.
is(tok::kw_typename);
817 ? diag::warn_cxx98_compat_variadic_templates
818 : diag::ext_variadic_templates);
824 if (Tok.
is(tok::identifier)) {
827 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
828 tok::greatergreater)) {
837 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
839 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
852 TypenameKeyword, EllipsisLoc,
853 KeyLoc, ParamName, NameLoc,
854 Depth, Position, EqualLoc,
860 cast<TemplateTypeParmDecl>(NewDecl),
879 Parser::ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position) {
880 assert(Tok.
is(tok::kw_template) &&
"Expected 'template' keyword");
887 MultiParseScope TemplateParmScope(*
this);
888 if (ParseTemplateParameters(TemplateParmScope,
Depth + 1, TemplateParams,
889 LAngleLoc, RAngleLoc)) {
900 bool Replace = Tok.
isOneOf(tok::kw_typename, tok::kw_struct);
902 if (Tok.
is(tok::kw_typename)) {
905 ? diag::warn_cxx14_compat_template_template_param_typename
906 : diag::ext_template_template_param_typename)
910 }
else if (Next.isOneOf(tok::identifier, tok::comma, tok::greater,
911 tok::greatergreater, tok::ellipsis)) {
916 :
FixItHint::CreateInsertion(Tok.getLocation(),
"class "));
930 ? diag::warn_cxx98_compat_variadic_templates
931 : diag::ext_variadic_templates);
936 if (Tok.
is(tok::identifier)) {
939 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
940 tok::greatergreater)) {
949 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
951 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
955 TemplateLoc, LAngleLoc,
965 DefaultArg = ParseTemplateTemplateArgument();
968 diag::err_default_template_template_parameter_not_template);
969 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
975 ParamList, EllipsisLoc,
976 ParamName, NameLoc,
Depth,
977 Position, EqualLoc, DefaultArg);
987 Parser::ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position) {
992 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(),
AS_none,
993 DeclSpecContext::DSC_template_param);
997 ParseDeclarator(ParamDecl);
1006 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, ParamDecl);
1014 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::l_brace)) {
1035 Depth, Position, EqualLoc,
1039 void Parser::DiagnoseMisplacedEllipsis(
SourceLocation EllipsisLoc,
1041 bool AlreadyHasEllipsis,
1042 bool IdentifierHasName) {
1044 if (!AlreadyHasEllipsis)
1046 Diag(EllipsisLoc, diag::err_misplaced_ellipsis_in_declaration)
1048 << !IdentifierHasName;
1051 void Parser::DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
1053 assert(EllipsisLoc.
isValid());
1055 if (!AlreadyHasEllipsis)
1058 AlreadyHasEllipsis, D.
hasName());
1076 bool Parser::ParseGreaterThanInTemplateList(
SourceLocation LAngleLoc,
1078 bool ConsumeLastToken,
1079 bool ObjCGenericList) {
1082 const char *ReplacementStr =
"> >";
1083 bool MergeWithNextToken =
false;
1088 Diag(LAngleLoc, diag::note_matching) << tok::less;
1095 if (ConsumeLastToken)
1099 case tok::greatergreater:
1100 RemainingToken = tok::greater;
1103 case tok::greatergreatergreater:
1104 RemainingToken = tok::greatergreater;
1107 case tok::greaterequal:
1108 RemainingToken = tok::equal;
1109 ReplacementStr =
"> =";
1116 RemainingToken = tok::equalequal;
1117 MergeWithNextToken =
true;
1121 case tok::greatergreaterequal:
1122 RemainingToken = tok::greaterequal;
1141 bool PreventMergeWithNextToken =
1142 (RemainingToken == tok::greater ||
1143 RemainingToken == tok::greatergreater) &&
1144 (Next.isOneOf(tok::greater, tok::greatergreater,
1145 tok::greatergreatergreater, tok::equal, tok::greaterequal,
1146 tok::greatergreaterequal, tok::equalequal)) &&
1147 areTokensAdjacent(Tok, Next);
1150 if (!ObjCGenericList) {
1165 if (PreventMergeWithNextToken)
1168 unsigned DiagId = diag::err_two_right_angle_brackets_need_space;
1170 (Tok.
is(tok::greatergreater) || Tok.
is(tok::greatergreatergreater)))
1171 DiagId = diag::warn_cxx98_compat_two_right_angle_brackets;
1172 else if (Tok.
is(tok::greaterequal))
1173 DiagId = diag::err_right_angle_bracket_equal_needs_space;
1174 Diag(TokLoc, DiagId) << Hint1 << Hint2;
1185 RAngleLoc = PP.
SplitToken(TokLoc, GreaterLength);
1191 Greater.setLocation(RAngleLoc);
1192 Greater.setKind(tok::greater);
1193 Greater.setLength(GreaterLength);
1196 if (MergeWithNextToken) {
1202 Tok.
setLength(OldLength - GreaterLength);
1207 if (PreventMergeWithNextToken)
1212 if (CachingTokens) {
1214 if (MergeWithNextToken)
1217 if (ConsumeLastToken)
1223 if (ConsumeLastToken) {
1224 PrevTokLocation = RAngleLoc;
1226 PrevTokLocation = TokBeforeGreaterLoc;
1245 bool Parser::ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
1247 TemplateArgList &TemplateArgs,
1249 TemplateTy Template) {
1250 assert(Tok.
is(tok::less) &&
"Must have already parsed the template-name");
1259 if (!Tok.
isOneOf(tok::greater, tok::greatergreater,
1260 tok::greatergreatergreater, tok::greaterequal,
1261 tok::greatergreaterequal))
1262 Invalid = ParseTemplateArgumentList(TemplateArgs, Template, LAngleLoc);
1267 SkipUntil(tok::greater, tok::greatergreater,
1274 return ParseGreaterThanInTemplateList(LAngleLoc, RAngleLoc, ConsumeLastToken,
1320 bool Parser::AnnotateTemplateIdToken(TemplateTy Template,
TemplateNameKind TNK,
1324 bool AllowTypeAnnotation,
1328 "Parser isn't at the beginning of a template-id");
1329 assert(!(
TypeConstraint && AllowTypeAnnotation) &&
"type-constraint can't be "
1330 "a type annotation");
1332 "must accompany a concept name");
1340 TemplateArgList TemplateArgs;
1341 bool ArgsInvalid =
false;
1343 ArgsInvalid = ParseTemplateIdAfterTemplateName(
1344 false, LAngleLoc, TemplateArgs, RAngleLoc, Template);
1359 : Actions.ActOnTemplateIdType(
1362 LAngleLoc, TemplateArgsPtr, RAngleLoc);
1364 Tok.
setKind(tok::annot_typename);
1365 setTypeAnnotation(Tok,
Type);
1368 else if (TemplateKWLoc.
isValid())
1375 Tok.
setKind(tok::annot_template_id);
1388 TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
1389 LAngleLoc, RAngleLoc, TemplateArgs, ArgsInvalid, TemplateIds);
1420 void Parser::AnnotateTemplateIdTokenAsType(
CXXScopeSpec &SS,
1422 assert(Tok.
is(tok::annot_template_id) &&
"Requires template-id tokens");
1426 "Only works for type and dependent templates");
1434 : Actions.ActOnTemplateIdType(
1436 TemplateId->Template, TemplateId->Name,
1437 TemplateId->TemplateNameLoc, TemplateId->LAngleLoc,
1438 TemplateArgsPtr, TemplateId->RAngleLoc,
1439 false, IsClassName);
1441 Tok.
setKind(tok::annot_typename);
1442 setTypeAnnotation(Tok,
Type);
1455 return Tok.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
1456 tok::greatergreatergreater);
1461 if (!Tok.
is(tok::identifier) && !Tok.
is(tok::coloncolon) &&
1462 !Tok.
is(tok::annot_cxxscope))
1477 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1483 if (SS.
isSet() && Tok.
is(tok::kw_template)) {
1488 if (Tok.
is(tok::identifier)) {
1506 }
else if (Tok.
is(tok::identifier)) {
1516 bool MemberOfUnknownSpecialization;
1521 false, Template, MemberOfUnknownSpecialization);
1531 if (EllipsisLoc.
isValid() && !Result.isInvalid())
1558 if (isCXXTypeId(TypeIdAsTemplateArgument)) {
1566 TentativeParsingAction TPA(*
this);
1569 = ParseTemplateTemplateArgument();
1570 if (!TemplateTemplateArgument.
isInvalid()) {
1572 return TemplateTemplateArgument;
1587 ExprArg.
get(), Loc);
1598 bool Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs,
1599 TemplateTy Template,
1604 auto RunSignatureHelp = [&] {
1607 CalledSignatureHelp =
true;
1626 TemplateArgs.push_back(Arg);
1652 return ParseSingleDeclarationAfterTemplate(
1653 Context, ParsedTemplateInfo(ExternLoc, TemplateLoc),
1654 ParsingTemplateParams, DeclEnd, AccessAttrs, AS);
1660 TemplateParams->size());
1664 R.setBegin(ExternLoc);
1669 ((
Parser *)
P)->ParseLateTemplatedFuncDef(LPT);
1678 DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*
this);
1683 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1689 MultiParseScope Scopes(*
this);
1694 DC = DC->getLexicalParent())
1695 DeclContextsToReenter.push_back(DC);
1698 for (
DeclContext *DC : reverse(DeclContextsToReenter)) {
1699 CurTemplateDepthTracker.addDepth(
1707 assert(!LPT.
Toks.empty() &&
"Empty body!");
1711 LPT.
Toks.push_back(Tok);
1712 PP.EnterTokenStream(LPT.
Toks,
true,
true);
1716 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try) &&
1717 "Inline method not starting with '{', ':' or 'try'");
1729 if (Tok.
is(tok::kw_try)) {
1730 ParseFunctionTryBlock(LPT.
D, FnScope);
1732 if (Tok.
is(tok::colon))
1733 ParseConstructorInitializer(LPT.
D);
1737 if (Tok.
is(tok::l_brace)) {
1738 assert((!isa<FunctionTemplateDecl>(LPT.
D) ||
1739 cast<FunctionTemplateDecl>(LPT.
D)
1740 ->getTemplateParameters()
1741 ->getDepth() == TemplateParameterDepth - 1) &&
1742 "TemplateParameterDepth should be greater than the depth of "
1743 "current template being instantiated!");
1744 ParseFunctionStatementBody(LPT.
D, FnScope);
1752 void Parser::LexTemplateFunctionForLateParsing(
CachedTokens &Toks) {
1754 if (!ConsumeAndStoreFunctionPrologue(Toks)) {
1756 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1760 if (
kind == tok::kw_try) {
1761 while (Tok.
is(tok::kw_catch)) {
1762 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
1763 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1773 TentativeParsingAction TPA(*
this);
1775 if (
SkipUntil(tok::greater, tok::greatergreater, tok::greatergreatergreater,
1780 ParseGreaterThanInTemplateList(Less, Greater,
true,
false);
1792 void Parser::checkPotentialAngleBracket(
ExprResult &PotentialTemplateName) {
1793 assert(Tok.
is(tok::less) &&
"not at a potential angle bracket");
1809 ParseGreaterThanInTemplateList(Less, Greater,
true,
false);
1811 getCurScope(), PotentialTemplateName, Less, Greater);
1821 TentativeParsingAction TPA(*
this);
1823 if (isTypeIdUnambiguously() &&
1824 diagnoseUnknownTemplateId(PotentialTemplateName, Less)) {
1837 : AngleBracketTracker::PotentialTypo) |
1839 : AngleBracketTracker::NoSpaceBeforeLess);
1840 AngleBrackets.add(*
this, PotentialTemplateName.
get(), Tok.
getLocation(),
1844 bool Parser::checkPotentialAngleBracketDelimiter(
1845 const AngleBracketTracker::Loc &LAngle,
const Token &OpToken) {
1849 if (OpToken.
is(tok::comma) && isTypeIdUnambiguously() &&
1850 diagnoseUnknownTemplateId(LAngle.TemplateName, LAngle.LessLoc)) {
1851 AngleBrackets.clear(*
this);
1858 if (OpToken.
is(tok::greater) && Tok.
is(tok::l_paren) &&
1861 getCurScope(), LAngle.TemplateName, LAngle.LessLoc,
1863 AngleBrackets.clear(*
this);
1869 if (OpToken.
is(tok::greater) ||
1871 OpToken.
isOneOf(tok::greatergreater, tok::greatergreatergreater)))
1872 AngleBrackets.clear(*
this);