Skip to content

Commit f2d5f38

Browse files
committed
[Refactoring] Remove ConditionType::INVALID
This will make it a little nicer to switch on ConditionType.
1 parent 63b6232 commit f2d5f38

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/IDE/Refactoring.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,12 +4410,12 @@ struct AsyncHandlerParamDesc : public AsyncHandlerDesc {
44104410
}
44114411
};
44124412

4413-
enum class ConditionType { INVALID, NIL, NOT_NIL };
4413+
enum class ConditionType { NIL, NOT_NIL };
44144414

44154415
/// Finds the `Subject` being compared to in various conditions. Also finds any
44164416
/// pattern that may have a bound name.
44174417
struct CallbackCondition {
4418-
ConditionType Type = ConditionType::INVALID;
4418+
Optional<ConditionType> Type;
44194419
const Decl *Subject = nullptr;
44204420
const Pattern *BindPattern = nullptr;
44214421
// Bit of a hack. When the `Subject` is a `Result` type we use this to
@@ -4487,7 +4487,7 @@ struct CallbackCondition {
44874487
}
44884488
}
44894489

4490-
bool isValid() const { return Type != ConditionType::INVALID; }
4490+
bool isValid() const { return Type.hasValue(); }
44914491

44924492
/// Given an `if` condition `Cond` and a set of `Decls`, find any
44934493
/// `CallbackCondition`s in `Cond` that use one of those `Decls` and add them
@@ -4886,10 +4886,10 @@ struct CallbackClassifier {
48864886
ThenBlock = ElseBlock;
48874887
ElseBlock = TempBlock;
48884888
} else {
4889-
ConditionType CondType = ConditionType::INVALID;
4889+
Optional<ConditionType> CondType;
48904890
for (auto &Entry : CallbackConditions) {
48914891
if (IsResultParam || Entry.second.Subject != ErrParam) {
4892-
if (CondType == ConditionType::INVALID) {
4892+
if (!CondType) {
48934893
CondType = Entry.second.Type;
48944894
} else if (CondType != Entry.second.Type) {
48954895
// Similar to the unknown conditions case. Add the whole if unless

0 commit comments

Comments
 (0)