|
23 | 23 | #include "swift/AST/AvailabilityRange.h" |
24 | 24 | #include "swift/AST/ConcreteDeclRef.h" |
25 | 25 | #include "swift/AST/DeclNameLoc.h" |
| 26 | +#include "swift/AST/DiagnosticGroups.h" |
26 | 27 | #include "swift/AST/Identifier.h" |
27 | 28 | #include "swift/AST/KnownProtocols.h" |
28 | 29 | #include "swift/AST/LifetimeDependence.h" |
@@ -3564,6 +3565,40 @@ class NonexhaustiveAttr : public DeclAttribute { |
3564 | 3565 | } |
3565 | 3566 | }; |
3566 | 3567 |
|
| 3568 | +class WarnAttr : public DeclAttribute { |
| 3569 | +public: |
| 3570 | + enum class Behavior : uint8_t { Error, Warning, Ignored }; |
| 3571 | + |
| 3572 | + WarnAttr(DiagGroupID DiagnosticGroupID, Behavior Behavior, |
| 3573 | + std::optional<StringRef> Reason, SourceLoc AtLoc, SourceRange Range, |
| 3574 | + bool Implicit) |
| 3575 | + : DeclAttribute(DeclAttrKind::Warn, AtLoc, Range, Implicit), |
| 3576 | + DiagnosticBehavior(Behavior), DiagnosticGroupID(DiagnosticGroupID), |
| 3577 | + Reason(Reason) {} |
| 3578 | + |
| 3579 | + WarnAttr(DiagGroupID DiagnosticGroupID, Behavior Behavior, bool Implicit) |
| 3580 | + : WarnAttr(DiagnosticGroupID, Behavior, std::nullopt, SourceLoc(), |
| 3581 | + SourceRange(), Implicit) {} |
| 3582 | + |
| 3583 | + Behavior DiagnosticBehavior; |
| 3584 | + DiagGroupID DiagnosticGroupID; |
| 3585 | + const std::optional<StringRef> Reason; |
| 3586 | + |
| 3587 | + static bool classof(const DeclAttribute *DA) { |
| 3588 | + return DA->getKind() == DeclAttrKind::Warn; |
| 3589 | + } |
| 3590 | + |
| 3591 | + WarnAttr *clone(ASTContext &ctx) const { |
| 3592 | + return new (ctx) WarnAttr(DiagnosticGroupID, DiagnosticBehavior, Reason, |
| 3593 | + AtLoc, Range, isImplicit()); |
| 3594 | + } |
| 3595 | + |
| 3596 | + bool isEquivalent(const WarnAttr *other, |
| 3597 | + Decl *attachedTo) const { |
| 3598 | + return Reason == other->Reason; |
| 3599 | + } |
| 3600 | +}; |
| 3601 | + |
3567 | 3602 |
|
3568 | 3603 | /// The kind of unary operator, if any. |
3569 | 3604 | enum class UnaryOperatorKind : uint8_t { None, Prefix, Postfix }; |
|
0 commit comments