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 {
428
428
429
429
// / Describes the current behavior to take with a diagnostic.
430
430
// / 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
+ }
439
454
};
440
455
441
456
struct DiagnosticFormatOptions {
Original file line number Diff line number Diff line change 45
45
46
46
namespace swift {
47
47
48
- enum class DiagnosticBehavior : uint8_t ;
48
+ struct DiagnosticBehavior ;
49
49
50
50
// / Kind of implicit platform conditions.
51
51
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"
54
54
};
55
55
56
56
// / Describes how strict concurrency checking should be.
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class SourceFile;
29
29
class NominalTypeDecl ;
30
30
class VarDecl ;
31
31
32
- enum class DiagnosticBehavior : uint8_t ;
32
+ struct DiagnosticBehavior ;
33
33
34
34
// / If any of the imports in this source file was @preconcurrency but there were
35
35
// / 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) {
122
122
static std::optional<DiagnosticBehavior>
123
123
getDiagnosticBehaviorLimitForCapturedValues (
124
124
ArrayRef<CapturedValue> capturedValues) {
125
- using UnderlyingType = std::underlying_type<DiagnosticBehavior>::type;
126
-
127
125
std::optional<DiagnosticBehavior> diagnosticBehavior;
128
126
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);
135
131
if (result != DiagnosticBehavior::Unspecified)
136
132
diagnosticBehavior = result;
137
133
}
You can’t perform that action at this time.
0 commit comments