Skip to content

Commit 44d8aa8

Browse files
committed
[clang][NFC] Convert Parser::CachedInitKind to scoped enum
1 parent 159628c commit 44d8aa8

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ enum class ParsedTemplateKind {
8484
ExplicitInstantiation
8585
};
8686

87+
enum class CachedInitKind { DefaultArgument, DefaultInitializer };
88+
8789
/// Parser - This implements a parser for the C family of languages. After
8890
/// parsing units of the grammar, productions are invoked to handle whatever has
8991
/// been read.
@@ -1646,11 +1648,6 @@ class Parser : public CodeCompletionHandler {
16461648
void DeallocateParsedClasses(ParsingClass *Class);
16471649
void PopParsingClass(Sema::ParsingClassState);
16481650

1649-
enum CachedInitKind {
1650-
CIK_DefaultArgument,
1651-
CIK_DefaultInitializer
1652-
};
1653-
16541651
NamedDecl *ParseCXXInlineMethodDef(AccessSpecifier AS,
16551652
const ParsedAttributesView &AccessAttrs,
16561653
ParsingDeclarator &D,

clang/lib/Parse/ParseCXXInlineMethods.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void Parser::ParseCXXNonStaticMemberInitializer(Decl *VarD) {
266266
ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/true);
267267
} else {
268268
// Consume everything up to (but excluding) the comma or semicolon.
269-
ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer);
269+
ConsumeAndStoreInitializer(Toks, CachedInitKind::DefaultInitializer);
270270
}
271271

272272
// Store an artificial EOF token to ensure that we don't run off the end of
@@ -1238,15 +1238,15 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks,
12381238
TPResult Result = TPResult::Error;
12391239
ConsumeToken();
12401240
switch (CIK) {
1241-
case CIK_DefaultInitializer:
1241+
case CachedInitKind::DefaultInitializer:
12421242
Result = TryParseInitDeclaratorList();
12431243
// If we parsed a complete, ambiguous init-declarator-list, this
12441244
// is only syntactically-valid if it's followed by a semicolon.
12451245
if (Result == TPResult::Ambiguous && Tok.isNot(tok::semi))
12461246
Result = TPResult::False;
12471247
break;
12481248

1249-
case CIK_DefaultArgument:
1249+
case CachedInitKind::DefaultArgument:
12501250
bool InvalidAsDeclaration = false;
12511251
Result = TryParseParameterDeclarationClause(
12521252
&InvalidAsDeclaration, /*VersusTemplateArg=*/true);
@@ -1372,7 +1372,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks,
13721372
// and return it. Otherwise, this is a spurious RHS token, which we
13731373
// consume and pass on to downstream code to diagnose.
13741374
case tok::r_paren:
1375-
if (CIK == CIK_DefaultArgument)
1375+
if (CIK == CachedInitKind::DefaultArgument)
13761376
return true; // End of the default argument.
13771377
if (ParenCount && !IsFirstToken)
13781378
return false;
@@ -1406,7 +1406,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens &Toks,
14061406
ConsumeStringToken();
14071407
break;
14081408
case tok::semi:
1409-
if (CIK == CIK_DefaultInitializer)
1409+
if (CIK == CachedInitKind::DefaultInitializer)
14101410
return true; // End of the default initializer.
14111411
[[fallthrough]];
14121412
default:

clang/lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8156,7 +8156,8 @@ void Parser::ParseParameterDeclarationClause(
81568156
DefArgToks.reset(new CachedTokens);
81578157

81588158
SourceLocation ArgStartLoc = NextToken().getLocation();
8159-
ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
8159+
ConsumeAndStoreInitializer(*DefArgToks,
8160+
CachedInitKind::DefaultArgument);
81608161
Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
81618162
ArgStartLoc);
81628163
} else {

0 commit comments

Comments
 (0)