24NamedDecl *Parser::ParseCXXInlineMethodDef(
29 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try, tok::equal) &&
30 "Current token not a '{', ':', '=', or 'try'!");
33 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
35 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
43 TemplateParams,
nullptr,
53 HandleMemberFunctionDeclDelays(D, FnD);
68 ? diag::warn_cxx98_compat_defaulted_deleted_function
69 : diag::ext_defaulted_deleted_function)
73 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
74 DeclAsFunction->setRangeEnd(KWEndLoc);
78 ? diag::warn_cxx98_compat_defaulted_deleted_function
79 : diag::ext_defaulted_deleted_function)
82 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
83 DeclAsFunction->setRangeEnd(KWEndLoc);
86 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
89 if (Tok.
is(tok::comma)) {
90 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
93 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
94 Delete ?
"delete" :
"default")) {
102 trySkippingFunctionBody()) {
116 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
117 TemplateInfo.Kind != ParsedTemplateInfo::ExplicitSpecialization)) &&
121 LexTemplateFunctionForLateParsing(Toks);
134 LexedMethod* LM =
new LexedMethod(
this, FnD);
135 getCurrentClass().LateParsedDeclarations.push_back(LM);
141 if (ConsumeAndStoreFunctionPrologue(Toks)) {
148 llvm::any_of(Toks, [](
const Token &Tok) {
149 return Tok.is(tok::code_completion);
162 delete getCurrentClass().LateParsedDeclarations.back();
163 getCurrentClass().LateParsedDeclarations.pop_back();
167 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
171 if (kind == tok::kw_try) {
172 while (Tok.
is(tok::kw_catch)) {
173 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
174 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
187 delete getCurrentClass().LateParsedDeclarations.back();
188 getCurrentClass().LateParsedDeclarations.pop_back();
198void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
199 assert(Tok.
isOneOf(tok::l_brace, tok::equal) &&
200 "Current token not a '{' or '='!");
202 LateParsedMemberInitializer *MI =
203 new LateParsedMemberInitializer(
this, VarD);
204 getCurrentClass().LateParsedDeclarations.push_back(MI);
208 if (kind == tok::equal) {
213 if (kind == tok::l_brace) {
219 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
222 ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer);
235Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
236void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
237void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() {}
238void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
239void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
240void Parser::LateParsedDeclaration::ParseLexedPragmas() {}
242Parser::LateParsedClass::LateParsedClass(
Parser *
P, ParsingClass *
C)
245Parser::LateParsedClass::~LateParsedClass() {
246 Self->DeallocateParsedClasses(Class);
249void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
250 Self->ParseLexedMethodDeclarations(*Class);
253void Parser::LateParsedClass::ParseLexedMemberInitializers() {
254 Self->ParseLexedMemberInitializers(*Class);
257void Parser::LateParsedClass::ParseLexedMethodDefs() {
258 Self->ParseLexedMethodDefs(*Class);
261void Parser::LateParsedClass::ParseLexedAttributes() {
262 Self->ParseLexedAttributes(*Class);
265void Parser::LateParsedClass::ParseLexedPragmas() {
266 Self->ParseLexedPragmas(*Class);
269void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
270 Self->ParseLexedMethodDeclaration(*
this);
273void Parser::LexedMethod::ParseLexedMethodDefs() {
274 Self->ParseLexedMethodDef(*
this);
277void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() {
278 Self->ParseLexedMemberInitializer(*
this);
281void Parser::LateParsedAttribute::ParseLexedAttributes() {
282 Self->ParseLexedAttribute(*
this,
true,
false);
285void Parser::LateParsedPragma::ParseLexedPragmas() {
286 Self->ParseLexedPragma(*
this);
311 !
Class.TopLevelClass),
314 if (
Class.TopLevelClass)
320 Class.TagOrTemplate);
323 if (
Class.TopLevelClass)
327 Class.TagOrTemplate);
335void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
336 ReenterClassScopeRAII InClassScope(*
this, Class);
338 for (LateParsedDeclaration *LateD : Class.LateParsedDeclarations)
339 LateD->ParseLexedMethodDeclarations();
342void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
344 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
354 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
355 auto Param = cast<ParmVarDecl>(LM.DefaultArgs[I].Param);
357 bool HasUnparsed = Param->hasUnparsedDefaultArg();
359 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
365 Token LastDefaultArgToken = Toks->back();
371 Toks->push_back(DefArgEnd);
374 Toks->push_back(Tok);
375 PP.EnterTokenStream(*Toks,
true,
true);
381 assert(Tok.
is(tok::equal) &&
"Default argument not starting with '='");
392 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
393 DefArgResult = ParseBraceInitializer();
404 assert(Toks->size() >= 3 &&
"expected a token in default arg");
407 (*Toks)[Toks->size() - 3].getLocation());
415 while (Tok.
isNot(tok::eof))
420 }
else if (HasUnparsed) {
421 assert(Param->hasInheritedDefaultArg());
423 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
432 Param->setUninstantiatedDefaultArg(
435 Param->setDefaultArg(OldParam->
getInit());
445 Token LastExceptionSpecToken = Toks->back();
446 Token ExceptionSpecEnd;
448 ExceptionSpecEnd.
setKind(tok::eof);
451 Toks->push_back(ExceptionSpecEnd);
454 Toks->push_back(Tok);
455 PP.EnterTokenStream(*Toks,
true,
true);
468 = dyn_cast<FunctionTemplateDecl>(LM.Method))
469 Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
471 Method = dyn_cast<CXXMethodDecl>(LM.Method);
474 Actions, Method ? Method->
getParent() :
nullptr,
486 = tryParseExceptionSpecification(
false, SpecificationRange,
488 DynamicExceptionRanges, NoexceptExpr,
489 ExceptionSpecTokens);
498 DynamicExceptionRanges,
500 NoexceptExpr.
get() :
nullptr);
504 while (Tok.
isNot(tok::eof))
512 LM.ExceptionSpecTokens =
nullptr;
515 InFunctionTemplateScope.Scopes.Exit();
524void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
525 ReenterClassScopeRAII InClassScope(*
this, Class);
527 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
528 D->ParseLexedMethodDefs();
531void Parser::ParseLexedMethodDef(LexedMethod &LM) {
533 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.D);
537 assert(!LM.Toks.empty() &&
"Empty body!");
538 Token LastBodyToken = LM.Toks.back();
544 LM.Toks.push_back(BodyEnd);
547 LM.Toks.push_back(Tok);
548 PP.EnterTokenStream(LM.Toks,
true,
true);
552 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)
553 &&
"Inline method not starting with '{', ':' or 'try'");
561 if (Tok.
is(tok::kw_try)) {
562 ParseFunctionTryBlock(LM.D, FnScope);
564 while (Tok.
isNot(tok::eof))
571 if (Tok.
is(tok::colon)) {
572 ParseConstructorInitializer(LM.D);
575 if (!Tok.
is(tok::l_brace)) {
579 while (Tok.
isNot(tok::eof))
590 !isa<FunctionTemplateDecl>(LM.D) ||
591 cast<FunctionTemplateDecl>(LM.D)->getTemplateParameters()->getDepth()
592 < TemplateParameterDepth) &&
593 "TemplateParameterDepth should be greater than the depth of "
594 "current template being instantiated!");
596 ParseFunctionStatementBody(LM.D, FnScope);
598 while (Tok.
isNot(tok::eof))
604 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
605 if (isa<CXXMethodDecl>(FD) ||
613void Parser::ParseLexedMemberInitializers(ParsingClass &Class) {
614 ReenterClassScopeRAII InClassScope(*
this, Class);
616 if (!
Class.LateParsedDeclarations.empty()) {
626 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
627 D->ParseLexedMemberInitializers();
633void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
634 if (!MI.Field || MI.Field->isInvalidDecl())
641 MI.Toks.push_back(Tok);
642 PP.EnterTokenStream(MI.Toks,
true,
true);
656 ExprResult Init = ParseCXXMemberInitializer(MI.Field,
false,
663 if (Tok.
isNot(tok::eof)) {
664 if (!Init.isInvalid()) {
669 Diag(EndLoc, diag::err_expected_semi_decl_list);
673 while (Tok.
isNot(tok::eof))
683void Parser::ParseLexedAttributes(ParsingClass &Class) {
684 ReenterClassScopeRAII InClassScope(*
this, Class);
686 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
687 LateD->ParseLexedAttributes();
691void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
692 bool EnterScope,
bool OnDefinition) {
693 assert(LAs.parseSoon() &&
694 "Attribute list should be marked for immediate parsing.");
695 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
698 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
709void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
710 bool EnterScope,
bool OnDefinition) {
718 LA.Toks.push_back(AttrEnd);
722 LA.Toks.push_back(Tok);
723 PP.EnterTokenStream(LA.Toks,
true,
true);
729 if (LA.Decls.size() > 0) {
730 Decl *D = LA.Decls[0];
738 if (LA.Decls.size() == 1) {
740 ReenterTemplateScopeRAII InDeclScope(*
this, D,
EnterScope);
750 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
759 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
764 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
767 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
768 Attrs.begin()->isKnownToGCC())
769 Diag(Tok, diag::warn_attribute_on_function_definition)
772 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
777 while (Tok.
isNot(tok::eof))
784void Parser::ParseLexedPragmas(ParsingClass &Class) {
785 ReenterClassScopeRAII InClassScope(*
this, Class);
787 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
788 D->ParseLexedPragmas();
791void Parser::ParseLexedPragma(LateParsedPragma &LP) {
793 PP.EnterTokenStream(LP.toks(),
true,
798 assert(Tok.
isAnnotation() &&
"Expected annotation token.");
800 case tok::annot_attr_openmp:
801 case tok::annot_pragma_openmp: {
804 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
808 llvm_unreachable(
"Unexpected token.");
820 bool StopAtSemi,
bool ConsumeFinalToken) {
823 bool isFirstTokenConsumed =
true;
826 if (Tok.
is(T1) || Tok.
is(T2)) {
827 if (ConsumeFinalToken) {
836 case tok::annot_module_begin:
837 case tok::annot_module_end:
838 case tok::annot_module_include:
846 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
852 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
858 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
867 if (ParenCount && !isFirstTokenConsumed)
873 if (BracketCount && !isFirstTokenConsumed)
879 if (BraceCount && !isFirstTokenConsumed)
895 isFirstTokenConsumed =
false;
905bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
906 if (Tok.
is(tok::kw_try)) {
911 if (Tok.
isNot(tok::colon)) {
917 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
920 if (Tok.
isNot(tok::l_brace))
941 bool MightBeTemplateArgument =
false;
945 if (Tok.
is(tok::kw_decltype)) {
948 if (Tok.
isNot(tok::l_paren))
953 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
955 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
961 if (Tok.
is(tok::coloncolon)) {
965 if (Tok.
is(tok::kw_template)) {
971 if (Tok.
is(tok::identifier)) {
977 }
while (Tok.
is(tok::coloncolon));
979 if (Tok.
is(tok::code_completion)) {
981 ConsumeCodeCompletionToken();
982 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
989 if (Tok.
is(tok::comma)) {
995 if (Tok.
is(tok::less))
996 MightBeTemplateArgument =
true;
998 if (MightBeTemplateArgument) {
1005 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1012 }
else if (Tok.
isNot(tok::l_paren) && Tok.
isNot(tok::l_brace)) {
1016 << tok::l_paren << tok::l_brace;
1022 Toks.push_back(Tok);
1023 bool IsLParen = (
kind == tok::l_paren);
1029 assert(kind == tok::l_brace &&
"Must be left paren or brace here.");
1036 const Token &PreviousToken = Toks[Toks.size() - 2];
1037 if (!MightBeTemplateArgument &&
1038 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1039 tok::greatergreater)) {
1045 TentativeParsingAction PA(*
this);
1047 !Tok.
isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1060 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1061 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1062 Diag(Tok, diag::err_expected) << CloseKind;
1063 Diag(OpenLoc, diag::note_matching) <<
kind;
1068 if (Tok.
is(tok::ellipsis)) {
1069 Toks.push_back(Tok);
1075 if (Tok.
is(tok::comma)) {
1076 Toks.push_back(Tok);
1078 }
else if (Tok.
is(tok::l_brace)) {
1093 Toks.push_back(Tok);
1096 }
else if (!MightBeTemplateArgument) {
1097 return Diag(Tok.
getLocation(), diag::err_expected_either) << tok::l_brace
1105bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1107 assert(Tok.
is(tok::question));
1108 Toks.push_back(Tok);
1111 while (Tok.
isNot(tok::colon)) {
1112 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1118 if (Tok.
is(tok::question) && !ConsumeAndStoreConditional(Toks))
1123 Toks.push_back(Tok);
1133 : TentativeParsingAction(Self), Self(Self), EndKind(EndKind) {
1136 TentativeParsingAction Inner(Self);
1137 Self.ConsumeAndStoreUntil(EndKind, Toks,
true,
false);
1147 auto Buffer = std::make_unique<Token[]>(Toks.size());
1148 std::copy(Toks.begin() + 1, Toks.end(), Buffer.get());
1149 Buffer[Toks.size() - 1] = Self.Tok;
1150 Self.PP.EnterTokenStream(std::move(Buffer), Toks.size(),
true,
1153 Self.Tok = Toks.front();
1169bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1170 CachedInitKind CIK) {
1172 bool IsFirstToken =
true;
1177 unsigned AngleCount = 0;
1178 unsigned KnownTemplateCount = 0;
1187 if (KnownTemplateCount)
1200 UnannotatedTentativeParsingAction PA(*
this,
1201 CIK == CIK_DefaultInitializer
1202 ? tok::semi : tok::r_paren);
1205 TPResult
Result = TPResult::Error;
1208 case CIK_DefaultInitializer:
1209 Result = TryParseInitDeclaratorList();
1212 if (
Result == TPResult::Ambiguous && Tok.
isNot(tok::semi))
1213 Result = TPResult::False;
1216 case CIK_DefaultArgument:
1217 bool InvalidAsDeclaration =
false;
1218 Result = TryParseParameterDeclarationClause(
1219 &InvalidAsDeclaration,
true);
1222 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1223 Result = TPResult::False;
1230 PA.RevertAnnotations();
1233 if (
Result != TPResult::False &&
Result != TPResult::Error)
1238 ++KnownTemplateCount;
1242 case tok::annot_module_begin:
1243 case tok::annot_module_end:
1244 case tok::annot_module_include:
1257 if (!ConsumeAndStoreConditional(Toks))
1261 case tok::greatergreatergreater:
1264 if (AngleCount) --AngleCount;
1265 if (KnownTemplateCount) --KnownTemplateCount;
1267 case tok::greatergreater:
1270 if (AngleCount) --AngleCount;
1271 if (KnownTemplateCount) --KnownTemplateCount;
1274 if (AngleCount) --AngleCount;
1275 if (KnownTemplateCount) --KnownTemplateCount;
1278 case tok::kw_template:
1282 Toks.push_back(Tok);
1284 if (Tok.
is(tok::identifier)) {
1285 Toks.push_back(Tok);
1287 if (Tok.
is(tok::less)) {
1289 ++KnownTemplateCount;
1290 Toks.push_back(Tok);
1296 case tok::kw_operator:
1299 Toks.push_back(Tok);
1303 case tok::greatergreatergreater:
1304 case tok::greatergreater:
1307 Toks.push_back(Tok);
1317 Toks.push_back(Tok);
1319 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1323 Toks.push_back(Tok);
1325 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1329 Toks.push_back(Tok);
1331 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1341 if (CIK == CIK_DefaultArgument)
1343 if (ParenCount && !IsFirstToken)
1345 Toks.push_back(Tok);
1349 if (BracketCount && !IsFirstToken)
1351 Toks.push_back(Tok);
1355 if (BraceCount && !IsFirstToken)
1357 Toks.push_back(Tok);
1361 case tok::code_completion:
1362 Toks.push_back(Tok);
1363 ConsumeCodeCompletionToken();
1366 case tok::string_literal:
1367 case tok::wide_string_literal:
1368 case tok::utf8_string_literal:
1369 case tok::utf16_string_literal:
1370 case tok::utf32_string_literal:
1371 Toks.push_back(Tok);
1372 ConsumeStringToken();
1375 if (CIK == CIK_DefaultInitializer)
1380 Toks.push_back(Tok);
1384 IsFirstToken =
false;
Defines the C++ template declaration subclasses.
A tentative parsing action that can also revert token annotations.
UnannotatedTentativeParsingAction(Parser &Self, tok::TokenKind EndKind)
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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
bool hasErrorOccurred() const
RAII object that enters a new expression evaluation context.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
QualType getReturnType() const
void setWillHaveBody(bool V=true)
Declaration of a template function.
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,...
Represents a parameter to a function.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
bool hasUninstantiatedDefaultArg() const
Expr * getUninstantiatedDefaultArg()
ParsedAttributes - A collection of parsed attributes.
Introduces zero or more scopes for parsing.
void Enter(unsigned ScopeFlags)
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.
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
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...
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
const LangOptions & getLangOpts() const
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
unsigned ReenterTemplateScopes(MultiParseScope &S, Decl *D)
Re-enter the template scopes for a declaration that might be a template.
A class for parsing a declarator.
const ParsingDeclSpec & getDeclSpec() const
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
The collection of all-type qualifiers we support.
Represents a struct/union/class.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Scope - A scope is a transient data structure that is used while parsing the program.
@ 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.
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Decl * ActOnSkippedFunctionBody(Decl *Decl)
void ActOnFinishDelayedMemberInitializers(Decl *Record)
void ActOnExitFunctionContext()
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool IsInsideALocalClassWithinATemplateFunction()
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
DiagnosticsEngine & getDiagnostics() const
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
void ActOnFinishInlineFunctionDef(FunctionDecl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
@ 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 ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
Token - This structure provides full information about a lexed token.
SourceLocation getEndLoc() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setKind(tok::TokenKind K)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
void setEofData(const void *D)
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
const void * getEofData() const
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.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
@ ICIS_NoInit
No in-class initializer.
@ C
Languages that the frontend can parse and compile.
@ Result
The result type of a method or function.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Utility to re-enter a class scope while parsing its late-parsed components.
ReenterClassScopeRAII(Parser &P, ParsingClass &Class)
Utility to re-enter a possibly-templated scope while parsing its late-parsed components.
ReenterTemplateScopeRAII(Parser &P, Decl *MaybeTemplated, bool Enter=true)
TemplateParameterDepthRAII CurTemplateDepthTracker