22 using namespace clang;
34 return ParseExplicitInstantiation(Context,
38 return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AS,
64 assert(Tok.
isOneOf(tok::kw_export, tok::kw_template) &&
65 "Token does not start a template declaration.");
96 bool isSpecialization =
true;
97 bool LastParamListWasEmpty =
false;
99 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
116 if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(),
117 TemplateParams, LAngleLoc, RAngleLoc)) {
124 ExprResult OptionalRequiresClauseConstraintER;
125 if (!TemplateParams.empty()) {
126 isSpecialization =
false;
127 ++CurTemplateDepthTracker;
130 OptionalRequiresClauseConstraintER =
132 if (!OptionalRequiresClauseConstraintER.
isUsable()) {
140 LastParamListWasEmpty =
true;
144 CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
145 TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.
get()));
146 }
while (Tok.
isOneOf(tok::kw_export, tok::kw_template));
149 ParseScopeFlags TemplateScopeFlags(
this, NewFlags, isSpecialization);
152 return ParseSingleDeclarationAfterTemplate(Context,
153 ParsedTemplateInfo(&ParamLists,
155 LastParamListWasEmpty),
156 ParsingTemplateParams,
157 DeclEnd, AS, AccessAttrs);
171 Parser::ParseSingleDeclarationAfterTemplate(
173 const ParsedTemplateInfo &TemplateInfo,
178 assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
179 "Template information required");
181 if (Tok.
is(tok::kw_static_assert)) {
184 << TemplateInfo.getSourceRange();
186 return ParseStaticAssertDeclaration(DeclEnd);
191 ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
196 ParsedAttributesWithRange prefixAttrs(AttrFactory);
197 MaybeParseCXX11Attributes(prefixAttrs);
199 if (Tok.
is(tok::kw_using)) {
200 auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
202 if (!usingDeclPtr || !usingDeclPtr.get().isSingleDecl())
204 return usingDeclPtr.get().getSingleDecl();
211 ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
212 getDeclSpecContextFromDeclaratorContext(Context));
214 if (Tok.
is(tok::semi)) {
215 ProhibitAttributes(prefixAttrs);
220 TemplateInfo.TemplateParams ? *TemplateInfo.TemplateParams
222 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation,
224 assert(!AnonRecord &&
225 "Anonymous unions/structs should not be valid with template");
231 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
232 ProhibitAttributes(prefixAttrs);
234 DS.takeAttributesFrom(prefixAttrs);
238 ParseDeclarator(DeclaratorInfo);
240 if (!DeclaratorInfo.hasName()) {
243 if (Tok.
is(tok::semi))
248 LateParsedAttrList LateParsedAttrs(
true);
249 if (DeclaratorInfo.isFunctionDeclarator())
250 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
252 if (DeclaratorInfo.isFunctionDeclarator() &&
253 isStartOfFunctionDefinition(DeclaratorInfo)) {
259 Diag(Tok, diag::err_function_definition_not_allowed);
268 Diag(DS.getStorageClassSpecLoc(), diag::err_function_declared_typedef)
270 DS.ClearStorageClassSpecs();
273 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
274 if (DeclaratorInfo.getName().getKind() !=
278 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
279 return ParseFunctionDefinition(DeclaratorInfo, ParsedTemplateInfo(),
284 Diag(DeclaratorInfo.getIdentifierLoc(),
285 diag::err_explicit_instantiation_with_definition)
293 LAngleLoc,
nullptr));
295 return ParseFunctionDefinition(
296 DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
302 return ParseFunctionDefinition(DeclaratorInfo, TemplateInfo,
307 Decl *ThisDecl = ParseDeclarationAfterDeclarator(DeclaratorInfo,
310 if (Tok.
is(tok::comma)) {
311 Diag(Tok, diag::err_multiple_template_declarators)
312 << (int)TemplateInfo.Kind;
318 ExpectAndConsumeSemi(diag::err_expected_semi_declaration);
319 if (LateParsedAttrs.size() > 0)
320 ParseLexedAttributeList(LateParsedAttrs, ThisDecl,
true,
false);
321 DeclaratorInfo.complete(ThisDecl);
334 bool Parser::ParseTemplateParameters(
345 if (!Tok.
is(tok::greater) && !Tok.
is(tok::greatergreater))
346 Failed = ParseTemplateParameterList(Depth, TemplateParams);
348 if (Tok.
is(tok::greatergreater)) {
373 Parser::ParseTemplateParameterList(
const unsigned Depth,
378 = ParseTemplateParameter(Depth, TemplateParams.size())) {
379 TemplateParams.push_back(TmpParam);
383 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
388 if (Tok.
is(tok::comma)) {
390 }
else if (Tok.
isOneOf(tok::greater, tok::greatergreater)) {
398 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
408 bool Parser::isStartOfTemplateTypeParameter() {
409 if (Tok.
is(tok::kw_class)) {
416 case tok::greatergreater:
420 case tok::identifier:
429 switch (GetLookAheadToken(2).
getKind()) {
433 case tok::greatergreater:
441 if (Tok.
isNot(tok::kw_typename))
453 if (Next.
getKind() == tok::identifier)
454 Next = GetLookAheadToken(2);
460 case tok::greatergreater:
484 NamedDecl *Parser::ParseTemplateParameter(
unsigned Depth,
unsigned Position) {
485 if (isStartOfTemplateTypeParameter())
486 return ParseTypeParameter(Depth, Position);
488 if (Tok.
is(tok::kw_template))
489 return ParseTemplateTemplateParameter(Depth, Position);
494 return ParseNonTypeTemplateParameter(Depth, Position);
506 NamedDecl *Parser::ParseTypeParameter(
unsigned Depth,
unsigned Position) {
507 assert(Tok.
isOneOf(tok::kw_class, tok::kw_typename) &&
508 "A type-parameter starts with 'class' or 'typename'");
511 bool TypenameKeyword = Tok.
is(tok::kw_typename);
519 ? diag::warn_cxx98_compat_variadic_templates
520 : diag::ext_variadic_templates);
526 if (Tok.
is(tok::identifier)) {
529 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
530 tok::greatergreater)) {
539 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
541 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
553 KeyLoc, ParamName, NameLoc, Depth, Position,
554 EqualLoc, DefaultArg);
569 Parser::ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position) {
570 assert(Tok.
is(tok::kw_template) &&
"Expected 'template' keyword");
578 if (ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
590 bool Replace = Tok.
isOneOf(tok::kw_typename, tok::kw_struct);
592 if (Tok.
is(tok::kw_typename)) {
595 ? diag::warn_cxx14_compat_template_template_param_typename
596 : diag::ext_template_template_param_typename)
600 }
else if (Next.
isOneOf(tok::identifier, tok::comma, tok::greater,
601 tok::greatergreater, tok::ellipsis)) {
617 ? diag::warn_cxx98_compat_variadic_templates
618 : diag::ext_variadic_templates);
623 if (Tok.
is(tok::identifier)) {
626 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
627 tok::greatergreater)) {
636 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
638 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
642 TemplateLoc, LAngleLoc,
652 DefaultArg = ParseTemplateTemplateArgument();
655 diag::err_default_template_template_parameter_not_template);
656 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
662 ParamList, EllipsisLoc,
663 ParamName, NameLoc, Depth,
664 Position, EqualLoc, DefaultArg);
674 Parser::ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position) {
679 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(),
AS_none,
680 DeclSpecContext::DSC_template_param);
684 ParseDeclarator(ParamDecl);
693 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, ParamDecl);
717 Depth, Position, EqualLoc,
721 void Parser::DiagnoseMisplacedEllipsis(
SourceLocation EllipsisLoc,
723 bool AlreadyHasEllipsis,
724 bool IdentifierHasName) {
726 if (!AlreadyHasEllipsis)
728 Diag(EllipsisLoc, diag::err_misplaced_ellipsis_in_declaration)
730 << !IdentifierHasName;
733 void Parser::DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
737 if (!AlreadyHasEllipsis)
740 AlreadyHasEllipsis, D.
hasName());
758 bool Parser::ParseGreaterThanInTemplateList(
SourceLocation &RAngleLoc,
759 bool ConsumeLastToken,
760 bool ObjCGenericList) {
763 const char *ReplacementStr =
"> >";
774 if (ConsumeLastToken)
778 case tok::greatergreater:
779 RemainingToken = tok::greater;
782 case tok::greatergreatergreater:
783 RemainingToken = tok::greatergreater;
786 case tok::greaterequal:
787 RemainingToken = tok::equal;
788 ReplacementStr =
"> =";
791 case tok::greatergreaterequal:
792 RemainingToken = tok::greaterequal;
806 if (!ObjCGenericList) {
822 if ((RemainingToken == tok::greater ||
823 RemainingToken == tok::greatergreater) &&
824 (Next.
isOneOf(tok::greater, tok::greatergreater,
825 tok::greatergreatergreater, tok::equal,
826 tok::greaterequal, tok::greatergreaterequal,
828 areTokensAdjacent(Tok, Next))
831 unsigned DiagId = diag::err_two_right_angle_brackets_need_space;
833 (Tok.
is(tok::greatergreater) || Tok.
is(tok::greatergreatergreater)))
834 DiagId = diag::warn_cxx98_compat_two_right_angle_brackets;
835 else if (Tok.
is(tok::greaterequal))
836 DiagId = diag::err_right_angle_bracket_equal_needs_space;
842 if (RemainingToken == tok::equal && Next.
is(tok::equal) &&
843 areTokensAdjacent(Tok, Next)) {
861 if (ObjCGenericList && PrevTok.getKind() == tok::greatergreater &&
863 PrevTok.setKind(RemainingToken);
864 PrevTok.setLength(1);
867 if (ConsumeLastToken)
873 if (!ConsumeLastToken) {
897 Parser::ParseTemplateIdAfterTemplateName(
bool ConsumeLastToken,
899 TemplateArgList &TemplateArgs,
901 assert(Tok.
is(tok::less) &&
"Must have already parsed the template-name");
910 if (Tok.
isNot(tok::greater) && Tok.
isNot(tok::greatergreater))
911 Invalid = ParseTemplateArgumentList(TemplateArgs);
915 if (ConsumeLastToken)
923 return ParseGreaterThanInTemplateList(RAngleLoc, ConsumeLastToken,
968 bool AllowTypeAnnotation) {
970 assert(Template && Tok.
is(tok::less) &&
971 "Parser isn't at the beginning of a template-id");
978 TemplateArgList TemplateArgs;
979 bool Invalid = ParseTemplateIdAfterTemplateName(
false, LAngleLoc,
995 SS, TemplateKWLoc, Template, TemplateName.
Identifier,
996 TemplateNameLoc, LAngleLoc, TemplateArgsPtr, RAngleLoc);
1005 Tok.
setKind(tok::annot_typename);
1006 setTypeAnnotation(Tok, Type.
get());
1009 else if (TemplateKWLoc.
isValid())
1016 Tok.
setKind(tok::annot_template_id);
1029 SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
1030 LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
1059 void Parser::AnnotateTemplateIdTokenAsType(
bool IsClassName) {
1060 assert(Tok.
is(tok::annot_template_id) &&
"Requires template-id tokens");
1065 "Only works for type and dependent templates");
1068 TemplateId->NumArgs);
1072 TemplateId->TemplateKWLoc,
1073 TemplateId->Template,
1075 TemplateId->TemplateNameLoc,
1076 TemplateId->LAngleLoc,
1078 TemplateId->RAngleLoc,
1082 Tok.
setKind(tok::annot_typename);
1083 setTypeAnnotation(Tok, Type.isInvalid() ? nullptr : Type.get());
1084 if (TemplateId->SS.isNotEmpty())
1095 return Tok.
isOneOf(tok::comma, tok::greater, tok::greatergreater);
1100 if (!Tok.
is(tok::identifier) && !Tok.
is(tok::coloncolon) &&
1101 !Tok.
is(tok::annot_cxxscope))
1116 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1121 if (SS.
isSet() && Tok.
is(tok::kw_template)) {
1126 if (Tok.
is(tok::identifier)) {
1145 }
else if (Tok.
is(tok::identifier)) {
1155 bool MemberOfUnknownSpecialization;
1160 false, Template, MemberOfUnknownSpecialization);
1195 if (isCXXTypeId(TypeIdAsTemplateArgument)) {
1203 TypeArg.
get().getAsOpaquePtr(),
1209 TentativeParsingAction TPA(*
this);
1212 = ParseTemplateTemplateArgument();
1213 if (!TemplateTemplateArgument.
isInvalid()) {
1215 return TemplateTemplateArgument;
1229 ExprArg.
get(), Loc);
1235 bool Parser::IsTemplateArgumentList(
unsigned Skip) {
1236 struct AlwaysRevertAction : TentativeParsingAction {
1237 AlwaysRevertAction(
Parser &
P) : TentativeParsingAction(P) { }
1238 ~AlwaysRevertAction() { Revert(); }
1251 if (Tok.
is(tok::greater))
1255 while (isCXXDeclarationSpecifier() == TPResult::True)
1259 return Tok.
isOneOf(tok::greater, tok::comma);
1269 Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) {
1277 Arg = Actions.ActOnPackExpansion(Arg, EllipsisLoc);
1285 TemplateArgs.push_back(Arg);
1310 return ParseSingleDeclarationAfterTemplate(Context,
1311 ParsedTemplateInfo(ExternLoc,
1313 ParsingTemplateParams,
1320 TemplateParams->size());
1324 R.setBegin(ExternLoc);
1329 ((
Parser *)P)->ParseLateTemplatedFuncDef(LPT);
1340 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1344 Actions, Actions.Context.getTranslationUnitDecl());
1352 DeclContextsToReenter.push_back(DD);
1358 DeclContextsToReenter.rbegin();
1359 for (; II != DeclContextsToReenter.rend(); ++II) {
1360 TemplateParamScopeStack.push_back(
new ParseScope(
this,
1362 unsigned NumParamLists =
1363 Actions.ActOnReenterTemplateScope(
getCurScope(), cast<Decl>(*II));
1364 CurTemplateDepthTracker.addDepth(NumParamLists);
1367 Actions.PushDeclContext(Actions.getCurScope(), *II);
1371 assert(!LPT.
Toks.empty() &&
"Empty body!");
1375 LPT.
Toks.push_back(Tok);
1376 PP.EnterTokenStream(LPT.
Toks,
true);
1380 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try) &&
1381 "Inline method not starting with '{', ':' or 'try'");
1390 Actions.getContainingDC(FunD));
1392 Actions.ActOnStartOfFunctionDef(
getCurScope(), FunD);
1394 if (Tok.
is(tok::kw_try)) {
1395 ParseFunctionTryBlock(LPT.
D, FnScope);
1397 if (Tok.
is(tok::colon))
1398 ParseConstructorInitializer(LPT.
D);
1400 Actions.ActOnDefaultCtorInitializers(LPT.
D);
1402 if (Tok.
is(tok::l_brace)) {
1403 assert((!isa<FunctionTemplateDecl>(LPT.
D) ||
1404 cast<FunctionTemplateDecl>(LPT.
D)
1405 ->getTemplateParameters()
1406 ->getDepth() == TemplateParameterDepth - 1) &&
1407 "TemplateParameterDepth should be greater than the depth of " 1408 "current template being instantiated!");
1409 ParseFunctionStatementBody(LPT.
D, FnScope);
1410 Actions.UnmarkAsLateParsedTemplate(FunD);
1412 Actions.ActOnFinishFunctionBody(LPT.
D,
nullptr);
1418 TemplateParamScopeStack.rbegin();
1419 for (; I != TemplateParamScopeStack.rend(); ++I)
1424 void Parser::LexTemplateFunctionForLateParsing(
CachedTokens &Toks) {
1426 if (!ConsumeAndStoreFunctionPrologue(Toks)) {
1428 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1432 if (kind == tok::kw_try) {
1433 while (Tok.
is(tok::kw_catch)) {
1434 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
1435 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
Defines the clang::ASTContext interface.
void ReplacePreviousCachedToken(ArrayRef< Token > NewToks)
Replace token in CachedLexPos - 1 in CachedTokens by the tokens in NewToks.
An instance of this class is created to represent 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.
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.
RecordDecl - 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.
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.
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...
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
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)
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
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)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Scope * getCurScope() const
A template type parameter, stored as a type.
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
bool isNot(tok::TokenKind K) const
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)
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.
NamedDecl - This represents a decl with 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
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].
AttributeList - Represents a syntactic attribute.
Stop skipping at specified token, but don't skip the token itself.