@@ -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);
@@ -2710,20 +2708,20 @@ bool Parser::ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS,
2710
2708
// / DeclaratorContext enumerator values.
2711
2709
Parser::DeclSpecContext
2712
2710
Parser::getDeclSpecContextFromDeclaratorContext (DeclaratorContext Context) {
2713
- if (Context == DeclaratorContext::MemberContext )
2711
+ if (Context == DeclaratorContext::Member )
2714
2712
return DeclSpecContext::DSC_class;
2715
- if (Context == DeclaratorContext::FileContext )
2713
+ if (Context == DeclaratorContext::File )
2716
2714
return DeclSpecContext::DSC_top_level;
2717
- if (Context == DeclaratorContext::TemplateParamContext )
2715
+ if (Context == DeclaratorContext::TemplateParam )
2718
2716
return DeclSpecContext::DSC_template_param;
2719
- if (Context == DeclaratorContext::TemplateArgContext ||
2720
- Context == DeclaratorContext::TemplateTypeArgContext )
2717
+ if (Context == DeclaratorContext::TemplateArg ||
2718
+ Context == DeclaratorContext::TemplateTypeArg )
2721
2719
return DeclSpecContext::DSC_template_type_arg;
2722
- if (Context == DeclaratorContext::TrailingReturnContext ||
2723
- Context == DeclaratorContext::TrailingReturnVarContext )
2720
+ if (Context == DeclaratorContext::TrailingReturn ||
2721
+ Context == DeclaratorContext::TrailingReturnVar )
2724
2722
return DeclSpecContext::DSC_trailing;
2725
- if (Context == DeclaratorContext::AliasDeclContext ||
2726
- Context == DeclaratorContext::AliasTemplateContext )
2723
+ if (Context == DeclaratorContext::AliasDecl ||
2724
+ Context == DeclaratorContext::AliasTemplate )
2727
2725
return DeclSpecContext::DSC_alias_declaration;
2728
2726
return DeclSpecContext::DSC_normal;
2729
2727
}
@@ -4474,7 +4472,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
4474
4472
// declares 'enum E : int; E *p;' not 'enum E : int*; E p;'.
4475
4473
DeclSpec DS (AttrFactory);
4476
4474
ParseSpecifierQualifierList (DS, AS, DeclSpecContext::DSC_type_specifier);
4477
- Declarator DeclaratorInfo (DS, DeclaratorContext::TypeNameContext );
4475
+ Declarator DeclaratorInfo (DS, DeclaratorContext::TypeName );
4478
4476
BaseType = Actions.ActOnTypeName (getCurScope (), DeclaratorInfo);
4479
4477
4480
4478
BaseRange = SourceRange (ColonLoc, DeclaratorInfo.getSourceRange ().getEnd ());
@@ -5574,9 +5572,8 @@ static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang,
5574
5572
// (The same thing can in theory happen after a trailing-return-type, but
5575
5573
// since those are a C++11 feature, there is no rejects-valid issue there.)
5576
5574
if (Kind == tok::ampamp)
5577
- return Lang.CPlusPlus11 ||
5578
- (TheContext != DeclaratorContext::ConversionIdContext &&
5579
- TheContext != DeclaratorContext::CXXNewContext);
5575
+ return Lang.CPlusPlus11 || (TheContext != DeclaratorContext::ConversionId &&
5576
+ TheContext != DeclaratorContext::CXXNew);
5580
5577
5581
5578
return false ;
5582
5579
}
@@ -5630,9 +5627,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
5630
5627
(Tok.is (tok::identifier) &&
5631
5628
(NextToken ().is (tok::coloncolon) || NextToken ().is (tok::less))) ||
5632
5629
Tok.is (tok::annot_cxxscope))) {
5633
- bool EnteringContext =
5634
- D.getContext () == DeclaratorContext::FileContext ||
5635
- D.getContext () == DeclaratorContext::MemberContext;
5630
+ bool EnteringContext = D.getContext () == DeclaratorContext::File ||
5631
+ D.getContext () == DeclaratorContext::Member;
5636
5632
CXXScopeSpec SS;
5637
5633
ParseOptionalCXXScopeSpecifier (SS, /* ObjectType=*/ nullptr ,
5638
5634
/* ObjectHadErrors=*/ false , EnteringContext);
@@ -5704,7 +5700,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
5704
5700
// GNU attributes are not allowed here in a new-type-id, but Declspec and
5705
5701
// C++11 attributes are allowed.
5706
5702
unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
5707
- ((D.getContext () != DeclaratorContext::CXXNewContext )
5703
+ ((D.getContext () != DeclaratorContext::CXXNew )
5708
5704
? AR_GNUAttributesParsed
5709
5705
: AR_GNUAttributesParsedAndRejected);
5710
5706
ParseTypeQualifierListOpt (DS, Reqs, true , !D.mayOmitIdentifier ());
@@ -5854,15 +5850,14 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5854
5850
// this context it is a bitfield. Also in range-based for statement colon
5855
5851
// may delimit for-range-declaration.
5856
5852
ColonProtectionRAIIObject X (
5857
- *this , D.getContext () == DeclaratorContext::MemberContext ||
5858
- (D.getContext () == DeclaratorContext::ForContext &&
5853
+ *this , D.getContext () == DeclaratorContext::Member ||
5854
+ (D.getContext () == DeclaratorContext::ForInit &&
5859
5855
getLangOpts ().CPlusPlus11 ));
5860
5856
5861
5857
// ParseDeclaratorInternal might already have parsed the scope.
5862
5858
if (D.getCXXScopeSpec ().isEmpty ()) {
5863
- bool EnteringContext =
5864
- D.getContext () == DeclaratorContext::FileContext ||
5865
- D.getContext () == DeclaratorContext::MemberContext;
5859
+ bool EnteringContext = D.getContext () == DeclaratorContext::File ||
5860
+ D.getContext () == DeclaratorContext::Member;
5866
5861
ParseOptionalCXXScopeSpecifier (
5867
5862
D.getCXXScopeSpec (), /* ObjectType=*/ nullptr ,
5868
5863
/* ObjectHadErrors=*/ false , EnteringContext);
@@ -5892,11 +5887,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5892
5887
// been expanded or contains auto; otherwise, it is parsed as part of the
5893
5888
// parameter-declaration-clause.
5894
5889
if (Tok.is (tok::ellipsis) && D.getCXXScopeSpec ().isEmpty () &&
5895
- !((D.getContext () == DeclaratorContext::PrototypeContext ||
5896
- D.getContext () == DeclaratorContext::LambdaExprParameterContext ||
5897
- D.getContext () == DeclaratorContext::BlockLiteralContext) &&
5898
- NextToken ().is (tok::r_paren) &&
5899
- !D.hasGroupingParens () &&
5890
+ !((D.getContext () == DeclaratorContext::Prototype ||
5891
+ D.getContext () == DeclaratorContext::LambdaExprParameter ||
5892
+ D.getContext () == DeclaratorContext::BlockLiteral) &&
5893
+ NextToken ().is (tok::r_paren) && !D.hasGroupingParens () &&
5900
5894
!Actions.containsUnexpandedParameterPacks (D) &&
5901
5895
D.getDeclSpec ().getTypeSpecType () != TST_auto)) {
5902
5896
SourceLocation EllipsisLoc = ConsumeToken ();
@@ -5925,16 +5919,13 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5925
5919
AllowConstructorName = false ;
5926
5920
AllowDeductionGuide = false ;
5927
5921
} else if (D.getCXXScopeSpec ().isSet ()) {
5928
- AllowConstructorName =
5929
- (D.getContext () == DeclaratorContext::FileContext ||
5930
- D.getContext () == DeclaratorContext::MemberContext);
5922
+ AllowConstructorName = (D.getContext () == DeclaratorContext::File ||
5923
+ D.getContext () == DeclaratorContext::Member);
5931
5924
AllowDeductionGuide = false ;
5932
5925
} else {
5933
- AllowConstructorName =
5934
- (D.getContext () == DeclaratorContext::MemberContext);
5935
- AllowDeductionGuide =
5936
- (D.getContext () == DeclaratorContext::FileContext ||
5937
- D.getContext () == DeclaratorContext::MemberContext);
5926
+ AllowConstructorName = (D.getContext () == DeclaratorContext::Member);
5927
+ AllowDeductionGuide = (D.getContext () == DeclaratorContext::File ||
5928
+ D.getContext () == DeclaratorContext::Member);
5938
5929
}
5939
5930
5940
5931
bool HadScope = D.getCXXScopeSpec ().isValid ();
@@ -5990,16 +5981,16 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
5990
5981
// An identifier within parens is unlikely to be intended to be anything
5991
5982
// other than a name being "declared".
5992
5983
DiagnoseIdentifier = true ;
5993
- else if (D.getContext () == DeclaratorContext::TemplateArgContext )
5984
+ else if (D.getContext () == DeclaratorContext::TemplateArg )
5994
5985
// T<int N> is an accidental identifier; T<int N indicates a missing '>'.
5995
5986
DiagnoseIdentifier =
5996
5987
NextToken ().isOneOf (tok::comma, tok::greater, tok::greatergreater);
5997
- else if (D.getContext () == DeclaratorContext::AliasDeclContext ||
5998
- D.getContext () == DeclaratorContext::AliasTemplateContext )
5988
+ else if (D.getContext () == DeclaratorContext::AliasDecl ||
5989
+ D.getContext () == DeclaratorContext::AliasTemplate )
5999
5990
// The most likely error is that the ';' was forgotten.
6000
5991
DiagnoseIdentifier = NextToken ().isOneOf (tok::comma, tok::semi);
6001
- else if ((D.getContext () == DeclaratorContext::TrailingReturnContext ||
6002
- D.getContext () == DeclaratorContext::TrailingReturnVarContext ) &&
5992
+ else if ((D.getContext () == DeclaratorContext::TrailingReturn ||
5993
+ D.getContext () == DeclaratorContext::TrailingReturnVar ) &&
6003
5994
!isCXX11VirtSpecifier (Tok))
6004
5995
DiagnoseIdentifier = NextToken ().isOneOf (
6005
5996
tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
@@ -6058,7 +6049,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
6058
6049
LLVM_BUILTIN_TRAP;
6059
6050
if (Tok.is (tok::l_square))
6060
6051
return ParseMisplacedBracketDeclarator (D);
6061
- if (D.getContext () == DeclaratorContext::MemberContext ) {
6052
+ if (D.getContext () == DeclaratorContext::Member ) {
6062
6053
// Objective-C++: Detect C++ keywords and try to prevent further errors by
6063
6054
// treating these keyword as valid member names.
6064
6055
if (getLangOpts ().ObjC && getLangOpts ().CPlusPlus &&
@@ -6349,13 +6340,14 @@ void Parser::InitCXXThisScopeForDeclaratorIfRelevant(
6349
6340
// and the end of the function-definition, member-declarator, or
6350
6341
// declarator.
6351
6342
// FIXME: currently, "static" case isn't handled correctly.
6352
- bool IsCXX11MemberFunction = getLangOpts ().CPlusPlus11 &&
6353
- D.getDeclSpec ().getStorageClassSpec () != DeclSpec::SCS_typedef &&
6354
- (D.getContext () == DeclaratorContext::MemberContext
6355
- ? !D.getDeclSpec ().isFriendSpecified ()
6356
- : D.getContext () == DeclaratorContext::FileContext &&
6357
- D.getCXXScopeSpec ().isValid () &&
6358
- Actions.CurContext ->isRecord ());
6343
+ bool IsCXX11MemberFunction =
6344
+ getLangOpts ().CPlusPlus11 &&
6345
+ D.getDeclSpec ().getStorageClassSpec () != DeclSpec::SCS_typedef &&
6346
+ (D.getContext () == DeclaratorContext::Member
6347
+ ? !D.getDeclSpec ().isFriendSpecified ()
6348
+ : D.getContext () == DeclaratorContext::File &&
6349
+ D.getCXXScopeSpec ().isValid () &&
6350
+ Actions.CurContext ->isRecord ());
6359
6351
if (!IsCXX11MemberFunction)
6360
6352
return ;
6361
6353
@@ -6757,11 +6749,11 @@ void Parser::ParseParameterDeclarationClause(
6757
6749
// "LambdaExprParameterContext", because we must accept either
6758
6750
// 'declarator' or 'abstract-declarator' here.
6759
6751
Declarator ParmDeclarator (
6760
- DS, DeclaratorCtx == DeclaratorContext::RequiresExprContext
6761
- ? DeclaratorContext::RequiresExprContext
6762
- : DeclaratorCtx == DeclaratorContext::LambdaExprContext
6763
- ? DeclaratorContext::LambdaExprParameterContext
6764
- : DeclaratorContext::PrototypeContext );
6752
+ DS, DeclaratorCtx == DeclaratorContext::RequiresExpr
6753
+ ? DeclaratorContext::RequiresExpr
6754
+ : DeclaratorCtx == DeclaratorContext::LambdaExpr
6755
+ ? DeclaratorContext::LambdaExprParameter
6756
+ : DeclaratorContext::Prototype );
6765
6757
ParseDeclarator (ParmDeclarator);
6766
6758
6767
6759
// Parse GNU attributes, if present.
@@ -6840,7 +6832,7 @@ void Parser::ParseParameterDeclarationClause(
6840
6832
SourceLocation EqualLoc = Tok.getLocation ();
6841
6833
6842
6834
// Parse the default argument
6843
- if (DeclaratorCtx == DeclaratorContext::MemberContext ) {
6835
+ if (DeclaratorCtx == DeclaratorContext::Member ) {
6844
6836
// If we're inside a class definition, cache the tokens
6845
6837
// corresponding to the default argument. We'll actually parse
6846
6838
// them when we see the end of the class definition.
0 commit comments