20#include "llvm/ADT/ScopeExit.h"
25 if (!Tok.is(tok::l_paren))
27 StringLiteral *
Message =
nullptr;
31 if (isTokenStringLiteral()) {
39 Diag(Tok.getLocation(), diag::err_expected_string_literal)
48void Parser::SkipDeletedFunctionBody() {
49 if (!Tok.is(tok::l_paren))
57 if (Tok.is(tok::r_paren))
61NamedDecl *Parser::ParseCXXInlineMethodDef(
66 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try, tok::equal) &&
67 "Current token not a '{', ':', '=', or 'try'!");
70 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
72 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
76 FnD = Actions.ActOnFriendFunctionDecl(
getCurScope(), D,
79 FnD = Actions.ActOnCXXMemberDeclarator(
getCurScope(), AS, D,
80 TemplateParams,
nullptr,
83 Actions.ProcessDeclAttributeList(
getCurScope(), FnD, AccessAttrs);
85 Actions.ActOnPureSpecifier(FnD, PureSpecLoc);
90 HandleMemberFunctionDeclDelays(D, FnD);
101 SourceLocation KWLoc;
103 DiagCompat(KWLoc, diag_compat::defaulted_deleted_function)
105 StringLiteral *
Message = ParseCXXDeletedFunctionMessage();
106 Actions.SetDeclDeleted(FnD, KWLoc, Message);
108 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
109 DeclAsFunction->setRangeEnd(PrevTokLocation);
112 DiagCompat(KWLoc, diag_compat::defaulted_deleted_function)
114 Actions.SetDeclDefaulted(FnD, KWLoc);
115 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
116 DeclAsFunction->setRangeEnd(PrevTokLocation);
119 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
122 if (Tok.is(tok::comma)) {
123 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
126 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
127 Delete ?
"delete" :
"default") &&
128 !isLikelyAtStartOfNewDeclaration()) {
135 if (SkipFunctionBodies && (!FnD || Actions.canSkipFunctionBody(FnD)) &&
136 trySkippingFunctionBody()) {
137 Actions.ActOnSkippedFunctionBody(FnD);
149 ((Actions.CurContext->isDependentContext() ||
152 !Actions.IsInsideALocalClassWithinATemplateFunction())) {
155 LexTemplateFunctionForLateParsing(Toks);
159 Actions.CheckForFunctionRedefinition(FD);
160 Actions.MarkAsLateParsedTemplate(FD, FnD, Toks);
168 LexedMethod* LM =
new LexedMethod(
this, FnD);
169 getCurrentClass().LateParsedDeclarations.push_back(LM);
175 if (ConsumeAndStoreFunctionPrologue(Toks)) {
181 if (PP.isCodeCompletionEnabled() &&
182 llvm::any_of(Toks, [](
const Token &Tok) {
183 return Tok.is(tok::code_completion);
196 delete getCurrentClass().LateParsedDeclarations.back();
197 getCurrentClass().LateParsedDeclarations.pop_back();
201 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
205 if (
kind == tok::kw_try) {
206 while (Tok.is(tok::kw_catch)) {
207 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
208 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
216 Actions.CheckForFunctionRedefinition(FD);
221 delete getCurrentClass().LateParsedDeclarations.back();
222 getCurrentClass().LateParsedDeclarations.pop_back();
228void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
229 assert(Tok.isOneOf(tok::l_brace, tok::equal) &&
230 "Current token not a '{' or '='!");
232 LateParsedMemberInitializer *MI =
233 new LateParsedMemberInitializer(
this, VarD);
234 getCurrentClass().LateParsedDeclarations.push_back(MI);
238 if (
kind == tok::equal) {
243 if (
kind == tok::l_brace) {
249 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
272Parser::LateParsedClass::LateParsedClass(
Parser *P, ParsingClass *
C)
275Parser::LateParsedClass::~LateParsedClass() {
276 Self->DeallocateParsedClasses(Class);
280 Self->ParseLexedMethodDeclarations(*
Class);
284 Self->ParseLexedMemberInitializers(*
Class);
300 Self->ParseLexedMethodDeclaration(*
this);
304 Self->ParseLexedMethodDef(*
this);
308 Self->ParseLexedMemberInitializer(*
this);
312 Self->ParseLexedAttribute(*
this,
true,
false);
318 Self->ParseLexedPragma(*
this);
330 P.ReenterTemplateScopes(
Scopes, MaybeTemplated));
340 !
Class.TopLevelClass),
343 if (
Class.TopLevelClass)
348 P.Actions.ActOnStartDelayedMemberDeclarations(
P.getCurScope(),
349 Class.TagOrTemplate);
352 if (
Class.TopLevelClass)
355 P.Actions.ActOnFinishDelayedMemberDeclarations(
P.getCurScope(),
356 Class.TagOrTemplate);
360void Parser::ParseLexedMethodDeclarations(ParsingClass &
Class) {
361 ReenterClassScopeRAII InClassScope(*
this,
Class);
367void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
369 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
393 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
396 bool HasUnparsed = Param->hasUnparsedDefaultArg();
398 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
404 Token LastDefaultArgToken = Toks->back();
410 Toks->push_back(DefArgEnd);
413 Toks->push_back(
Tok);
414 PP.EnterTokenStream(*Toks,
true,
true);
420 assert(
Tok.is(tok::equal) &&
"Default argument not starting with '='");
431 Diag(
Tok, diag::compat_cxx11_generalized_initializer_lists);
432 DefArgResult = ParseBraceInitializer();
436 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc,
439 if (Tok.isNot(tok::eof) || Tok.getEofData() != Param) {
443 assert(Toks->size() >= 3 &&
"expected a token in default arg");
444 Diag(Tok.getLocation(), diag::err_default_arg_unparsed)
445 << SourceRange(Tok.getLocation(),
446 (*Toks)[Toks->size() - 3].getLocation());
448 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
454 while (Tok.isNot(tok::eof))
457 if (Tok.is(tok::eof) && Tok.getEofData() == Param)
459 }
else if (HasUnparsed) {
460 assert(Param->hasInheritedDefaultArg());
462 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
471 Param->setUninstantiatedDefaultArg(
474 Param->setDefaultArg(OldParam->
getInit());
484 Token LastExceptionSpecToken = Toks->back();
485 Token ExceptionSpecEnd;
487 ExceptionSpecEnd.
setKind(tok::eof);
490 Toks->push_back(ExceptionSpecEnd);
493 Toks->push_back(Tok);
494 PP.EnterTokenStream(*Toks,
true,
true);
506 FunctionDecl *FunctionToPush;
507 if (FunctionTemplateDecl *FunTmpl
508 = dyn_cast<FunctionTemplateDecl>(LM.Method))
509 FunctionToPush = FunTmpl->getTemplatedDecl();
512 Method = dyn_cast<CXXMethodDecl>(FunctionToPush);
517 Sema::ContextRAII FnContext(Actions, FunctionToPush,
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)
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 assert((Actions.getDiagnostics().hasErrorOccurred() ||
623 < TemplateParameterDepth) &&
624 "TemplateParameterDepth should be greater than the depth of "
625 "current template being instantiated!");
627 ParseFunctionBody(LM.D, FnScope);
630void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
633 if (!
Class.LateParsedDeclarations.empty()) {
640 Sema::CXXThisScopeRAII ThisScope(Actions,
Class.TagOrTemplate,
643 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
647 Actions.ActOnFinishDelayedMemberInitializers(
Class.TagOrTemplate);
650void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
651 if (!MI.Field || MI.Field->isInvalidDecl())
658 MI.Toks.push_back(Tok);
659 PP.EnterTokenStream(MI.Toks,
true,
true);
664 SourceLocation EqualLoc;
666 Actions.ActOnStartCXXInClassMemberInitializer();
670 EnterExpressionEvaluationContext Eval(
676 Actions.ActOnFinishCXXInClassMemberInitializer(MI.Field, EqualLoc,
Init);
679 if (Tok.isNot(tok::eof)) {
680 if (!
Init.isInvalid()) {
681 SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
683 EndLoc = Tok.getLocation();
685 Diag(EndLoc, diag::err_expected_semi_decl_list);
689 while (Tok.isNot(tok::eof))
693 if (Tok.getEofData() == MI.Field)
697void Parser::ParseLexedAttributes(ParsingClass &
Class) {
700 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
704void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
706 ParsedAttributes *OutAttrs) {
708 "Attribute list should be marked for immediate parsing.");
709 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
712 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition, OutAttrs);
720 ParsedAttributes *OutAttrs) {
724 AttrEnd.startToken();
725 AttrEnd.setKind(tok::eof);
726 AttrEnd.setLocation(Tok.getLocation());
727 AttrEnd.setEofData(LPA.
Toks.data());
728 LPA.
Toks.push_back(AttrEnd);
732 LPA.
Toks.push_back(Tok);
733 PP.EnterTokenStream(LPA.
Toks,
true,
true);
737 ParsedAttributes Attrs(AttrFactory);
739 if (LPA.
Decls.size() > 0) {
745 NamedDecl *ND = dyn_cast<NamedDecl>(D);
746 RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->
getDeclContext());
749 Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
760 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
765 SourceLocation(), ParsedAttr::Form::GNU(),
769 Actions.ActOnExitFunctionContext();
770 }
else if (OutAttrs) {
773 SourceLocation(), ParsedAttr::Form::GNU(),
779 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
780 Attrs.begin()->isKnownToGCC())
781 Diag(Tok, diag::warn_attribute_on_function_definition) << &LPA.
AttrName;
783 for (
auto *D : LPA.
Decls)
784 Actions.ActOnFinishDelayedAttribute(
getCurScope(), D, Attrs);
788 while (Tok.isNot(tok::eof))
791 if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
798void Parser::ParseLexedPragmas(ParsingClass &
Class) {
801 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
805void Parser::ParseLexedPragma(LateParsedPragma &LP) {
806 PP.EnterToken(Tok,
true);
807 PP.EnterTokenStream(LP.toks(),
true,
812 assert(Tok.isAnnotation() &&
"Expected annotation token.");
813 switch (Tok.getKind()) {
814 case tok::annot_attr_openmp:
815 case tok::annot_pragma_openmp: {
817 ParsedAttributes Attrs(AttrFactory);
818 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
822 llvm_unreachable(
"Unexpected token.");
831 bool isFirstTokenConsumed =
true;
834 if (Tok.is(T1) || Tok.is(T2)) {
835 if (ConsumeFinalToken) {
842 switch (Tok.getKind()) {
844 case tok::annot_module_begin:
845 case tok::annot_module_end:
846 case tok::annot_module_include:
847 case tok::annot_repl_input_end:
851 case tok::annot_pragma_openacc:
852 case tok::annot_pragma_openmp:
853 case tok::annot_attr_openmp: {
857 ? tok::annot_pragma_openacc_end
858 : tok::annot_pragma_openmp_end;
860 ConsumeAnnotationToken();
861 while (Tok.isNot(EndKind) && Tok.isNot(tok::eof)) {
865 if (Tok.is(EndKind)) {
867 ConsumeAnnotationToken();
876 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
882 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
888 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
897 if (ParenCount && !isFirstTokenConsumed)
903 if (BracketCount && !isFirstTokenConsumed)
909 if (BraceCount && !isFirstTokenConsumed)
925 isFirstTokenConsumed =
false;
929bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
930 if (Tok.is(tok::kw_try)) {
935 if (Tok.isNot(tok::colon)) {
941 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
944 if (Tok.isNot(tok::l_brace))
945 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
965 bool MightBeTemplateArgument =
false;
969 if (Tok.is(tok::kw_decltype)) {
972 if (Tok.isNot(tok::l_paren))
973 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
977 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
978 Diag(Tok.getLocation(), diag::err_expected) << tok::r_paren;
979 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
985 if (Tok.is(tok::coloncolon)) {
989 if (Tok.is(tok::kw_template)) {
995 if (Tok.is(tok::identifier)) {
1002 if (Tok.is(tok::ellipsis) &&
NextToken().
is(tok::l_square)) {
1003 Toks.push_back(Tok);
1005 Toks.push_back(Tok);
1007 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1008 Diag(Tok.getLocation(), diag::err_expected) << tok::r_square;
1009 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1014 }
while (Tok.is(tok::coloncolon));
1016 if (Tok.is(tok::code_completion)) {
1017 Toks.push_back(Tok);
1018 ConsumeCodeCompletionToken();
1019 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1026 if (Tok.is(tok::comma)) {
1028 Toks.push_back(Tok);
1032 if (Tok.is(tok::less))
1033 MightBeTemplateArgument =
true;
1035 if (MightBeTemplateArgument) {
1042 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1047 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
1049 }
else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
1052 return Diag(Tok.getLocation(), diag::err_expected_either)
1053 << tok::l_paren << tok::l_brace;
1055 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_paren;
1059 Toks.push_back(Tok);
1060 bool IsLParen = (
kind == tok::l_paren);
1061 SourceLocation OpenLoc = Tok.getLocation();
1066 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1073 const Token &PreviousToken = Toks[Toks.size() - 2];
1074 if (!MightBeTemplateArgument &&
1075 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1076 tok::greatergreater)) {
1082 TentativeParsingAction PA(*
this);
1084 !Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1097 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1098 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1099 Diag(Tok, diag::err_expected) << CloseKind;
1100 Diag(OpenLoc, diag::note_matching) <<
kind;
1105 if (Tok.is(tok::ellipsis)) {
1106 Toks.push_back(Tok);
1112 if (Tok.is(tok::comma)) {
1113 Toks.push_back(Tok);
1115 }
else if (Tok.is(tok::l_brace)) {
1130 Toks.push_back(Tok);
1133 }
else if (!MightBeTemplateArgument) {
1134 return Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
1140bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1142 assert(Tok.is(tok::question));
1143 Toks.push_back(Tok);
1146 while (Tok.isNot(tok::colon)) {
1147 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1153 if (Tok.is(tok::question) && !ConsumeAndStoreConditional(Toks))
1158 Toks.push_back(Tok);
1163bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1166 bool IsFirstToken =
true;
1171 unsigned AngleCount = 0;
1172 unsigned KnownTemplateCount = 0;
1175 switch (Tok.getKind()) {
1179 if (ParenCount == 1 &&
NextToken().
is(tok::r_paren))
1187 if (KnownTemplateCount)
1200 TentativeParsingAction TPA(*
this,
true);
1201 Sema::TentativeAnalysisScope Scope(Actions);
1203 TPResult
Result = TPResult::Error;
1207 Result = TryParseInitDeclaratorList();
1210 if (
Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
1211 Result = TPResult::False;
1215 bool InvalidAsDeclaration =
false;
1216 Result = TryParseParameterDeclarationClause(
1217 &InvalidAsDeclaration,
true);
1220 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1221 Result = TPResult::False;
1231 if (
Result != TPResult::False &&
Result != TPResult::Error)
1236 ++KnownTemplateCount;
1252 if (!ConsumeAndStoreConditional(Toks))
1256 case tok::greatergreatergreater:
1259 if (AngleCount) --AngleCount;
1260 if (KnownTemplateCount) --KnownTemplateCount;
1262 case tok::greatergreater:
1265 if (AngleCount) --AngleCount;
1266 if (KnownTemplateCount) --KnownTemplateCount;
1269 if (AngleCount) --AngleCount;
1270 if (KnownTemplateCount) --KnownTemplateCount;
1273 case tok::kw_template:
1277 Toks.push_back(Tok);
1279 if (Tok.is(tok::identifier)) {
1280 Toks.push_back(Tok);
1282 if (Tok.is(tok::less)) {
1284 ++KnownTemplateCount;
1285 Toks.push_back(Tok);
1291 case tok::kw_operator:
1294 Toks.push_back(Tok);
1296 switch (Tok.getKind()) {
1298 case tok::greatergreatergreater:
1299 case tok::greatergreater:
1302 Toks.push_back(Tok);
1312 Toks.push_back(Tok);
1314 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1318 Toks.push_back(Tok);
1320 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1324 Toks.push_back(Tok);
1326 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1338 if (ParenCount && !IsFirstToken)
1340 Toks.push_back(Tok);
1344 if (BracketCount && !IsFirstToken)
1346 Toks.push_back(Tok);
1350 if (BraceCount && !IsFirstToken)
1352 Toks.push_back(Tok);
1356 case tok::code_completion:
1357 Toks.push_back(Tok);
1358 ConsumeCodeCompletionToken();
1361 case tok::string_literal:
1362 case tok::wide_string_literal:
1363 case tok::utf8_string_literal:
1364 case tok::utf16_string_literal:
1365 case tok::utf32_string_literal:
1366 Toks.push_back(Tok);
1367 ConsumeStringToken();
1377 if (Tok.isAnnotation())
1380 Toks.push_back(Tok);
1384 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()
void takeAllAppendingFrom(ParsedAttributes &Other)
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)
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
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.
Top level wrappers for InstallAPI frontend operations.
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
void ParseLexedAttributes() override
An RAII helper that pops function a function scope on exit.