20#include "llvm/ADT/ScopeExit.h"
25 if (!Tok.is(tok::l_paren))
27 StringLiteral *
Message =
nullptr;
31 if (isTokenStringLiteral()) {
36 ? diag::warn_cxx23_delete_with_message
37 : diag::ext_delete_with_message)
41 Diag(Tok.getLocation(), diag::err_expected_string_literal)
50void Parser::SkipDeletedFunctionBody() {
51 if (!Tok.is(tok::l_paren))
59 if (Tok.is(tok::r_paren))
63NamedDecl *Parser::ParseCXXInlineMethodDef(
68 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try, tok::equal) &&
69 "Current token not a '{', ':', '=', or 'try'!");
72 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
74 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
78 FnD = Actions.ActOnFriendFunctionDecl(
getCurScope(), D,
81 FnD = Actions.ActOnCXXMemberDeclarator(
getCurScope(), AS, D,
82 TemplateParams,
nullptr,
85 Actions.ProcessDeclAttributeList(
getCurScope(), FnD, AccessAttrs);
87 Actions.ActOnPureSpecifier(FnD, PureSpecLoc);
92 HandleMemberFunctionDeclDelays(D, FnD);
103 SourceLocation KWLoc;
104 SourceLocation KWEndLoc = Tok.getEndLoc().getLocWithOffset(-1);
107 ? diag::warn_cxx98_compat_defaulted_deleted_function
108 : diag::ext_defaulted_deleted_function)
110 StringLiteral *
Message = ParseCXXDeletedFunctionMessage();
111 Actions.SetDeclDeleted(FnD, KWLoc, Message);
113 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
114 DeclAsFunction->setRangeEnd(KWEndLoc);
118 ? diag::warn_cxx98_compat_defaulted_deleted_function
119 : diag::ext_defaulted_deleted_function)
121 Actions.SetDeclDefaulted(FnD, KWLoc);
122 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
123 DeclAsFunction->setRangeEnd(KWEndLoc);
126 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
129 if (Tok.is(tok::comma)) {
130 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
133 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
134 Delete ?
"delete" :
"default") &&
135 !isLikelyAtStartOfNewDeclaration()) {
142 if (SkipFunctionBodies && (!FnD || Actions.canSkipFunctionBody(FnD)) &&
143 trySkippingFunctionBody()) {
144 Actions.ActOnSkippedFunctionBody(FnD);
156 ((Actions.CurContext->isDependentContext() ||
159 !Actions.IsInsideALocalClassWithinATemplateFunction())) {
162 LexTemplateFunctionForLateParsing(Toks);
166 Actions.CheckForFunctionRedefinition(FD);
167 Actions.MarkAsLateParsedTemplate(FD, FnD, Toks);
175 LexedMethod* LM =
new LexedMethod(
this, FnD);
176 getCurrentClass().LateParsedDeclarations.push_back(LM);
182 if (ConsumeAndStoreFunctionPrologue(Toks)) {
188 if (PP.isCodeCompletionEnabled() &&
189 llvm::any_of(Toks, [](
const Token &Tok) {
190 return Tok.is(tok::code_completion);
203 delete getCurrentClass().LateParsedDeclarations.back();
204 getCurrentClass().LateParsedDeclarations.pop_back();
208 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
212 if (
kind == tok::kw_try) {
213 while (Tok.is(tok::kw_catch)) {
214 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
215 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
223 Actions.CheckForFunctionRedefinition(FD);
228 delete getCurrentClass().LateParsedDeclarations.back();
229 getCurrentClass().LateParsedDeclarations.pop_back();
235void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
236 assert(Tok.isOneOf(tok::l_brace, tok::equal) &&
237 "Current token not a '{' or '='!");
239 LateParsedMemberInitializer *MI =
240 new LateParsedMemberInitializer(
this, VarD);
241 getCurrentClass().LateParsedDeclarations.push_back(MI);
245 if (
kind == tok::equal) {
250 if (
kind == tok::l_brace) {
256 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
272Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
273void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
274void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() {}
275void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
276void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
277void Parser::LateParsedDeclaration::ParseLexedPragmas() {}
279Parser::LateParsedClass::LateParsedClass(
Parser *P, ParsingClass *
C)
282Parser::LateParsedClass::~LateParsedClass() {
283 Self->DeallocateParsedClasses(Class);
286void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
287 Self->ParseLexedMethodDeclarations(*
Class);
290void Parser::LateParsedClass::ParseLexedMemberInitializers() {
291 Self->ParseLexedMemberInitializers(*
Class);
294void Parser::LateParsedClass::ParseLexedMethodDefs() {
298void Parser::LateParsedClass::ParseLexedAttributes() {
302void Parser::LateParsedClass::ParseLexedPragmas() {
306void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
307 Self->ParseLexedMethodDeclaration(*
this);
310void Parser::LexedMethod::ParseLexedMethodDefs() {
311 Self->ParseLexedMethodDef(*
this);
314void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() {
315 Self->ParseLexedMemberInitializer(*
this);
318void Parser::LateParsedAttribute::ParseLexedAttributes() {
319 Self->ParseLexedAttribute(*
this,
true,
false);
322void Parser::LateParsedPragma::ParseLexedPragmas() {
323 Self->ParseLexedPragma(*
this);
335 P.ReenterTemplateScopes(
Scopes, MaybeTemplated));
345 !
Class.TopLevelClass),
348 if (
Class.TopLevelClass)
353 P.Actions.ActOnStartDelayedMemberDeclarations(
P.getCurScope(),
354 Class.TagOrTemplate);
357 if (
Class.TopLevelClass)
360 P.Actions.ActOnFinishDelayedMemberDeclarations(
P.getCurScope(),
361 Class.TagOrTemplate);
365void Parser::ParseLexedMethodDeclarations(ParsingClass &
Class) {
366 ReenterClassScopeRAII InClassScope(*
this,
Class);
368 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
369 LateD->ParseLexedMethodDeclarations();
372void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
374 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
384 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
387 bool HasUnparsed = Param->hasUnparsedDefaultArg();
389 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
395 Token LastDefaultArgToken = Toks->back();
401 Toks->push_back(DefArgEnd);
404 Toks->push_back(
Tok);
405 PP.EnterTokenStream(*Toks,
true,
true);
411 assert(
Tok.is(tok::equal) &&
"Default argument not starting with '='");
422 Diag(
Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
423 DefArgResult = ParseBraceInitializer();
427 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc,
430 if (Tok.isNot(tok::eof) || Tok.getEofData() != Param) {
434 assert(Toks->size() >= 3 &&
"expected a token in default arg");
435 Diag(Tok.getLocation(), diag::err_default_arg_unparsed)
436 << SourceRange(Tok.getLocation(),
437 (*Toks)[Toks->size() - 3].getLocation());
439 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
445 while (Tok.isNot(tok::eof))
448 if (Tok.is(tok::eof) && Tok.getEofData() == Param)
450 }
else if (HasUnparsed) {
451 assert(Param->hasInheritedDefaultArg());
453 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
462 Param->setUninstantiatedDefaultArg(
465 Param->setDefaultArg(OldParam->
getInit());
475 Token LastExceptionSpecToken = Toks->back();
476 Token ExceptionSpecEnd;
478 ExceptionSpecEnd.
setKind(tok::eof);
481 Toks->push_back(ExceptionSpecEnd);
484 Toks->push_back(Tok);
485 PP.EnterTokenStream(*Toks,
true,
true);
497 FunctionDecl *FunctionToPush;
498 if (FunctionTemplateDecl *FunTmpl
499 = dyn_cast<FunctionTemplateDecl>(LM.Method))
500 FunctionToPush = FunTmpl->getTemplatedDecl();
503 Method = dyn_cast<CXXMethodDecl>(FunctionToPush);
515 Sema::ContextRAII FnContext(Actions, FunctionToPush,
517 Sema::FunctionScopeRAII PopFnContext(Actions);
518 Actions.PushFunctionScope();
520 Sema::CXXThisScopeRAII ThisScope(
526 SourceRange SpecificationRange;
527 SmallVector<ParsedType, 4> DynamicExceptions;
528 SmallVector<SourceRange, 4> DynamicExceptionRanges;
533 = tryParseExceptionSpecification(
false, SpecificationRange,
535 DynamicExceptionRanges, NoexceptExpr,
536 ExceptionSpecTokens);
538 if (Tok.isNot(tok::eof) || Tok.getEofData() != LM.Method)
539 Diag(Tok.getLocation(), diag::err_except_spec_unparsed);
542 Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
545 DynamicExceptionRanges,
547 NoexceptExpr.
get() :
nullptr);
551 while (Tok.isNot(tok::eof))
555 if (Tok.is(tok::eof) && Tok.getEofData() == LM.Method)
559 LM.ExceptionSpecTokens =
nullptr;
562 InFunctionTemplateScope.Scopes.Exit();
565 Actions.ActOnFinishDelayedCXXMethodDeclaration(
getCurScope(), LM.Method);
568void Parser::ParseLexedMethodDefs(ParsingClass &
Class) {
571 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
572 D->ParseLexedMethodDefs();
575void Parser::ParseLexedMethodDef(LexedMethod &LM) {
581 assert(!LM.Toks.empty() &&
"Empty body!");
582 Token LastBodyToken = LM.Toks.back();
588 LM.Toks.push_back(BodyEnd);
591 LM.Toks.push_back(Tok);
592 PP.EnterTokenStream(LM.Toks,
true,
true);
596 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)
597 &&
"Inline method not starting with '{', ':' or 'try'");
603 Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
605 Actions.ActOnStartOfFunctionDef(
getCurScope(), LM.D);
607 llvm::scope_exit _([&]() {
608 while (Tok.isNot(tok::eof))
611 if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
614 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
617 Actions.ActOnFinishInlineFunctionDef(FD);
620 if (Tok.is(tok::kw_try)) {
621 ParseFunctionTryBlock(LM.D, FnScope);
624 if (Tok.is(tok::colon)) {
625 ParseConstructorInitializer(LM.D);
628 if (!Tok.is(tok::l_brace)) {
630 Actions.ActOnFinishFunctionBody(LM.D,
nullptr);
634 Actions.ActOnDefaultCtorInitializers(LM.D);
636 assert((Actions.getDiagnostics().hasErrorOccurred() ||
639 < TemplateParameterDepth) &&
640 "TemplateParameterDepth should be greater than the depth of "
641 "current template being instantiated!");
643 ParseFunctionStatementBody(LM.D, FnScope);
646void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
649 if (!
Class.LateParsedDeclarations.empty()) {
656 Sema::CXXThisScopeRAII ThisScope(Actions,
Class.TagOrTemplate,
659 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
660 D->ParseLexedMemberInitializers();
663 Actions.ActOnFinishDelayedMemberInitializers(
Class.TagOrTemplate);
666void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
667 if (!MI.Field || MI.Field->isInvalidDecl())
674 MI.Toks.push_back(Tok);
675 PP.EnterTokenStream(MI.Toks,
true,
true);
680 SourceLocation EqualLoc;
682 Actions.ActOnStartCXXInClassMemberInitializer();
686 EnterExpressionEvaluationContext Eval(
692 Actions.ActOnFinishCXXInClassMemberInitializer(MI.Field, EqualLoc,
Init);
695 if (Tok.isNot(tok::eof)) {
696 if (!
Init.isInvalid()) {
697 SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
699 EndLoc = Tok.getLocation();
701 Diag(EndLoc, diag::err_expected_semi_decl_list);
705 while (Tok.isNot(tok::eof))
709 if (Tok.getEofData() == MI.Field)
713void Parser::ParseLexedAttributes(ParsingClass &
Class) {
716 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
717 LateD->ParseLexedAttributes();
720void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
722 assert(LAs.parseSoon() &&
723 "Attribute list should be marked for immediate parsing.");
724 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
727 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
733void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
738 AttrEnd.startToken();
739 AttrEnd.setKind(tok::eof);
740 AttrEnd.setLocation(Tok.getLocation());
741 AttrEnd.setEofData(LA.Toks.data());
742 LA.Toks.push_back(AttrEnd);
746 LA.Toks.push_back(Tok);
747 PP.EnterTokenStream(LA.Toks,
true,
true);
751 ParsedAttributes Attrs(AttrFactory);
753 if (LA.Decls.size() > 0) {
754 Decl *D = LA.Decls[0];
755 NamedDecl *ND = dyn_cast<NamedDecl>(D);
756 RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->
getDeclContext());
759 Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
762 if (LA.Decls.size() == 1) {
771 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
774 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
775 nullptr, SourceLocation(), ParsedAttr::Form::GNU(),
779 Actions.ActOnExitFunctionContext();
783 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
784 nullptr, SourceLocation(), ParsedAttr::Form::GNU(),
788 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
791 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
792 Attrs.begin()->isKnownToGCC())
793 Diag(Tok, diag::warn_attribute_on_function_definition)
796 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
797 Actions.ActOnFinishDelayedAttribute(
getCurScope(), LA.Decls[i], Attrs);
801 while (Tok.isNot(tok::eof))
804 if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
808void Parser::ParseLexedPragmas(ParsingClass &
Class) {
811 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
812 D->ParseLexedPragmas();
815void Parser::ParseLexedPragma(LateParsedPragma &LP) {
816 PP.EnterToken(Tok,
true);
817 PP.EnterTokenStream(LP.toks(),
true,
822 assert(Tok.isAnnotation() &&
"Expected annotation token.");
823 switch (Tok.getKind()) {
824 case tok::annot_attr_openmp:
825 case tok::annot_pragma_openmp: {
827 ParsedAttributes Attrs(AttrFactory);
828 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
832 llvm_unreachable(
"Unexpected token.");
841 bool isFirstTokenConsumed =
true;
844 if (Tok.is(T1) || Tok.is(T2)) {
845 if (ConsumeFinalToken) {
852 switch (Tok.getKind()) {
854 case tok::annot_module_begin:
855 case tok::annot_module_end:
856 case tok::annot_module_include:
857 case tok::annot_repl_input_end:
865 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
871 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
877 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
886 if (ParenCount && !isFirstTokenConsumed)
892 if (BracketCount && !isFirstTokenConsumed)
898 if (BraceCount && !isFirstTokenConsumed)
914 isFirstTokenConsumed =
false;
918bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
919 if (Tok.is(tok::kw_try)) {
924 if (Tok.isNot(tok::colon)) {
930 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
933 if (Tok.isNot(tok::l_brace))
934 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
954 bool MightBeTemplateArgument =
false;
958 if (Tok.is(tok::kw_decltype)) {
961 if (Tok.isNot(tok::l_paren))
962 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
966 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
967 Diag(Tok.getLocation(), diag::err_expected) << tok::r_paren;
968 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
974 if (Tok.is(tok::coloncolon)) {
978 if (Tok.is(tok::kw_template)) {
984 if (Tok.is(tok::identifier)) {
991 if (Tok.is(tok::ellipsis) &&
NextToken().
is(tok::l_square)) {
996 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
997 Diag(Tok.getLocation(), diag::err_expected) << tok::r_square;
998 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1003 }
while (Tok.is(tok::coloncolon));
1005 if (Tok.is(tok::code_completion)) {
1006 Toks.push_back(Tok);
1007 ConsumeCodeCompletionToken();
1008 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1015 if (Tok.is(tok::comma)) {
1017 Toks.push_back(Tok);
1021 if (Tok.is(tok::less))
1022 MightBeTemplateArgument =
true;
1024 if (MightBeTemplateArgument) {
1031 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1036 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
1038 }
else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
1041 return Diag(Tok.getLocation(), diag::err_expected_either)
1042 << tok::l_paren << tok::l_brace;
1044 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_paren;
1048 Toks.push_back(Tok);
1049 bool IsLParen = (
kind == tok::l_paren);
1050 SourceLocation OpenLoc = Tok.getLocation();
1055 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1062 const Token &PreviousToken = Toks[Toks.size() - 2];
1063 if (!MightBeTemplateArgument &&
1064 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1065 tok::greatergreater)) {
1071 TentativeParsingAction PA(*
this);
1073 !Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1086 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1087 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1088 Diag(Tok, diag::err_expected) << CloseKind;
1089 Diag(OpenLoc, diag::note_matching) <<
kind;
1094 if (Tok.is(tok::ellipsis)) {
1095 Toks.push_back(Tok);
1101 if (Tok.is(tok::comma)) {
1102 Toks.push_back(Tok);
1104 }
else if (Tok.is(tok::l_brace)) {
1119 Toks.push_back(Tok);
1122 }
else if (!MightBeTemplateArgument) {
1123 return Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
1129bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1131 assert(Tok.is(tok::question));
1132 Toks.push_back(Tok);
1135 while (Tok.isNot(tok::colon)) {
1136 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1142 if (Tok.is(tok::question) && !ConsumeAndStoreConditional(Toks))
1147 Toks.push_back(Tok);
1152bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1155 bool IsFirstToken =
true;
1160 unsigned AngleCount = 0;
1161 unsigned KnownTemplateCount = 0;
1164 switch (Tok.getKind()) {
1168 if (ParenCount == 1 &&
NextToken().
is(tok::r_paren))
1176 if (KnownTemplateCount)
1189 TentativeParsingAction TPA(*
this,
true);
1190 Sema::TentativeAnalysisScope Scope(Actions);
1192 TPResult
Result = TPResult::Error;
1196 Result = TryParseInitDeclaratorList();
1199 if (
Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
1200 Result = TPResult::False;
1204 bool InvalidAsDeclaration =
false;
1205 Result = TryParseParameterDeclarationClause(
1206 &InvalidAsDeclaration,
true);
1209 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1210 Result = TPResult::False;
1220 if (
Result != TPResult::False &&
Result != TPResult::Error)
1225 ++KnownTemplateCount;
1241 if (!ConsumeAndStoreConditional(Toks))
1245 case tok::greatergreatergreater:
1248 if (AngleCount) --AngleCount;
1249 if (KnownTemplateCount) --KnownTemplateCount;
1251 case tok::greatergreater:
1254 if (AngleCount) --AngleCount;
1255 if (KnownTemplateCount) --KnownTemplateCount;
1258 if (AngleCount) --AngleCount;
1259 if (KnownTemplateCount) --KnownTemplateCount;
1262 case tok::kw_template:
1266 Toks.push_back(Tok);
1268 if (Tok.is(tok::identifier)) {
1269 Toks.push_back(Tok);
1271 if (Tok.is(tok::less)) {
1273 ++KnownTemplateCount;
1274 Toks.push_back(Tok);
1280 case tok::kw_operator:
1283 Toks.push_back(Tok);
1285 switch (Tok.getKind()) {
1287 case tok::greatergreatergreater:
1288 case tok::greatergreater:
1291 Toks.push_back(Tok);
1301 Toks.push_back(Tok);
1303 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1307 Toks.push_back(Tok);
1309 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1313 Toks.push_back(Tok);
1315 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1327 if (ParenCount && !IsFirstToken)
1329 Toks.push_back(Tok);
1333 if (BracketCount && !IsFirstToken)
1335 Toks.push_back(Tok);
1339 if (BraceCount && !IsFirstToken)
1341 Toks.push_back(Tok);
1345 case tok::code_completion:
1346 Toks.push_back(Tok);
1347 ConsumeCodeCompletionToken();
1350 case tok::string_literal:
1351 case tok::wide_string_literal:
1352 case tok::utf8_string_literal:
1353 case tok::utf16_string_literal:
1354 case tok::utf32_string_literal:
1355 Toks.push_back(Tok);
1356 ConsumeStringToken();
1366 if (Tok.isAnnotation())
1369 Toks.push_back(Tok);
1373 IsFirstToken =
false;
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
FriendSpecified isFriendSpecified() const
bool hasConstexprSpecifier() const
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 isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
FunctionDefinitionKind getFunctionDefinitionKind() const
RAII object that enters a new expression evaluation context.
const ParmVarDecl * getParamDecl(unsigned i) const
QualType getReturnType() const
void setWillHaveBody(bool V=true)
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,...
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
bool hasUninstantiatedDefaultArg() const
Expr * getUninstantiatedDefaultArg()
Introduces zero or more scopes for parsing.
ParseScope - Introduces a new scope for parsing.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
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...
const LangOptions & getLangOpts() const
friend class ParenBraceBracketBalancer
@ 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.
ExprResult ParseAssignmentExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Parse an expr that doesn't include (top-level) commas.
friend class BalancedDelimiterTracker
A class for parsing a declarator.
const ParsingDeclSpec & getDeclSpec() const
@ 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.
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
StringLiteral - This represents a string literal expression, e.g.
Token - This structure provides full information about a lexed token.
SourceLocation getEndLoc() const
void setKind(tok::TokenKind K)
bool isOneOf(Ts... Ks) const
void setEofData(const void *D)
void setLocation(SourceLocation L)
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.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ 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.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
@ Result
The result type of a method or function.
@ ExplicitSpecialization
We are parsing an explicit specialization.
@ NonTemplate
We are not parsing a template at all.
U cast(CodeGen::Address addr)
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ReenterClassScopeRAII(Parser &P, ParsingClass &Class)
ReenterTemplateScopeRAII(Parser &P, Decl *MaybeTemplated, bool Enter=true)
TemplateParameterDepthRAII CurTemplateDepthTracker