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);
325 Self->ParseLexedPragma(*
this);
337 P.ReenterTemplateScopes(
Scopes, MaybeTemplated));
347 !
Class.TopLevelClass),
350 if (
Class.TopLevelClass)
355 P.Actions.ActOnStartDelayedMemberDeclarations(
P.getCurScope(),
356 Class.TagOrTemplate);
359 if (
Class.TopLevelClass)
362 P.Actions.ActOnFinishDelayedMemberDeclarations(
P.getCurScope(),
363 Class.TagOrTemplate);
367void Parser::ParseLexedMethodDeclarations(ParsingClass &
Class) {
368 ReenterClassScopeRAII InClassScope(*
this,
Class);
374void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
376 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
400 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
403 bool HasUnparsed = Param->hasUnparsedDefaultArg();
405 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
411 Token LastDefaultArgToken = Toks->back();
417 Toks->push_back(DefArgEnd);
420 Toks->push_back(
Tok);
421 PP.EnterTokenStream(*Toks,
true,
true);
427 assert(
Tok.is(tok::equal) &&
"Default argument not starting with '='");
438 Diag(
Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
439 DefArgResult = ParseBraceInitializer();
443 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc,
446 if (Tok.isNot(tok::eof) || Tok.getEofData() != Param) {
450 assert(Toks->size() >= 3 &&
"expected a token in default arg");
451 Diag(Tok.getLocation(), diag::err_default_arg_unparsed)
452 << SourceRange(Tok.getLocation(),
453 (*Toks)[Toks->size() - 3].getLocation());
455 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
461 while (Tok.isNot(tok::eof))
464 if (Tok.is(tok::eof) && Tok.getEofData() == Param)
466 }
else if (HasUnparsed) {
467 assert(Param->hasInheritedDefaultArg());
469 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
478 Param->setUninstantiatedDefaultArg(
481 Param->setDefaultArg(OldParam->
getInit());
491 Token LastExceptionSpecToken = Toks->back();
492 Token ExceptionSpecEnd;
494 ExceptionSpecEnd.
setKind(tok::eof);
497 Toks->push_back(ExceptionSpecEnd);
500 Toks->push_back(Tok);
501 PP.EnterTokenStream(*Toks,
true,
true);
513 FunctionDecl *FunctionToPush;
514 if (FunctionTemplateDecl *FunTmpl
515 = dyn_cast<FunctionTemplateDecl>(LM.Method))
516 FunctionToPush = FunTmpl->getTemplatedDecl();
519 Method = dyn_cast<CXXMethodDecl>(FunctionToPush);
524 Sema::ContextRAII FnContext(Actions, FunctionToPush,
527 Sema::CXXThisScopeRAII ThisScope(
533 SourceRange SpecificationRange;
534 SmallVector<ParsedType, 4> DynamicExceptions;
535 SmallVector<SourceRange, 4> DynamicExceptionRanges;
540 = tryParseExceptionSpecification(
false, SpecificationRange,
542 DynamicExceptionRanges, NoexceptExpr,
543 ExceptionSpecTokens);
545 if (Tok.isNot(tok::eof) || Tok.getEofData() != LM.Method)
546 Diag(Tok.getLocation(), diag::err_except_spec_unparsed);
549 Actions.actOnDelayedExceptionSpecification(LM.Method, EST,
552 DynamicExceptionRanges,
554 NoexceptExpr.
get() :
nullptr);
558 while (Tok.isNot(tok::eof))
562 if (Tok.is(tok::eof) && Tok.getEofData() == LM.Method)
566 LM.ExceptionSpecTokens =
nullptr;
569 InFunctionTemplateScope.Scopes.Exit();
572 Actions.ActOnFinishDelayedCXXMethodDeclaration(
getCurScope(), LM.Method);
575void Parser::ParseLexedMethodDefs(ParsingClass &
Class) {
578 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
582void Parser::ParseLexedMethodDef(LexedMethod &LM) {
588 assert(!LM.Toks.empty() &&
"Empty body!");
589 Token LastBodyToken = LM.Toks.back();
595 LM.Toks.push_back(BodyEnd);
598 LM.Toks.push_back(Tok);
599 PP.EnterTokenStream(LM.Toks,
true,
true);
603 assert(Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)
604 &&
"Inline method not starting with '{', ':' or 'try'");
610 Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
612 Actions.ActOnStartOfFunctionDef(
getCurScope(), LM.D);
614 llvm::scope_exit _([&]() {
615 while (Tok.isNot(tok::eof))
618 if (Tok.is(tok::eof) && Tok.getEofData() == LM.D)
621 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
624 Actions.ActOnFinishInlineFunctionDef(FD);
627 if (Tok.is(tok::kw_try)) {
628 ParseFunctionTryBlock(LM.D, FnScope);
631 if (Tok.is(tok::colon)) {
632 ParseConstructorInitializer(LM.D);
635 if (!Tok.is(tok::l_brace)) {
637 Actions.ActOnFinishFunctionBody(LM.D,
nullptr);
641 Actions.ActOnDefaultCtorInitializers(LM.D);
643 assert((Actions.getDiagnostics().hasErrorOccurred() ||
646 < TemplateParameterDepth) &&
647 "TemplateParameterDepth should be greater than the depth of "
648 "current template being instantiated!");
650 ParseFunctionStatementBody(LM.D, FnScope);
653void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
656 if (!
Class.LateParsedDeclarations.empty()) {
663 Sema::CXXThisScopeRAII ThisScope(Actions,
Class.TagOrTemplate,
666 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
670 Actions.ActOnFinishDelayedMemberInitializers(
Class.TagOrTemplate);
673void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
674 if (!MI.Field || MI.Field->isInvalidDecl())
681 MI.Toks.push_back(Tok);
682 PP.EnterTokenStream(MI.Toks,
true,
true);
687 SourceLocation EqualLoc;
689 Actions.ActOnStartCXXInClassMemberInitializer();
693 EnterExpressionEvaluationContext Eval(
699 Actions.ActOnFinishCXXInClassMemberInitializer(MI.Field, EqualLoc,
Init);
702 if (Tok.isNot(tok::eof)) {
703 if (!
Init.isInvalid()) {
704 SourceLocation EndLoc = PP.getLocForEndOfToken(PrevTokLocation);
706 EndLoc = Tok.getLocation();
708 Diag(EndLoc, diag::err_expected_semi_decl_list);
712 while (Tok.isNot(tok::eof))
716 if (Tok.getEofData() == MI.Field)
720void Parser::ParseLexedAttributes(ParsingClass &
Class) {
723 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
727void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs, Decl *D,
729 ParsedAttributes *OutAttrs) {
731 "Attribute list should be marked for immediate parsing.");
732 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
735 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition, OutAttrs);
743 ParsedAttributes *OutAttrs) {
747 AttrEnd.startToken();
748 AttrEnd.setKind(tok::eof);
749 AttrEnd.setLocation(Tok.getLocation());
750 AttrEnd.setEofData(LPA.
Toks.data());
751 LPA.
Toks.push_back(AttrEnd);
755 LPA.
Toks.push_back(Tok);
756 PP.EnterTokenStream(LPA.
Toks,
true,
true);
760 ParsedAttributes Attrs(AttrFactory);
762 if (LPA.
Decls.size() > 0) {
768 NamedDecl *ND = dyn_cast<NamedDecl>(D);
769 RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->
getDeclContext());
772 Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
783 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
788 SourceLocation(), ParsedAttr::Form::GNU(),
792 Actions.ActOnExitFunctionContext();
793 }
else if (OutAttrs) {
796 SourceLocation(), ParsedAttr::Form::GNU(),
802 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
803 Attrs.begin()->isKnownToGCC())
804 Diag(Tok, diag::warn_attribute_on_function_definition) << &LPA.
AttrName;
806 for (
auto *D : LPA.
Decls)
807 Actions.ActOnFinishDelayedAttribute(
getCurScope(), D, Attrs);
811 while (Tok.isNot(tok::eof))
814 if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
821void Parser::ParseLexedPragmas(ParsingClass &
Class) {
824 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
828void Parser::ParseLexedPragma(LateParsedPragma &LP) {
829 PP.EnterToken(Tok,
true);
830 PP.EnterTokenStream(LP.toks(),
true,
835 assert(Tok.isAnnotation() &&
"Expected annotation token.");
836 switch (Tok.getKind()) {
837 case tok::annot_attr_openmp:
838 case tok::annot_pragma_openmp: {
840 ParsedAttributes Attrs(AttrFactory);
841 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
845 llvm_unreachable(
"Unexpected token.");
854 bool isFirstTokenConsumed =
true;
857 if (Tok.is(T1) || Tok.is(T2)) {
858 if (ConsumeFinalToken) {
865 switch (Tok.getKind()) {
867 case tok::annot_module_begin:
868 case tok::annot_module_end:
869 case tok::annot_module_include:
870 case tok::annot_repl_input_end:
878 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
884 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
890 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
899 if (ParenCount && !isFirstTokenConsumed)
905 if (BracketCount && !isFirstTokenConsumed)
911 if (BraceCount && !isFirstTokenConsumed)
927 isFirstTokenConsumed =
false;
931bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
932 if (Tok.is(tok::kw_try)) {
937 if (Tok.isNot(tok::colon)) {
943 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
946 if (Tok.isNot(tok::l_brace))
947 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
967 bool MightBeTemplateArgument =
false;
971 if (Tok.is(tok::kw_decltype)) {
974 if (Tok.isNot(tok::l_paren))
975 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
979 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
980 Diag(Tok.getLocation(), diag::err_expected) << tok::r_paren;
981 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
987 if (Tok.is(tok::coloncolon)) {
991 if (Tok.is(tok::kw_template)) {
997 if (Tok.is(tok::identifier)) {
1004 if (Tok.is(tok::ellipsis) &&
NextToken().
is(tok::l_square)) {
1005 Toks.push_back(Tok);
1007 Toks.push_back(Tok);
1009 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1010 Diag(Tok.getLocation(), diag::err_expected) << tok::r_square;
1011 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1016 }
while (Tok.is(tok::coloncolon));
1018 if (Tok.is(tok::code_completion)) {
1019 Toks.push_back(Tok);
1020 ConsumeCodeCompletionToken();
1021 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1028 if (Tok.is(tok::comma)) {
1030 Toks.push_back(Tok);
1034 if (Tok.is(tok::less))
1035 MightBeTemplateArgument =
true;
1037 if (MightBeTemplateArgument) {
1044 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1049 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
1051 }
else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
1054 return Diag(Tok.getLocation(), diag::err_expected_either)
1055 << tok::l_paren << tok::l_brace;
1057 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_paren;
1061 Toks.push_back(Tok);
1062 bool IsLParen = (
kind == tok::l_paren);
1063 SourceLocation OpenLoc = Tok.getLocation();
1068 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1075 const Token &PreviousToken = Toks[Toks.size() - 2];
1076 if (!MightBeTemplateArgument &&
1077 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1078 tok::greatergreater)) {
1084 TentativeParsingAction PA(*
this);
1086 !Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1099 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1100 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1101 Diag(Tok, diag::err_expected) << CloseKind;
1102 Diag(OpenLoc, diag::note_matching) <<
kind;
1107 if (Tok.is(tok::ellipsis)) {
1108 Toks.push_back(Tok);
1114 if (Tok.is(tok::comma)) {
1115 Toks.push_back(Tok);
1117 }
else if (Tok.is(tok::l_brace)) {
1132 Toks.push_back(Tok);
1135 }
else if (!MightBeTemplateArgument) {
1136 return Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
1142bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1144 assert(Tok.is(tok::question));
1145 Toks.push_back(Tok);
1148 while (Tok.isNot(tok::colon)) {
1149 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1155 if (Tok.is(tok::question) && !ConsumeAndStoreConditional(Toks))
1160 Toks.push_back(Tok);
1165bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1168 bool IsFirstToken =
true;
1173 unsigned AngleCount = 0;
1174 unsigned KnownTemplateCount = 0;
1177 switch (Tok.getKind()) {
1181 if (ParenCount == 1 &&
NextToken().
is(tok::r_paren))
1189 if (KnownTemplateCount)
1202 TentativeParsingAction TPA(*
this,
true);
1203 Sema::TentativeAnalysisScope Scope(Actions);
1205 TPResult
Result = TPResult::Error;
1209 Result = TryParseInitDeclaratorList();
1212 if (
Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
1213 Result = TPResult::False;
1217 bool InvalidAsDeclaration =
false;
1218 Result = TryParseParameterDeclarationClause(
1219 &InvalidAsDeclaration,
true);
1222 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1223 Result = TPResult::False;
1233 if (
Result != TPResult::False &&
Result != TPResult::Error)
1238 ++KnownTemplateCount;
1254 if (!ConsumeAndStoreConditional(Toks))
1258 case tok::greatergreatergreater:
1261 if (AngleCount) --AngleCount;
1262 if (KnownTemplateCount) --KnownTemplateCount;
1264 case tok::greatergreater:
1267 if (AngleCount) --AngleCount;
1268 if (KnownTemplateCount) --KnownTemplateCount;
1271 if (AngleCount) --AngleCount;
1272 if (KnownTemplateCount) --KnownTemplateCount;
1275 case tok::kw_template:
1279 Toks.push_back(Tok);
1281 if (Tok.is(tok::identifier)) {
1282 Toks.push_back(Tok);
1284 if (Tok.is(tok::less)) {
1286 ++KnownTemplateCount;
1287 Toks.push_back(Tok);
1293 case tok::kw_operator:
1296 Toks.push_back(Tok);
1298 switch (Tok.getKind()) {
1300 case tok::greatergreatergreater:
1301 case tok::greatergreater:
1304 Toks.push_back(Tok);
1314 Toks.push_back(Tok);
1316 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1320 Toks.push_back(Tok);
1322 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1326 Toks.push_back(Tok);
1328 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1340 if (ParenCount && !IsFirstToken)
1342 Toks.push_back(Tok);
1346 if (BracketCount && !IsFirstToken)
1348 Toks.push_back(Tok);
1352 if (BraceCount && !IsFirstToken)
1354 Toks.push_back(Tok);
1358 case tok::code_completion:
1359 Toks.push_back(Tok);
1360 ConsumeCodeCompletionToken();
1363 case tok::string_literal:
1364 case tok::wide_string_literal:
1365 case tok::utf8_string_literal:
1366 case tok::utf16_string_literal:
1367 case tok::utf32_string_literal:
1368 Toks.push_back(Tok);
1369 ConsumeStringToken();
1379 if (Tok.isAnnotation())
1382 Toks.push_back(Tok);
1386 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.