22 using namespace clang;
26 Decl *Parser::ParseDeclarationStartingWithTemplate(
33 DeclEnd, AccessAttrs, AS);
35 return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AccessAttrs,
54 Decl *Parser::ParseTemplateDeclarationOrSpecialization(
57 assert(Tok.
isOneOf(tok::kw_export, tok::kw_template) &&
58 "Token does not start a template declaration.");
89 bool isSpecialization =
true;
90 bool LastParamListWasEmpty =
false;
92 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
109 if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(),
110 TemplateParams, LAngleLoc, RAngleLoc)) {
117 ExprResult OptionalRequiresClauseConstraintER;
118 if (!TemplateParams.empty()) {
119 isSpecialization =
false;
120 ++CurTemplateDepthTracker;
123 OptionalRequiresClauseConstraintER =
125 if (!OptionalRequiresClauseConstraintER.
isUsable()) {
133 LastParamListWasEmpty =
true;
137 CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
138 TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.
get()));
139 }
while (Tok.
isOneOf(tok::kw_export, tok::kw_template));
142 ParseScopeFlags TemplateScopeFlags(
this, NewFlags, isSpecialization);
145 return ParseSingleDeclarationAfterTemplate(
147 ParsedTemplateInfo(&ParamLists, isSpecialization, LastParamListWasEmpty),
148 ParsingTemplateParams, DeclEnd, AccessAttrs, AS);
161 Decl *Parser::ParseSingleDeclarationAfterTemplate(
165 assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
166 "Template information required");
168 if (Tok.
is(tok::kw_static_assert)) {
171 << TemplateInfo.getSourceRange();
173 return ParseStaticAssertDeclaration(DeclEnd);
178 ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
183 ParsedAttributesWithRange prefixAttrs(AttrFactory);
184 MaybeParseCXX11Attributes(prefixAttrs);
186 if (Tok.
is(tok::kw_using)) {
187 auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
189 if (!usingDeclPtr || !usingDeclPtr.get().isSingleDecl())
191 return usingDeclPtr.get().getSingleDecl();
198 ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
199 getDeclSpecContextFromDeclaratorContext(Context));
201 if (Tok.
is(tok::semi)) {
202 ProhibitAttributes(prefixAttrs);
207 TemplateInfo.TemplateParams ? *TemplateInfo.TemplateParams
209 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation,
211 assert(!AnonRecord &&
212 "Anonymous unions/structs should not be valid with template");
218 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
219 ProhibitAttributes(prefixAttrs);
221 DS.takeAttributesFrom(prefixAttrs);
225 ParseDeclarator(DeclaratorInfo);
227 if (!DeclaratorInfo.hasName()) {
230 if (Tok.
is(tok::semi))
235 LateParsedAttrList LateParsedAttrs(
true);
236 if (DeclaratorInfo.isFunctionDeclarator())
237 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
239 if (DeclaratorInfo.isFunctionDeclarator() &&
240 isStartOfFunctionDefinition(DeclaratorInfo)) {
246 Diag(Tok, diag::err_function_definition_not_allowed);
255 Diag(DS.getStorageClassSpecLoc(), diag::err_function_declared_typedef)
257 DS.ClearStorageClassSpecs();
260 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
261 if (DeclaratorInfo.getName().getKind() !=
265 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
266 return ParseFunctionDefinition(DeclaratorInfo, ParsedTemplateInfo(),
271 Diag(DeclaratorInfo.getIdentifierLoc(),
272 diag::err_explicit_instantiation_with_definition)
280 LAngleLoc,
nullptr));
282 return ParseFunctionDefinition(
283 DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
289 return ParseFunctionDefinition(DeclaratorInfo, TemplateInfo,
294 Decl *ThisDecl = ParseDeclarationAfterDeclarator(DeclaratorInfo,
297 if (Tok.
is(tok::comma)) {
298 Diag(Tok, diag::err_multiple_template_declarators)
299 << (int)TemplateInfo.Kind;
305 ExpectAndConsumeSemi(diag::err_expected_semi_declaration);
306 if (LateParsedAttrs.size() > 0)
307 ParseLexedAttributeList(LateParsedAttrs, ThisDecl,
true,
false);
308 DeclaratorInfo.complete(ThisDecl);
321 bool Parser::ParseTemplateParameters(
332 if (!Tok.
is(tok::greater) && !Tok.
is(tok::greatergreater))
333 Failed = ParseTemplateParameterList(Depth, TemplateParams);
335 if (Tok.
is(tok::greatergreater)) {
360 Parser::ParseTemplateParameterList(
const unsigned Depth,
365 = ParseTemplateParameter(Depth, TemplateParams.size())) {
366 TemplateParams.push_back(TmpParam);
370 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
375 if (Tok.
is(tok::comma)) {
377 }
else if (Tok.
isOneOf(tok::greater, tok::greatergreater)) {
385 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
395 bool Parser::isStartOfTemplateTypeParameter() {
396 if (Tok.
is(tok::kw_class)) {
403 case tok::greatergreater:
407 case tok::identifier:
416 switch (GetLookAheadToken(2).
getKind()) {
420 case tok::greatergreater:
428 if (Tok.
isNot(tok::kw_typename))
440 if (Next.
getKind() == tok::identifier)
441 Next = GetLookAheadToken(2);
447 case tok::greatergreater:
471 NamedDecl *Parser::ParseTemplateParameter(
unsigned Depth,
unsigned Position) {
472 if (isStartOfTemplateTypeParameter())
473 return ParseTypeParameter(Depth, Position);
475 if (Tok.
is(tok::kw_template))
476 return ParseTemplateTemplateParameter(Depth, Position);
479 if (Tok.
is(tok::kw_typedef)) {
489 return ParseTypeParameter(Depth, Position);
495 return ParseNonTypeTemplateParameter(Depth, Position);
507 NamedDecl *Parser::ParseTypeParameter(
unsigned Depth,
unsigned Position) {
508 assert(Tok.
isOneOf(tok::kw_class, tok::kw_typename) &&
509 "A type-parameter starts with 'class' or 'typename'");
512 bool TypenameKeyword = Tok.
is(tok::kw_typename);
520 ? diag::warn_cxx98_compat_variadic_templates
521 : diag::ext_variadic_templates);
527 if (Tok.
is(tok::identifier)) {
530 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
531 tok::greatergreater)) {
540 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
542 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
554 KeyLoc, ParamName, NameLoc, Depth, Position,
555 EqualLoc, DefaultArg);
570 Parser::ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position) {
571 assert(Tok.
is(tok::kw_template) &&
"Expected 'template' keyword");
579 if (ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
591 bool Replace = Tok.
isOneOf(tok::kw_typename, tok::kw_struct);
593 if (Tok.
is(tok::kw_typename)) {
596 ? diag::warn_cxx14_compat_template_template_param_typename
597 : diag::ext_template_template_param_typename)
601 }
else if (Next.
isOneOf(tok::identifier, tok::comma, tok::greater,
602 tok::greatergreater, tok::ellipsis)) {
618 ? diag::warn_cxx98_compat_variadic_templates
619 : diag::ext_variadic_templates);
624 if (Tok.
is(tok::identifier)) {
627 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
628 tok::greatergreater)) {
637 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
639 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
643 TemplateLoc, LAngleLoc,
653 DefaultArg = ParseTemplateTemplateArgument();
656 diag::err_default_template_template_parameter_not_template);
657 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
663 ParamList, EllipsisLoc,
664 ParamName, NameLoc, Depth,
665 Position, EqualLoc, DefaultArg);
675 Parser::ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position) {
680 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(),
AS_none,
681 DeclSpecContext::DSC_template_param);
685 ParseDeclarator(ParamDecl);
694 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, ParamDecl);
718 Depth, Position, EqualLoc,
722 void Parser::DiagnoseMisplacedEllipsis(
SourceLocation EllipsisLoc,
724 bool AlreadyHasEllipsis,
725 bool IdentifierHasName) {
727 if (!AlreadyHasEllipsis)
729 Diag(EllipsisLoc, diag::err_misplaced_ellipsis_in_declaration)
731 << !IdentifierHasName;
734 void Parser::DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
738 if (!AlreadyHasEllipsis)
741 AlreadyHasEllipsis, D.
hasName());
759 bool Parser::ParseGreaterThanInTemplateList(
SourceLocation &RAngleLoc,
760 bool ConsumeLastToken,
761 bool ObjCGenericList) {
764 const char *ReplacementStr =
"> >";
765 bool MergeWithNextToken =
false;
776 if (ConsumeLastToken)
780 case tok::greatergreater:
781 RemainingToken = tok::greater;
784 case tok::greatergreatergreater:
785 RemainingToken = tok::greatergreater;
788 case tok::greaterequal:
789 RemainingToken = tok::equal;
790 ReplacementStr =
"> =";
797 RemainingToken = tok::equalequal;
798 MergeWithNextToken =
true;
802 case tok::greatergreaterequal:
803 RemainingToken = tok::greaterequal;
822 bool PreventMergeWithNextToken =
823 (RemainingToken == tok::greater ||
824 RemainingToken == tok::greatergreater) &&
825 (Next.
isOneOf(tok::greater, tok::greatergreater,
826 tok::greatergreatergreater, tok::equal, tok::greaterequal,
827 tok::greatergreaterequal, tok::equalequal)) &&
828 areTokensAdjacent(Tok, Next);
831 if (!ObjCGenericList) {
846 if (PreventMergeWithNextToken)
849 unsigned DiagId = diag::err_two_right_angle_brackets_need_space;
851 (Tok.
is(tok::greatergreater) || Tok.
is(tok::greatergreatergreater)))
852 DiagId = diag::warn_cxx98_compat_two_right_angle_brackets;
853 else if (Tok.
is(tok::greaterequal))
854 DiagId = diag::err_right_angle_bracket_equal_needs_space;
855 Diag(TokLoc, DiagId) << Hint1 << Hint2;
866 RAngleLoc = PP.
SplitToken(TokLoc, GreaterLength);
877 if (MergeWithNextToken) {
883 Tok.
setLength(OldLength - GreaterLength);
888 if (PreventMergeWithNextToken)
895 if (MergeWithNextToken)
898 if (ConsumeLastToken)
904 if (ConsumeLastToken) {
905 PrevTokLocation = RAngleLoc;
907 PrevTokLocation = TokBeforeGreaterLoc;
928 Parser::ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
930 TemplateArgList &TemplateArgs,
932 assert(Tok.
is(tok::less) &&
"Must have already parsed the template-name");
941 if (Tok.
isNot(tok::greater) && Tok.
isNot(tok::greatergreater))
942 Invalid = ParseTemplateArgumentList(TemplateArgs);
946 if (ConsumeLastToken)
954 return ParseGreaterThanInTemplateList(RAngleLoc, ConsumeLastToken,
999 bool AllowTypeAnnotation) {
1001 assert(Template && Tok.
is(tok::less) &&
1002 "Parser isn't at the beginning of a template-id");
1009 TemplateArgList TemplateArgs;
1010 bool Invalid = ParseTemplateIdAfterTemplateName(
false, LAngleLoc,
1026 SS, TemplateKWLoc, Template, TemplateName.
Identifier,
1027 TemplateNameLoc, LAngleLoc, TemplateArgsPtr, RAngleLoc);
1036 Tok.
setKind(tok::annot_typename);
1037 setTypeAnnotation(Tok, Type.
get());
1040 else if (TemplateKWLoc.
isValid())
1047 Tok.
setKind(tok::annot_template_id);
1060 SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
1061 LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
1090 void Parser::AnnotateTemplateIdTokenAsType(
bool IsClassName) {
1091 assert(Tok.
is(tok::annot_template_id) &&
"Requires template-id tokens");
1096 "Only works for type and dependent templates");
1099 TemplateId->NumArgs);
1103 TemplateId->TemplateKWLoc,
1104 TemplateId->Template,
1106 TemplateId->TemplateNameLoc,
1107 TemplateId->LAngleLoc,
1109 TemplateId->RAngleLoc,
1113 Tok.
setKind(tok::annot_typename);
1114 setTypeAnnotation(Tok, Type.isInvalid() ? nullptr : Type.get());
1115 if (TemplateId->SS.isNotEmpty())
1126 return Tok.
isOneOf(tok::comma, tok::greater, tok::greatergreater);
1131 if (!Tok.
is(tok::identifier) && !Tok.
is(tok::coloncolon) &&
1132 !Tok.
is(tok::annot_cxxscope))
1147 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1152 if (SS.
isSet() && Tok.
is(tok::kw_template)) {
1157 if (Tok.
is(tok::identifier)) {
1176 }
else if (Tok.
is(tok::identifier)) {
1186 bool MemberOfUnknownSpecialization;
1191 false, Template, MemberOfUnknownSpecialization);
1228 if (isCXXTypeId(TypeIdAsTemplateArgument)) {
1236 TentativeParsingAction TPA(*
this);
1239 = ParseTemplateTemplateArgument();
1240 if (!TemplateTemplateArgument.
isInvalid()) {
1242 return TemplateTemplateArgument;
1256 ExprArg.
get(), Loc);
1262 bool Parser::IsTemplateArgumentList(
unsigned Skip) {
1263 struct AlwaysRevertAction : TentativeParsingAction {
1264 AlwaysRevertAction(
Parser &
P) : TentativeParsingAction(P) { }
1265 ~AlwaysRevertAction() { Revert(); }
1278 if (Tok.
is(tok::greater))
1282 while (isCXXDeclarationSpecifier() == TPResult::True)
1286 return Tok.
isOneOf(tok::greater, tok::comma);
1296 Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) {
1304 Arg = Actions.ActOnPackExpansion(Arg, EllipsisLoc);
1312 TemplateArgs.push_back(Arg);
1338 return ParseSingleDeclarationAfterTemplate(
1339 Context, ParsedTemplateInfo(ExternLoc, TemplateLoc),
1340 ParsingTemplateParams, DeclEnd, AccessAttrs, AS);
1346 TemplateParams->size());
1350 R.setBegin(ExternLoc);
1355 ((
Parser *)P)->ParseLateTemplatedFuncDef(LPT);
1366 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1370 Actions, Actions.Context.getTranslationUnitDecl());
1378 DeclContextsToReenter.push_back(DD);
1384 DeclContextsToReenter.rbegin();
1385 for (; II != DeclContextsToReenter.rend(); ++II) {
1386 TemplateParamScopeStack.push_back(
new ParseScope(
this,
1388 unsigned NumParamLists =
1389 Actions.ActOnReenterTemplateScope(
getCurScope(), cast<Decl>(*II));
1390 CurTemplateDepthTracker.addDepth(NumParamLists);
1393 Actions.PushDeclContext(Actions.getCurScope(), *II);
1397 assert(!LPT.
Toks.empty() &&
"Empty body!");
1401 LPT.
Toks.push_back(Tok);
1402 PP.EnterTokenStream(LPT.
Toks,
true);
1406 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try) &&
1407 "Inline method not starting with '{', ':' or 'try'");
1416 Actions.getContainingDC(FunD));
1418 Actions.ActOnStartOfFunctionDef(
getCurScope(), FunD);
1420 if (Tok.
is(tok::kw_try)) {
1421 ParseFunctionTryBlock(LPT.
D, FnScope);
1423 if (Tok.
is(tok::colon))
1424 ParseConstructorInitializer(LPT.
D);
1426 Actions.ActOnDefaultCtorInitializers(LPT.
D);
1428 if (Tok.
is(tok::l_brace)) {
1429 assert((!isa<FunctionTemplateDecl>(LPT.
D) ||
1430 cast<FunctionTemplateDecl>(LPT.
D)
1431 ->getTemplateParameters()
1432 ->getDepth() == TemplateParameterDepth - 1) &&
1433 "TemplateParameterDepth should be greater than the depth of " 1434 "current template being instantiated!");
1435 ParseFunctionStatementBody(LPT.
D, FnScope);
1436 Actions.UnmarkAsLateParsedTemplate(FunD);
1438 Actions.ActOnFinishFunctionBody(LPT.
D,
nullptr);
1444 TemplateParamScopeStack.rbegin();
1445 for (; I != TemplateParamScopeStack.rend(); ++I)
1450 void Parser::LexTemplateFunctionForLateParsing(
CachedTokens &Toks) {
1452 if (!ConsumeAndStoreFunctionPrologue(Toks)) {
1454 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1458 if (kind == tok::kw_try) {
1459 while (Tok.
is(tok::kw_catch)) {
1460 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
1461 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1471 TentativeParsingAction TPA(*
this);
1473 if (
SkipUntil(tok::greater, tok::greatergreater, tok::greatergreatergreater,
1478 ParseGreaterThanInTemplateList(Greater,
true,
false);
1479 Actions.diagnoseExprIntendedAsTemplateName(
getCurScope(), LHS,
1490 void Parser::checkPotentialAngleBracket(
ExprResult &PotentialTemplateName) {
1491 assert(Tok.
is(tok::less) &&
"not at a potential angle bracket");
1494 if (!Actions.mightBeIntendedToBeTemplateName(PotentialTemplateName,
1495 DependentTemplateName))
1507 ParseGreaterThanInTemplateList(Greater,
true,
false);
1508 Actions.diagnoseExprIntendedAsTemplateName(
1509 getCurScope(), PotentialTemplateName, Less, Greater);
1519 TentativeParsingAction TPA(*
this);
1521 if (isTypeIdUnambiguously() &&
1522 diagnoseUnknownTemplateId(PotentialTemplateName, Less)) {
1533 AngleBracketTracker::Priority Priority =
1534 (DependentTemplateName ? AngleBracketTracker::DependentName
1535 : AngleBracketTracker::PotentialTypo) |
1536 (Tok.hasLeadingSpace() ? AngleBracketTracker::SpaceBeforeLess
1537 : AngleBracketTracker::NoSpaceBeforeLess);
1538 AngleBrackets.add(*
this, PotentialTemplateName.
get(), Tok.getLocation(),
1542 bool Parser::checkPotentialAngleBracketDelimiter(
1543 const AngleBracketTracker::Loc &LAngle,
const Token &OpToken) {
1547 if (OpToken.
is(tok::comma) && isTypeIdUnambiguously() &&
1548 diagnoseUnknownTemplateId(LAngle.TemplateName, LAngle.LessLoc)) {
1549 AngleBrackets.clear(*
this);
1556 if (OpToken.
is(tok::greater) && Tok.
is(tok::l_paren) &&
1558 Actions.diagnoseExprIntendedAsTemplateName(
1559 getCurScope(), LAngle.TemplateName, LAngle.LessLoc,
1561 AngleBrackets.clear(*
this);
1567 if (OpToken.
is(tok::greater) ||
1569 OpToken.
isOneOf(tok::greatergreater, tok::greatergreatergreater)))
1570 AngleBrackets.clear(*
this);
Defines the clang::ASTContext interface.
void ReplacePreviousCachedToken(ArrayRef< Token > NewToks)
Replace token in CachedLexPos - 1 in CachedTokens by the tokens in NewToks.
Represents a function declaration or definition.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
The name refers to a dependent template name:
Decl - This represents one declaration (or definition), e.g.
RAII object used to inform the actions that we're currently parsing a declaration.
Defines the C++ template declaration subclasses.
The base class of the type hierarchy.
This indicates that the scope corresponds to a function, which means that labels are set here...
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Parser - This implements a parser for the C family of languages.
static TemplateIdAnnotation * Create(CXXScopeSpec SS, SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, IdentifierInfo *Name, OverloadedOperatorKind OperatorKind, ParsedTemplateTy OpaqueTemplateName, TemplateNameKind TemplateKind, SourceLocation LAngleLoc, SourceLocation RAngleLoc, ArrayRef< ParsedTemplateArgument > TemplateArgs, SmallVectorImpl< TemplateIdAnnotation *> &CleanupList)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List. ...
RAII object that enters a new expression evaluation context.
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
Information about one declarator, including the parsed type information and the identifier.
Stores a list of template parameters for a TemplateDecl and its derived classes.
friend class ObjCDeclContextSwitch
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
Information about a template-id annotation token.
Represents a struct/union/class.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
One of these records is kept for each identifier that is lexed.
Represents a dependent template name that cannot be resolved prior to template instantiation.
OverloadedOperatorKind Operator
The kind of overloaded operator.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
Token - This structure provides full information about a lexed token.
A non-type template parameter, stored as an expression.
void setKind(tok::TokenKind K)
NamedDecl * ActOnTemplateTemplateParameter(Scope *S, SourceLocation TmpLoc, TemplateParameterList *Params, SourceLocation EllipsisLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedTemplateArgument DefaultArg)
ActOnTemplateTemplateParameter - Called when a C++ template template parameter (e.g.
Represents a C++ unqualified-id that has been parsed.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
Scope - A scope is a transient data structure that is used while parsing the program.
bool IsPreviousCachedToken(const Token &Tok) const
Whether Tok is the most recent token (CachedLexPos - 1) in CachedTokens.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
Represents a C++ nested-name-specifier or a global scope specifier.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
unsigned getFlags() const
getFlags - Return the flags for this scope.
A class for parsing a declarator.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
void setAnnotationValue(void *val)
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
Represents a character-granular source range.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
OpaquePtr< TemplateName > TemplateTy
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
SourceLocation getBeginLoc() const
static bool isEndOfTemplateArgument(Token Tok)
Determine whether the given token can end a template argument.
Represents a C++ template name within the type system.
This is a compound statement scope.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
void setEllipsisLoc(SourceLocation EL)
The result type of a method or function.
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
RAII object that makes '>' behave either as an operator or as the closing angle bracket for a templat...
const LangOptions & getLangOpts() const
static CharSourceRange getCharRange(SourceRange R)
SourceManager & getSourceManager() const
A class for parsing a DeclSpec.
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Represents the parsed form of a C++ template argument.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Encodes a location in the source.
void setLength(unsigned Len)
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
NamedDecl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Scope * getCurScope() const
static unsigned getTokenPrefixLength(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
Get the physical length (including trigraphs and escaped newlines) of the first Characters characters...
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
bool isNot(tok::TokenKind K) const
SourceLocation SplitToken(SourceLocation TokLoc, unsigned Length)
Split the first Length characters out of the token starting at TokLoc and return a location pointing ...
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
This is a scope that corresponds to the template parameters of a C++ template.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
bool isInvalid() const
Determine whether the given template argument is invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
The name refers to a template whose specialization produces a type.
static const TST TST_unspecified
unsigned getLength() const
NamedDecl * ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, SourceLocation ParamNameLoc, unsigned Depth, unsigned Position, SourceLocation EqualLoc, ParsedType DefaultArg)
ActOnTypeParameter - Called when a C++ template type parameter (e.g., "typename T") has been parsed...
Not an overloaded operator.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ParsedTemplateArgument ActOnTemplateTypeArgument(TypeResult ParsedType)
Convert a parsed type into a parsed template argument.
SourceRange getTemplateParamsRange(TemplateParameterList const *const *Params, unsigned NumParams)
Retrieves the range of the given template parameter lists.
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
This is a scope that can contain a declaration.
SourceLocation getIdentifierLoc() const
bool isSet() const
Deprecated.
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false)
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
SourceLocation getEllipsisLoc() const
Decl * D
The template function declaration to be late parsed.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
A template-id, e.g., f<int>.
Contains a late templated function.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isTranslationUnit() const
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
Stop skipping at specified token, but don't skip the token itself.
SourceLocation getEndLoc() const