File tree Expand file tree Collapse file tree 4 files changed +31
-20
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 4 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -428,14 +428,29 @@ namespace swift {
428428
429429 // / Describes the current behavior to take with a diagnostic.
430430 // / Ordered from most severe to least.
431- enum class DiagnosticBehavior : uint8_t {
432- Unspecified = 0 ,
433- Fatal,
434- Error,
435- Warning,
436- Remark,
437- Note,
438- Ignore,
431+ struct DiagnosticBehavior {
432+ enum Kind : uint8_t {
433+ Unspecified = 0 ,
434+ Fatal,
435+ Error,
436+ Warning,
437+ Remark,
438+ Note,
439+ Ignore,
440+ };
441+
442+ Kind kind;
443+
444+ DiagnosticBehavior () : kind(Unspecified) {}
445+ DiagnosticBehavior (Kind kind) : kind(kind) {}
446+ operator Kind () const { return kind; }
447+
448+ // / Move up the lattice returning the max value.
449+ DiagnosticBehavior merge (DiagnosticBehavior other) const {
450+ auto value = std::max (std::underlying_type<Kind>::type (*this ),
451+ std::underlying_type<Kind>::type (other));
452+ return Kind (value);
453+ }
439454 };
440455
441456 struct DiagnosticFormatOptions {
Original file line number Diff line number Diff line change 4545
4646namespace swift {
4747
48- enum class DiagnosticBehavior : uint8_t ;
48+ struct DiagnosticBehavior ;
4949
5050 // / Kind of implicit platform conditions.
5151 enum class PlatformConditionKind {
52- #define PLATFORM_CONDITION (LABEL, IDENTIFIER ) LABEL,
53- #include " swift/AST/PlatformConditionKinds.def"
52+ #define PLATFORM_CONDITION (LABEL, IDENTIFIER ) LABEL,
53+ #include " swift/AST/PlatformConditionKinds.def"
5454 };
5555
5656 // / Describes how strict concurrency checking should be.
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class SourceFile;
2929class NominalTypeDecl ;
3030class VarDecl ;
3131
32- enum class DiagnosticBehavior : uint8_t ;
32+ struct DiagnosticBehavior ;
3333
3434// / If any of the imports in this source file was @preconcurrency but there were
3535// / no diagnostics downgraded or suppressed due to that @preconcurrency, suggest
Original file line number Diff line number Diff line change @@ -122,16 +122,12 @@ getDiagnosticBehaviorLimitForCapturedValue(CapturedValue value) {
122122static std::optional<DiagnosticBehavior>
123123getDiagnosticBehaviorLimitForCapturedValues (
124124 ArrayRef<CapturedValue> capturedValues) {
125- using UnderlyingType = std::underlying_type<DiagnosticBehavior>::type;
126-
127125 std::optional<DiagnosticBehavior> diagnosticBehavior;
128126 for (auto value : capturedValues) {
129- auto lhs = UnderlyingType (
130- diagnosticBehavior.value_or (DiagnosticBehavior::Unspecified));
131- auto rhs = UnderlyingType (
132- getDiagnosticBehaviorLimitForCapturedValue (value).value_or (
133- DiagnosticBehavior::Unspecified));
134- auto result = DiagnosticBehavior (std::max (lhs, rhs));
127+ auto lhs = diagnosticBehavior.value_or (DiagnosticBehavior::Unspecified);
128+ auto rhs = getDiagnosticBehaviorLimitForCapturedValue (value).value_or (
129+ DiagnosticBehavior::Unspecified);
130+ auto result = lhs.merge (rhs);
135131 if (result != DiagnosticBehavior::Unspecified)
136132 diagnosticBehavior = result;
137133 }
You can’t perform that action at this time.
0 commit comments