21 using namespace clang;
25 if (!Tok.
is(tok::l_paren))
31 if (isTokenStringLiteral()) {
36 ? diag::warn_cxx23_delete_with_message
37 : diag::ext_delete_with_message)
38 << Message->getSourceRange();
53 void Parser::SkipDeletedFunctionBody() {
54 if (!Tok.
is(tok::l_paren))
62 if (Tok.
is(tok::r_paren))
69 NamedDecl *Parser::ParseCXXInlineMethodDef(
74 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try, tok::equal) &&
75 "Current token not a '{', ':', '=', or 'try'!");
78 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
80 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
88 TemplateParams,
nullptr,
98 HandleMemberFunctionDeclDelays(D, FnD);
113 ? diag::warn_cxx98_compat_defaulted_deleted_function
114 : diag::ext_defaulted_deleted_function)
119 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
120 DeclAsFunction->setRangeEnd(KWEndLoc);
124 ? diag::warn_cxx98_compat_defaulted_deleted_function
125 : diag::ext_defaulted_deleted_function)
128 if (
auto *DeclAsFunction = dyn_cast<FunctionDecl>(FnD)) {
129 DeclAsFunction->setRangeEnd(KWEndLoc);
132 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
135 if (Tok.
is(tok::comma)) {
136 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
139 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
140 Delete ?
"delete" :
"default")) {
148 trySkippingFunctionBody()) {
162 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
163 TemplateInfo.Kind != ParsedTemplateInfo::ExplicitSpecialization)) &&
167 LexTemplateFunctionForLateParsing(Toks);
180 LexedMethod* LM =
new LexedMethod(
this, FnD);
181 getCurrentClass().LateParsedDeclarations.push_back(LM);
187 if (ConsumeAndStoreFunctionPrologue(Toks)) {
194 llvm::any_of(Toks, [](
const Token &Tok) {
195 return Tok.is(tok::code_completion);
208 delete getCurrentClass().LateParsedDeclarations.back();
209 getCurrentClass().LateParsedDeclarations.pop_back();
213 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
217 if (
kind == tok::kw_try) {
218 while (Tok.
is(tok::kw_catch)) {
219 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
220 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
233 delete getCurrentClass().LateParsedDeclarations.back();
234 getCurrentClass().LateParsedDeclarations.pop_back();
244 void Parser::ParseCXXNonStaticMemberInitializer(
Decl *VarD) {
245 assert(Tok.
isOneOf(tok::l_brace, tok::equal) &&
246 "Current token not a '{' or '='!");
248 LateParsedMemberInitializer *MI =
249 new LateParsedMemberInitializer(
this, VarD);
250 getCurrentClass().LateParsedDeclarations.push_back(MI);
254 if (
kind == tok::equal) {
259 if (
kind == tok::l_brace) {
265 ConsumeAndStoreUntil(tok::r_brace, Toks,
true);
268 ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer);
281 Parser::LateParsedDeclaration::~LateParsedDeclaration() {}
282 void Parser::LateParsedDeclaration::ParseLexedMethodDeclarations() {}
283 void Parser::LateParsedDeclaration::ParseLexedMemberInitializers() {}
284 void Parser::LateParsedDeclaration::ParseLexedMethodDefs() {}
285 void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
286 void Parser::LateParsedDeclaration::ParseLexedPragmas() {}
288 Parser::LateParsedClass::LateParsedClass(
Parser *
P, ParsingClass *C)
291 Parser::LateParsedClass::~LateParsedClass() {
292 Self->DeallocateParsedClasses(Class);
295 void Parser::LateParsedClass::ParseLexedMethodDeclarations() {
296 Self->ParseLexedMethodDeclarations(*Class);
299 void Parser::LateParsedClass::ParseLexedMemberInitializers() {
300 Self->ParseLexedMemberInitializers(*Class);
303 void Parser::LateParsedClass::ParseLexedMethodDefs() {
304 Self->ParseLexedMethodDefs(*Class);
307 void Parser::LateParsedClass::ParseLexedAttributes() {
308 Self->ParseLexedAttributes(*Class);
311 void Parser::LateParsedClass::ParseLexedPragmas() {
312 Self->ParseLexedPragmas(*Class);
315 void Parser::LateParsedMethodDeclaration::ParseLexedMethodDeclarations() {
316 Self->ParseLexedMethodDeclaration(*
this);
319 void Parser::LexedMethod::ParseLexedMethodDefs() {
320 Self->ParseLexedMethodDef(*
this);
323 void Parser::LateParsedMemberInitializer::ParseLexedMemberInitializers() {
324 Self->ParseLexedMemberInitializer(*
this);
327 void Parser::LateParsedAttribute::ParseLexedAttributes() {
328 Self->ParseLexedAttribute(*
this,
true,
false);
331 void Parser::LateParsedPragma::ParseLexedPragmas() {
332 Self->ParseLexedPragma(*
this);
357 !
Class.TopLevelClass),
360 if (
Class.TopLevelClass)
366 Class.TagOrTemplate);
369 if (
Class.TopLevelClass)
373 Class.TagOrTemplate);
381 void Parser::ParseLexedMethodDeclarations(ParsingClass &Class) {
382 ReenterClassScopeRAII InClassScope(*
this, Class);
384 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
385 LateD->ParseLexedMethodDeclarations();
388 void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
390 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.Method);
400 for (
unsigned I = 0, N = LM.DefaultArgs.size(); I != N; ++I) {
401 auto Param = cast<ParmVarDecl>(LM.DefaultArgs[I].Param);
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();
451 assert(Toks->size() >= 3 &&
"expected a token in default arg");
454 (*Toks)[Toks->size() - 3].getLocation());
467 }
else if (HasUnparsed) {
468 assert(Param->hasInheritedDefaultArg());
470 if (
const auto *FunTmpl = dyn_cast<FunctionTemplateDecl>(LM.Method))
479 Param->setUninstantiatedDefaultArg(
482 Param->setDefaultArg(OldParam->
getInit());
492 Token LastExceptionSpecToken = Toks->back();
493 Token ExceptionSpecEnd;
498 Toks->push_back(ExceptionSpecEnd);
501 Toks->push_back(Tok);
502 PP.EnterTokenStream(*Toks,
true,
true);
515 = dyn_cast<FunctionTemplateDecl>(LM.Method))
516 Method = dyn_cast<CXXMethodDecl>(FunTmpl->getTemplatedDecl());
518 Method = dyn_cast<CXXMethodDecl>(LM.Method);
521 Actions, Method ? Method->
getParent() :
nullptr,
533 = tryParseExceptionSpecification(
false, SpecificationRange,
535 DynamicExceptionRanges, NoexceptExpr,
536 ExceptionSpecTokens);
545 DynamicExceptionRanges,
547 NoexceptExpr.
get() :
nullptr);
559 LM.ExceptionSpecTokens =
nullptr;
562 InFunctionTemplateScope.Scopes.Exit();
571 void Parser::ParseLexedMethodDefs(ParsingClass &Class) {
572 ReenterClassScopeRAII InClassScope(*
this, Class);
574 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
575 D->ParseLexedMethodDefs();
578 void Parser::ParseLexedMethodDef(LexedMethod &LM) {
580 ReenterTemplateScopeRAII InFunctionTemplateScope(*
this, LM.D);
584 assert(!LM.Toks.empty() &&
"Empty body!");
585 Token LastBodyToken = LM.Toks.back();
591 LM.Toks.push_back(BodyEnd);
594 LM.Toks.push_back(Tok);
595 PP.EnterTokenStream(LM.Toks,
true,
true);
599 assert(Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)
600 &&
"Inline method not starting with '{', ':' or 'try'");
610 if (Tok.
is(tok::kw_try)) {
611 ParseFunctionTryBlock(LM.D, FnScope);
620 if (Tok.
is(tok::colon)) {
621 ParseConstructorInitializer(LM.D);
624 if (!Tok.
is(tok::l_brace)) {
639 !isa<FunctionTemplateDecl>(LM.D) ||
640 cast<FunctionTemplateDecl>(LM.D)->getTemplateParameters()->getDepth()
641 < TemplateParameterDepth) &&
642 "TemplateParameterDepth should be greater than the depth of "
643 "current template being instantiated!");
645 ParseFunctionStatementBody(LM.D, FnScope);
653 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(LM.D))
654 if (isa<CXXMethodDecl>(FD) ||
662 void Parser::ParseLexedMemberInitializers(ParsingClass &Class) {
663 ReenterClassScopeRAII InClassScope(*
this, Class);
665 if (!
Class.LateParsedDeclarations.empty()) {
675 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
676 D->ParseLexedMemberInitializers();
682 void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) {
683 if (!MI.Field || MI.Field->isInvalidDecl())
690 MI.Toks.push_back(Tok);
691 PP.EnterTokenStream(MI.Toks,
true,
true);
713 if (!
Init.isInvalid()) {
718 Diag(EndLoc, diag::err_expected_semi_decl_list);
732 void Parser::ParseLexedAttributes(ParsingClass &Class) {
733 ReenterClassScopeRAII InClassScope(*
this, Class);
735 for (LateParsedDeclaration *LateD :
Class.LateParsedDeclarations)
736 LateD->ParseLexedAttributes();
740 void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
741 bool EnterScope,
bool OnDefinition) {
742 assert(LAs.parseSoon() &&
743 "Attribute list should be marked for immediate parsing.");
744 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
747 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
758 void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
759 bool EnterScope,
bool OnDefinition) {
767 LA.Toks.push_back(AttrEnd);
771 LA.Toks.push_back(Tok);
772 PP.EnterTokenStream(LA.Toks,
true,
true);
778 if (LA.Decls.size() > 0) {
779 Decl *D = LA.Decls[0];
787 if (LA.Decls.size() == 1) {
789 ReenterTemplateScopeRAII InDeclScope(*
this, D,
EnterScope);
799 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
808 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
813 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
816 if (OnDefinition && !Attrs.empty() && !Attrs.begin()->isCXX11Attribute() &&
817 Attrs.begin()->isKnownToGCC())
818 Diag(Tok, diag::warn_attribute_on_function_definition)
821 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
833 void Parser::ParseLexedPragmas(ParsingClass &Class) {
834 ReenterClassScopeRAII InClassScope(*
this, Class);
836 for (LateParsedDeclaration *D :
Class.LateParsedDeclarations)
837 D->ParseLexedPragmas();
840 void Parser::ParseLexedPragma(LateParsedPragma &LP) {
842 PP.EnterTokenStream(LP.toks(),
true,
847 assert(Tok.
isAnnotation() &&
"Expected annotation token.");
849 case tok::annot_attr_openmp:
850 case tok::annot_pragma_openmp: {
853 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
857 llvm_unreachable(
"Unexpected token.");
869 bool StopAtSemi,
bool ConsumeFinalToken) {
872 bool isFirstTokenConsumed =
true;
875 if (Tok.
is(T1) || Tok.
is(T2)) {
876 if (ConsumeFinalToken) {
885 case tok::annot_module_begin:
886 case tok::annot_module_end:
887 case tok::annot_module_include:
888 case tok::annot_repl_input_end:
896 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
902 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
908 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
917 if (ParenCount && !isFirstTokenConsumed)
923 if (BracketCount && !isFirstTokenConsumed)
929 if (BraceCount && !isFirstTokenConsumed)
945 isFirstTokenConsumed =
false;
955 bool Parser::ConsumeAndStoreFunctionPrologue(
CachedTokens &Toks) {
956 if (Tok.
is(tok::kw_try)) {
961 if (Tok.
isNot(tok::colon)) {
967 ConsumeAndStoreUntil(tok::l_brace, tok::r_brace, Toks,
970 if (Tok.
isNot(tok::l_brace))
991 bool MightBeTemplateArgument =
false;
995 if (Tok.
is(tok::kw_decltype)) {
998 if (Tok.
isNot(tok::l_paren))
1001 Toks.push_back(Tok);
1003 if (!ConsumeAndStoreUntil(tok::r_paren, Toks,
true)) {
1005 Diag(OpenLoc, diag::note_matching) << tok::l_paren;
1011 if (Tok.
is(tok::coloncolon)) {
1012 Toks.push_back(Tok);
1015 if (Tok.
is(tok::kw_template)) {
1016 Toks.push_back(Tok);
1021 if (Tok.
is(tok::identifier)) {
1022 Toks.push_back(Tok);
1028 if (Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
1029 Toks.push_back(Tok);
1031 Toks.push_back(Tok);
1033 if (!ConsumeAndStoreUntil(tok::r_square, Toks,
true)) {
1035 Diag(OpenLoc, diag::note_matching) << tok::l_square;
1040 }
while (Tok.
is(tok::coloncolon));
1042 if (Tok.
is(tok::code_completion)) {
1043 Toks.push_back(Tok);
1044 ConsumeCodeCompletionToken();
1045 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
1052 if (Tok.
is(tok::comma)) {
1054 Toks.push_back(Tok);
1058 if (Tok.
is(tok::less))
1059 MightBeTemplateArgument =
true;
1061 if (MightBeTemplateArgument) {
1068 if (!ConsumeAndStoreUntil(tok::l_paren, tok::l_brace, Toks,
1075 }
else if (Tok.
isNot(tok::l_paren) && Tok.
isNot(tok::l_brace)) {
1079 << tok::l_paren << tok::l_brace;
1085 Toks.push_back(Tok);
1086 bool IsLParen = (
kind == tok::l_paren);
1092 assert(
kind == tok::l_brace &&
"Must be left paren or brace here.");
1099 const Token &PreviousToken = Toks[Toks.size() - 2];
1100 if (!MightBeTemplateArgument &&
1101 !PreviousToken.
isOneOf(tok::identifier, tok::greater,
1102 tok::greatergreater)) {
1108 TentativeParsingAction PA(*
this);
1110 !Tok.
isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
1123 tok::TokenKind CloseKind = IsLParen ? tok::r_paren : tok::r_brace;
1124 if (!ConsumeAndStoreUntil(CloseKind, Toks,
true)) {
1125 Diag(Tok, diag::err_expected) << CloseKind;
1126 Diag(OpenLoc, diag::note_matching) <<
kind;
1131 if (Tok.
is(tok::ellipsis)) {
1132 Toks.push_back(Tok);
1138 if (Tok.
is(tok::comma)) {
1139 Toks.push_back(Tok);
1141 }
else if (Tok.
is(tok::l_brace)) {
1156 Toks.push_back(Tok);
1159 }
else if (!MightBeTemplateArgument) {
1160 return Diag(Tok.
getLocation(), diag::err_expected_either) << tok::l_brace
1168 bool Parser::ConsumeAndStoreConditional(
CachedTokens &Toks) {
1170 assert(Tok.
is(tok::question));
1171 Toks.push_back(Tok);
1174 while (Tok.
isNot(tok::colon)) {
1175 if (!ConsumeAndStoreUntil(tok::question, tok::colon, Toks,
1181 if (Tok.
is(tok::question) && !ConsumeAndStoreConditional(Toks))
1186 Toks.push_back(Tok);
1196 : TentativeParsingAction(Self), Self(Self), EndKind(EndKind) {
1199 TentativeParsingAction Inner(Self);
1200 Self.ConsumeAndStoreUntil(EndKind, Toks,
true,
false);
1210 auto Buffer = std::make_unique<Token[]>(Toks.size());
1211 std::copy(Toks.begin() + 1, Toks.end(), Buffer.get());
1212 Buffer[Toks.size() - 1] = Self.Tok;
1213 Self.PP.EnterTokenStream(std::move(Buffer), Toks.size(),
true,
1216 Self.Tok = Toks.front();
1232 bool Parser::ConsumeAndStoreInitializer(
CachedTokens &Toks,
1233 CachedInitKind CIK) {
1235 bool IsFirstToken =
true;
1240 unsigned AngleCount = 0;
1241 unsigned KnownTemplateCount = 0;
1250 if (KnownTemplateCount)
1263 UnannotatedTentativeParsingAction PA(*
this,
1264 CIK == CIK_DefaultInitializer
1265 ? tok::semi : tok::r_paren);
1268 TPResult Result = TPResult::Error;
1271 case CIK_DefaultInitializer:
1272 Result = TryParseInitDeclaratorList();
1275 if (Result == TPResult::Ambiguous && Tok.
isNot(tok::semi))
1276 Result = TPResult::False;
1279 case CIK_DefaultArgument:
1280 bool InvalidAsDeclaration =
false;
1281 Result = TryParseParameterDeclarationClause(
1282 &InvalidAsDeclaration,
true);
1285 if (Result == TPResult::Ambiguous && InvalidAsDeclaration)
1286 Result = TPResult::False;
1293 PA.RevertAnnotations();
1296 if (Result != TPResult::False && Result != TPResult::Error)
1301 ++KnownTemplateCount;
1305 case tok::annot_module_begin:
1306 case tok::annot_module_end:
1307 case tok::annot_module_include:
1308 case tok::annot_repl_input_end:
1321 if (!ConsumeAndStoreConditional(Toks))
1325 case tok::greatergreatergreater:
1328 if (AngleCount) --AngleCount;
1329 if (KnownTemplateCount) --KnownTemplateCount;
1331 case tok::greatergreater:
1334 if (AngleCount) --AngleCount;
1335 if (KnownTemplateCount) --KnownTemplateCount;
1338 if (AngleCount) --AngleCount;
1339 if (KnownTemplateCount) --KnownTemplateCount;
1342 case tok::kw_template:
1346 Toks.push_back(Tok);
1348 if (Tok.
is(tok::identifier)) {
1349 Toks.push_back(Tok);
1351 if (Tok.
is(tok::less)) {
1353 ++KnownTemplateCount;
1354 Toks.push_back(Tok);
1360 case tok::kw_operator:
1363 Toks.push_back(Tok);
1367 case tok::greatergreatergreater:
1368 case tok::greatergreater:
1371 Toks.push_back(Tok);
1381 Toks.push_back(Tok);
1383 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
1387 Toks.push_back(Tok);
1389 ConsumeAndStoreUntil(tok::r_square, Toks,
false);
1393 Toks.push_back(Tok);
1395 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
1405 if (CIK == CIK_DefaultArgument)
1407 if (ParenCount && !IsFirstToken)
1409 Toks.push_back(Tok);
1413 if (BracketCount && !IsFirstToken)
1415 Toks.push_back(Tok);
1419 if (BraceCount && !IsFirstToken)
1421 Toks.push_back(Tok);
1425 case tok::code_completion:
1426 Toks.push_back(Tok);
1427 ConsumeCodeCompletionToken();
1430 case tok::string_literal:
1431 case tok::wide_string_literal:
1432 case tok::utf8_string_literal:
1433 case tok::utf16_string_literal:
1434 case tok::utf32_string_literal:
1435 Toks.push_back(Tok);
1436 ConsumeStringToken();
1439 if (CIK == CIK_DefaultInitializer)
1444 Toks.push_back(Tok);
1448 IsFirstToken =
false;
Defines the C++ template declaration subclasses.
A tentative parsing action that can also revert token annotations.
UnannotatedTentativeParsingAction(Parser &Self, tok::TokenKind EndKind)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
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.
QualType getReturnType() const
void setWillHaveBody(bool V=true)
const ParmVarDecl * getParamDecl(unsigned i) const
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)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
Scope * getCurScope() const
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
bool TryConsumeToken(tok::TokenKind Expected)
const LangOptions & getLangOpts() 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.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
ExprResult ParseUnevaluatedStringLiteralExpression()
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.
@ 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...
Records and restores the CurFPFeatures state on entry/exit of compound statements.
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...
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)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
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 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 actOnDelayedExceptionSpecification(Decl *D, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member or friend function (or function template).
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc, StringLiteral *Message=nullptr)
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 ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
DiagnosticsEngine & getDiagnostics() const
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.
StringLiteral - This represents a string literal expression, e.g.
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.
bool Init(InterpState &S, CodePtr OpPC)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
@ ICIS_NoInit
No in-class initializer.
@ 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