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,
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);
745 AttrEnd.startToken();
746 AttrEnd.setKind(tok::eof);
747 AttrEnd.setLocation(Tok.getLocation());
748 AttrEnd.setEofData(LA.
Toks.data());
749 LA.
Toks.push_back(AttrEnd);
753 LA.
Toks.push_back(Tok);
754 PP.EnterTokenStream(LA.
Toks,
true,
true);
758 ParsedAttributes Attrs(AttrFactory);
760 if (LA.
Decls.size() > 0) {
762 NamedDecl *ND = dyn_cast<NamedDecl>(D);
763 RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->
getDeclContext());
766 Sema::CXXThisScopeRAII ThisScope(Actions, RD, Qualifiers(),
769 if (LA.
Decls.size() == 1) {
778 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
782 nullptr, SourceLocation(), ParsedAttr::Form::GNU(),
786 Actions.ActOnExitFunctionContext();
791 nullptr, SourceLocation(), ParsedAttr::Form::GNU(),
798 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
799 Attrs.begin()->isKnownToGCC())
800 Diag(Tok, diag::warn_attribute_on_function_definition)
803 for (
unsigned i = 0, ni = LA.
Decls.size(); i < ni; ++i)
808 while (Tok.isNot(tok::eof))
811 if (Tok.is(tok::eof) && Tok.getEofData() == AttrEnd.getEofData())
815void Parser::ParseLexedPragmas(ParsingClass &
Class) {
818 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
822void Parser::ParseLexedPragma(LateParsedPragma &LP) {
823 PP.EnterToken(Tok,
true);
824 PP.EnterTokenStream(LP.toks(),
true,
829 assert(Tok.isAnnotation() &&
"Expected annotation token.");
830 switch (Tok.getKind()) {
831 case tok::annot_attr_openmp:
832 case tok::annot_pragma_openmp: {
834 ParsedAttributes Attrs(AttrFactory);
835 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
839 llvm_unreachable(
"Unexpected token.");
848 bool isFirstTokenConsumed =
true;
851 if (Tok.is(T1) || Tok.is(T2)) {
852 if (ConsumeFinalToken) {
859 switch (Tok.getKind()) {
861 case tok::annot_module_begin:
862 case tok::annot_module_end:
863 case tok::annot_module_include:
864 case tok::annot_repl_input_end:
872 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
878 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
884 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
893 if (ParenCount && !isFirstTokenConsumed)
899 if (BracketCount && !isFirstTokenConsumed)
905 if (BraceCount && !isFirstTokenConsumed)
921 isFirstTokenConsumed =
false;
925bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
926 if (Tok.is(tok::kw_try)) {
931 if (Tok.isNot(tok::colon)) {
937 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
940 if (Tok.isNot(tok::l_brace))
941 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
961 bool MightBeTemplateArgument =
false;
965 if (Tok.is(tok::kw_decltype)) {
968 if (Tok.isNot(tok::l_paren))
969 return Diag(Tok.getLocation(), diag::err_expected_lparen_after)
973 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
974 Diag(Tok.getLocation(), diag::err_expected) << tok::r_paren;
975 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
981 if (Tok.is(tok::coloncolon)) {
985 if (Tok.is(tok::kw_template)) {
991 if (Tok.is(tok::identifier)) {
998 if (Tok.is(tok::ellipsis) &&
NextToken().
is(tok::l_square)) {
1001 Toks.push_back(Tok);
1003 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1004 Diag(Tok.getLocation(), diag::err_expected) << tok::r_square;
1005 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1010 }
while (Tok.is(tok::coloncolon));
1012 if (Tok.is(tok::code_completion)) {
1013 Toks.push_back(Tok);
1014 ConsumeCodeCompletionToken();
1015 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1022 if (Tok.is(tok::comma)) {
1024 Toks.push_back(Tok);
1028 if (Tok.is(tok::less))
1029 MightBeTemplateArgument =
true;
1031 if (MightBeTemplateArgument) {
1038 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1043 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_brace;
1045 }
else if (Tok.isNot(tok::l_paren) && Tok.isNot(tok::l_brace)) {
1048 return Diag(Tok.getLocation(), diag::err_expected_either)
1049 << tok::l_paren << tok::l_brace;
1051 return Diag(Tok.getLocation(), diag::err_expected) << tok::l_paren;
1055 Toks.push_back(Tok);
1056 bool IsLParen = (
kind == tok::l_paren);
1057 SourceLocation OpenLoc = Tok.getLocation();
1062 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1069 const Token &PreviousToken = Toks[Toks.size() - 2];
1070 if (!MightBeTemplateArgument &&
1071 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1072 tok::greatergreater)) {
1078 TentativeParsingAction PA(*
this);
1080 !Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1093 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1094 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1095 Diag(Tok, diag::err_expected) << CloseKind;
1096 Diag(OpenLoc, diag::note_matching) <<
kind;
1101 if (Tok.is(tok::ellipsis)) {
1102 Toks.push_back(Tok);
1108 if (Tok.is(tok::comma)) {
1109 Toks.push_back(Tok);
1111 }
else if (Tok.is(tok::l_brace)) {
1126 Toks.push_back(Tok);
1129 }
else if (!MightBeTemplateArgument) {
1130 return Diag(Tok.getLocation(), diag::err_expected_either) << tok::l_brace
1136bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1138 assert(Tok.is(tok::question));
1139 Toks.push_back(Tok);
1142 while (Tok.isNot(tok::colon)) {
1143 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1149 if (Tok.is(tok::question) && !ConsumeAndStoreConditional(Toks))
1154 Toks.push_back(Tok);
1159bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1162 bool IsFirstToken =
true;
1167 unsigned AngleCount = 0;
1168 unsigned KnownTemplateCount = 0;
1171 switch (Tok.getKind()) {
1175 if (ParenCount == 1 &&
NextToken().
is(tok::r_paren))
1183 if (KnownTemplateCount)
1196 TentativeParsingAction TPA(*
this,
true);
1197 Sema::TentativeAnalysisScope Scope(Actions);
1199 TPResult
Result = TPResult::Error;
1203 Result = TryParseInitDeclaratorList();
1206 if (
Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
1207 Result = TPResult::False;
1211 bool InvalidAsDeclaration =
false;
1212 Result = TryParseParameterDeclarationClause(
1213 &InvalidAsDeclaration,
true);
1216 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1217 Result = TPResult::False;
1227 if (
Result != TPResult::False &&
Result != TPResult::Error)
1232 ++KnownTemplateCount;
1248 if (!ConsumeAndStoreConditional(Toks))
1252 case tok::greatergreatergreater:
1255 if (AngleCount) --AngleCount;
1256 if (KnownTemplateCount) --KnownTemplateCount;
1258 case tok::greatergreater:
1261 if (AngleCount) --AngleCount;
1262 if (KnownTemplateCount) --KnownTemplateCount;
1265 if (AngleCount) --AngleCount;
1266 if (KnownTemplateCount) --KnownTemplateCount;
1269 case tok::kw_template:
1273 Toks.push_back(Tok);
1275 if (Tok.is(tok::identifier)) {
1276 Toks.push_back(Tok);
1278 if (Tok.is(tok::less)) {
1280 ++KnownTemplateCount;
1281 Toks.push_back(Tok);
1287 case tok::kw_operator:
1290 Toks.push_back(Tok);
1292 switch (Tok.getKind()) {
1294 case tok::greatergreatergreater:
1295 case tok::greatergreater:
1298 Toks.push_back(Tok);
1308 Toks.push_back(Tok);
1310 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1314 Toks.push_back(Tok);
1316 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1320 Toks.push_back(Tok);
1322 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1334 if (ParenCount && !IsFirstToken)
1336 Toks.push_back(Tok);
1340 if (BracketCount && !IsFirstToken)
1342 Toks.push_back(Tok);
1346 if (BraceCount && !IsFirstToken)
1348 Toks.push_back(Tok);
1352 case tok::code_completion:
1353 Toks.push_back(Tok);
1354 ConsumeCodeCompletionToken();
1357 case tok::string_literal:
1358 case tok::wide_string_literal:
1359 case tok::utf8_string_literal:
1360 case tok::utf16_string_literal:
1361 case tok::utf32_string_literal:
1362 Toks.push_back(Tok);
1363 ConsumeStringToken();
1373 if (Tok.isAnnotation())
1376 Toks.push_back(Tok);
1380 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
void ParseLexedAttributes() override
An RAII helper that pops function a function scope on exit.