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 ParamLists.push_back(
128 TemplateLoc, LAngleLoc,
129 TemplateParams, RAngleLoc));
131 if (!TemplateParams.empty()) {
132 isSpecialization =
false;
133 ++CurTemplateDepthTracker;
146 LastParamListWasEmpty =
true;
148 }
while (Tok.
isOneOf(tok::kw_export, tok::kw_template));
151 return ParseSingleDeclarationAfterTemplate(Context,
152 ParsedTemplateInfo(&ParamLists,
154 LastParamListWasEmpty),
155 ParsingTemplateParams,
156 DeclEnd, AS, AccessAttrs);
170 Parser::ParseSingleDeclarationAfterTemplate(
172 const ParsedTemplateInfo &TemplateInfo,
177 assert(TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
178 "Template information required");
180 if (Tok.
is(tok::kw_static_assert)) {
183 << TemplateInfo.getSourceRange();
185 return ParseStaticAssertDeclaration(DeclEnd);
190 ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
195 ParsedAttributesWithRange prefixAttrs(AttrFactory);
196 MaybeParseCXX11Attributes(prefixAttrs);
198 if (Tok.
is(tok::kw_using))
199 return ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
206 ParseDeclarationSpecifiers(DS, TemplateInfo, AS,
207 getDeclSpecContextFromDeclaratorContext(Context));
209 if (Tok.
is(tok::semi)) {
210 ProhibitAttributes(prefixAttrs);
214 TemplateInfo.TemplateParams ? *TemplateInfo.TemplateParams
216 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation);
222 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
223 ProhibitAttributes(prefixAttrs);
225 DS.takeAttributesFrom(prefixAttrs);
229 ParseDeclarator(DeclaratorInfo);
231 if (!DeclaratorInfo.hasName()) {
234 if (Tok.
is(tok::semi))
239 LateParsedAttrList LateParsedAttrs(
true);
240 if (DeclaratorInfo.isFunctionDeclarator())
241 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
243 if (DeclaratorInfo.isFunctionDeclarator() &&
244 isStartOfFunctionDefinition(DeclaratorInfo)) {
250 Diag(Tok, diag::err_function_definition_not_allowed);
259 Diag(DS.getStorageClassSpecLoc(), diag::err_function_declared_typedef)
261 DS.ClearStorageClassSpecs();
264 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
268 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
269 return ParseFunctionDefinition(DeclaratorInfo, ParsedTemplateInfo(),
274 Diag(DeclaratorInfo.getIdentifierLoc(),
275 diag::err_explicit_instantiation_with_definition)
285 return ParseFunctionDefinition(
286 DeclaratorInfo, ParsedTemplateInfo(&FakedParamLists,
292 return ParseFunctionDefinition(DeclaratorInfo, TemplateInfo,
297 Decl *ThisDecl = ParseDeclarationAfterDeclarator(DeclaratorInfo,
300 if (Tok.
is(tok::comma)) {
301 Diag(Tok, diag::err_multiple_template_declarators)
302 << (int)TemplateInfo.Kind;
308 ExpectAndConsumeSemi(diag::err_expected_semi_declaration);
309 if (LateParsedAttrs.size() > 0)
310 ParseLexedAttributeList(LateParsedAttrs, ThisDecl,
true,
false);
311 DeclaratorInfo.complete(ThisDecl);
324 bool Parser::ParseTemplateParameters(
unsigned Depth,
336 if (!Tok.
is(tok::greater) && !Tok.
is(tok::greatergreater))
337 Failed = ParseTemplateParameterList(Depth, TemplateParams);
339 if (Tok.
is(tok::greatergreater)) {
364 Parser::ParseTemplateParameterList(
unsigned Depth,
368 = ParseTemplateParameter(Depth, TemplateParams.size())) {
369 TemplateParams.push_back(TmpParam);
373 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
378 if (Tok.
is(tok::comma)) {
380 }
else if (Tok.
isOneOf(tok::greater, tok::greatergreater)) {
388 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
398 bool Parser::isStartOfTemplateTypeParameter() {
399 if (Tok.
is(tok::kw_class)) {
406 case tok::greatergreater:
410 case tok::identifier:
419 switch (GetLookAheadToken(2).
getKind()) {
423 case tok::greatergreater:
431 if (Tok.
isNot(tok::kw_typename))
443 if (Next.
getKind() == tok::identifier)
444 Next = GetLookAheadToken(2);
450 case tok::greatergreater:
474 Decl *Parser::ParseTemplateParameter(
unsigned Depth,
unsigned Position) {
475 if (isStartOfTemplateTypeParameter())
476 return ParseTypeParameter(Depth, Position);
478 if (Tok.
is(tok::kw_template))
479 return ParseTemplateTemplateParameter(Depth, Position);
484 return ParseNonTypeTemplateParameter(Depth, Position);
496 Decl *Parser::ParseTypeParameter(
unsigned Depth,
unsigned Position) {
497 assert(Tok.
isOneOf(tok::kw_class, tok::kw_typename) &&
498 "A type-parameter starts with 'class' or 'typename'");
501 bool TypenameKeyword = Tok.
is(tok::kw_typename);
509 ? diag::warn_cxx98_compat_variadic_templates
510 : diag::ext_variadic_templates);
516 if (Tok.
is(tok::identifier)) {
519 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
520 tok::greatergreater)) {
529 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
531 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
543 KeyLoc, ParamName, NameLoc, Depth, Position,
544 EqualLoc, DefaultArg);
559 Parser::ParseTemplateTemplateParameter(
unsigned Depth,
unsigned Position) {
560 assert(Tok.
is(tok::kw_template) &&
"Expected 'template' keyword");
568 if (ParseTemplateParameters(Depth + 1, TemplateParams, LAngleLoc,
580 bool Replace = Tok.
isOneOf(tok::kw_typename, tok::kw_struct);
582 if (Tok.
is(tok::kw_typename)) {
585 ? diag::warn_cxx14_compat_template_template_param_typename
586 : diag::ext_template_template_param_typename)
590 }
else if (Next.
isOneOf(tok::identifier, tok::comma, tok::greater,
591 tok::greatergreater, tok::ellipsis)) {
607 ? diag::warn_cxx98_compat_variadic_templates
608 : diag::ext_variadic_templates);
613 if (Tok.
is(tok::identifier)) {
616 }
else if (Tok.
isOneOf(tok::equal, tok::comma, tok::greater,
617 tok::greatergreater)) {
626 bool AlreadyHasEllipsis = EllipsisLoc.
isValid();
628 DiagnoseMisplacedEllipsis(EllipsisLoc, NameLoc, AlreadyHasEllipsis,
true);
632 TemplateLoc, LAngleLoc,
642 DefaultArg = ParseTemplateTemplateArgument();
645 diag::err_default_template_template_parameter_not_template);
646 SkipUntil(tok::comma, tok::greater, tok::greatergreater,
652 ParamList, EllipsisLoc,
653 ParamName, NameLoc, Depth,
654 Position, EqualLoc, DefaultArg);
664 Parser::ParseNonTypeTemplateParameter(
unsigned Depth,
unsigned Position) {
669 ParseDeclarationSpecifiers(DS);
673 ParseDeclarator(ParamDecl);
682 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, ParamDecl);
706 Depth, Position, EqualLoc,
710 void Parser::DiagnoseMisplacedEllipsis(
SourceLocation EllipsisLoc,
712 bool AlreadyHasEllipsis,
713 bool IdentifierHasName) {
715 if (!AlreadyHasEllipsis)
717 Diag(EllipsisLoc, diag::err_misplaced_ellipsis_in_declaration)
719 << !IdentifierHasName;
722 void Parser::DiagnoseMisplacedEllipsisInDeclarator(
SourceLocation EllipsisLoc,
726 if (!AlreadyHasEllipsis)
729 AlreadyHasEllipsis, D.
hasName());
747 bool Parser::ParseGreaterThanInTemplateList(
SourceLocation &RAngleLoc,
748 bool ConsumeLastToken,
749 bool ObjCGenericList) {
752 const char *ReplacementStr =
"> >";
763 if (ConsumeLastToken)
767 case tok::greatergreater:
768 RemainingToken = tok::greater;
771 case tok::greatergreatergreater:
772 RemainingToken = tok::greatergreater;
775 case tok::greaterequal:
776 RemainingToken = tok::equal;
777 ReplacementStr =
"> =";
780 case tok::greatergreaterequal:
781 RemainingToken = tok::greaterequal;
795 if (!ObjCGenericList) {
811 if ((RemainingToken == tok::greater ||
812 RemainingToken == tok::greatergreater) &&
813 (Next.
isOneOf(tok::greater, tok::greatergreater,
814 tok::greatergreatergreater, tok::equal,
815 tok::greaterequal, tok::greatergreaterequal,
817 areTokensAdjacent(Tok, Next))
820 unsigned DiagId = diag::err_two_right_angle_brackets_need_space;
822 (Tok.
is(tok::greatergreater) || Tok.
is(tok::greatergreatergreater)))
823 DiagId = diag::warn_cxx98_compat_two_right_angle_brackets;
824 else if (Tok.
is(tok::greaterequal))
825 DiagId = diag::err_right_angle_bracket_equal_needs_space;
830 if (RemainingToken == tok::equal && Next.
is(tok::equal) &&
831 areTokensAdjacent(Tok, Next)) {
846 if (!ConsumeLastToken) {
877 Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
880 bool ConsumeLastToken,
882 TemplateArgList &TemplateArgs,
884 assert(Tok.
is(tok::less) &&
"Must have already parsed the template-name");
893 if (Tok.
isNot(tok::greater) && Tok.
isNot(tok::greatergreater))
894 Invalid = ParseTemplateArgumentList(TemplateArgs);
898 if (ConsumeLastToken)
906 return ParseGreaterThanInTemplateList(RAngleLoc, ConsumeLastToken,
947 bool Parser::AnnotateTemplateIdToken(TemplateTy Template,
TemplateNameKind TNK,
951 bool AllowTypeAnnotation) {
953 assert(Template && Tok.
is(tok::less) &&
954 "Parser isn't at the beginning of a template-id");
961 TemplateArgList TemplateArgs;
962 bool Invalid = ParseTemplateIdAfterTemplateName(Template,
964 SS,
false, LAngleLoc,
981 Template, TemplateNameLoc,
982 LAngleLoc, TemplateArgsPtr, RAngleLoc);
990 Tok.
setKind(tok::annot_typename);
991 setTypeAnnotation(Tok, Type.
get());
994 else if (TemplateKWLoc.
isValid())
1001 Tok.
setKind(tok::annot_template_id);
1009 TemplateId->
Name =
nullptr;
1012 TemplateId->
SS = SS;
1015 TemplateId->
Kind = TNK;
1019 for (
unsigned Arg = 0, ArgEnd = TemplateArgs.size(); Arg != ArgEnd; ++Arg)
1043 void Parser::AnnotateTemplateIdTokenAsType() {
1044 assert(Tok.
is(tok::annot_template_id) &&
"Requires template-id tokens");
1049 "Only works for type and dependent templates");
1052 TemplateId->NumArgs);
1056 TemplateId->TemplateKWLoc,
1057 TemplateId->Template,
1058 TemplateId->TemplateNameLoc,
1059 TemplateId->LAngleLoc,
1061 TemplateId->RAngleLoc);
1063 Tok.
setKind(tok::annot_typename);
1064 setTypeAnnotation(Tok, Type.isInvalid() ?
ParsedType() : Type.get());
1065 if (TemplateId->SS.isNotEmpty())
1076 return Tok.
isOneOf(tok::comma, tok::greater, tok::greatergreater);
1081 if (!Tok.
is(tok::identifier) && !Tok.
is(tok::coloncolon) &&
1082 !Tok.
is(tok::annot_cxxscope))
1097 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
1102 if (SS.
isSet() && Tok.
is(tok::kw_template)) {
1107 if (Tok.
is(tok::identifier)) {
1121 SS, TemplateKWLoc, Name,
1127 }
else if (Tok.
is(tok::identifier)) {
1137 bool MemberOfUnknownSpecialization;
1144 MemberOfUnknownSpecialization);
1173 if (isCXXTypeId(TypeIdAsTemplateArgument)) {
1181 TypeArg.
get().getAsOpaquePtr(),
1187 TentativeParsingAction TPA(*
this);
1190 = ParseTemplateTemplateArgument();
1191 if (!TemplateTemplateArgument.
isInvalid()) {
1193 return TemplateTemplateArgument;
1207 ExprArg.
get(), Loc);
1213 bool Parser::IsTemplateArgumentList(
unsigned Skip) {
1214 struct AlwaysRevertAction : TentativeParsingAction {
1215 AlwaysRevertAction(
Parser &
P) : TentativeParsingAction(P) { }
1216 ~AlwaysRevertAction() { Revert(); }
1229 if (Tok.
is(tok::greater))
1237 return Tok.
isOneOf(tok::greater, tok::comma);
1247 Parser::ParseTemplateArgumentList(TemplateArgList &TemplateArgs) {
1264 TemplateArgs.push_back(Arg);
1280 Decl *Parser::ParseExplicitInstantiation(
unsigned Context,
1289 return ParseSingleDeclarationAfterTemplate(Context,
1290 ParsedTemplateInfo(ExternLoc,
1292 ParsingTemplateParams,
1296 SourceRange Parser::ParsedTemplateInfo::getSourceRange()
const {
1299 TemplateParams->size());
1303 R.setBegin(ExternLoc);
1308 ((
Parser *)P)->ParseLateTemplatedFuncDef(LPT);
1319 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1331 DeclContextsToReenter.push_back(DD);
1337 DeclContextsToReenter.rbegin();
1338 for (; II != DeclContextsToReenter.rend(); ++II) {
1339 TemplateParamScopeStack.push_back(
new ParseScope(
this,
1341 unsigned NumParamLists =
1343 CurTemplateDepthTracker.addDepth(NumParamLists);
1350 assert(!LPT.
Toks.empty() &&
"Empty body!");
1354 LPT.
Toks.push_back(Tok);
1358 ConsumeAnyToken(
true);
1359 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try) &&
1360 "Inline method not starting with '{', ':' or 'try'");
1372 if (Tok.
is(tok::kw_try)) {
1373 ParseFunctionTryBlock(LPT.
D, FnScope);
1375 if (Tok.
is(tok::colon))
1376 ParseConstructorInitializer(LPT.
D);
1380 if (Tok.
is(tok::l_brace)) {
1381 assert((!isa<FunctionTemplateDecl>(LPT.
D) ||
1382 cast<FunctionTemplateDecl>(LPT.
D)
1383 ->getTemplateParameters()
1384 ->getDepth() == TemplateParameterDepth - 1) &&
1385 "TemplateParameterDepth should be greater than the depth of "
1386 "current template being instantiated!");
1387 ParseFunctionStatementBody(LPT.
D, FnScope);
1396 TemplateParamScopeStack.rbegin();
1397 for (; I != TemplateParamScopeStack.rend(); ++
I)
1402 void Parser::LexTemplateFunctionForLateParsing(
CachedTokens &Toks) {
1404 if (!ConsumeAndStoreFunctionPrologue(Toks)) {
1406 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1410 if (kind == tok::kw_try) {
1411 while (Tok.
is(tok::kw_catch)) {
1412 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
1413 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
SourceManager & getSourceManager() const
Defines the clang::ASTContext interface.
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.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc)
ActOnTemplateParameterList - Builds a TemplateParameterList that contains the template parameters in ...
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.
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...
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)
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.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
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.
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.
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)
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.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
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
void EnterTokenStream(const Token *Toks, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens)
Add a "macro" context to the top of the include stack, which will cause the lexer to start returning ...
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.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
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