26NamedDecl *Parser::ParseCXXInlineMethodDef(
31 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try, tok::equal) &&
32 "Current token not a '{', ':', '=', or 'try'!");
35 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
37 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
45 TemplateParams,
nullptr,
55 HandleMemberFunctionDeclDelays(D, FnD);
70 ? diag::warn_cxx98_compat_defaulted_deleted_function
71 : diag::ext_defaulted_deleted_function)
75 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
76 DeclAsFunction->setRangeEnd(KWEndLoc);
80 ? diag::warn_cxx98_compat_defaulted_deleted_function
81 : diag::ext_defaulted_deleted_function)
84 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
85 DeclAsFunction->setRangeEnd(KWEndLoc);
88 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
91 if (Tok.
is(tok::comma)) {
92 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
95 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
96 Delete ?
"delete" :
"default")) {
104 trySkippingFunctionBody()) {
118 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
119 TemplateInfo.Kind != ParsedTemplateInfo::ExplicitSpecialization)) &&
123 LexTemplateFunctionForLateParsing(Toks);
136 LexedMethod* LM =
new LexedMethod(
this, FnD);
137 getCurrentClass().LateParsedDeclarations.push_back(LM);
143 if (ConsumeAndStoreFunctionPrologue(Toks)) {
150 llvm::any_of(Toks, [](
const Token &Tok) {
151 return Tok.is(tok::code_completion);
164 delete getCurrentClass().LateParsedDeclarations.back();
165 getCurrentClass().LateParsedDeclarations.pop_back();
169 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
173 if (kind == tok::kw_try) {
174 while (Tok.
is(tok::kw_catch)) {
175 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
176 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
189 delete getCurrentClass().LateParsedDeclarations.back();
190 getCurrentClass().LateParsedDeclarations.pop_back();
200void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
201 assert(Tok.
isOneOf(tok::l_brace, tok::equal) &&
202 "Current token not a '{' or '='!");
204 LateParsedMemberInitializer *MI =
205 new LateParsedMemberInitializer(
this, VarD);
206 getCurrentClass().LateParsedDeclarations.push_back(MI);
210 if (kind == tok::equal) {
215 if (kind == tok::l_brace) {
221 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
224 ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer);
237Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
238void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
239void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() {}
240void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
241void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
242void Parser::LateParsedDeclaration::ParseLexedPragmas() {}
244Parser::LateParsedClass::LateParsedClass(
Parser *
P, ParsingClass *
C)
247Parser::LateParsedClass::~LateParsedClass() {
248 Self->DeallocateParsedClasses(Class);
251void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
252 Self->ParseLexedMethodDeclarations(*Class);
255void Parser::LateParsedClass::ParseLexedMemberInitializers() {
256 Self->ParseLexedMemberInitializers(*Class);
259void Parser::LateParsedClass::ParseLexedMethodDefs() {
260 Self->ParseLexedMethodDefs(*Class);
263void Parser::LateParsedClass::ParseLexedAttributes() {
264 Self->ParseLexedAttributes(*Class);
267void Parser::LateParsedClass::ParseLexedPragmas() {
268 Self->ParseLexedPragmas(*Class);
271void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
272 Self->ParseLexedMethodDeclaration(*
this);
275void Parser::LexedMethod::ParseLexedMethodDefs() {
276 Self->ParseLexedMethodDef(*
this);
279void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() {
280 Self->ParseLexedMemberInitializer(*
this);
283void Parser::LateParsedAttribute::ParseLexedAttributes() {
284 Self->ParseLexedAttribute(*
this,
true,
false);
287void Parser::LateParsedPragma::ParseLexedPragmas() {
288 Self->ParseLexedPragma(*
this);
313 !
Class.TopLevelClass),
316 if (
Class.TopLevelClass)
322 Class.TagOrTemplate);
325 if (
Class.TopLevelClass)
329 Class.TagOrTemplate);
337void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
338 ReenterClassScopeRAII InClassScope(*
this,
Class);
340 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
341 LateD->ParseLexedMethodDeclarations();
344void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
346 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
356 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
357 auto Param = cast<ParmVarDecl>(LM.DefaultArgs[I].Param);
359 bool HasUnparsed = Param->hasUnparsedDefaultArg();
361 std::unique_ptr<CachedTokens> Toks = std::move(LM.DefaultArgs[I].Toks);
367 Token LastDefaultArgToken = Toks->back();
373 Toks->push_back(DefArgEnd);
376 Toks->push_back(Tok);
377 PP.EnterTokenStream(*Toks,
true,
true);
383 assert(Tok.
is(tok::equal) &&
"Default argument not starting with '='");
394 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
395 DefArgResult = ParseBraceInitializer();
407 assert(Toks->size() >= 3 &&
"expected a token in default arg");
410 (*Toks)[Toks->size() - 3].getLocation());
418 while (Tok.
isNot(tok::eof))
423 }
else if (HasUnparsed) {
424 assert(Param->hasInheritedDefaultArg());
426 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
435 Param->setUninstantiatedDefaultArg(
438 Param->setDefaultArg(OldParam->
getInit());
448 Token LastExceptionSpecToken = Toks->back();
449 Token ExceptionSpecEnd;
451 ExceptionSpecEnd.
setKind(tok::eof);
454 Toks->push_back(ExceptionSpecEnd);
457 Toks->push_back(Tok);
458 PP.EnterTokenStream(*Toks,
true,
true);
471 = dyn_cast<FunctionTemplateDecl>(LM.Method))
472 Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
474 Method = dyn_cast<CXXMethodDecl>(LM.Method);
477 Actions, Method ? Method->
getParent() :
nullptr,
489 = tryParseExceptionSpecification(
false, SpecificationRange,
491 DynamicExceptionRanges, NoexceptExpr,
492 ExceptionSpecTokens);
501 DynamicExceptionRanges,
503 NoexceptExpr.
get() :
nullptr);
507 while (Tok.
isNot(tok::eof))
515 LM.ExceptionSpecTokens =
nullptr;
518 InFunctionTemplateScope.Scopes.Exit();
527void Parser::ParseLexedMethodDefs(ParsingClass &
Class) {
528 ReenterClassScopeRAII InClassScope(*
this,
Class);
530 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
531 D->ParseLexedMethodDefs();
534void Parser::ParseLexedMethodDef(LexedMethod &LM) {
536 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.D);
540 assert(!LM.Toks.empty() &&
"Empty body!");
541 Token LastBodyToken = LM.Toks.back();
547 LM.Toks.push_back(BodyEnd);
550 LM.Toks.push_back(Tok);
551 PP.EnterTokenStream(LM.Toks,
true,
true);
555 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)
556 &&
"Inline method not starting with '{', ':' or 'try'");
564 if (Tok.
is(tok::kw_try)) {
565 ParseFunctionTryBlock(LM.D, FnScope);
567 while (Tok.
isNot(tok::eof))
574 if (Tok.
is(tok::colon)) {
575 ParseConstructorInitializer(LM.D);
578 if (!Tok.
is(tok::l_brace)) {
582 while (Tok.
isNot(tok::eof))
593 !isa<FunctionTemplateDecl>(LM.D) ||
594 cast<FunctionTemplateDecl>(LM.D)->getTemplateParameters()->getDepth()
595 < TemplateParameterDepth) &&
596 "TemplateParameterDepth should be greater than the depth of "
597 "current template being instantiated!");
599 ParseFunctionStatementBody(LM.D, FnScope);
601 while (Tok.
isNot(tok::eof))
607 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
608 if (isa<CXXMethodDecl>(FD) ||
616void Parser::ParseLexedMemberInitializers(ParsingClass &
Class) {
617 ReenterClassScopeRAII InClassScope(*
this,
Class);
619 if (!
Class.LateParsedDeclarations.empty()) {
629 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
630 D->ParseLexedMemberInitializers();
636void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
637 if (!MI.Field || MI.Field->isInvalidDecl())
644 MI.Toks.push_back(Tok);
645 PP.EnterTokenStream(MI.Toks,
true,
true);
666 if (Tok.
isNot(tok::eof)) {
667 if (!
Init.isInvalid()) {
672 Diag(EndLoc, diag::err_expected_semi_decl_list);
676 while (Tok.
isNot(tok::eof))
686void Parser::ParseLexedAttributes(ParsingClass &
Class) {
687 ReenterClassScopeRAII InClassScope(*
this,
Class);
689 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
690 LateD->ParseLexedAttributes();
694void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
695 bool EnterScope,
bool OnDefinition) {
696 assert(LAs.parseSoon() &&
697 "Attribute list should be marked for immediate parsing.");
698 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
701 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
712void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
713 bool EnterScope,
bool OnDefinition) {
721 LA.Toks.push_back(AttrEnd);
725 LA.Toks.push_back(Tok);
726 PP.EnterTokenStream(LA.Toks,
true,
true);
732 if (LA.Decls.size() > 0) {
733 Decl *D = LA.Decls[0];
741 if (LA.Decls.size() == 1) {
743 ReenterTemplateScopeRAII InDeclScope(*
this, D,
EnterScope);
753 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
762 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
767 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
770 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
771 Attrs.begin()->isKnownToGCC())
772 Diag(Tok, diag::warn_attribute_on_function_definition)
775 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
780 while (Tok.
isNot(tok::eof))
787void Parser::ParseLexedPragmas(ParsingClass &
Class) {
788 ReenterClassScopeRAII InClassScope(*
this,
Class);
790 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
791 D->ParseLexedPragmas();
794void Parser::ParseLexedPragma(LateParsedPragma &LP) {
796 PP.EnterTokenStream(LP.toks(),
true,
801 assert(Tok.
isAnnotation() &&
"Expected annotation token.");
803 case tok::annot_attr_openmp:
804 case tok::annot_pragma_openmp: {
807 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
811 llvm_unreachable(
"Unexpected token.");
823 bool StopAtSemi,
bool ConsumeFinalToken) {
826 bool isFirstTokenConsumed =
true;
829 if (Tok.
is(T1) || Tok.
is(T2)) {
830 if (ConsumeFinalToken) {
839 case tok::annot_module_begin:
840 case tok::annot_module_end:
841 case tok::annot_module_include:
842 case tok::annot_repl_input_end:
850 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
856 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
862 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
871 if (ParenCount && !isFirstTokenConsumed)
877 if (BracketCount && !isFirstTokenConsumed)
883 if (BraceCount && !isFirstTokenConsumed)
899 isFirstTokenConsumed =
false;
909bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
910 if (Tok.
is(tok::kw_try)) {
915 if (Tok.
isNot(tok::colon)) {
921 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
924 if (Tok.
isNot(tok::l_brace))
945 bool MightBeTemplateArgument =
false;
949 if (Tok.
is(tok::kw_decltype)) {
952 if (Tok.
isNot(tok::l_paren))
957 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
959 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
965 if (Tok.
is(tok::coloncolon)) {
969 if (Tok.
is(tok::kw_template)) {
975 if (Tok.
is(tok::identifier)) {
982 if (Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
987 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
989 Diag(OpenLoc, diag::note_matching) << tok::l_square;
994 }
while (Tok.
is(tok::coloncolon));
996 if (Tok.
is(tok::code_completion)) {
998 ConsumeCodeCompletionToken();
999 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1006 if (Tok.
is(tok::comma)) {
1008 Toks.push_back(Tok);
1012 if (Tok.
is(tok::less))
1013 MightBeTemplateArgument =
true;
1015 if (MightBeTemplateArgument) {
1022 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1029 }
else if (Tok.
isNot(tok::l_paren) && Tok.
isNot(tok::l_brace)) {
1033 << tok::l_paren << tok::l_brace;
1039 Toks.push_back(Tok);
1040 bool IsLParen = (
kind == tok::l_paren);
1046 assert(kind == tok::l_brace &&
"Must be left paren or brace here.");
1053 const Token &PreviousToken = Toks[Toks.size() - 2];
1054 if (!MightBeTemplateArgument &&
1055 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1056 tok::greatergreater)) {
1062 TentativeParsingAction PA(*
this);
1064 !Tok.
isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1077 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1078 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1079 Diag(Tok, diag::err_expected) << CloseKind;
1080 Diag(OpenLoc, diag::note_matching) <<
kind;
1085 if (Tok.
is(tok::ellipsis)) {
1086 Toks.push_back(Tok);
1092 if (Tok.
is(tok::comma)) {
1093 Toks.push_back(Tok);
1095 }
else if (Tok.
is(tok::l_brace)) {
1110 Toks.push_back(Tok);
1113 }
else if (!MightBeTemplateArgument) {
1114 return Diag(Tok.
getLocation(), diag::err_expected_either) << tok::l_brace
1122bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1124 assert(Tok.
is(tok::question));
1125 Toks.push_back(Tok);
1128 while (Tok.
isNot(tok::colon)) {
1129 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1135 if (Tok.
is(tok::question) && !ConsumeAndStoreConditional(Toks))
1140 Toks.push_back(Tok);
1150 : TentativeParsingAction(
Self),
Self(
Self), EndKind(EndKind) {
1153 TentativeParsingAction Inner(
Self);
1154 Self.ConsumeAndStoreUntil(EndKind, Toks,
true,
false);
1164 auto Buffer = std::make_unique<Token[]>(Toks.size());
1165 std::copy(Toks.begin() + 1, Toks.end(), Buffer.get());
1166 Buffer[Toks.size() - 1] =
Self.Tok;
1167 Self.PP.EnterTokenStream(std::move(Buffer), Toks.size(),
true,
1170 Self.Tok = Toks.front();
1186bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1187 CachedInitKind CIK) {
1189 bool IsFirstToken =
true;
1194 unsigned AngleCount = 0;
1195 unsigned KnownTemplateCount = 0;
1204 if (KnownTemplateCount)
1217 UnannotatedTentativeParsingAction PA(*
this,
1218 CIK == CIK_DefaultInitializer
1219 ? tok::semi : tok::r_paren);
1222 TPResult
Result = TPResult::Error;
1225 case CIK_DefaultInitializer:
1226 Result = TryParseInitDeclaratorList();
1229 if (
Result == TPResult::Ambiguous && Tok.
isNot(tok::semi))
1230 Result = TPResult::False;
1233 case CIK_DefaultArgument:
1234 bool InvalidAsDeclaration =
false;
1235 Result = TryParseParameterDeclarationClause(
1236 &InvalidAsDeclaration,
true);
1239 if (
Result == TPResult::Ambiguous && InvalidAsDeclaration)
1240 Result = TPResult::False;
1247 PA.RevertAnnotations();
1250 if (
Result != TPResult::False &&
Result != TPResult::Error)
1255 ++KnownTemplateCount;
1259 case tok::annot_module_begin:
1260 case tok::annot_module_end:
1261 case tok::annot_module_include:
1262 case tok::annot_repl_input_end:
1275 if (!ConsumeAndStoreConditional(Toks))
1279 case tok::greatergreatergreater:
1282 if (AngleCount) --AngleCount;
1283 if (KnownTemplateCount) --KnownTemplateCount;
1285 case tok::greatergreater:
1288 if (AngleCount) --AngleCount;
1289 if (KnownTemplateCount) --KnownTemplateCount;
1292 if (AngleCount) --AngleCount;
1293 if (KnownTemplateCount) --KnownTemplateCount;
1296 case tok::kw_template:
1300 Toks.push_back(Tok);
1302 if (Tok.
is(tok::identifier)) {
1303 Toks.push_back(Tok);
1305 if (Tok.
is(tok::less)) {
1307 ++KnownTemplateCount;
1308 Toks.push_back(Tok);
1314 case tok::kw_operator:
1317 Toks.push_back(Tok);
1321 case tok::greatergreatergreater:
1322 case tok::greatergreater:
1325 Toks.push_back(Tok);
1335 Toks.push_back(Tok);
1337 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1341 Toks.push_back(Tok);
1343 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1347 Toks.push_back(Tok);
1349 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1359 if (CIK == CIK_DefaultArgument)
1361 if (ParenCount && !IsFirstToken)
1363 Toks.push_back(Tok);
1367 if (BracketCount && !IsFirstToken)
1369 Toks.push_back(Tok);
1373 if (BraceCount && !IsFirstToken)
1375 Toks.push_back(Tok);
1379 case tok::code_completion:
1380 Toks.push_back(Tok);
1381 ConsumeCodeCompletionToken();
1384 case tok::string_literal:
1385 case tok::wide_string_literal:
1386 case tok::utf8_string_literal:
1387 case tok::utf16_string_literal:
1388 case tok::utf32_string_literal:
1389 Toks.push_back(Tok);
1390 ConsumeStringToken();
1393 if (CIK == CIK_DefaultInitializer)
1398 Toks.push_back(Tok);
1402 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.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
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 ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc, Expr *DefaultArg)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
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 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.
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ ICIS_NoInit
No in-class initializer.
@ Result
The result type of a method or function.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
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