@@ -1773,12 +1773,11 @@ bool Parser::MightBeDeclarator(DeclaratorContext Context) {
17731773 return getLangOpts ().CPlusPlus ;
17741774
17751775 case tok::l_square: // Might be an attribute on an unnamed bit-field.
1776- return Context == DeclaratorContext::MemberContext &&
1777- getLangOpts (). CPlusPlus11 && NextToken ().is (tok::l_square);
1776+ return Context == DeclaratorContext::Member && getLangOpts (). CPlusPlus11 &&
1777+ NextToken ().is (tok::l_square);
17781778
17791779 case tok::colon: // Might be a typo for '::' or an unnamed bit-field.
1780- return Context == DeclaratorContext::MemberContext ||
1781- getLangOpts ().CPlusPlus ;
1780+ return Context == DeclaratorContext::Member || getLangOpts ().CPlusPlus ;
17821781
17831782 case tok::identifier:
17841783 switch (NextToken ().getKind ()) {
@@ -1804,9 +1803,8 @@ bool Parser::MightBeDeclarator(DeclaratorContext Context) {
18041803 // At namespace scope, 'identifier:' is probably a typo for 'identifier::'
18051804 // and in block scope it's probably a label. Inside a class definition,
18061805 // this is a bit-field.
1807- return Context == DeclaratorContext::MemberContext ||
1808- (getLangOpts ().CPlusPlus &&
1809- Context == DeclaratorContext::FileContext);
1806+ return Context == DeclaratorContext::Member ||
1807+ (getLangOpts ().CPlusPlus && Context == DeclaratorContext::File);
18101808
18111809 case tok::identifier: // Possible virt-specifier.
18121810 return getLangOpts ().CPlusPlus11 && isCXX11VirtSpecifier (NextToken ());
@@ -1964,7 +1962,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
19641962 // Function definitions are only allowed at file scope and in C++ classes.
19651963 // The C++ inline method definition case is handled elsewhere, so we only
19661964 // need to handle the file scope definition case.
1967- if (Context == DeclaratorContext::FileContext ) {
1965+ if (Context == DeclaratorContext::File ) {
19681966 if (isStartOfFunctionDefinition (D)) {
19691967 if (DS.getStorageClassSpec () == DeclSpec::SCS_typedef) {
19701968 Diag (Tok, diag::err_function_declared_typedef);
@@ -2043,7 +2041,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
20432041 if (FirstDecl)
20442042 DeclsInGroup.push_back (FirstDecl);
20452043
2046- bool ExpectSemi = Context != DeclaratorContext::ForContext ;
2044+ bool ExpectSemi = Context != DeclaratorContext::ForInit ;
20472045
20482046 // If we don't have a comma, it is either the end of the list (a ';') or an
20492047 // error, bail out.
@@ -2094,10 +2092,10 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
20942092 if (DeclEnd)
20952093 *DeclEnd = Tok.getLocation ();
20962094
2097- if (ExpectSemi &&
2098- ExpectAndConsumeSemi ( Context == DeclaratorContext::FileContext
2099- ? diag::err_invalid_token_after_toplevel_declarator
2100- : diag::err_expected_semi_declaration)) {
2095+ if (ExpectSemi && ExpectAndConsumeSemi (
2096+ Context == DeclaratorContext::File
2097+ ? diag::err_invalid_token_after_toplevel_declarator
2098+ : diag::err_expected_semi_declaration)) {
21012099 // Okay, there was no semicolon and one was expected. If we see a
21022100 // declaration specifier, just assume it was missing and continue parsing.
21032101 // Otherwise things are very confused and we skip to recover.
@@ -2303,8 +2301,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
23032301 if (Init.isInvalid ()) {
23042302 SmallVector<tok::TokenKind, 2 > StopTokens;
23052303 StopTokens.push_back (tok::comma);
2306- if (D.getContext () == DeclaratorContext::ForContext ||
2307- D.getContext () == DeclaratorContext::InitStmtContext )
2304+ if (D.getContext () == DeclaratorContext::ForInit ||
2305+ D.getContext () == DeclaratorContext::SelectionInit )
23082306 StopTokens.push_back (tok::r_paren);
23092307 SkipUntil (StopTokens, StopAtSemi | StopBeforeMatch);
23102308 Actions.ActOnInitializerError (ThisDecl);
@@ -2711,20 +2709,20 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
27112709// / DeclaratorContext enumerator values.
27122710Parser::DeclSpecContext
27132711Parser::getDeclSpecContextFromDeclaratorContext (DeclaratorContext Context) {
2714- if (Context == DeclaratorContext::MemberContext )
2712+ if (Context == DeclaratorContext::Member )
27152713 return DeclSpecContext::DSC_class;
2716- if (Context == DeclaratorContext::FileContext )
2714+ if (Context == DeclaratorContext::File )
27172715 return DeclSpecContext::DSC_top_level;
2718- if (Context == DeclaratorContext::TemplateParamContext )
2716+ if (Context == DeclaratorContext::TemplateParam )
27192717 return DeclSpecContext::DSC_template_param;
2720- if (Context == DeclaratorContext::TemplateArgContext ||
2721- Context == DeclaratorContext::TemplateTypeArgContext )
2718+ if (Context == DeclaratorContext::TemplateArg ||
2719+ Context == DeclaratorContext::TemplateTypeArg )
27222720 return DeclSpecContext::DSC_template_type_arg;
2723- if (Context == DeclaratorContext::TrailingReturnContext ||
2724- Context == DeclaratorContext::TrailingReturnVarContext )
2721+ if (Context == DeclaratorContext::TrailingReturn ||
2722+ Context == DeclaratorContext::TrailingReturnVar )
27252723 return DeclSpecContext::DSC_trailing;
2726- if (Context == DeclaratorContext::AliasDeclContext ||
2727- Context == DeclaratorContext::AliasTemplateContext )
2724+ if (Context == DeclaratorContext::AliasDecl ||
2725+ Context == DeclaratorContext::AliasTemplate )
27282726 return DeclSpecContext::DSC_alias_declaration;
27292727 return DeclSpecContext::DSC_normal;
27302728}
@@ -4475,7 +4473,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
44754473 // declares 'enum E : int; E *p;' not 'enum E : int*; E p;'.
44764474 DeclSpec DS (AttrFactory);
44774475 ParseSpecifierQualifierList (DS, AS, DeclSpecContext::DSC_type_specifier);
4478- Declarator DeclaratorInfo (DS, DeclaratorContext::TypeNameContext );
4476+ Declarator DeclaratorInfo (DS, DeclaratorContext::TypeName );
44794477 BaseType = Actions.ActOnTypeName (getCurScope (), DeclaratorInfo);
44804478
44814479 BaseRange = SourceRange (ColonLoc, DeclaratorInfo.getSourceRange ().getEnd ());
@@ -5575,9 +5573,8 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang,
55755573 // (The same thing can in theory happen after a trailing-return-type, but
55765574 // since those are a C++11 feature, there is no rejects-valid issue there.)
55775575 if (Kind == tok::ampamp)
5578- return Lang.CPlusPlus11 ||
5579- (TheContext != DeclaratorContext::ConversionIdContext &&
5580- TheContext != DeclaratorContext::CXXNewContext);
5576+ return Lang.CPlusPlus11 || (TheContext != DeclaratorContext::ConversionId &&
5577+ TheContext != DeclaratorContext::CXXNew);
55815578
55825579 return false ;
55835580}
@@ -5631,9 +5628,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
56315628 (Tok.is (tok::identifier) &&
56325629 (NextToken ().is (tok::coloncolon) || NextToken ().is (tok::less))) ||
56335630 Tok.is (tok::annot_cxxscope))) {
5634- bool EnteringContext =
5635- D.getContext () == DeclaratorContext::FileContext ||
5636- D.getContext () == DeclaratorContext::MemberContext;
5631+ bool EnteringContext = D.getContext () == DeclaratorContext::File ||
5632+ D.getContext () == DeclaratorContext::Member;
56375633 CXXScopeSpec SS;
56385634 ParseOptionalCXXScopeSpecifier (SS, /* ObjectType=*/ nullptr ,
56395635 /* ObjectHadErrors=*/ false , EnteringContext);
@@ -5705,7 +5701,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
57055701 // GNU attributes are not allowed here in a new-type-id, but Declspec and
57065702 // C++11 attributes are allowed.
57075703 unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
5708- ((D.getContext () != DeclaratorContext::CXXNewContext )
5704+ ((D.getContext () != DeclaratorContext::CXXNew )
57095705 ? AR_GNUAttributesParsed
57105706 : AR_GNUAttributesParsedAndRejected);
57115707 ParseTypeQualifierListOpt (DS, Reqs, true , !D.mayOmitIdentifier ());
@@ -5855,15 +5851,14 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
58555851 // this context it is a bitfield. Also in range-based for statement colon
58565852 // may delimit for-range-declaration.
58575853 ColonProtectionRAIIObject X (
5858- *this , D.getContext () == DeclaratorContext::MemberContext ||
5859- (D.getContext () == DeclaratorContext::ForContext &&
5854+ *this , D.getContext () == DeclaratorContext::Member ||
5855+ (D.getContext () == DeclaratorContext::ForInit &&
58605856 getLangOpts ().CPlusPlus11 ));
58615857
58625858 // ParseDeclaratorInternal might already have parsed the scope.
58635859 if (D.getCXXScopeSpec ().isEmpty ()) {
5864- bool EnteringContext =
5865- D.getContext () == DeclaratorContext::FileContext ||
5866- D.getContext () == DeclaratorContext::MemberContext;
5860+ bool EnteringContext = D.getContext () == DeclaratorContext::File ||
5861+ D.getContext () == DeclaratorContext::Member;
58675862 ParseOptionalCXXScopeSpecifier (
58685863 D.getCXXScopeSpec (), /* ObjectType=*/ nullptr ,
58695864 /* ObjectHadErrors=*/ false , EnteringContext);
@@ -5893,11 +5888,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
58935888 // been expanded or contains auto; otherwise, it is parsed as part of the
58945889 // parameter-declaration-clause.
58955890 if (Tok.is (tok::ellipsis) && D.getCXXScopeSpec ().isEmpty () &&
5896- !((D.getContext () == DeclaratorContext::PrototypeContext ||
5897- D.getContext () == DeclaratorContext::LambdaExprParameterContext ||
5898- D.getContext () == DeclaratorContext::BlockLiteralContext) &&
5899- NextToken ().is (tok::r_paren) &&
5900- !D.hasGroupingParens () &&
5891+ !((D.getContext () == DeclaratorContext::Prototype ||
5892+ D.getContext () == DeclaratorContext::LambdaExprParameter ||
5893+ D.getContext () == DeclaratorContext::BlockLiteral) &&
5894+ NextToken ().is (tok::r_paren) && !D.hasGroupingParens () &&
59015895 !Actions.containsUnexpandedParameterPacks (D) &&
59025896 D.getDeclSpec ().getTypeSpecType () != TST_auto)) {
59035897 SourceLocation EllipsisLoc = ConsumeToken ();
@@ -5926,16 +5920,13 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
59265920 AllowConstructorName = false ;
59275921 AllowDeductionGuide = false ;
59285922 } else if (D.getCXXScopeSpec ().isSet ()) {
5929- AllowConstructorName =
5930- (D.getContext () == DeclaratorContext::FileContext ||
5931- D.getContext () == DeclaratorContext::MemberContext);
5923+ AllowConstructorName = (D.getContext () == DeclaratorContext::File ||
5924+ D.getContext () == DeclaratorContext::Member);
59325925 AllowDeductionGuide = false ;
59335926 } else {
5934- AllowConstructorName =
5935- (D.getContext () == DeclaratorContext::MemberContext);
5936- AllowDeductionGuide =
5937- (D.getContext () == DeclaratorContext::FileContext ||
5938- D.getContext () == DeclaratorContext::MemberContext);
5927+ AllowConstructorName = (D.getContext () == DeclaratorContext::Member);
5928+ AllowDeductionGuide = (D.getContext () == DeclaratorContext::File ||
5929+ D.getContext () == DeclaratorContext::Member);
59395930 }
59405931
59415932 bool HadScope = D.getCXXScopeSpec ().isValid ();
@@ -5991,16 +5982,16 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
59915982 // An identifier within parens is unlikely to be intended to be anything
59925983 // other than a name being "declared".
59935984 DiagnoseIdentifier = true ;
5994- else if (D.getContext () == DeclaratorContext::TemplateArgContext )
5985+ else if (D.getContext () == DeclaratorContext::TemplateArg )
59955986 // T<int N> is an accidental identifier; T<int N indicates a missing '>'.
59965987 DiagnoseIdentifier =
59975988 NextToken ().isOneOf (tok::comma, tok::greater, tok::greatergreater);
5998- else if (D.getContext () == DeclaratorContext::AliasDeclContext ||
5999- D.getContext () == DeclaratorContext::AliasTemplateContext )
5989+ else if (D.getContext () == DeclaratorContext::AliasDecl ||
5990+ D.getContext () == DeclaratorContext::AliasTemplate )
60005991 // The most likely error is that the ';' was forgotten.
60015992 DiagnoseIdentifier = NextToken ().isOneOf (tok::comma, tok::semi);
6002- else if ((D.getContext () == DeclaratorContext::TrailingReturnContext ||
6003- D.getContext () == DeclaratorContext::TrailingReturnVarContext ) &&
5993+ else if ((D.getContext () == DeclaratorContext::TrailingReturn ||
5994+ D.getContext () == DeclaratorContext::TrailingReturnVar ) &&
60045995 !isCXX11VirtSpecifier (Tok))
60055996 DiagnoseIdentifier = NextToken ().isOneOf (
60065997 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
@@ -6059,7 +6050,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
60596050 LLVM_BUILTIN_TRAP;
60606051 if (Tok.is (tok::l_square))
60616052 return ParseMisplacedBracketDeclarator (D);
6062- if (D.getContext () == DeclaratorContext::MemberContext ) {
6053+ if (D.getContext () == DeclaratorContext::Member ) {
60636054 // Objective-C++: Detect C++ keywords and try to prevent further errors by
60646055 // treating these keyword as valid member names.
60656056 if (getLangOpts ().ObjC && getLangOpts ().CPlusPlus &&
@@ -6350,13 +6341,14 @@ void Parser::InitCXXThisScopeForDeclaratorIfRelevant(
63506341 // and the end of the function-definition, member-declarator, or
63516342 // declarator.
63526343 // FIXME: currently, "static" case isn't handled correctly.
6353- bool IsCXX11MemberFunction = getLangOpts ().CPlusPlus11 &&
6354- D.getDeclSpec ().getStorageClassSpec () != DeclSpec::SCS_typedef &&
6355- (D.getContext () == DeclaratorContext::MemberContext
6356- ? !D.getDeclSpec ().isFriendSpecified ()
6357- : D.getContext () == DeclaratorContext::FileContext &&
6358- D.getCXXScopeSpec ().isValid () &&
6359- Actions.CurContext ->isRecord ());
6344+ bool IsCXX11MemberFunction =
6345+ getLangOpts ().CPlusPlus11 &&
6346+ D.getDeclSpec ().getStorageClassSpec () != DeclSpec::SCS_typedef &&
6347+ (D.getContext () == DeclaratorContext::Member
6348+ ? !D.getDeclSpec ().isFriendSpecified ()
6349+ : D.getContext () == DeclaratorContext::File &&
6350+ D.getCXXScopeSpec ().isValid () &&
6351+ Actions.CurContext ->isRecord ());
63606352 if (!IsCXX11MemberFunction)
63616353 return ;
63626354
@@ -6758,11 +6750,11 @@ void Parser::ParseParameterDeclarationClause(
67586750 // "LambdaExprParameterContext", because we must accept either
67596751 // 'declarator' or 'abstract-declarator' here.
67606752 Declarator ParmDeclarator (
6761- DS, DeclaratorCtx == DeclaratorContext::RequiresExprContext
6762- ? DeclaratorContext::RequiresExprContext
6763- : DeclaratorCtx == DeclaratorContext::LambdaExprContext
6764- ? DeclaratorContext::LambdaExprParameterContext
6765- : DeclaratorContext::PrototypeContext );
6753+ DS, DeclaratorCtx == DeclaratorContext::RequiresExpr
6754+ ? DeclaratorContext::RequiresExpr
6755+ : DeclaratorCtx == DeclaratorContext::LambdaExpr
6756+ ? DeclaratorContext::LambdaExprParameter
6757+ : DeclaratorContext::Prototype );
67666758 ParseDeclarator (ParmDeclarator);
67676759
67686760 // Parse GNU attributes, if present.
@@ -6841,7 +6833,7 @@ void Parser::ParseParameterDeclarationClause(
68416833 SourceLocation EqualLoc = Tok.getLocation ();
68426834
68436835 // Parse the default argument
6844- if (DeclaratorCtx == DeclaratorContext::MemberContext ) {
6836+ if (DeclaratorCtx == DeclaratorContext::Member ) {
68456837 // If we're inside a class definition, cache the tokens
68466838 // corresponding to the default argument. We'll actually parse
68476839 // them when we see the end of the class definition.
0 commit comments