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;
106 ? diag::warn_cxx98_compat_defaulted_deleted_function
107 : diag::ext_defaulted_deleted_function)
109 StringLiteral *
Message = ParseCXXDeletedFunctionMessage();
110 Actions.SetDeclDeleted(FnD, KWLoc, Message);
112 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
113 DeclAsFunction->setRangeEnd(PrevTokLocation);
117 ? diag::warn_cxx98_compat_defaulted_deleted_function
118 : diag::ext_defaulted_deleted_function)
120 Actions.SetDeclDefaulted(FnD, KWLoc);
121 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
122 DeclAsFunction->setRangeEnd(PrevTokLocation);
125 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
128 if (Tok.is(tok::comma)) {
129 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
132 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
133 Delete ?
"delete" :
"default") &&
134 !isLikelyAtStartOfNewDeclaration()) {
141 if (SkipFunctionBodies && (!FnD || Actions.canSkipFunctionBody(FnD)) &&
142 trySkippingFunctionBody()) {
143 Actions.ActOnSkippedFunctionBody(FnD);
155 ((Actions.CurContext->isDependentContext() ||
158 !Actions.IsInsideALocalClassWithinATemplateFunction())) {
161 LexTemplateFunctionForLateParsing(Toks);
165 Actions.CheckForFunctionRedefinition(FD);
166 Actions.MarkAsLateParsedTemplate(FD, FnD, Toks);
174 LexedMethod* LM =
new LexedMethod(
this, FnD);
175 getCurrentClass().LateParsedDeclarations.push_back(LM);
181 if (ConsumeAndStoreFunctionPrologue(Toks)) {
187 if (PP.isCodeCompletionEnabled() &&
188 llvm::any_of(Toks, [](
const Token &Tok) {
189 return Tok.is(tok::code_completion);
202 delete getCurrentClass().LateParsedDeclarations.back();
203 getCurrentClass().LateParsedDeclarations.pop_back();
207 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
211 if (
kind == tok::kw_try) {
212 while (Tok.is(tok::kw_catch)) {
213 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
214 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
222 Actions.CheckForFunctionRedefinition(FD);
227 delete getCurrentClass().LateParsedDeclarations.back();
228 getCurrentClass().LateParsedDeclarations.pop_back();
234void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
235 assert(Tok.isOneOf(tok::l_brace, tok::equal) &&
236 "Current token not a '{' or '='!");
238 LateParsedMemberInitializer *MI =
239 new LateParsedMemberInitializer(
this, VarD);
240 getCurrentClass().LateParsedDeclarations.push_back(MI);
244 if (
kind == tok::equal) {
249 if (
kind == tok::l_brace) {
255 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
278Parser::LateParsedClass::LateParsedClass(
Parser *P, ParsingClass *
C)
281Parser::LateParsedClass::~LateParsedClass() {
282 Self->DeallocateParsedClasses(Class);
286 Self->ParseLexedMethodDeclarations(*
Class);
290 Self->ParseLexedMemberInitializers(*
Class);
306 Self->ParseLexedMethodDeclaration(*
this);
310 Self->ParseLexedMethodDef(*
this);
314 Self->ParseLexedMemberInitializer(*
this);
318 Self->ParseLexedAttribute(*
this,
true,
false);
324 Self->ParseLexedPragma(*
this);
336 P.ReenterTemplateScopes(
Scopes, MaybeTemplated));
346 !
Class.TopLevelClass),
349 if (
Class.TopLevelClass)
354 P.Actions.ActOnStartDelayedMemberDeclarations(
P.getCurScope(),
355 Class.TagOrTemplate);
358 if (
Class.TopLevelClass)
361 P.Actions.ActOnFinishDelayedMemberDeclarations(
P.getCurScope(),
362 Class.TagOrTemplate);
366void Parser::ParseLexedMethodDeclarations(ParsingClass &
Class) {
367 ReenterClassScopeRAII InClassScope(*
this,
Class);
373void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
375 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
399 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
402 bool HasUnparsed = Param->hasUnparsedDefaultArg();
404 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
410 Token LastDefaultArgToken = Toks->back();
416 Toks->push_back(DefArgEnd);
419 Toks->push_back(
Tok);
420 PP.EnterTokenStream(*Toks,
true,
true);
426 assert(
Tok.is(tok::equal) &&
"Default argument not starting with '='");
437 Diag(
Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
438 DefArgResult = ParseBraceInitializer();
442 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc,
445 if (Tok.isNot(tok::eof) || Tok.getEofData() != Param) {
449 assert(Toks->size() >= 3 &&
"expected a token in default arg");
450 Diag(Tok.getLocation(), diag::err_default_arg_unparsed)
451 << SourceRange(Tok.getLocation(),
452 (*Toks)[Toks->size() - 3].getLocation());
454 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
460 while (Tok.isNot(tok::eof))
463 if (Tok.is(tok::eof) && Tok.getEofData() == Param)
465 }
else if (HasUnparsed) {
466 assert(Param->hasInheritedDefaultArg());
468 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
477 Param->setUninstantiatedDefaultArg(
480 Param->setDefaultArg(OldParam->
getInit());
490 Token LastExceptionSpecToken = Toks->back();
491 Token ExceptionSpecEnd;
493 ExceptionSpecEnd.
setKind(tok::eof);
496 Toks->push_back(ExceptionSpecEnd);
499 Toks->push_back(Tok);
500 PP.EnterTokenStream(*Toks,
true,
true);
512 FunctionDecl *FunctionToPush;
513 if (FunctionTemplateDecl *FunTmpl
514 = dyn_cast<FunctionTemplateDecl>(LM.Method))
515 FunctionToPush = FunTmpl->getTemplatedDecl();
518 Method = dyn_cast<CXXMethodDecl>(FunctionToPush);
523 Sema::ContextRAII FnContext(Actions, FunctionToPush,
526 Sema::CXXThisScopeRAII ThisScope(
532 SourceRange SpecificationRange;
533 SmallVector<ParsedType, 4> DynamicExceptions;
534 SmallVector<SourceRange, 4> DynamicExceptionRanges;
539 = tryParseExceptionSpecification(
false, SpecificationRange,
541 DynamicExceptionRanges, NoexceptExpr,
542 ExceptionSpecTokens);
544 if (Tok.isNot(tok::eof) || Tok.getEofData() != LM.Method)
545 Diag(Tok.getLocation(), diag::err_except_spec_unparsed);
548 Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
551 DynamicExceptionRanges,
553 NoexceptExpr.
get() :
nullptr);
557 while (Tok.isNot(tok::eof))
561 if (Tok.is(tok::eof) && Tok.getEofData() == LM.Method)
565 LM.ExceptionSpecTokens =
nullptr;
568 InFunctionTemplateScope.Scopes.Exit();
571 Actions.ActOnFinishDelayedCXXMethodDeclaration(
getCurScope(), LM.Method);
574void Parser::ParseLexedMethodDefs(ParsingClass &
Class) {
577 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
581void Parser::ParseLexedMethodDef(LexedMethod &LM) {
587 assert(!LM.Toks.empty() &&
"Empty body!");
588 Token LastBodyToken = LM.Toks.back();
594 LM.Toks.push_back(BodyEnd);
597 LM.Toks.push_back(Tok);
598 PP.EnterTokenStream(LM.Toks,
true,
true);
602 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)
603 &&
"Inline method not starting with '{', ':' or 'try'");
609 Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
611 Actions.ActOnStartOfFunctionDef(
getCurScope(), LM.D);
613 llvm::scope_exit _([&]() {
614 while (Tok.isNot(tok::eof))
617 if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
620 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
623 Actions.ActOnFinishInlineFunctionDef(FD);
626 if (Tok.is(tok::kw_try)) {
627 ParseFunctionTryBlock(LM.D, FnScope);
630 if (Tok.is(tok::colon)) {
631 ParseConstructorInitializer(LM.D);
634 if (!Tok.is(tok::l_brace)) {
636 Actions.ActOnFinishFunctionBody(LM.D,
nullptr);
640 Actions.ActOnDefaultCtorInitializers(LM.D);
642 assert((Actions.getDiagnostics().hasErrorOccurred() ||
645 < TemplateParameterDepth) &&
646 "TemplateParameterDepth should be greater than the depth of "
647 "current template being instantiated!");
649 ParseFunctionStatementBody(LM.D, FnScope);
652void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
655 if (!
Class.LateParsedDeclarations.empty()) {
662 Sema::CXXThisScopeRAII ThisScope(Actions,
Class.TagOrTemplate,
665 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
669 Actions.ActOnFinishDelayedMemberInitializers(
Class.TagOrTemplate);
672void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
673 if (!MI.Field || MI.Field->isInvalidDecl())
680 MI.Toks.push_back(Tok);
681 PP.EnterTokenStream(MI.Toks,
true,
true);
686 SourceLocation EqualLoc;
688 Actions.ActOnStartCXXInClassMemberInitializer();
692 EnterExpressionEvaluationContext Eval(
698 Actions.ActOnFinishCXXInClassMemberInitializer(MI.Field, EqualLoc,
Init);
701 if (Tok.isNot(tok::eof)) {
702 if (!
Init.isInvalid()) {
703 SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
705 EndLoc = Tok.getLocation();
707 Diag(EndLoc, diag::err_expected_semi_decl_list);
711 while (Tok.isNot(tok::eof))
715 if (Tok.getEofData() == MI.Field)
719void Parser::ParseLexedAttributes(ParsingClass &
Class) {
722 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
726void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
728 ParsedAttributes *OutAttrs) {
730 "Attribute list should be marked for immediate parsing.");
731 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
734 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition, OutAttrs);
742 ParsedAttributes *OutAttrs) {
746 AttrEnd.startToken();
747 AttrEnd.setKind(tok::eof);
748 AttrEnd.setLocation(Tok.getLocation());
749 AttrEnd.setEofData(LPA.
Toks.data());
750 LPA.
Toks.push_back(AttrEnd);
754 LPA.
Toks.push_back(Tok);
755 PP.EnterTokenStream(LPA.
Toks,
true,
true);
759 ParsedAttributes Attrs(AttrFactory);
761 if (LPA.
Decls.size() > 0) {
767 NamedDecl *ND = dyn_cast<NamedDecl>(D);
768 RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->
getDeclContext());
771 Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
782 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
787 SourceLocation(), ParsedAttr::Form::GNU(),
791 Actions.ActOnExitFunctionContext();
792 }
else if (OutAttrs) {
795 SourceLocation(), ParsedAttr::Form::GNU(),
801 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
802 Attrs.begin()->isKnownToGCC())
803 Diag(Tok, diag::warn_attribute_on_function_definition) << &LPA.
AttrName;
805 for (
auto *D : LPA.
Decls)
806 Actions.ActOnFinishDelayedAttribute(
getCurScope(), D, Attrs);
810 while (Tok.isNot(tok::eof))
813 if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
820void Parser::ParseLexedPragmas(ParsingClass &
Class) {
823 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
827void Parser::ParseLexedPragma(LateParsedPragma &LP) {
828 PP.EnterToken(Tok,
true);
829 PP.EnterTokenStream(LP.toks(),
true,
834 assert(Tok.isAnnotation() &&
"Expected annotation token.");
835 switch (Tok.getKind()) {
836 case tok::annot_attr_openmp:
837 case tok::annot_pragma_openmp: {
839 ParsedAttributes Attrs(AttrFactory);
840 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
844 llvm_unreachable(
"Unexpected token.");
853 bool isFirstTokenConsumed =
true;
856 if (Tok.is(T1) || Tok.is(T2)) {
857 if (ConsumeFinalToken) {
864 switch (Tok.getKind()) {
866 case tok::annot_module_begin:
867 case tok::annot_module_end:
868 case tok::annot_module_include:
869 case tok::annot_repl_input_end:
877 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
883 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
889 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
898 if (ParenCount && !isFirstTokenConsumed)
904 if (BracketCount && !isFirstTokenConsumed)
910 if (BraceCount && !isFirstTokenConsumed)
926 isFirstTokenConsumed =
false;
930bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
931 if (Tok.is(tok::kw_try)) {
936 if (Tok.isNot(tok::colon)) {
942 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
945 if (Tok.isNot(tok::l_brace))
946 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
966 bool MightBeTemplateArgument =
false;
970 if (Tok.is(tok::kw_decltype)) {
973 if (Tok.isNot(tok::l_paren))
974 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
978 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
979 Diag(Tok.getLocation(), diag::err_expected) << tok::r_paren;
980 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
986 if (Tok.is(tok::coloncolon)) {
990 if (Tok.is(tok::kw_template)) {
996 if (Tok.is(tok::identifier)) {
1003 if (Tok.is(tok::ellipsis) &&
NextToken().
is(tok::l_square)) {
1004 Toks.push_back(Tok);
1006 Toks.push_back(Tok);
1008 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1009 Diag(Tok.getLocation(), diag::err_expected) << tok::r_square;
1010 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1015 }
while (Tok.is(tok::coloncolon));
1017 if (Tok.is(tok::code_completion)) {
1018 Toks.push_back(Tok);
1019 ConsumeCodeCompletionToken();
1020 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1027 if (Tok.is(tok::comma)) {
1029 Toks.push_back(Tok);
1033 if (Tok.is(tok::less))
1034 MightBeTemplateArgument =
true;
1036 if (MightBeTemplateArgument) {
1043 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1048 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
1050 }
else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
1053 return Diag(Tok.getLocation(), diag::err_expected_either)
1054 << tok::l_paren << tok::l_brace;
1056 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_paren;
1060 Toks.push_back(Tok);
1061 bool IsLParen = (
kind == tok::l_paren);
1062 SourceLocation OpenLoc = Tok.getLocation();
1067 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1074 const Token &PreviousToken = Toks[Toks.size() - 2];
1075 if (!MightBeTemplateArgument &&
1076 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1077 tok::greatergreater)) {
1083 TentativeParsingAction PA(*
this);
1085 !Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1098 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1099 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1100 Diag(Tok, diag::err_expected) << CloseKind;
1101 Diag(OpenLoc, diag::note_matching) <<
kind;
1106 if (Tok.is(tok::ellipsis)) {
1107 Toks.push_back(Tok);
1113 if (Tok.is(tok::comma)) {
1114 Toks.push_back(Tok);
1116 }
else if (Tok.is(tok::l_brace)) {
1131 Toks.push_back(Tok);
1134 }
else if (!MightBeTemplateArgument) {
1135 return Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
1141bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1143 assert(Tok.is(tok::question));
1144 Toks.push_back(Tok);
1147 while (Tok.isNot(tok::colon)) {
1148 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1154 if (Tok.is(tok::question) && !ConsumeAndStoreConditional(Toks))
1159 Toks.push_back(Tok);
1164bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1167 bool IsFirstToken =
true;
1172 unsigned AngleCount = 0;
1173 unsigned KnownTemplateCount = 0;
1176 switch (Tok.getKind()) {
1180 if (ParenCount == 1 &&
NextToken().
is(tok::r_paren))
1188 if (KnownTemplateCount)
1201 TentativeParsingAction TPA(*
this,
true);
1202 Sema::TentativeAnalysisScope Scope(Actions);
1204 TPResult
Result = TPResult::Error;
1208 Result = TryParseInitDeclaratorList();
1211 if (
Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
1212 Result = TPResult::False;
1216 bool InvalidAsDeclaration =
false;
1217 Result = TryParseParameterDeclarationClause(
1218 &InvalidAsDeclaration,
true);
1221 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1222 Result = TPResult::False;
1232 if (
Result != TPResult::False &&
Result != TPResult::Error)
1237 ++KnownTemplateCount;
1253 if (!ConsumeAndStoreConditional(Toks))
1257 case tok::greatergreatergreater:
1260 if (AngleCount) --AngleCount;
1261 if (KnownTemplateCount) --KnownTemplateCount;
1263 case tok::greatergreater:
1266 if (AngleCount) --AngleCount;
1267 if (KnownTemplateCount) --KnownTemplateCount;
1270 if (AngleCount) --AngleCount;
1271 if (KnownTemplateCount) --KnownTemplateCount;
1274 case tok::kw_template:
1278 Toks.push_back(Tok);
1280 if (Tok.is(tok::identifier)) {
1281 Toks.push_back(Tok);
1283 if (Tok.is(tok::less)) {
1285 ++KnownTemplateCount;
1286 Toks.push_back(Tok);
1292 case tok::kw_operator:
1295 Toks.push_back(Tok);
1297 switch (Tok.getKind()) {
1299 case tok::greatergreatergreater:
1300 case tok::greatergreater:
1303 Toks.push_back(Tok);
1313 Toks.push_back(Tok);
1315 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1319 Toks.push_back(Tok);
1321 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1325 Toks.push_back(Tok);
1327 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1339 if (ParenCount && !IsFirstToken)
1341 Toks.push_back(Tok);
1345 if (BracketCount && !IsFirstToken)
1347 Toks.push_back(Tok);
1351 if (BraceCount && !IsFirstToken)
1353 Toks.push_back(Tok);
1357 case tok::code_completion:
1358 Toks.push_back(Tok);
1359 ConsumeCodeCompletionToken();
1362 case tok::string_literal:
1363 case tok::wide_string_literal:
1364 case tok::utf8_string_literal:
1365 case tok::utf16_string_literal:
1366 case tok::utf32_string_literal:
1367 Toks.push_back(Tok);
1368 ConsumeStringToken();
1378 if (Tok.isAnnotation())
1381 Toks.push_back(Tok);
1385 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)
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
void ParseLexedAttributes() override
An RAII helper that pops function a function scope on exit.