Skip to content

Commit c0917ab

Browse files
committed
[clang][NFC] Convert Sema::IfExistsResult to scoped enum
1 parent f7fdc8d commit c0917ab

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,22 @@ enum class AllocationFunctionScope {
783783
Both
784784
};
785785

786+
/// Describes the result of an "if-exists" condition check.
787+
enum class IfExistsResult {
788+
/// The symbol exists.
789+
Exists,
790+
791+
/// The symbol does not exist.
792+
DoesNotExist,
793+
794+
/// The name is a dependent name, so the results will differ
795+
/// from one instantiation to the next.
796+
Dependent,
797+
798+
/// An error occurred.
799+
Error
800+
};
801+
786802
/// Sema - This implements semantic analysis and AST building for C.
787803
/// \nosubgrouping
788804
class Sema final : public SemaBase {
@@ -8667,22 +8683,6 @@ class Sema final : public SemaBase {
86678683
RecoverUncorrectedTypos, Filter);
86688684
}
86698685

8670-
/// Describes the result of an "if-exists" condition check.
8671-
enum IfExistsResult {
8672-
/// The symbol exists.
8673-
IER_Exists,
8674-
8675-
/// The symbol does not exist.
8676-
IER_DoesNotExist,
8677-
8678-
/// The name is a dependent name, so the results will differ
8679-
/// from one instantiation to the next.
8680-
IER_Dependent,
8681-
8682-
/// An error occurred.
8683-
IER_Error
8684-
};
8685-
86868686
IfExistsResult
86878687
CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
86888688
const DeclarationNameInfo &TargetNameInfo);

clang/lib/Parse/Parser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,21 +2436,21 @@ bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition& Result) {
24362436
switch (Actions.CheckMicrosoftIfExistsSymbol(getCurScope(), Result.KeywordLoc,
24372437
Result.IsIfExists, Result.SS,
24382438
Result.Name)) {
2439-
case Sema::IER_Exists:
2439+
case IfExistsResult::Exists:
24402440
Result.Behavior =
24412441
Result.IsIfExists ? IfExistsBehavior::Parse : IfExistsBehavior::Skip;
24422442
break;
24432443

2444-
case Sema::IER_DoesNotExist:
2444+
case IfExistsResult::DoesNotExist:
24452445
Result.Behavior =
24462446
!Result.IsIfExists ? IfExistsBehavior::Parse : IfExistsBehavior::Skip;
24472447
break;
24482448

2449-
case Sema::IER_Dependent:
2449+
case IfExistsResult::Dependent:
24502450
Result.Behavior = IfExistsBehavior::Dependent;
24512451
break;
24522452

2453-
case Sema::IER_Error:
2453+
case IfExistsResult::Error:
24542454
return true;
24552455
}
24562456

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9671,17 +9671,16 @@ StmtResult Sema::ActOnFinishFullStmt(Stmt *FullStmt) {
96719671
return MaybeCreateStmtWithCleanups(FullStmt);
96729672
}
96739673

9674-
Sema::IfExistsResult
9675-
Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
9676-
CXXScopeSpec &SS,
9674+
IfExistsResult
9675+
Sema::CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS,
96779676
const DeclarationNameInfo &TargetNameInfo) {
96789677
DeclarationName TargetName = TargetNameInfo.getName();
96799678
if (!TargetName)
9680-
return IER_DoesNotExist;
9679+
return IfExistsResult::DoesNotExist;
96819680

96829681
// If the name itself is dependent, then the result is dependent.
96839682
if (TargetName.isDependentName())
9684-
return IER_Dependent;
9683+
return IfExistsResult::Dependent;
96859684

96869685
// Do the redeclaration lookup in the current scope.
96879686
LookupResult R(*this, TargetNameInfo, Sema::LookupAnyName,
@@ -9694,29 +9693,30 @@ Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
96949693
case LookupResultKind::FoundOverloaded:
96959694
case LookupResultKind::FoundUnresolvedValue:
96969695
case LookupResultKind::Ambiguous:
9697-
return IER_Exists;
9696+
return IfExistsResult::Exists;
96989697

96999698
case LookupResultKind::NotFound:
9700-
return IER_DoesNotExist;
9699+
return IfExistsResult::DoesNotExist;
97019700

97029701
case LookupResultKind::NotFoundInCurrentInstantiation:
9703-
return IER_Dependent;
9702+
return IfExistsResult::Dependent;
97049703
}
97059704

97069705
llvm_unreachable("Invalid LookupResult Kind!");
97079706
}
97089707

9709-
Sema::IfExistsResult
9710-
Sema::CheckMicrosoftIfExistsSymbol(Scope *S, SourceLocation KeywordLoc,
9711-
bool IsIfExists, CXXScopeSpec &SS,
9712-
UnqualifiedId &Name) {
9708+
IfExistsResult Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
9709+
SourceLocation KeywordLoc,
9710+
bool IsIfExists,
9711+
CXXScopeSpec &SS,
9712+
UnqualifiedId &Name) {
97139713
DeclarationNameInfo TargetNameInfo = GetNameFromUnqualifiedId(Name);
97149714

97159715
// Check for an unexpanded parameter pack.
97169716
auto UPPC = IsIfExists ? UPPC_IfExists : UPPC_IfNotExists;
97179717
if (DiagnoseUnexpandedParameterPack(SS, UPPC) ||
97189718
DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC))
9719-
return IER_Error;
9719+
return IfExistsResult::Error;
97209720

97219721
return CheckMicrosoftIfExistsSymbol(S, SS, TargetNameInfo);
97229722
}

clang/lib/Sema/TreeTransform.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9292,23 +9292,23 @@ TreeTransform<Derived>::TransformMSDependentExistsStmt(
92929292
SS.Adopt(QualifierLoc);
92939293
bool Dependent = false;
92949294
switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9295-
case Sema::IER_Exists:
9295+
case IfExistsResult::Exists:
92969296
if (S->isIfExists())
92979297
break;
92989298

92999299
return new (getSema().Context) NullStmt(S->getKeywordLoc());
93009300

9301-
case Sema::IER_DoesNotExist:
9301+
case IfExistsResult::DoesNotExist:
93029302
if (S->isIfNotExists())
93039303
break;
93049304

93059305
return new (getSema().Context) NullStmt(S->getKeywordLoc());
93069306

9307-
case Sema::IER_Dependent:
9307+
case IfExistsResult::Dependent:
93089308
Dependent = true;
93099309
break;
93109310

9311-
case Sema::IER_Error:
9311+
case IfExistsResult::Error:
93129312
return StmtError();
93139313
}
93149314

0 commit comments

Comments
 (0)