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);
729 if (Tok.
isNot(tok::eof)) {
730 if (!
Init.isInvalid()) {
735 Diag(EndLoc, diag::err_expected_semi_decl_list);
739 while (Tok.
isNot(tok::eof))
749void Parser::ParseLexedAttributes(ParsingClass &
Class) {
750 ReenterClassScopeRAII InClassScope(*
this,
Class);
752 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
753 LateD->ParseLexedAttributes();
757void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *
D,
758 bool EnterScope,
bool OnDefinition) {
759 assert(LAs.parseSoon() &&
760 "Attribute list should be marked for immediate parsing.");
761 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
764 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
775void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
776 bool EnterScope,
bool OnDefinition) {
784 LA.Toks.push_back(AttrEnd);
788 LA.Toks.push_back(Tok);
789 PP.EnterTokenStream(LA.Toks,
true,
true);
795 if (LA.Decls.size() > 0) {
796 Decl *
D = LA.Decls[0];
804 if (LA.Decls.size() == 1) {
806 ReenterTemplateScopeRAII InDeclScope(*
this,
D,
EnterScope);
816 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
825 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
830 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
833 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
834 Attrs.begin()->isKnownToGCC())
835 Diag(Tok, diag::warn_attribute_on_function_definition)
838 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
843 while (Tok.
isNot(tok::eof))
850void Parser::ParseLexedPragmas(ParsingClass &
Class) {
851 ReenterClassScopeRAII InClassScope(*
this,
Class);
853 for (LateParsedDeclaration *
D :
Class.LateParsedDeclarations)
854 D->ParseLexedPragmas();
857void Parser::ParseLexedPragma(LateParsedPragma &LP) {
859 PP.EnterTokenStream(LP.toks(),
true,
864 assert(Tok.
isAnnotation() &&
"Expected annotation token.");
866 case tok::annot_attr_openmp:
867 case tok::annot_pragma_openmp: {
870 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
874 llvm_unreachable(
"Unexpected token.");
886 bool StopAtSemi,
bool ConsumeFinalToken) {
889 bool isFirstTokenConsumed =
true;
892 if (Tok.
is(T1) || Tok.
is(T2)) {
893 if (ConsumeFinalToken) {
902 case tok::annot_module_begin:
903 case tok::annot_module_end:
904 case tok::annot_module_include:
905 case tok::annot_repl_input_end:
913 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
919 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
925 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
934 if (ParenCount && !isFirstTokenConsumed)
940 if (BracketCount && !isFirstTokenConsumed)
946 if (BraceCount && !isFirstTokenConsumed)
962 isFirstTokenConsumed =
false;
972bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
973 if (Tok.
is(tok::kw_try)) {
978 if (Tok.
isNot(tok::colon)) {
984 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
987 if (Tok.
isNot(tok::l_brace))
1008 bool MightBeTemplateArgument =
false;
1012 if (Tok.
is(tok::kw_decltype)) {
1013 Toks.push_back(Tok);
1015 if (Tok.
isNot(tok::l_paren))
1018 Toks.push_back(Tok);
1020 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
1022 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
1028 if (Tok.
is(tok::coloncolon)) {
1029 Toks.push_back(Tok);
1032 if (Tok.
is(tok::kw_template)) {
1033 Toks.push_back(Tok);
1038 if (Tok.
is(tok::identifier)) {
1039 Toks.push_back(Tok);
1045 if (Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
1046 Toks.push_back(Tok);
1048 Toks.push_back(Tok);
1050 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1052 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1057 }
while (Tok.
is(tok::coloncolon));
1059 if (Tok.
is(tok::code_completion)) {
1060 Toks.push_back(Tok);
1061 ConsumeCodeCompletionToken();
1062 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1069 if (Tok.
is(tok::comma)) {
1071 Toks.push_back(Tok);
1075 if (Tok.
is(tok::less))
1076 MightBeTemplateArgument =
true;
1078 if (MightBeTemplateArgument) {
1085 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1092 }
else if (Tok.
isNot(tok::l_paren) && Tok.
isNot(tok::l_brace)) {
1096 << tok::l_paren << tok::l_brace;
1102 Toks.push_back(Tok);
1103 bool IsLParen = (
kind == tok::l_paren);
1109 assert(kind == tok::l_brace &&
"Must be left paren or brace here.");
1116 const Token &PreviousToken = Toks[Toks.size() - 2];
1117 if (!MightBeTemplateArgument &&
1118 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1119 tok::greatergreater)) {
1125 TentativeParsingAction PA(*
this);
1127 !Tok.
isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1140 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1141 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1142 Diag(Tok, diag::err_expected) << CloseKind;
1143 Diag(OpenLoc, diag::note_matching) <<
kind;
1148 if (Tok.
is(tok::ellipsis)) {
1149 Toks.push_back(Tok);
1155 if (Tok.
is(tok::comma)) {
1156 Toks.push_back(Tok);
1158 }
else if (Tok.
is(tok::l_brace)) {
1173 Toks.push_back(Tok);
1176 }
else if (!MightBeTemplateArgument) {
1177 return Diag(Tok.
getLocation(), diag::err_expected_either) << tok::l_brace
1185bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1187 assert(Tok.
is(tok::question));
1188 Toks.push_back(Tok);
1191 while (Tok.
isNot(tok::colon)) {
1192 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1198 if (Tok.
is(tok::question) && !ConsumeAndStoreConditional(Toks))
1203 Toks.push_back(Tok);
1214bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1215 CachedInitKind CIK) {
1217 bool IsFirstToken =
true;
1222 unsigned AngleCount = 0;
1223 unsigned KnownTemplateCount = 0;
1232 if (KnownTemplateCount)
1245 TentativeParsingAction TPA(*
this,
true);
1248 TPResult
Result = TPResult::Error;
1251 case CIK_DefaultInitializer:
1252 Result = TryParseInitDeclaratorList();
1255 if (
Result == TPResult::Ambiguous && Tok.
isNot(tok::semi))
1256 Result = TPResult::False;
1259 case CIK_DefaultArgument:
1260 bool InvalidAsDeclaration =
false;
1261 Result = TryParseParameterDeclarationClause(
1262 &InvalidAsDeclaration,
true);
1265 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1266 Result = TPResult::False;
1276 if (
Result != TPResult::False &&
Result != TPResult::Error)
1281 ++KnownTemplateCount;
1285 case tok::annot_module_begin:
1286 case tok::annot_module_end:
1287 case tok::annot_module_include:
1288 case tok::annot_repl_input_end:
1301 if (!ConsumeAndStoreConditional(Toks))
1305 case tok::greatergreatergreater:
1308 if (AngleCount) --AngleCount;
1309 if (KnownTemplateCount) --KnownTemplateCount;
1311 case tok::greatergreater:
1314 if (AngleCount) --AngleCount;
1315 if (KnownTemplateCount) --KnownTemplateCount;
1318 if (AngleCount) --AngleCount;
1319 if (KnownTemplateCount) --KnownTemplateCount;
1322 case tok::kw_template:
1326 Toks.push_back(Tok);
1328 if (Tok.
is(tok::identifier)) {
1329 Toks.push_back(Tok);
1331 if (Tok.
is(tok::less)) {
1333 ++KnownTemplateCount;
1334 Toks.push_back(Tok);
1340 case tok::kw_operator:
1343 Toks.push_back(Tok);
1347 case tok::greatergreatergreater:
1348 case tok::greatergreater:
1351 Toks.push_back(Tok);
1361 Toks.push_back(Tok);
1363 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1367 Toks.push_back(Tok);
1369 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1373 Toks.push_back(Tok);
1375 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1385 if (CIK == CIK_DefaultArgument)
1387 if (ParenCount && !IsFirstToken)
1389 Toks.push_back(Tok);
1393 if (BracketCount && !IsFirstToken)
1395 Toks.push_back(Tok);
1399 if (BraceCount && !IsFirstToken)
1401 Toks.push_back(Tok);
1405 case tok::code_completion:
1406 Toks.push_back(Tok);
1407 ConsumeCodeCompletionToken();
1410 case tok::string_literal:
1411 case tok::wide_string_literal:
1412 case tok::utf8_string_literal:
1413 case tok::utf16_string_literal:
1414 case tok::utf32_string_literal:
1415 Toks.push_back(Tok);
1416 ConsumeStringToken();
1419 if (CIK == CIK_DefaultInitializer)
1424 Toks.push_back(Tok);
1428 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, Expr *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.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ ICIS_NoInit
No in-class initializer.
@ 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.