23 using namespace clang;
28 Parser::ParseDeclarationStartingWithTemplate(
unsigned Context,
35 return ParseExplicitInstantiation(Context,
39 return ParseTemplateDeclarationOrSpecialization(Context, DeclEnd, AS,
61 Parser::ParseTemplateDeclarationOrSpecialization(
unsigned Context,
65 assert(Tok.
isOneOf(tok::kw_export, tok::kw_template) &&
66 "Token does not start a template declaration.");
97 bool isSpecialization =
true;
98 bool LastParamListWasEmpty =
false;
100 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
117 if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(),
118 TemplateParams, LAngleLoc, RAngleLoc)) {
125 ExprResult OptionalRequiresClauseConstraintER;
126 if (!TemplateParams.empty()) {
127 isSpecialization =
false;
128 ++CurTemplateDepthTracker;
131 OptionalRequiresClauseConstraintER =
133 if (!OptionalRequiresClauseConstraintER.
isUsable()) {
141 LastParamListWasEmpty =
true;
145 CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
146 TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.
get()));
147 }
while (Tok.
isOneOf(tok::kw_export, tok::kw_template));
150 ParseScopeFlags TemplateScopeFlags(
this, NewFlags, isSpecialization);
153 return ParseSingleDeclarationAfterTemplate(Context,
154 ParsedTemplateInfo(&ParamLists,
156 LastParamListWasEmpty),
157 ParsingTemplateParams,
158 DeclEnd, AS, AccessAttrs);
172 Parser::ParseSingleDeclarationAfterTemplate(
174 const ParsedTemplateInfo &TemplateInfo,
179 assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
180 "Template information required");
182 if (Tok.
is(tok::kw_static_assert)) {
185 << TemplateInfo.getSourceRange();
187 return ParseStaticAssertDeclaration(DeclEnd);
192 ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
197 ParsedAttributesWithRange prefixAttrs(AttrFactory);
198 MaybeParseCXX11Attributes(prefixAttrs);
200 if (Tok.
is(tok::kw_using))
201 return ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
208 ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
209 getDeclSpecContextFromDeclaratorContext(Context));
211 if (Tok.
is(tok::semi)) {
212 ProhibitAttributes(prefixAttrs);
217 TemplateInfo.TemplateParams ? *TemplateInfo.TemplateParams
219 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation,
221 assert(!AnonRecord &&
222 "Anonymous unions/structs should not be valid with template");
228 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
229 ProhibitAttributes(prefixAttrs);
231 DS.takeAttributesFrom(prefixAttrs);
235 ParseDeclarator(DeclaratorInfo);
237 if (!DeclaratorInfo.hasName()) {
240 if (Tok.
is(tok::semi))
245 LateParsedAttrList LateParsedAttrs(
true);
246 if (DeclaratorInfo.isFunctionDeclarator())
247 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
249 if (DeclaratorInfo.isFunctionDeclarator() &&
250 isStartOfFunctionDefinition(DeclaratorInfo)) {
256 Diag(Tok, diag::err_function_definition_not_allowed);
265 Diag(DS.getStorageClassSpecLoc(), diag::err_function_declared_typedef)
267 DS.ClearStorageClassSpecs();
270 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
274 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
275 return ParseFunctionDefinition(DeclaratorInfo, ParsedTemplateInfo(),
280 Diag(DeclaratorInfo.getIdentifierLoc(),
281 diag::err_explicit_instantiation_with_definition)
289 LAngleLoc,
nullptr));
291 return ParseFunctionDefinition(
292 DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
298 return ParseFunctionDefinition(DeclaratorInfo, TemplateInfo,
303 Decl *ThisDecl = ParseDeclarationAfterDeclarator(DeclaratorInfo,
306 if (Tok.
is(tok::comma)) {
307 Diag(Tok, diag::err_multiple_template_declarators)
308 << (int)TemplateInfo.Kind;
314 ExpectAndConsumeSemi(diag::err_expected_semi_declaration);
315 if (LateParsedAttrs.size() > 0)
316 ParseLexedAttributeList(LateParsedAttrs, ThisDecl,
true,
false);
317 DeclaratorInfo.complete(ThisDecl);
330 bool Parser::ParseTemplateParameters(
unsigned Depth,
342 if (!Tok.
is(tok::greater) && !Tok.
is(tok::greatergreater))
343 Failed = ParseTemplateParameterList(Depth, TemplateParams);
345 if (Tok.
is(tok::greatergreater)) {
370 Parser::ParseTemplateParameterList(
unsigned Depth,
374 = ParseTemplateParameter(Depth, TemplateParams.size())) {
375 TemplateParams.push_back(TmpParam);
379 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
384 if (Tok.
is(tok::comma)) {
386 }
else if (Tok.
isOneOf(tok::greater, tok::greatergreater)) {
394 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
404 bool Parser::isStartOfTemplateTypeParameter() {
405 if (Tok.
is(tok::kw_class)) {
412 case tok::greatergreater:
416 case tok::identifier:
425 switch (GetLookAheadToken(2).
getKind()) {
429 case tok::greatergreater:
437 if (Tok.
isNot(tok::kw_typename))
449 if (Next.
getKind() == tok::identifier)
450 Next = GetLookAheadToken(2);
456 case tok::greatergreater:
480 Decl *Parser::ParseTemplateParameter(
unsigned Depth,
unsigned Position) {
481 if (isStartOfTemplateTypeParameter())
482 return ParseTypeParameter(Depth, Position);
484 if (Tok.
is(tok::kw_template))
485 return ParseTemplateTemplateParameter(Depth, Position);
490 return ParseNonTypeTemplateParameter(Depth, Position);
502 Decl *Parser::ParseTypeParameter(
unsigned Depth,
unsigned Position) {
503 assert(Tok.
isOneOf(tok::kw_class, tok::kw_typename) &&
504 "A type-parameter starts with 'class' or 'typename'");
507 bool TypenameKeyword = Tok.
is(tok::kw_typename);
515 ? diag::warn_cxx98_compat_variadic_templates
516 : diag::ext_variadic_templates);
522 if (Tok.
is(tok::identifier)) {
525 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
526 tok::greatergreater)) {
535 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
537 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
549 KeyLoc, ParamName, NameLoc, Depth, Position,
550 EqualLoc, DefaultArg);
565 Parser::ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position) {
566 assert(Tok.
is(tok::kw_template) &&
"Expected 'template' keyword");
574 if (ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
586 bool Replace = Tok.
isOneOf(tok::kw_typename, tok::kw_struct);
588 if (Tok.
is(tok::kw_typename)) {
591 ? diag::warn_cxx14_compat_template_template_param_typename
592 : diag::ext_template_template_param_typename)
596 }
else if (Next.
isOneOf(tok::identifier, tok::comma, tok::greater,
597 tok::greatergreater, tok::ellipsis)) {
613 ? diag::warn_cxx98_compat_variadic_templates
614 : diag::ext_variadic_templates);
619 if (Tok.
is(tok::identifier)) {
622 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
623 tok::greatergreater)) {
632 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
634 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
638 TemplateLoc, LAngleLoc,
648 DefaultArg = ParseTemplateTemplateArgument();
651 diag::err_default_template_template_parameter_not_template);
652 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
658 ParamList, EllipsisLoc,
659 ParamName, NameLoc, Depth,
660 Position, EqualLoc, DefaultArg);
670 Parser::ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position) {
675 ParseDeclarationSpecifiers(DS);
679 ParseDeclarator(ParamDecl);
688 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, ParamDecl);
712 Depth, Position, EqualLoc,
716 void Parser::DiagnoseMisplacedEllipsis(
SourceLocation EllipsisLoc,
718 bool AlreadyHasEllipsis,
719 bool IdentifierHasName) {
721 if (!AlreadyHasEllipsis)
723 Diag(EllipsisLoc, diag::err_misplaced_ellipsis_in_declaration)
725 << !IdentifierHasName;
728 void Parser::DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
732 if (!AlreadyHasEllipsis)
735 AlreadyHasEllipsis, D.
hasName());
753 bool Parser::ParseGreaterThanInTemplateList(
SourceLocation &RAngleLoc,
754 bool ConsumeLastToken,
755 bool ObjCGenericList) {
758 const char *ReplacementStr =
"> >";
769 if (ConsumeLastToken)
773 case tok::greatergreater:
774 RemainingToken = tok::greater;
777 case tok::greatergreatergreater:
778 RemainingToken = tok::greatergreater;
781 case tok::greaterequal:
782 RemainingToken = tok::equal;
783 ReplacementStr =
"> =";
786 case tok::greatergreaterequal:
787 RemainingToken = tok::greaterequal;
801 if (!ObjCGenericList) {
817 if ((RemainingToken == tok::greater ||
818 RemainingToken == tok::greatergreater) &&
819 (Next.
isOneOf(tok::greater, tok::greatergreater,
820 tok::greatergreatergreater, tok::equal,
821 tok::greaterequal, tok::greatergreaterequal,
823 areTokensAdjacent(Tok, Next))
826 unsigned DiagId = diag::err_two_right_angle_brackets_need_space;
828 (Tok.
is(tok::greatergreater) || Tok.
is(tok::greatergreatergreater)))
829 DiagId = diag::warn_cxx98_compat_two_right_angle_brackets;
830 else if (Tok.
is(tok::greaterequal))
831 DiagId = diag::err_right_angle_bracket_equal_needs_space;
837 if (RemainingToken == tok::equal && Next.
is(tok::equal) &&
838 areTokensAdjacent(Tok, Next)) {
856 if (ObjCGenericList && PrevTok.
getKind() == tok::greatergreater &&
858 PrevTok.
setKind(RemainingToken);
862 if (ConsumeLastToken)
868 if (!ConsumeLastToken) {
899 Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
902 bool ConsumeLastToken,
904 TemplateArgList &TemplateArgs,
906 assert(Tok.
is(tok::less) &&
"Must have already parsed the template-name");
915 if (Tok.
isNot(tok::greater) && Tok.
isNot(tok::greatergreater))
916 Invalid = ParseTemplateArgumentList(TemplateArgs);
920 if (ConsumeLastToken)
928 return ParseGreaterThanInTemplateList(RAngleLoc, ConsumeLastToken,
969 bool Parser::AnnotateTemplateIdToken(TemplateTy Template,
TemplateNameKind TNK,
973 bool AllowTypeAnnotation) {
975 assert(Template && Tok.
is(tok::less) &&
976 "Parser isn't at the beginning of a template-id");
983 TemplateArgList TemplateArgs;
984 bool Invalid = ParseTemplateIdAfterTemplateName(Template,
986 SS,
false, LAngleLoc,
1003 Template, TemplateNameLoc,
1004 LAngleLoc, TemplateArgsPtr, RAngleLoc);
1012 Tok.
setKind(tok::annot_typename);
1013 setTypeAnnotation(Tok, Type.
get());
1016 else if (TemplateKWLoc.
isValid())
1023 Tok.
setKind(tok::annot_template_id);
1031 TemplateId->
Name =
nullptr;
1034 TemplateId->
SS = SS;
1037 TemplateId->
Kind = TNK;
1041 for (
unsigned Arg = 0, ArgEnd = TemplateArgs.size(); Arg != ArgEnd; ++Arg)
1065 void Parser::AnnotateTemplateIdTokenAsType() {
1066 assert(Tok.
is(tok::annot_template_id) &&
"Requires template-id tokens");
1071 "Only works for type and dependent templates");
1074 TemplateId->NumArgs);
1078 TemplateId->TemplateKWLoc,
1079 TemplateId->Template,
1080 TemplateId->TemplateNameLoc,
1081 TemplateId->LAngleLoc,
1083 TemplateId->RAngleLoc);
1085 Tok.
setKind(tok::annot_typename);
1086 setTypeAnnotation(Tok, Type.isInvalid() ?
nullptr : Type.get());
1087 if (TemplateId->SS.isNotEmpty())
1098 return Tok.
isOneOf(tok::comma, tok::greater, tok::greatergreater);
1103 if (!Tok.
is(tok::identifier) && !Tok.
is(tok::coloncolon) &&
1104 !Tok.
is(tok::annot_cxxscope))
1119 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1124 if (SS.
isSet() && Tok.
is(tok::kw_template)) {
1129 if (Tok.
is(tok::identifier)) {
1148 }
else if (Tok.
is(tok::identifier)) {
1158 bool MemberOfUnknownSpecialization;
1163 false, Template, MemberOfUnknownSpecialization);
1192 if (isCXXTypeId(TypeIdAsTemplateArgument)) {
1200 TypeArg.
get().getAsOpaquePtr(),
1206 TentativeParsingAction TPA(*
this);
1209 = ParseTemplateTemplateArgument();
1210 if (!TemplateTemplateArgument.
isInvalid()) {
1212 return TemplateTemplateArgument;
1226 ExprArg.
get(), Loc);
1232 bool Parser::IsTemplateArgumentList(
unsigned Skip) {
1233 struct AlwaysRevertAction : TentativeParsingAction {
1234 AlwaysRevertAction(
Parser &
P) : TentativeParsingAction(P) { }
1235 ~AlwaysRevertAction() { Revert(); }
1248 if (Tok.
is(tok::greater))
1256 return Tok.
isOneOf(tok::greater, tok::comma);
1266 Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) {
1283 TemplateArgs.push_back(Arg);
1299 Decl *Parser::ParseExplicitInstantiation(
unsigned Context,
1308 return ParseSingleDeclarationAfterTemplate(Context,
1309 ParsedTemplateInfo(ExternLoc,
1311 ParsingTemplateParams,
1318 TemplateParams->size());
1322 R.setBegin(ExternLoc);
1327 ((
Parser *)P)->ParseLateTemplatedFuncDef(LPT);
1338 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1350 DeclContextsToReenter.push_back(DD);
1356 DeclContextsToReenter.rbegin();
1357 for (; II != DeclContextsToReenter.rend(); ++II) {
1358 TemplateParamScopeStack.push_back(
new ParseScope(
this,
1360 unsigned NumParamLists =
1362 CurTemplateDepthTracker.addDepth(NumParamLists);
1369 assert(!LPT.
Toks.empty() &&
"Empty body!");
1373 LPT.
Toks.push_back(Tok);
1374 PP.EnterTokenStream(LPT.
Toks,
true);
1377 ConsumeAnyToken(
true);
1378 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try) &&
1379 "Inline method not starting with '{', ':' or 'try'");
1391 if (Tok.
is(tok::kw_try)) {
1392 ParseFunctionTryBlock(LPT.
D, FnScope);
1394 if (Tok.
is(tok::colon))
1395 ParseConstructorInitializer(LPT.
D);
1399 if (Tok.
is(tok::l_brace)) {
1400 assert((!isa<FunctionTemplateDecl>(LPT.
D) ||
1401 cast<FunctionTemplateDecl>(LPT.
D)
1402 ->getTemplateParameters()
1403 ->getDepth() == TemplateParameterDepth - 1) &&
1404 "TemplateParameterDepth should be greater than the depth of "
1405 "current template being instantiated!");
1406 ParseFunctionStatementBody(LPT.
D, FnScope);
1415 TemplateParamScopeStack.rbegin();
1416 for (; I != TemplateParamScopeStack.rend(); ++
I)
1421 void Parser::LexTemplateFunctionForLateParsing(
CachedTokens &Toks) {
1423 if (!ConsumeAndStoreFunctionPrologue(Toks)) {
1425 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1429 if (kind == tok::kw_try) {
1430 while (Tok.
is(tok::kw_catch)) {
1431 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
1432 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
unsigned getFlags() const
getFlags - Return the flags for this scope.
SourceManager & getSourceManager() const
Defines the clang::ASTContext interface.
void ReplacePreviousCachedToken(ArrayRef< Token > NewToks)
Replace token in CachedLexPos - 1 in CachedTokens by the tokens in NewToks.
IdKind getKind() const
Determine what kind of name we have.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Scope * getCurScope() const
Retrieve the parser's current scope.
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 * Name
FIXME: Temporarily stores the name of a specialization.
const LangOptions & getLangOpts() const
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
The name refers to a dependent template name.
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...
TemplateNameKind Kind
The kind of template that Template refers to.
Parser - This implements a parser for the C family of languages.
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
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...
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.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
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.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Decl * ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, unsigned Depth, unsigned Position, SourceLocation EqualLoc, Expr *DefaultArg)
OverloadedOperatorKind Operator
The kind of overloaded operator.
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false)
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
bool isTranslationUnit() const
Token - This structure provides full information about a lexed token.
A non-type template parameter, stored as an expression.
void setKind(tok::TokenKind K)
Represents a C++ unqualified-id that has been parsed.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
Scope - A scope is a transient data structure that is used while parsing the program.
Represents a C++ nested-name-specifier or a global scope specifier.
tok::TokenKind getKind() const
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
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...
detail::InMemoryDirectory::const_iterator I
Decl * 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...
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword within the source.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
A class for parsing a declarator.
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
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...
TranslationUnitDecl * getTranslationUnitDecl() const
OpaquePtr< TemplateName > TemplateTy
static bool isEndOfTemplateArgument(Token Tok)
Determine whether the given token can end a template argument.
Represents a C++ template name within the type system.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
bool isNot(tok::TokenKind K) const
void setEllipsisLoc(SourceLocation EL)
DeclContext * getContainingDC(DeclContext *DC)
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 temp...
static CharSourceRange getCharRange(SourceRange R)
A class for parsing a DeclSpec.
Stop skipping at semicolon.
Represents the parsed form of a C++ template argument.
Encodes a location in the source.
void setLength(unsigned Len)
bool isValid() const
Return true if this is a valid SourceLocation object.
void setAnnotationEndLoc(SourceLocation L)
Scope * getCurScope() const
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
SourceLocation getBegin() const
SourceLocation getBeginLoc() const
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)) {...
A template type parameter, stored as a type.
void UnmarkAsLateParsedTemplate(FunctionDecl *FD)
Decl * 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.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
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.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
The name refers to a template whose specialization produces a type.
static const TST TST_unspecified
Not an overloaded operator.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
OverloadedOperatorKind Operator
FIXME: Temporarily stores the overloaded operator kind.
bool isInvalid() const
Determine whether the given template argument is invalid.
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.
A template-id, e.g., f<int>.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
This is a scope that can contain a declaration.
bool IsPreviousCachedToken(const Token &Tok) const
Whether Tok is the most recent token (CachedLexPos - 1) in CachedTokens.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template)
Form a dependent template name.
Captures information about "declaration specifiers".
SourceLocation getIdentifierLoc() const
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static TemplateIdAnnotation * Allocate(unsigned NumArgs, SmallVectorImpl< TemplateIdAnnotation * > &List)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List. ...
Decl * D
The template function declaration to be late parsed.
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
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...
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...
bool isSet() const
Deprecated.
unsigned getLength() const
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.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
AttributeList - Represents a syntactic attribute.
Stop skipping at specified token, but don't skip the token itself.
SourceLocation getEllipsisLoc() const
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
IdentifierInfo * getIdentifierInfo() const