================
@@ -171,13 +172,61 @@ class DiagnosticMapping {
 class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
 public:
   /// The level of the diagnostic, after it has been through mapping.
-  enum Level {
+  enum Level : uint8_t {
     Ignored, Note, Remark, Warning, Error, Fatal
   };
 
+  // Diagnostic classes.
+  enum Class {
+    CLASS_NOTE       = 0x01,
+    CLASS_REMARK     = 0x02,
+    CLASS_WARNING    = 0x03,
+    CLASS_EXTENSION  = 0x04,
+    CLASS_ERROR      = 0x05
+  };
+
+  struct CustomDiagDesc {
+    diag::Severity DefaultSeverity : 3 = diag::Severity::Warning;
+    unsigned Class : 3 = CLASS_WARNING;
+    unsigned ShowInSystemHeader : 1 = false;
+    unsigned ShowInSystemMacro : 1 = false;
+    unsigned HasGroup : 1 = false;
+    diag::Group Group = {};
+    std::string Description;
+
+    friend bool operator==(const CustomDiagDesc &lhs, const CustomDiagDesc 
&rhs) {
+      return lhs.DefaultSeverity == rhs.DefaultSeverity &&
+              lhs.Class == rhs.Class &&
+              lhs.ShowInSystemHeader == rhs.ShowInSystemHeader &&
+              lhs.ShowInSystemMacro == rhs.ShowInSystemMacro &&
+              lhs.HasGroup == rhs.HasGroup &&
+              (!lhs.HasGroup || lhs.Group == rhs.Group) &&
----------------
erichkeane wrote:

This little 'or' probably isn't necessary, since they'd both be default 
constructed, right?  So they'd be equal if both missing?

Also, std::tie trick would probably work here then.

That is:

`std::tie(lhs.DefaultSeverity, lhs.Class,...) == std::tie(rhs.DefaultSeverity, 
rhs.Class, ...)`

You can even create a private method of 'get-tied-version' so you could only 
type it 1x.

https://github.com/llvm/llvm-project/pull/70976
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to