25 if (!Tok.
is(tok::l_paren))
31 if (isTokenStringLiteral()) {
36 ? diag::warn_cxx23_delete_with_message
37 : diag::ext_delete_with_message)
38 << Message->getSourceRange();
53void Parser::SkipDeletedFunctionBody() {
54 if (!Tok.
is(tok::l_paren))
62 if (Tok.
is(tok::r_paren))
69NamedDecl *Parser::ParseCXXInlineMethodDef(
73 assert(
D.isFunctionDeclarator() &&
"This isn't a function declarator!");
74 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try, tok::equal) &&
75 "Current token not a '{', ':', '=', or 'try'!");
78 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
80 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
83 if (
D.getDeclSpec().isFriendSpecified())
88 TemplateParams,
nullptr,
98 HandleMemberFunctionDeclDelays(
D, FnD);
113 ? diag::warn_cxx98_compat_defaulted_deleted_function
114 : diag::ext_defaulted_deleted_function)
119 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
120 DeclAsFunction->setRangeEnd(KWEndLoc);
124 ? diag::warn_cxx98_compat_defaulted_deleted_function
125 : diag::ext_defaulted_deleted_function)
128 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
129 DeclAsFunction->setRangeEnd(KWEndLoc);
132 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
135 if (Tok.
is(tok::comma)) {
136 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
139 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
140 Delete ?
"delete" :
"default")) {
148 trySkippingFunctionBody()) {
158 !
D.getDeclSpec().hasConstexprSpecifier() &&
162 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
163 TemplateInfo.Kind != ParsedTemplateInfo::ExplicitSpecialization)) &&
167 LexTemplateFunctionForLateParsing(Toks);
180 LexedMethod* LM =
new LexedMethod(
this, FnD);
181 getCurrentClass().LateParsedDeclarations.push_back(LM);
187 if (ConsumeAndStoreFunctionPrologue(Toks)) {
194 llvm::any_of(Toks, [](
const Token &Tok) {
195 return Tok.is(tok::code_completion);
208 delete getCurrentClass().LateParsedDeclarations.back();
209 getCurrentClass().LateParsedDeclarations.pop_back();
213 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
217 if (kind == tok::kw_try) {
218 while (Tok.
is(tok::kw_catch)) {
219 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
220 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
233 delete getCurrentClass().LateParsedDeclarations.back();
234 getCurrentClass().LateParsedDeclarations.pop_back();
244void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
245 assert(Tok.
isOneOf(tok::l_brace, tok::equal) &&
246 "Current token not a '{' or '='!");
248 LateParsedMemberInitializer *MI =
249 new LateParsedMemberInitializer(
this, VarD);
250 getCurrentClass().LateParsedDeclarations.push_back(MI);
254 if (kind == tok::equal) {
259 if (kind == tok::l_brace) {
265 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
268 ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer);
281Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
282void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
283void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() {}
284void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
285void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
286void Parser::LateParsedDeclaration::ParseLexedPragmas() {}
288Parser::LateParsedClass::LateParsedClass(
Parser *
P, ParsingClass *
C)
291Parser::LateParsedClass::~LateParsedClass() {
292 Self->DeallocateParsedClasses(Class);
295void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
296 Self->ParseLexedMethodDeclarations(*Class);
299void Parser::LateParsedClass::ParseLexedMemberInitializers() {
300 Self->ParseLexedMemberInitializers(*Class);
303void Parser::LateParsedClass::ParseLexedMethodDefs() {
304 Self->ParseLexedMethodDefs(*Class);
307void Parser::LateParsedClass::ParseLexedAttributes() {
308 Self->ParseLexedAttributes(*Class);
311void Parser::LateParsedClass::ParseLexedPragmas() {
312 Self->ParseLexedPragmas(*Class);
315void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
316 Self->ParseLexedMethodDeclaration(*
this);
319void Parser::LexedMethod::ParseLexedMethodDefs() {
320 Self->ParseLexedMethodDef(*
this);
323void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() {
324 Self->ParseLexedMemberInitializer(*
this);
327void Parser::LateParsedAttribute::ParseLexedAttributes() {
328 Self->ParseLexedAttribute(*
this,
true,
false);
331void Parser::LateParsedPragma::ParseLexedPragmas() {
332 Self->ParseLexedPragma(*
this);
357 !
Class.TopLevelClass),
360 if (
Class.TopLevelClass)
366 Class.TagOrTemplate);
369 if (
Class.TopLevelClass)
373 Class.TagOrTemplate);
381void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
382 ReenterClassScopeRAII InClassScope(*
this,
Class);
384 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
385 LateD->ParseLexedMethodDeclarations();
388void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
390 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
400 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
401 auto Param = cast<ParmVarDecl>(LM.DefaultArgs[I].Param);
403 bool HasUnparsed = Param->hasUnparsedDefaultArg();
405 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
411 Token LastDefaultArgToken = Toks->back();
417 Toks->push_back(DefArgEnd);
420 Toks->push_back(Tok);
421 PP.EnterTokenStream(*Toks,
true,
true);
427 assert(Tok.
is(tok::equal) &&
"Default argument not starting with '='");
438 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
439 DefArgResult = ParseBraceInitializer();
451 assert(Toks->size() >= 3 &&
"expected a token in default arg");
454 (*Toks)[Toks->size() - 3].getLocation());
462 while (Tok.
isNot(tok::eof))
467 }
else if (HasUnparsed) {
468 assert(Param->hasInheritedDefaultArg());
470 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
479 Param->setUninstantiatedDefaultArg(
482 Param->setDefaultArg(OldParam->
getInit());
492 Token LastExceptionSpecToken = Toks->back();
493 Token ExceptionSpecEnd;
495 ExceptionSpecEnd.
setKind(tok::eof);
498 Toks->push_back(ExceptionSpecEnd);
501 Toks->push_back(Tok);
502 PP.EnterTokenStream(*Toks,
true,
true);
516 = dyn_cast<FunctionTemplateDecl>(LM.Method))
517 FunctionToPush = FunTmpl->getTemplatedDecl();
519 FunctionToPush = cast<FunctionDecl>(LM.Method);
520 Method = dyn_cast<CXXMethodDecl>(FunctionToPush);
538 Actions, Method ? Method->
getParent() :
nullptr,
550 = tryParseExceptionSpecification(
false, SpecificationRange,
552 DynamicExceptionRanges, NoexceptExpr,
553 ExceptionSpecTokens);
562 DynamicExceptionRanges,
564 NoexceptExpr.
get() :
nullptr);
568 while (Tok.
isNot(tok::eof))
576 LM.ExceptionSpecTokens =
nullptr;
579 InFunctionTemplateScope.Scopes.Exit();
588void Parser::ParseLexedMethodDefs(ParsingClass &
Class) {
589 ReenterClassScopeRAII InClassScope(*
this,
Class);
591 for (LateParsedDeclaration *
D :
Class.LateParsedDeclarations)
592 D->ParseLexedMethodDefs();
595void Parser::ParseLexedMethodDef(LexedMethod &LM) {
597 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.D);
601 assert(!LM.Toks.empty() &&
"Empty body!");
602 Token LastBodyToken = LM.Toks.back();
608 LM.Toks.push_back(BodyEnd);
611 LM.Toks.push_back(Tok);
612 PP.EnterTokenStream(LM.Toks,
true,
true);
616 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)
617 &&
"Inline method not starting with '{', ':' or 'try'");
627 if (Tok.
is(tok::kw_try)) {
628 ParseFunctionTryBlock(LM.D, FnScope);
630 while (Tok.
isNot(tok::eof))
637 if (Tok.
is(tok::colon)) {
638 ParseConstructorInitializer(LM.D);
641 if (!Tok.
is(tok::l_brace)) {
645 while (Tok.
isNot(tok::eof))
656 !isa<FunctionTemplateDecl>(LM.D) ||
657 cast<FunctionTemplateDecl>(LM.D)->getTemplateParameters()->getDepth()
658 < TemplateParameterDepth) &&
659 "TemplateParameterDepth should be greater than the depth of "
660 "current template being instantiated!");
662 ParseFunctionStatementBody(LM.D, FnScope);
664 while (Tok.
isNot(tok::eof))
670 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
671 if (isa<CXXMethodDecl>(FD) ||
679void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
680 ReenterClassScopeRAII InClassScope(*
this,
Class);
682 if (!
Class.LateParsedDeclarations.empty()) {
692 for (LateParsedDeclaration *
D :
Class.LateParsedDeclarations)
693 D->ParseLexedMemberInitializers();
699void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
700 if (!MI.Field || MI.Field->isInvalidDecl())
707 MI.Toks.push_back(Tok);
708 PP.EnterTokenStream(MI.Toks,
true,
true);
728 if (Tok.
isNot(tok::eof)) {
729 if (!
Init.isInvalid()) {
734 Diag(EndLoc, diag::err_expected_semi_decl_list);
738 while (Tok.
isNot(tok::eof))
748void Parser::ParseLexedAttributes(ParsingClass &
Class) {
749 ReenterClassScopeRAII InClassScope(*
this,
Class);
751 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
752 LateD->ParseLexedAttributes();
756void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *
D,
757 bool EnterScope,
bool OnDefinition) {
758 assert(LAs.parseSoon() &&
759 "Attribute list should be marked for immediate parsing.");
760 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
763 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
774void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
775 bool EnterScope,
bool OnDefinition) {
783 LA.Toks.push_back(AttrEnd);
787 LA.Toks.push_back(Tok);
788 PP.EnterTokenStream(LA.Toks,
true,
true);
794 if (LA.Decls.size() > 0) {
795 Decl *
D = LA.Decls[0];
803 if (LA.Decls.size() == 1) {
805 ReenterTemplateScopeRAII InDeclScope(*
this,
D,
EnterScope);
815 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
824 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
829 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
832 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
833 Attrs.begin()->isKnownToGCC())
834 Diag(Tok, diag::warn_attribute_on_function_definition)
837 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
842 while (Tok.
isNot(tok::eof))
849void Parser::ParseLexedPragmas(ParsingClass &
Class) {
850 ReenterClassScopeRAII InClassScope(*
this,
Class);
852 for (LateParsedDeclaration *
D :
Class.LateParsedDeclarations)
853 D->ParseLexedPragmas();
856void Parser::ParseLexedPragma(LateParsedPragma &LP) {
858 PP.EnterTokenStream(LP.toks(),
true,
863 assert(Tok.
isAnnotation() &&
"Expected annotation token.");
865 case tok::annot_attr_openmp:
866 case tok::annot_pragma_openmp: {
869 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
873 llvm_unreachable(
"Unexpected token.");
885 bool StopAtSemi,
bool ConsumeFinalToken) {
888 bool isFirstTokenConsumed =
true;
891 if (Tok.
is(T1) || Tok.
is(T2)) {
892 if (ConsumeFinalToken) {
901 case tok::annot_module_begin:
902 case tok::annot_module_end:
903 case tok::annot_module_include:
904 case tok::annot_repl_input_end:
912 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
918 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
924 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
933 if (ParenCount && !isFirstTokenConsumed)
939 if (BracketCount && !isFirstTokenConsumed)
945 if (BraceCount && !isFirstTokenConsumed)
961 isFirstTokenConsumed =
false;
971bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
972 if (Tok.
is(tok::kw_try)) {
977 if (Tok.
isNot(tok::colon)) {
983 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
986 if (Tok.
isNot(tok::l_brace))
1007 bool MightBeTemplateArgument =
false;
1011 if (Tok.
is(tok::kw_decltype)) {
1012 Toks.push_back(Tok);
1014 if (Tok.
isNot(tok::l_paren))
1017 Toks.push_back(Tok);
1019 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
1021 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
1027 if (Tok.
is(tok::coloncolon)) {
1028 Toks.push_back(Tok);
1031 if (Tok.
is(tok::kw_template)) {
1032 Toks.push_back(Tok);
1037 if (Tok.
is(tok::identifier)) {
1038 Toks.push_back(Tok);
1044 if (Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
1045 Toks.push_back(Tok);
1047 Toks.push_back(Tok);
1049 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1051 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1056 }
while (Tok.
is(tok::coloncolon));
1058 if (Tok.
is(tok::code_completion)) {
1059 Toks.push_back(Tok);
1060 ConsumeCodeCompletionToken();
1061 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1068 if (Tok.
is(tok::comma)) {
1070 Toks.push_back(Tok);
1074 if (Tok.
is(tok::less))
1075 MightBeTemplateArgument =
true;
1077 if (MightBeTemplateArgument) {
1084 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1091 }
else if (Tok.
isNot(tok::l_paren) && Tok.
isNot(tok::l_brace)) {
1095 << tok::l_paren << tok::l_brace;
1101 Toks.push_back(Tok);
1102 bool IsLParen = (
kind == tok::l_paren);
1108 assert(kind == tok::l_brace &&
"Must be left paren or brace here.");
1115 const Token &PreviousToken = Toks[Toks.size() - 2];
1116 if (!MightBeTemplateArgument &&
1117 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1118 tok::greatergreater)) {
1124 TentativeParsingAction PA(*
this);
1126 !Tok.
isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1139 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1140 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1141 Diag(Tok, diag::err_expected) << CloseKind;
1142 Diag(OpenLoc, diag::note_matching) <<
kind;
1147 if (Tok.
is(tok::ellipsis)) {
1148 Toks.push_back(Tok);
1154 if (Tok.
is(tok::comma)) {
1155 Toks.push_back(Tok);
1157 }
else if (Tok.
is(tok::l_brace)) {
1172 Toks.push_back(Tok);
1175 }
else if (!MightBeTemplateArgument) {
1176 return Diag(Tok.
getLocation(), diag::err_expected_either) << tok::l_brace
1184bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1186 assert(Tok.
is(tok::question));
1187 Toks.push_back(Tok);
1190 while (Tok.
isNot(tok::colon)) {
1191 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1197 if (Tok.
is(tok::question) && !ConsumeAndStoreConditional(Toks))
1202 Toks.push_back(Tok);
1213bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1214 CachedInitKind CIK) {
1216 bool IsFirstToken =
true;
1221 unsigned AngleCount = 0;
1222 unsigned KnownTemplateCount = 0;
1231 if (KnownTemplateCount)
1244 TentativeParsingAction TPA(*
this,
true);
1247 TPResult
Result = TPResult::Error;
1250 case CIK_DefaultInitializer:
1251 Result = TryParseInitDeclaratorList();
1254 if (
Result == TPResult::Ambiguous && Tok.
isNot(tok::semi))
1255 Result = TPResult::False;
1258 case CIK_DefaultArgument:
1259 bool InvalidAsDeclaration =
false;
1260 Result = TryParseParameterDeclarationClause(
1261 &InvalidAsDeclaration,
true);
1264 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1265 Result = TPResult::False;
1275 if (
Result != TPResult::False &&
Result != TPResult::Error)
1280 ++KnownTemplateCount;
1284 case tok::annot_module_begin:
1285 case tok::annot_module_end:
1286 case tok::annot_module_include:
1287 case tok::annot_repl_input_end:
1300 if (!ConsumeAndStoreConditional(Toks))
1304 case tok::greatergreatergreater:
1307 if (AngleCount) --AngleCount;
1308 if (KnownTemplateCount) --KnownTemplateCount;
1310 case tok::greatergreater:
1313 if (AngleCount) --AngleCount;
1314 if (KnownTemplateCount) --KnownTemplateCount;
1317 if (AngleCount) --AngleCount;
1318 if (KnownTemplateCount) --KnownTemplateCount;
1321 case tok::kw_template:
1325 Toks.push_back(Tok);
1327 if (Tok.
is(tok::identifier)) {
1328 Toks.push_back(Tok);
1330 if (Tok.
is(tok::less)) {
1332 ++KnownTemplateCount;
1333 Toks.push_back(Tok);
1339 case tok::kw_operator:
1342 Toks.push_back(Tok);
1346 case tok::greatergreatergreater:
1347 case tok::greatergreater:
1350 Toks.push_back(Tok);
1360 Toks.push_back(Tok);
1362 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1366 Toks.push_back(Tok);
1368 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1372 Toks.push_back(Tok);
1374 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1384 if (CIK == CIK_DefaultArgument)
1386 if (ParenCount && !IsFirstToken)
1388 Toks.push_back(Tok);
1392 if (BracketCount && !IsFirstToken)
1394 Toks.push_back(Tok);
1398 if (BraceCount && !IsFirstToken)
1400 Toks.push_back(Tok);
1404 case tok::code_completion:
1405 Toks.push_back(Tok);
1406 ConsumeCodeCompletionToken();
1409 case tok::string_literal:
1410 case tok::wide_string_literal:
1411 case tok::utf8_string_literal:
1412 case tok::utf16_string_literal:
1413 case tok::utf32_string_literal:
1414 Toks.push_back(Tok);
1415 ConsumeStringToken();
1418 if (CIK == CIK_DefaultInitializer)
1423 Toks.push_back(Tok);
1427 IsFirstToken =
false;
Defines the C++ template declaration subclasses.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Decl - This represents one declaration (or definition), e.g.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
bool isInIdentifierNamespace(unsigned NS) const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
@ IDNS_OrdinaryFriend
This declaration is a friend function.
DeclContext * getDeclContext()
bool hasErrorOccurred() const
RAII object that enters a new expression evaluation context.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
QualType getReturnType() const
void setWillHaveBody(bool V=true)
Declaration of a template function.
This represents a decl that may have a name.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
Represents a parameter to a function.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
bool hasUninstantiatedDefaultArg() const
Expr * getUninstantiatedDefaultArg()
ParsedAttributes - A collection of parsed attributes.
Introduces zero or more scopes for parsing.
void Enter(unsigned ScopeFlags)
Parser - This implements a parser for the C family of languages.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() 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 ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
const LangOptions & getLangOpts() const
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
ExprResult ParseUnevaluatedStringLiteralExpression()
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
unsigned ReenterTemplateScopes(MultiParseScope &S, Decl *D)
Re-enter the template scopes for a declaration that might be a template.
A class for parsing a declarator.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
The collection of all-type qualifiers we support.
Represents a struct/union/class.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ CompoundStmtScope
This is a compound statement scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ DeclScope
This is a scope that can contain a declaration.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Records and restores the CurFPFeatures state on entry/exit of compound statements.
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Decl * ActOnSkippedFunctionBody(Decl *Decl)
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc, Expr *DefaultArg)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
void ActOnFinishDelayedMemberInitializers(Decl *Record)
void ActOnExitFunctionContext()
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool IsInsideALocalClassWithinATemplateFunction()
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
DiagnosticsEngine & getDiagnostics() const
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
void PushFunctionScope()
Enter a new function scope.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, ExprResult Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void actOnDelayedExceptionSpecification(Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member or friend function (or function template).
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, 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...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
StringLiteral - This represents a string literal expression, e.g.
Token - This structure provides full information about a lexed token.
SourceLocation getEndLoc() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setKind(tok::TokenKind K)
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)) {....
tok::TokenKind getKind() const
void setEofData(const void *D)
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
const void * getEofData() const
void startToken()
Reset all flags to cleared.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
const Expr * getInit() const
Represents a C++11 virt-specifier-seq.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ ICIS_NoInit
No in-class initializer.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ Result
The result type of a method or function.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Utility to re-enter a class scope while parsing its late-parsed components.
ReenterClassScopeRAII(Parser &P, ParsingClass &Class)
Utility to re-enter a possibly-templated scope while parsing its late-parsed components.
ReenterTemplateScopeRAII(Parser &P, Decl *MaybeTemplated, bool Enter=true)
TemplateParameterDepthRAII CurTemplateDepthTracker
An RAII helper that pops function a function scope on exit.