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);
279Parser::LateParsedClass::LateParsedClass(
Parser *P, ParsingClass *
C)
282Parser::LateParsedClass::~LateParsedClass() {
283 Self->DeallocateParsedClasses(Class);
287 Self->ParseLexedMethodDeclarations(*
Class);
291 Self->ParseLexedMemberInitializers(*
Class);
307 Self->ParseLexedMethodDeclaration(*
this);
311 Self->ParseLexedMethodDef(*
this);
315 Self->ParseLexedMemberInitializer(*
this);
319 Self->ParseLexedAttribute(*
this,
true,
false);
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);
372void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
374 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
398 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
401 bool HasUnparsed = Param->hasUnparsedDefaultArg();
403 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
409 Token LastDefaultArgToken = Toks->back();
415 Toks->push_back(DefArgEnd);
418 Toks->push_back(
Tok);
419 PP.EnterTokenStream(*Toks,
true,
true);
425 assert(
Tok.is(tok::equal) &&
"Default argument not starting with '='");
436 Diag(
Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
437 DefArgResult = ParseBraceInitializer();
441 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc,
444 if (Tok.isNot(tok::eof) || Tok.getEofData() != Param) {
448 assert(Toks->size() >= 3 &&
"expected a token in default arg");
449 Diag(Tok.getLocation(), diag::err_default_arg_unparsed)
450 << SourceRange(Tok.getLocation(),
451 (*Toks)[Toks->size() - 3].getLocation());
453 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
459 while (Tok.isNot(tok::eof))
462 if (Tok.is(tok::eof) && Tok.getEofData() == Param)
464 }
else if (HasUnparsed) {
465 assert(Param->hasInheritedDefaultArg());
467 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
476 Param->setUninstantiatedDefaultArg(
479 Param->setDefaultArg(OldParam->
getInit());
489 Token LastExceptionSpecToken = Toks->back();
490 Token ExceptionSpecEnd;
492 ExceptionSpecEnd.
setKind(tok::eof);
495 Toks->push_back(ExceptionSpecEnd);
498 Toks->push_back(Tok);
499 PP.EnterTokenStream(*Toks,
true,
true);
511 FunctionDecl *FunctionToPush;
512 if (FunctionTemplateDecl *FunTmpl
513 = dyn_cast<FunctionTemplateDecl>(LM.Method))
514 FunctionToPush = FunTmpl->getTemplatedDecl();
517 Method = dyn_cast<CXXMethodDecl>(FunctionToPush);
522 Sema::ContextRAII FnContext(Actions, FunctionToPush,
525 Sema::CXXThisScopeRAII ThisScope(
531 SourceRange SpecificationRange;
532 SmallVector<ParsedType, 4> DynamicExceptions;
533 SmallVector<SourceRange, 4> DynamicExceptionRanges;
538 = tryParseExceptionSpecification(
false, SpecificationRange,
540 DynamicExceptionRanges, NoexceptExpr,
541 ExceptionSpecTokens);
543 if (Tok.isNot(tok::eof) || Tok.getEofData() != LM.Method)
544 Diag(Tok.getLocation(), diag::err_except_spec_unparsed);
547 Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
550 DynamicExceptionRanges,
552 NoexceptExpr.
get() :
nullptr);
556 while (Tok.isNot(tok::eof))
560 if (Tok.is(tok::eof) && Tok.getEofData() == LM.Method)
564 LM.ExceptionSpecTokens =
nullptr;
567 InFunctionTemplateScope.Scopes.Exit();
570 Actions.ActOnFinishDelayedCXXMethodDeclaration(
getCurScope(), LM.Method);
573void Parser::ParseLexedMethodDefs(ParsingClass &
Class) {
576 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
580void Parser::ParseLexedMethodDef(LexedMethod &LM) {
586 assert(!LM.Toks.empty() &&
"Empty body!");
587 Token LastBodyToken = LM.Toks.back();
593 LM.Toks.push_back(BodyEnd);
596 LM.Toks.push_back(Tok);
597 PP.EnterTokenStream(LM.Toks,
true,
true);
601 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)
602 &&
"Inline method not starting with '{', ':' or 'try'");
608 Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
610 Actions.ActOnStartOfFunctionDef(
getCurScope(), LM.D);
612 llvm::scope_exit _([&]() {
613 while (Tok.isNot(tok::eof))
616 if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
619 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
622 Actions.ActOnFinishInlineFunctionDef(FD);
625 if (Tok.is(tok::kw_try)) {
626 ParseFunctionTryBlock(LM.D, FnScope);
629 if (Tok.is(tok::colon)) {
630 ParseConstructorInitializer(LM.D);
633 if (!Tok.is(tok::l_brace)) {
635 Actions.ActOnFinishFunctionBody(LM.D,
nullptr);
639 Actions.ActOnDefaultCtorInitializers(LM.D);
641 assert((Actions.getDiagnostics().hasErrorOccurred() ||
644 < TemplateParameterDepth) &&
645 "TemplateParameterDepth should be greater than the depth of "
646 "current template being instantiated!");
648 ParseFunctionStatementBody(LM.D, FnScope);
651void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
654 if (!
Class.LateParsedDeclarations.empty()) {
661 Sema::CXXThisScopeRAII ThisScope(Actions,
Class.TagOrTemplate,
664 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
668 Actions.ActOnFinishDelayedMemberInitializers(
Class.TagOrTemplate);
671void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
672 if (!MI.Field || MI.Field->isInvalidDecl())
679 MI.Toks.push_back(Tok);
680 PP.EnterTokenStream(MI.Toks,
true,
true);
685 SourceLocation EqualLoc;
687 Actions.ActOnStartCXXInClassMemberInitializer();
691 EnterExpressionEvaluationContext Eval(
697 Actions.ActOnFinishCXXInClassMemberInitializer(MI.Field, EqualLoc,
Init);
700 if (Tok.isNot(tok::eof)) {
701 if (!
Init.isInvalid()) {
702 SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
704 EndLoc = Tok.getLocation();
706 Diag(EndLoc, diag::err_expected_semi_decl_list);
710 while (Tok.isNot(tok::eof))
714 if (Tok.getEofData() == MI.Field)
718void Parser::ParseLexedAttributes(ParsingClass &
Class) {
721 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
725void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
728 "Attribute list should be marked for immediate parsing.");
729 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
732 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
743 AttrEnd.startToken();
744 AttrEnd.setKind(tok::eof);
745 AttrEnd.setLocation(Tok.getLocation());
746 AttrEnd.setEofData(LA.
Toks.data());
747 LA.
Toks.push_back(AttrEnd);
751 LA.
Toks.push_back(Tok);
752 PP.EnterTokenStream(LA.
Toks,
true,
true);
756 ParsedAttributes Attrs(AttrFactory);
758 if (LA.
Decls.size() > 0) {
760 NamedDecl *ND = dyn_cast<NamedDecl>(D);
761 RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->
getDeclContext());
764 Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
767 if (LA.
Decls.size() == 1) {
776 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
780 nullptr, SourceLocation(), ParsedAttr::Form::GNU(),
784 Actions.ActOnExitFunctionContext();
789 nullptr, SourceLocation(), ParsedAttr::Form::GNU(),
796 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
797 Attrs.begin()->isKnownToGCC())
798 Diag(Tok, diag::warn_attribute_on_function_definition)
801 for (
unsigned i = 0, ni = LA.
Decls.size(); i < ni; ++i)
806 while (Tok.isNot(tok::eof))
809 if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
813void Parser::ParseLexedPragmas(ParsingClass &
Class) {
816 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
820void Parser::ParseLexedPragma(LateParsedPragma &LP) {
821 PP.EnterToken(Tok,
true);
822 PP.EnterTokenStream(LP.toks(),
true,
827 assert(Tok.isAnnotation() &&
"Expected annotation token.");
828 switch (Tok.getKind()) {
829 case tok::annot_attr_openmp:
830 case tok::annot_pragma_openmp: {
832 ParsedAttributes Attrs(AttrFactory);
833 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
837 llvm_unreachable(
"Unexpected token.");
846 bool isFirstTokenConsumed =
true;
849 if (Tok.is(T1) || Tok.is(T2)) {
850 if (ConsumeFinalToken) {
857 switch (Tok.getKind()) {
859 case tok::annot_module_begin:
860 case tok::annot_module_end:
861 case tok::annot_module_include:
862 case tok::annot_repl_input_end:
870 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
876 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
882 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
891 if (ParenCount && !isFirstTokenConsumed)
897 if (BracketCount && !isFirstTokenConsumed)
903 if (BraceCount && !isFirstTokenConsumed)
919 isFirstTokenConsumed =
false;
923bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
924 if (Tok.is(tok::kw_try)) {
929 if (Tok.isNot(tok::colon)) {
935 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
938 if (Tok.isNot(tok::l_brace))
939 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
959 bool MightBeTemplateArgument =
false;
963 if (Tok.is(tok::kw_decltype)) {
966 if (Tok.isNot(tok::l_paren))
967 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
971 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
972 Diag(Tok.getLocation(), diag::err_expected) << tok::r_paren;
973 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
979 if (Tok.is(tok::coloncolon)) {
983 if (Tok.is(tok::kw_template)) {
989 if (Tok.is(tok::identifier)) {
996 if (Tok.is(tok::ellipsis) &&
NextToken().
is(tok::l_square)) {
1001 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1002 Diag(Tok.getLocation(), diag::err_expected) << tok::r_square;
1003 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1008 }
while (Tok.is(tok::coloncolon));
1010 if (Tok.is(tok::code_completion)) {
1011 Toks.push_back(Tok);
1012 ConsumeCodeCompletionToken();
1013 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1020 if (Tok.is(tok::comma)) {
1022 Toks.push_back(Tok);
1026 if (Tok.is(tok::less))
1027 MightBeTemplateArgument =
true;
1029 if (MightBeTemplateArgument) {
1036 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1041 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
1043 }
else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
1046 return Diag(Tok.getLocation(), diag::err_expected_either)
1047 << tok::l_paren << tok::l_brace;
1049 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_paren;
1053 Toks.push_back(Tok);
1054 bool IsLParen = (
kind == tok::l_paren);
1055 SourceLocation OpenLoc = Tok.getLocation();
1060 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1067 const Token &PreviousToken = Toks[Toks.size() - 2];
1068 if (!MightBeTemplateArgument &&
1069 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1070 tok::greatergreater)) {
1076 TentativeParsingAction PA(*
this);
1078 !Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1091 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1092 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1093 Diag(Tok, diag::err_expected) << CloseKind;
1094 Diag(OpenLoc, diag::note_matching) <<
kind;
1099 if (Tok.is(tok::ellipsis)) {
1100 Toks.push_back(Tok);
1106 if (Tok.is(tok::comma)) {
1107 Toks.push_back(Tok);
1109 }
else if (Tok.is(tok::l_brace)) {
1124 Toks.push_back(Tok);
1127 }
else if (!MightBeTemplateArgument) {
1128 return Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
1134bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1136 assert(Tok.is(tok::question));
1137 Toks.push_back(Tok);
1140 while (Tok.isNot(tok::colon)) {
1141 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1147 if (Tok.is(tok::question) && !ConsumeAndStoreConditional(Toks))
1152 Toks.push_back(Tok);
1157bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1160 bool IsFirstToken =
true;
1165 unsigned AngleCount = 0;
1166 unsigned KnownTemplateCount = 0;
1169 switch (Tok.getKind()) {
1173 if (ParenCount == 1 &&
NextToken().
is(tok::r_paren))
1181 if (KnownTemplateCount)
1194 TentativeParsingAction TPA(*
this,
true);
1195 Sema::TentativeAnalysisScope Scope(Actions);
1197 TPResult
Result = TPResult::Error;
1201 Result = TryParseInitDeclaratorList();
1204 if (
Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
1205 Result = TPResult::False;
1209 bool InvalidAsDeclaration =
false;
1210 Result = TryParseParameterDeclarationClause(
1211 &InvalidAsDeclaration,
true);
1214 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1215 Result = TPResult::False;
1225 if (
Result != TPResult::False &&
Result != TPResult::Error)
1230 ++KnownTemplateCount;
1246 if (!ConsumeAndStoreConditional(Toks))
1250 case tok::greatergreatergreater:
1253 if (AngleCount) --AngleCount;
1254 if (KnownTemplateCount) --KnownTemplateCount;
1256 case tok::greatergreater:
1259 if (AngleCount) --AngleCount;
1260 if (KnownTemplateCount) --KnownTemplateCount;
1263 if (AngleCount) --AngleCount;
1264 if (KnownTemplateCount) --KnownTemplateCount;
1267 case tok::kw_template:
1271 Toks.push_back(Tok);
1273 if (Tok.is(tok::identifier)) {
1274 Toks.push_back(Tok);
1276 if (Tok.is(tok::less)) {
1278 ++KnownTemplateCount;
1279 Toks.push_back(Tok);
1285 case tok::kw_operator:
1288 Toks.push_back(Tok);
1290 switch (Tok.getKind()) {
1292 case tok::greatergreatergreater:
1293 case tok::greatergreater:
1296 Toks.push_back(Tok);
1306 Toks.push_back(Tok);
1308 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1312 Toks.push_back(Tok);
1314 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1318 Toks.push_back(Tok);
1320 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1332 if (ParenCount && !IsFirstToken)
1334 Toks.push_back(Tok);
1338 if (BracketCount && !IsFirstToken)
1340 Toks.push_back(Tok);
1344 if (BraceCount && !IsFirstToken)
1346 Toks.push_back(Tok);
1350 case tok::code_completion:
1351 Toks.push_back(Tok);
1352 ConsumeCodeCompletionToken();
1355 case tok::string_literal:
1356 case tok::wide_string_literal:
1357 case tok::utf8_string_literal:
1358 case tok::utf16_string_literal:
1359 case tok::utf32_string_literal:
1360 Toks.push_back(Tok);
1361 ConsumeStringToken();
1371 if (Tok.isAnnotation())
1374 Toks.push_back(Tok);
1378 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)
StringRef getName() const
Return the actual identifier string.
[class.mem]p1: "... the class is regarded as complete within
virtual ~LateParsedDeclaration()
virtual void ParseLexedMethodDefs()
virtual void ParseLexedAttributes()
virtual void ParseLexedPragmas()
virtual void ParseLexedMethodDeclarations()
virtual void ParseLexedMemberInitializers()
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.
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.
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
friend struct LateParsedAttribute
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.
void PushFunctionScope()
Enter a new function scope.
@ 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
IdentifierInfo & AttrName
void ParseLexedAttributes() override
SourceLocation AttrNameLoc
SmallVector< Decl *, 2 > Decls
An RAII helper that pops function a function scope on exit.