@@ -1773,12 +1773,11 @@ bool Parser::MightBeDeclarator(DeclaratorContext Context) {
1773
1773
return getLangOpts ().CPlusPlus ;
1774
1774
1775
1775
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);
1778
1778
1779
1779
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 ;
1782
1781
1783
1782
case tok::identifier:
1784
1783
switch (NextToken ().getKind ()) {
@@ -1804,9 +1803,8 @@ bool Parser::MightBeDeclarator(DeclaratorContext Context) {
1804
1803
// At namespace scope, 'identifier:' is probably a typo for 'identifier::'
1805
1804
// and in block scope it's probably a label. Inside a class definition,
1806
1805
// 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);
1810
1808
1811
1809
case tok::identifier: // Possible virt-specifier.
1812
1810
return getLangOpts ().CPlusPlus11 && isCXX11VirtSpecifier (NextToken ());
@@ -1964,7 +1962,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
1964
1962
// Function definitions are only allowed at file scope and in C++ classes.
1965
1963
// The C++ inline method definition case is handled elsewhere, so we only
1966
1964
// need to handle the file scope definition case.
1967
- if (Context == DeclaratorContext::FileContext ) {
1965
+ if (Context == DeclaratorContext::File ) {
1968
1966
if (isStartOfFunctionDefinition (D)) {
1969
1967
if (DS.getStorageClassSpec () == DeclSpec::SCS_typedef) {
1970
1968
Diag (Tok, diag::err_function_declared_typedef);
@@ -2043,7 +2041,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
2043
2041
if (FirstDecl)
2044
2042
DeclsInGroup.push_back (FirstDecl);
2045
2043
2046
- bool ExpectSemi = Context != DeclaratorContext::ForContext ;
2044
+ bool ExpectSemi = Context != DeclaratorContext::ForInit ;
2047
2045
2048
2046
// If we don't have a comma, it is either the end of the list (a ';') or an
2049
2047
// error, bail out.
@@ -2094,10 +2092,10 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
2094
2092
if (DeclEnd)
2095
2093
*DeclEnd = Tok.getLocation ();
2096
2094
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)) {
2101
2099
// Okay, there was no semicolon and one was expected. If we see a
2102
2100
// declaration specifier, just assume it was missing and continue parsing.
2103
2101
// Otherwise things are very confused and we skip to recover.
@@ -2303,8 +2301,8 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
2303
2301
if (Init.isInvalid ()) {
2304
2302
SmallVector<tok::TokenKind, 2 > StopTokens;
2305
2303
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 )
2308
2306
StopTokens.push_back (tok::r_paren);
2309
2307
SkipUntil (StopTokens, StopAtSemi | StopBeforeMatch);
2310
2308
Actions.ActOnInitializerError (ThisDecl);
@@ -2711,20 +2709,20 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2711
2709
// / DeclaratorContext enumerator values.
2712
2710
Parser::DeclSpecContext
2713
2711
Parser::getDeclSpecContextFromDeclaratorContext (DeclaratorContext Context) {
2714
- if (Context == DeclaratorContext::MemberContext )
2712
+ if (Context == DeclaratorContext::Member )
2715
2713
return DeclSpecContext::DSC_class;
2716
- if (Context == DeclaratorContext::FileContext )
2714
+ if (Context == DeclaratorContext::File )
2717
2715
return DeclSpecContext::DSC_top_level;
2718
- if (Context == DeclaratorContext::TemplateParamContext )
2716
+ if (Context == DeclaratorContext::TemplateParam )
2719
2717
return DeclSpecContext::DSC_template_param;
2720
- if (Context == DeclaratorContext::TemplateArgContext ||
2721
- Context == DeclaratorContext::TemplateTypeArgContext )
2718
+ if (Context == DeclaratorContext::TemplateArg ||
2719
+ Context == DeclaratorContext::TemplateTypeArg )
2722
2720
return DeclSpecContext::DSC_template_type_arg;
2723
- if (Context == DeclaratorContext::TrailingReturnContext ||
2724
- Context == DeclaratorContext::TrailingReturnVarContext )
2721
+ if (Context == DeclaratorContext::TrailingReturn ||
2722
+ Context == DeclaratorContext::TrailingReturnVar )
2725
2723
return DeclSpecContext::DSC_trailing;
2726
- if (Context == DeclaratorContext::AliasDeclContext ||
2727
- Context == DeclaratorContext::AliasTemplateContext )
2724
+ if (Context == DeclaratorContext::AliasDecl ||
2725
+ Context == DeclaratorContext::AliasTemplate )
2728
2726
return DeclSpecContext::DSC_alias_declaration;
2729
2727
return DeclSpecContext::DSC_normal;
2730
2728
}
@@ -4475,7 +4473,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
4475
4473
// declares 'enum E : int; E *p;' not 'enum E : int*; E p;'.
4476
4474
DeclSpec DS (AttrFactory);
4477
4475
ParseSpecifierQualifierList (DS, AS, DeclSpecContext::DSC_type_specifier);
4478
- Declarator DeclaratorInfo (DS, DeclaratorContext::TypeNameContext );
4476
+ Declarator DeclaratorInfo (DS, DeclaratorContext::TypeName );
4479
4477
BaseType = Actions.ActOnTypeName (getCurScope (), DeclaratorInfo);
4480
4478
4481
4479
BaseRange = SourceRange (ColonLoc, DeclaratorInfo.getSourceRange ().getEnd ());
@@ -5575,9 +5573,8 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang,
5575
5573
// (The same thing can in theory happen after a trailing-return-type, but
5576
5574
// since those are a C++11 feature, there is no rejects-valid issue there.)
5577
5575
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);
5581
5578
5582
5579
return false ;
5583
5580
}
@@ -5631,9 +5628,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
5631
5628
(Tok.is (tok::identifier) &&
5632
5629
(NextToken ().is (tok::coloncolon) || NextToken ().is (tok::less))) ||
5633
5630
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;
5637
5633
CXXScopeSpec SS;
5638
5634
ParseOptionalCXXScopeSpecifier (SS, /* ObjectType=*/ nullptr ,
5639
5635
/* ObjectHadErrors=*/ false , EnteringContext);
@@ -5705,7 +5701,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
5705
5701
// GNU attributes are not allowed here in a new-type-id, but Declspec and
5706
5702
// C++11 attributes are allowed.
5707
5703
unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
5708
- ((D.getContext () != DeclaratorContext::CXXNewContext )
5704
+ ((D.getContext () != DeclaratorContext::CXXNew )
5709
5705
? AR_GNUAttributesParsed
5710
5706
: AR_GNUAttributesParsedAndRejected);
5711
5707
ParseTypeQualifierListOpt (DS, Reqs, true , !D.mayOmitIdentifier ());
@@ -5855,15 +5851,14 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5855
5851
// this context it is a bitfield. Also in range-based for statement colon
5856
5852
// may delimit for-range-declaration.
5857
5853
ColonProtectionRAIIObject X (
5858
- *this , D.getContext () == DeclaratorContext::MemberContext ||
5859
- (D.getContext () == DeclaratorContext::ForContext &&
5854
+ *this , D.getContext () == DeclaratorContext::Member ||
5855
+ (D.getContext () == DeclaratorContext::ForInit &&
5860
5856
getLangOpts ().CPlusPlus11 ));
5861
5857
5862
5858
// ParseDeclaratorInternal might already have parsed the scope.
5863
5859
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;
5867
5862
ParseOptionalCXXScopeSpecifier (
5868
5863
D.getCXXScopeSpec (), /* ObjectType=*/ nullptr ,
5869
5864
/* ObjectHadErrors=*/ false , EnteringContext);
@@ -5893,11 +5888,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5893
5888
// been expanded or contains auto; otherwise, it is parsed as part of the
5894
5889
// parameter-declaration-clause.
5895
5890
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 () &&
5901
5895
!Actions.containsUnexpandedParameterPacks (D) &&
5902
5896
D.getDeclSpec ().getTypeSpecType () != TST_auto)) {
5903
5897
SourceLocation EllipsisLoc = ConsumeToken ();
@@ -5926,16 +5920,13 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5926
5920
AllowConstructorName = false ;
5927
5921
AllowDeductionGuide = false ;
5928
5922
} 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);
5932
5925
AllowDeductionGuide = false ;
5933
5926
} 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);
5939
5930
}
5940
5931
5941
5932
bool HadScope = D.getCXXScopeSpec ().isValid ();
@@ -5991,16 +5982,16 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5991
5982
// An identifier within parens is unlikely to be intended to be anything
5992
5983
// other than a name being "declared".
5993
5984
DiagnoseIdentifier = true ;
5994
- else if (D.getContext () == DeclaratorContext::TemplateArgContext )
5985
+ else if (D.getContext () == DeclaratorContext::TemplateArg )
5995
5986
// T<int N> is an accidental identifier; T<int N indicates a missing '>'.
5996
5987
DiagnoseIdentifier =
5997
5988
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 )
6000
5991
// The most likely error is that the ';' was forgotten.
6001
5992
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 ) &&
6004
5995
!isCXX11VirtSpecifier (Tok))
6005
5996
DiagnoseIdentifier = NextToken ().isOneOf (
6006
5997
tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
@@ -6059,7 +6050,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
6059
6050
LLVM_BUILTIN_TRAP;
6060
6051
if (Tok.is (tok::l_square))
6061
6052
return ParseMisplacedBracketDeclarator (D);
6062
- if (D.getContext () == DeclaratorContext::MemberContext ) {
6053
+ if (D.getContext () == DeclaratorContext::Member ) {
6063
6054
// Objective-C++: Detect C++ keywords and try to prevent further errors by
6064
6055
// treating these keyword as valid member names.
6065
6056
if (getLangOpts ().ObjC && getLangOpts ().CPlusPlus &&
@@ -6350,13 +6341,14 @@ void Parser::InitCXXThisScopeForDeclaratorIfRelevant(
6350
6341
// and the end of the function-definition, member-declarator, or
6351
6342
// declarator.
6352
6343
// 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 ());
6360
6352
if (!IsCXX11MemberFunction)
6361
6353
return ;
6362
6354
@@ -6758,11 +6750,11 @@ void Parser::ParseParameterDeclarationClause(
6758
6750
// "LambdaExprParameterContext", because we must accept either
6759
6751
// 'declarator' or 'abstract-declarator' here.
6760
6752
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 );
6766
6758
ParseDeclarator (ParmDeclarator);
6767
6759
6768
6760
// Parse GNU attributes, if present.
@@ -6841,7 +6833,7 @@ void Parser::ParseParameterDeclarationClause(
6841
6833
SourceLocation EqualLoc = Tok.getLocation ();
6842
6834
6843
6835
// Parse the default argument
6844
- if (DeclaratorCtx == DeclaratorContext::MemberContext ) {
6836
+ if (DeclaratorCtx == DeclaratorContext::Member ) {
6845
6837
// If we're inside a class definition, cache the tokens
6846
6838
// corresponding to the default argument. We'll actually parse
6847
6839
// them when we see the end of the class definition.
0 commit comments