Skip to content

Commit 5f22b84

Browse files
committed
[clang][NFC] Convert Parser::IfExistsBehavior to scoped enum
1 parent e8c684a commit 5f22b84

File tree

5 files changed

+30
-28
lines changed

5 files changed

+30
-28
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ enum class ParenParseOption {
116116
CastExpr // Also allow '(' type-name ')' <anything>
117117
};
118118

119+
/// Describes the behavior that should be taken for an __if_exists
120+
/// block.
121+
enum class IfExistsBehavior {
122+
/// Parse the block; this code is always used.
123+
Parse,
124+
/// Skip the block entirely; this code is never used.
125+
Skip,
126+
/// Parse the block as a dependent block, which may be used in
127+
/// some template instantiations but not others.
128+
Dependent
129+
};
130+
119131
/// Parser - This implements a parser for the C family of languages. After
120132
/// parsing units of the grammar, productions are invoked to handle whatever has
121133
/// been read.
@@ -2225,18 +2237,6 @@ class Parser : public CodeCompletionHandler {
22252237
SourceLocation *TrailingElseLoc,
22262238
ParsedAttributes &Attrs);
22272239

2228-
/// Describes the behavior that should be taken for an __if_exists
2229-
/// block.
2230-
enum IfExistsBehavior {
2231-
/// Parse the block; this code is always used.
2232-
IEB_Parse,
2233-
/// Skip the block entirely; this code is never used.
2234-
IEB_Skip,
2235-
/// Parse the block as a dependent block, which may be used in
2236-
/// some template instantiations but not others.
2237-
IEB_Dependent
2238-
};
2239-
22402240
/// Describes the condition of a Microsoft __if_exists or
22412241
/// __if_not_exists block.
22422242
struct IfExistsCondition {

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5289,17 +5289,17 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration(
52895289
}
52905290

52915291
switch (Result.Behavior) {
5292-
case IEB_Parse:
5292+
case IfExistsBehavior::Parse:
52935293
// Parse the declarations below.
52945294
break;
52955295

5296-
case IEB_Dependent:
5296+
case IfExistsBehavior::Dependent:
52975297
Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
52985298
<< Result.IsIfExists;
52995299
// Fall through to skip.
53005300
[[fallthrough]];
53015301

5302-
case IEB_Skip:
5302+
case IfExistsBehavior::Skip:
53035303
Braces.skipToEnd();
53045304
return;
53055305
}

clang/lib/Parse/ParseInit.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,17 +595,17 @@ bool Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
595595
}
596596

597597
switch (Result.Behavior) {
598-
case IEB_Parse:
598+
case IfExistsBehavior::Parse:
599599
// Parse the declarations below.
600600
break;
601601

602-
case IEB_Dependent:
602+
case IfExistsBehavior::Dependent:
603603
Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
604604
<< Result.IsIfExists;
605605
// Fall through to skip.
606606
[[fallthrough]];
607607

608-
case IEB_Skip:
608+
case IfExistsBehavior::Skip:
609609
Braces.skipToEnd();
610610
return false;
611611
}

clang/lib/Parse/ParseStmt.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,7 @@ void Parser::ParseMicrosoftIfExistsStatement(StmtVector &Stmts) {
28252825
// This is not the same behavior as Visual C++, which don't treat this as a
28262826
// compound statement, but for Clang's type checking we can't have anything
28272827
// inside these braces escaping to the surrounding code.
2828-
if (Result.Behavior == IEB_Dependent) {
2828+
if (Result.Behavior == IfExistsBehavior::Dependent) {
28292829
if (!Tok.is(tok::l_brace)) {
28302830
Diag(Tok, diag::err_expected) << tok::l_brace;
28312831
return;
@@ -2852,14 +2852,14 @@ void Parser::ParseMicrosoftIfExistsStatement(StmtVector &Stmts) {
28522852
}
28532853

28542854
switch (Result.Behavior) {
2855-
case IEB_Parse:
2855+
case IfExistsBehavior::Parse:
28562856
// Parse the statements below.
28572857
break;
28582858

2859-
case IEB_Dependent:
2859+
case IfExistsBehavior::Dependent:
28602860
llvm_unreachable("Dependent case handled above");
28612861

2862-
case IEB_Skip:
2862+
case IfExistsBehavior::Skip:
28632863
Braces.skipToEnd();
28642864
return;
28652865
}

clang/lib/Parse/Parser.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,15 +2435,17 @@ bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) {
24352435
Result.IsIfExists, Result.SS,
24362436
Result.Name)) {
24372437
case Sema::IER_Exists:
2438-
Result.Behavior = Result.IsIfExists ? IEB_Parse : IEB_Skip;
2438+
Result.Behavior =
2439+
Result.IsIfExists ? IfExistsBehavior::Parse : IfExistsBehavior::Skip;
24392440
break;
24402441

24412442
case Sema::IER_DoesNotExist:
2442-
Result.Behavior = !Result.IsIfExists ? IEB_Parse : IEB_Skip;
2443+
Result.Behavior =
2444+
!Result.IsIfExists ? IfExistsBehavior::Parse : IfExistsBehavior::Skip;
24432445
break;
24442446

24452447
case Sema::IER_Dependent:
2446-
Result.Behavior = IEB_Dependent;
2448+
Result.Behavior = IfExistsBehavior::Dependent;
24472449
break;
24482450

24492451
case Sema::IER_Error:
@@ -2465,14 +2467,14 @@ void Parser::ParseMicrosoftIfExistsExternalDeclaration() {
24652467
}
24662468

24672469
switch (Result.Behavior) {
2468-
case IEB_Parse:
2470+
case IfExistsBehavior::Parse:
24692471
// Parse declarations below.
24702472
break;
24712473

2472-
case IEB_Dependent:
2474+
case IfExistsBehavior::Dependent:
24732475
llvm_unreachable("Cannot have a dependent external declaration");
24742476

2475-
case IEB_Skip:
2477+
case IfExistsBehavior::Skip:
24762478
Braces.skipToEnd();
24772479
return;
24782480
}

0 commit comments

Comments
 (0)