Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang] Extend diagnose_if to accept more detailed warning information #70976

Merged
merged 21 commits into from
Sep 12, 2024

Conversation

philnik777
Copy link
Contributor

This implements parts of the extension proposed in https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7.

Specifically, this makes it possible to specify a diagnostic group in an optional third argument.

@philnik777 philnik777 added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Nov 1, 2023
@llvmbot llvmbot added clang Clang issues not falling into any other category clangd clang-tidy clang:modules C++20 modules and Clang Header Modules labels Nov 1, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 1, 2023

@llvm/pr-subscribers-clang-static-analyzer-1
@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-clangd
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang-tidy

Author: None (philnik777)

Changes

This implements parts of the extension proposed in https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7.

Specifically, this makes it possible to specify a diagnostic group in an optional third argument.


Patch is 51.10 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/70976.diff

25 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp (+4-4)
  • (modified) clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h (+4)
  • (modified) clang-tools-extra/clangd/Diagnostics.cpp (+4-2)
  • (modified) clang-tools-extra/clangd/ParsedAST.cpp (+1-1)
  • (modified) clang/include/clang/Basic/Attr.td (+5-8)
  • (modified) clang/include/clang/Basic/Diagnostic.h (+6-3)
  • (modified) clang/include/clang/Basic/DiagnosticCategories.h (+1)
  • (modified) clang/include/clang/Basic/DiagnosticIDs.h (+99-17)
  • (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+6)
  • (modified) clang/lib/Basic/Diagnostic.cpp (+8-7)
  • (modified) clang/lib/Basic/DiagnosticIDs.cpp (+128-104)
  • (modified) clang/lib/Frontend/LogDiagnosticPrinter.cpp (+2-2)
  • (modified) clang/lib/Frontend/SerializedDiagnosticPrinter.cpp (+2-1)
  • (modified) clang/lib/Frontend/TextDiagnosticPrinter.cpp (+5-3)
  • (modified) clang/lib/Sema/Sema.cpp (+2-2)
  • (modified) clang/lib/Sema/SemaCUDA.cpp (+2-2)
  • (modified) clang/lib/Sema/SemaDeclAttr.cpp (+17-5)
  • (modified) clang/lib/Sema/SemaOverload.cpp (+19-5)
  • (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+2-1)
  • (modified) clang/lib/Serialization/ASTReader.cpp (+1-1)
  • (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1)
  • (added) clang/test/SemaCXX/diagnose_if-warning-group.cpp (+35)
  • (modified) clang/tools/diagtool/ListWarnings.cpp (+3-4)
  • (modified) clang/tools/diagtool/ShowEnabledWarnings.cpp (+3-3)
  • (modified) clang/tools/libclang/CXStoredDiagnostic.cpp (+7-8)
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index b19a84f5dc21577..a2f78d8f060a1a3 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -177,8 +177,8 @@ DiagnosticBuilder ClangTidyContext::diag(
     StringRef CheckName, SourceLocation Loc, StringRef Description,
     DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
   assert(Loc.isValid());
-  unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
-      Level, (Description + " [" + CheckName + "]").str());
+  unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(Level,
+      (Description + " [" + CheckName + "]").str());
   CheckNamesByDiagnosticID.try_emplace(ID, CheckName);
   return DiagEngine->Report(Loc, ID);
 }
@@ -186,8 +186,8 @@ DiagnosticBuilder ClangTidyContext::diag(
 DiagnosticBuilder ClangTidyContext::diag(
     StringRef CheckName, StringRef Description,
     DiagnosticIDs::Level Level /* = DiagnosticIDs::Warning*/) {
-  unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(
-      Level, (Description + " [" + CheckName + "]").str());
+  unsigned ID = DiagEngine->getDiagnosticIDs()->getCustomDiagID(Level,
+      (Description + " [" + CheckName + "]").str());
   CheckNamesByDiagnosticID.try_emplace(ID, CheckName);
   return DiagEngine->Report(ID);
 }
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 9280eb1e1f218df..c7694ad05f03e5c 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -79,6 +79,10 @@ class ClangTidyContext {
     this->DiagEngine = DiagEngine;
   }
 
+  const DiagnosticsEngine* getDiagnosticsEngine() const {
+    return DiagEngine;
+  }
+
   ~ClangTidyContext();
 
   /// Report any errors detected using this method.
diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp
index 704e61b1e4dd792..0962fd971342fdb 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -579,7 +579,9 @@ std::vector<Diag> StoreDiags::take(const clang::tidy::ClangTidyContext *Tidy) {
   for (auto &Diag : Output) {
     if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
       // Warnings controlled by -Wfoo are better recognized by that name.
-      StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(Diag.ID);
+      StringRef Warning = Tidy->getDiagnosticsEngine()
+                              ->getDiagnosticIDs()
+                              ->getWarningOptionForDiag(Diag.ID);
       if (!Warning.empty()) {
         Diag.Name = ("-W" + Warning).str();
       } else {
@@ -909,7 +911,7 @@ bool isBuiltinDiagnosticSuppressed(unsigned ID,
     if (Suppress.contains(normalizeSuppressedCode(CodePtr)))
       return true;
   }
-  StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID);
+  StringRef Warning = DiagnosticIDs{}.getWarningOptionForDiag(ID);
   if (!Warning.empty() && Suppress.contains(Warning))
     return true;
   return false;
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index edd0f77b1031ef0..57d21fa27117933 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -340,7 +340,7 @@ void applyWarningOptions(llvm::ArrayRef<std::string> ExtraArgs,
       if (Enable) {
         if (Diags.getDiagnosticLevel(ID, SourceLocation()) <
             DiagnosticsEngine::Warning) {
-          auto Group = DiagnosticIDs::getGroupForDiag(ID);
+          auto Group = Diags.getDiagnosticIDs()->getGroupForDiag(ID);
           if (!Group || !EnabledGroups(*Group))
             continue;
           Diags.setSeverity(ID, diag::Severity::Warning, SourceLocation());
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 25231c5b82b907c..e08b7720508d40e 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2959,18 +2959,15 @@ def DiagnoseIf : InheritableAttr {
   let Spellings = [GNU<"diagnose_if">];
   let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
   let Args = [ExprArgument<"Cond">, StringArgument<"Message">,
-              EnumArgument<"DiagnosticType",
-                           "DiagnosticType",
-                           ["error", "warning"],
-                           ["DT_Error", "DT_Warning"]>,
+              EnumArgument<"DefaultSeverity",
+                           "DefaultSeverity",
+                           ["error",    "warning"],
+                           ["DS_error", "DS_warning"]>,
+              StringArgument<"WarningGroup", /*optional*/ 1>,
               BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
               DeclArgument<Named, "Parent", 0, /*fake*/ 1>];
   let InheritEvenIfAlreadyPresent = 1;
   let LateParsed = 1;
-  let AdditionalMembers = [{
-    bool isError() const { return diagnosticType == DT_Error; }
-    bool isWarning() const { return diagnosticType == DT_Warning; }
-  }];
   let TemplateDependent = 1;
   let Documentation = [DiagnoseIfDocs];
 }
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 3df037b793b3946..168e403a798a9e7 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -331,10 +331,12 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
     // Map extensions to warnings or errors?
     diag::Severity ExtBehavior = diag::Severity::Ignored;
 
-    DiagState()
+    DiagnosticIDs& DiagIDs;
+
+    DiagState(DiagnosticIDs &DiagIDs)
         : IgnoreAllWarnings(false), EnableAllWarnings(false),
           WarningsAsErrors(false), ErrorsAsFatal(false),
-          SuppressSystemWarnings(false) {}
+          SuppressSystemWarnings(false), DiagIDs(DiagIDs) {}
 
     using iterator = llvm::DenseMap<unsigned, DiagnosticMapping>::iterator;
     using const_iterator =
@@ -865,7 +867,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
   /// \param FormatString A fixed diagnostic format string that will be hashed
   /// and mapped to a unique DiagID.
   template <unsigned N>
-  unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) {
+  [[deprecated("Use a CustomDiagDesc instead of a Level")]] unsigned
+  getCustomDiagID(Level L, const char (&FormatString)[N]) {
     return Diags->getCustomDiagID((DiagnosticIDs::Level)L,
                                   StringRef(FormatString, N - 1));
   }
diff --git a/clang/include/clang/Basic/DiagnosticCategories.h b/clang/include/clang/Basic/DiagnosticCategories.h
index 14be326f7515f8f..e9a1fe87202d828 100644
--- a/clang/include/clang/Basic/DiagnosticCategories.h
+++ b/clang/include/clang/Basic/DiagnosticCategories.h
@@ -26,6 +26,7 @@ namespace clang {
 #include "clang/Basic/DiagnosticGroups.inc"
 #undef CATEGORY
 #undef DIAG_ENTRY
+      NUM_GROUPS
     };
   }  // end namespace diag
 }  // end namespace clang
diff --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index 06ef1c6904c31d1..b8aedc732fc3cd9 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_BASIC_DIAGNOSTICIDS_H
 #define LLVM_CLANG_BASIC_DIAGNOSTICIDS_H
 
+#include "clang/Basic/DiagnosticCategories.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
@@ -80,7 +81,7 @@ namespace clang {
     /// to either Ignore (nothing), Remark (emit a remark), Warning
     /// (emit a warning) or Error (emit as an error).  It allows clients to
     /// map ERRORs to Error or Fatal (stop emitting diagnostics after this one).
-    enum class Severity {
+    enum class Severity : uint8_t {
       // NOTE: 0 means "uncomputed".
       Ignored = 1, ///< Do not present this diagnostic, ignore it.
       Remark = 2,  ///< Present this diagnostic as a remark.
@@ -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) &&
+              lhs.Description == rhs.Description;
+    }
+
+    friend bool operator<(const CustomDiagDesc& lhs, const CustomDiagDesc& rhs) {
+      if (lhs.DefaultSeverity != rhs.DefaultSeverity)
+        return lhs.DefaultSeverity < rhs.DefaultSeverity;
+      if (lhs.Class != rhs.Class)
+        return lhs.Class < rhs.Class;
+      if (lhs.ShowInSystemHeader != rhs.ShowInSystemHeader)
+        return lhs.ShowInSystemHeader < rhs.ShowInSystemHeader;
+      if (lhs.ShowInSystemMacro != rhs.ShowInSystemMacro)
+        return lhs.ShowInSystemMacro < rhs.ShowInSystemMacro;
+      if (lhs.HasGroup != rhs.HasGroup)
+        return lhs.HasGroup < rhs.HasGroup;
+      if (lhs.HasGroup && lhs.Group != rhs.Group)
+        return lhs.Group < rhs.Group;
+      return lhs.Description < rhs.Description;
+    }
+  };
+
 private:
   /// Information for uniquing and looking up custom diags.
   std::unique_ptr<diag::CustomDiagInfo> CustomDiagInfo;
+  std::unique_ptr<diag::Severity[]> GroupSeverity =
+      std::make_unique<diag::Severity[]>(
+          static_cast<size_t>(diag::Group::NUM_GROUPS));
 
 public:
   DiagnosticIDs();
@@ -192,7 +241,37 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
   // FIXME: Replace this function with a create-only facilty like
   // createCustomDiagIDFromFormatString() to enforce safe usage. At the time of
   // writing, nearly all callers of this function were invalid.
-  unsigned getCustomDiagID(Level L, StringRef FormatString);
+  unsigned getCustomDiagID(CustomDiagDesc Diag);
+
+  [[deprecated("Use a CustomDiagDesc instead of a Level")]] unsigned
+  getCustomDiagID(Level Level, StringRef Message) {
+    return getCustomDiagID([&] -> CustomDiagDesc {
+      switch (Level) {
+      case DiagnosticIDs::Level::Ignored:
+        return {.DefaultSeverity = diag::Severity::Ignored,
+                .Description = std::string(Message)};
+      case DiagnosticIDs::Level::Note:
+        return {.DefaultSeverity = diag::Severity::Fatal,
+                .Class = CLASS_NOTE,
+                .Description = std::string(Message)};
+      case DiagnosticIDs::Level::Remark:
+        return {.DefaultSeverity = diag::Severity::Remark,
+                .Description = std::string(Message)};
+      case DiagnosticIDs::Level::Warning:
+        return {.DefaultSeverity = diag::Severity::Warning,
+                .Class = CLASS_WARNING,
+                .Description = std::string(Message)};
+      case DiagnosticIDs::Level::Error:
+        return {.DefaultSeverity = diag::Severity::Error,
+                .Class = CLASS_ERROR,
+                .Description = std::string(Message)};
+      case DiagnosticIDs::Level::Fatal:
+        return {.DefaultSeverity=diag::Severity::Fatal,
+                .Class = CLASS_ERROR,
+                .Description = std::string(Message)};
+      }
+    }());
+  }
 
   //===--------------------------------------------------------------------===//
   // Diagnostic classification and reporting interfaces.
@@ -204,35 +283,34 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
   /// Return true if the unmapped diagnostic levelof the specified
   /// diagnostic ID is a Warning or Extension.
   ///
-  /// This only works on builtin diagnostics, not custom ones, and is not
-  /// legal to call on NOTEs.
-  static bool isBuiltinWarningOrExtension(unsigned DiagID);
+  /// This is not legal to call on NOTEs.
+  bool isWarningOrExtension(unsigned DiagID) const;
 
   /// Return true if the specified diagnostic is mapped to errors by
   /// default.
-  static bool isDefaultMappingAsError(unsigned DiagID);
+  bool isDefaultMappingAsError(unsigned DiagID) const;
 
   /// Get the default mapping for this diagnostic.
-  static DiagnosticMapping getDefaultMapping(unsigned DiagID);
+  DiagnosticMapping getDefaultMapping(unsigned DiagID) const;
 
-  /// Determine whether the given built-in diagnostic ID is a Note.
-  static bool isBuiltinNote(unsigned DiagID);
+  /// Determine whether the given diagnostic ID is a Note.
+  bool isNote(unsigned DiagID) const;
 
-  /// Determine whether the given built-in diagnostic ID is for an
+  /// Determine whether the given diagnostic ID is for an
   /// extension of some sort.
-  static bool isBuiltinExtensionDiag(unsigned DiagID) {
+  bool isExtensionDiag(unsigned DiagID) const {
     bool ignored;
-    return isBuiltinExtensionDiag(DiagID, ignored);
+    return isExtensionDiag(DiagID, ignored);
   }
 
-  /// Determine whether the given built-in diagnostic ID is for an
+  /// Determine whether the given diagnostic ID is for an
   /// extension of some sort, and whether it is enabled by default.
   ///
   /// This also returns EnabledByDefault, which is set to indicate whether the
   /// diagnostic is ignored by default (in which case -pedantic enables it) or
   /// treated as a warning/error by default.
   ///
-  static bool isBuiltinExtensionDiag(unsigned DiagID, bool &EnabledByDefault);
+  bool isExtensionDiag(unsigned DiagID, bool &EnabledByDefault) const;
 
   /// Given a group ID, returns the flag that toggles the group.
   /// For example, for Group::DeprecatedDeclarations, returns
@@ -242,19 +320,21 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
   /// Given a diagnostic group ID, return its documentation.
   static StringRef getWarningOptionDocumentation(diag::Group GroupID);
 
+  void setGroupSeverity(StringRef Group, diag::Severity);
+
   /// Given a group ID, returns the flag that toggles the group.
   /// For example, for "deprecated-declarations", returns
   /// Group::DeprecatedDeclarations.
   static std::optional<diag::Group> getGroupForWarningOption(StringRef);
 
   /// Return the lowest-level group that contains the specified diagnostic.
-  static std::optional<diag::Group> getGroupForDiag(unsigned DiagID);
+  std::optional<diag::Group> getGroupForDiag(unsigned DiagID) const;
 
   /// Return the lowest-level warning option that enables the specified
   /// diagnostic.
   ///
   /// If there is no -Wfoo flag that controls the diagnostic, this returns null.
-  static StringRef getWarningOptionForDiag(unsigned DiagID);
+  StringRef getWarningOptionForDiag(unsigned DiagID);
 
   /// Return the category number that a specified \p DiagID belongs to,
   /// or 0 if no category.
@@ -352,6 +432,8 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
   getDiagnosticSeverity(unsigned DiagID, SourceLocation Loc,
                         const DiagnosticsEngine &Diag) const LLVM_READONLY;
 
+  Class getDiagClass(unsigned DiagID) const;
+
   /// Used to report a diagnostic that is finally fully formed.
   ///
   /// \returns \c true if the diagnostic was emitted, \c false if it was
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 453bd8a9a340425..f8d00ff802f1ecd 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2865,9 +2865,15 @@ def ext_constexpr_function_never_constant_expr : ExtWarn<
   "constant expression">, InGroup<DiagGroup<"invalid-constexpr">>, DefaultError;
 def err_attr_cond_never_constant_expr : Error<
   "%0 attribute expression never produces a constant expression">;
+def err_diagnose_if_unknown_warning : Error<"unknown warning group">;
 def err_diagnose_if_invalid_diagnostic_type : Error<
   "invalid diagnostic type for 'diagnose_if'; use \"error\" or \"warning\" "
   "instead">;
+def err_diagnose_if_unknown_option : Error<"unknown diagnostic option">;
+def err_diagnose_if_expected_equals : Error<
+  "expected '=' after diagnostic option">;
+def err_diagnose_if_unexpected_value : Error<
+  "unexpected value; use 'true' or 'false'">;
 def err_constexpr_body_no_return : Error<
   "no return statement in %select{constexpr|consteval}0 function">;
 def err_constexpr_return_missing_expr : Error<
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 0208ccc31bd7fc0..f67cf9c507fdc8d 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -138,7 +138,7 @@ void DiagnosticsEngine::Reset(bool soft /*=false*/) {
 
     // Create a DiagState and DiagStatePoint representing diagnostic changes
     // through command-line.
-    DiagStates.emplace_back();
+    DiagStates.emplace_back(*Diags);
     DiagStatesByLoc.appendFirst(&DiagStates.back());
   }
 }
@@ -167,7 +167,7 @@ DiagnosticsEngine::DiagState::getOrAddMapping(diag::kind Diag) {
 
   // Initialize the entry if we added it.
   if (Result.second)
-    Result.first->second = DiagnosticIDs::getDefaultMapping(Diag);
+    Result.first->second = DiagIDs.getDefaultMapping(Diag);
 
   return Result.first->second;
 }
@@ -309,7 +309,8 @@ void DiagnosticsEngine::DiagStateMap::dump(SourceManager &SrcMgr,
 
       for (auto &Mapping : *Transition.State) {
         StringRef Option =
-            DiagnosticIDs::getWarningOptionForDiag(Mapping.first);
+            SrcMgr.getDiagnostics().Diags->getWarningOptionForDiag(
+                Mapping.first);
         if (!DiagName.empty() && DiagName != Option)
           continue;
 
@@ -353,9 +354,7 @@ void DiagnosticsEngine::PushDiagStatePoint(DiagState *State,
 
 void DiagnosticsEngine::setSeverity(diag::kind Diag, diag::Severity Map,
                                     SourceLocation L) {
-  assert(Diag < diag::DIAG_UPPER_LIMIT &&
-         "Can only map builtin diagnostics");
-  assert((Diags->isBuiltinWarningOrExtension(Diag) ||
+  assert((Diags->isWarningOrExtension(Diag) ||
           (Map == diag::Severity::Fatal || Map == diag::Severity::Error)) &&
          "Cannot map errors into warnings!");
   assert((L.isInvalid() || SourceMgr) && "No SourceMgr for valid location");
@@ -406,6 +405,8 @@ bool DiagnosticsEngine::setSeverityForGroup(diag::Flavor Flavor,
   if (Diags->getDiagnosticsInGroup(Flavor, Group, GroupDiags))
     return true;
 
+  Diags->setGroupSeverity(Group, Map);
+
   // Set the mapping.
   for (diag::kind Diag : GroupDiags)
     setSeverity(Diag, Map, Loc);
@@ -491,7 +492,7 @@ void DiagnosticsEngine::setSeverityForAll(diag::Flavor Flavor,
 
   // Set the mapping.
   for (diag::kind Diag : AllDiags)
-    if (Diags->isBuiltinWarningOrExtension(Diag))
+    if (Diags->isWarningOrExtension(Diag))
       setSeverity(Diag, Map, Loc);
 }
 
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index e5667d57f8cff11..6b2ba485533f904 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -99,13 +99,12 @@ const uint32_t StaticDiagInfoDescriptionOffsets[] = {
 #undef DIAG
 };
 
-// Diagnostic classes.
 enum {
-  CLASS_NOTE       = 0x01,
-  CLASS_REMARK     = 0x02,
-  CLASS_WARNING    = 0x03,
-  CLASS_EXTENSION  = 0x04,
-  CLASS_ERROR      = 0x05
+  CLASS_NOTE = DiagnosticIDs::CLASS_NOTE,
+  CLASS_REMARK = DiagnosticIDs::CLASS_REMARK,
+  CLASS_WARNING = DiagnosticIDs::CLASS_WARNING,
+  CLASS_EXTENSION = DiagnosticIDs::CLASS_EXTENSION,
+  CLASS_ERROR = DiagnosticIDs::CLASS_ERROR,
 };
 
 struct S...
[truncated]

@philnik777
Copy link
Contributor Author

This is missing a few tests and probably has some bugs, but I'd like to know whether this is a good approach before putting a lot of work into it.

Copy link

github-actions bot commented Nov 1, 2023

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff b43302372f592fd48a22d32b2603f8efee40a88e 22509b9398a02f1f530232e6e7c1c09b3fd5111b --extensions cpp,c,h -- clang/test/SemaCXX/diagnose_if-warning-group.cpp clang-tools-extra/clangd/Diagnostics.cpp clang-tools-extra/clangd/Diagnostics.h clang-tools-extra/clangd/ParsedAST.cpp clang-tools-extra/clangd/Preamble.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp clang/include/clang/Basic/Diagnostic.h clang/include/clang/Basic/DiagnosticCategories.h clang/include/clang/Basic/DiagnosticIDs.h clang/lib/Basic/Diagnostic.cpp clang/lib/Basic/DiagnosticIDs.cpp clang/lib/Frontend/LogDiagnosticPrinter.cpp clang/lib/Frontend/SerializedDiagnosticPrinter.cpp clang/lib/Frontend/TextDiagnosticPrinter.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp clang/test/Sema/diagnose_if.c clang/tools/diagtool/ListWarnings.cpp clang/tools/diagtool/ShowEnabledWarnings.cpp clang/tools/libclang/CXStoredDiagnostic.cpp
View the diff from clang-format here.
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index ad59afb1f4..cae6642bd4 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -683,7 +683,7 @@ std::vector<std::string> DiagnosticIDs::getDiagnosticFlags() {
 static bool getDiagnosticsInGroup(diag::Flavor Flavor,
                                   const WarningOption *Group,
                                   SmallVectorImpl<diag::kind> &Diags,
-                                  diag::CustomDiagInfo* CustomDiagInfo) {
+                                  diag::CustomDiagInfo *CustomDiagInfo) {
   // An empty group is considered to be a warning group: we have empty groups
   // for GCC compatibility, and GCC does not have remarks.
   if (!Group->Members && !Group->SubGroups)
diff --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
index c741fd7ecf..d1db31763e 100644
--- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -536,7 +536,7 @@ unsigned SDiagsWriter::getEmitCategory(unsigned int category) {
 }
 
 unsigned SDiagsWriter::getEmitDiagnosticFlag(DiagnosticsEngine::Level DiagLevel,
-                                             const Diagnostic* Diag) {
+                                             const Diagnostic *Diag) {
   if (!Diag || DiagLevel == DiagnosticsEngine::Note)
     return 0; // No flag for notes.
 

@philnik777
Copy link
Contributor Author

gentle ping~

Copy link
Collaborator

@erichkeane erichkeane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! I can't really review the tidy stuff immediately, but I think this really makes sense. You DO have some unrelated WS changes that should be removed though.

Also, Most of the changes this causes along the way I think are vast improvements.

clang/include/clang/Basic/DiagnosticIDs.h Outdated Show resolved Hide resolved
clang/include/clang/Basic/DiagnosticIDs.h Outdated Show resolved Hide resolved
@erichkeane
Copy link
Collaborator

Please don't force push... it makes these 100x more difficult to review. ALso, it seems that the latest push has broken quite a lot, according to the build bots.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in review!

This seems like the right direction to go, in general. As @erichkeane, it's a bit hard to review due to the whitespace-only changes and changes to __is_trivially_equality_comparable, you should remove those changes or split them into a separate PR.

clang/test/SemaCXX/diagnose_if-warning-group.cpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@philnik777 philnik777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in review!

No worries! I dropped this for a few months myself. I can't expect to get a review within days when doing that :D

This seems like the right direction to go, in general. As @erichkeane, it's a bit hard to review due to the whitespace-only changes and changes to __is_trivially_equality_comparable, you should remove those changes or split them into a separate PR.

Oops, looks like a commit got in here that was supposed to be part of another PR.

Copy link
Collaborator

@AaronBallman AaronBallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@philnik777 philnik777 merged commit 030c6da into llvm:main Sep 12, 2024
5 of 7 checks passed
@philnik777 philnik777 deleted the extend_diagnose_if branch September 12, 2024 18:15
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 12, 2024

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building clang-tools-extra,clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/6211

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
219.022 [599/40/6541] Linking CXX shared library lib/libLLVMCFIVerify.so.20.0git
219.035 [599/39/6542] Linking CXX shared library lib/libFIRSupport.so.20.0git
219.103 [599/38/6543] Building CXX object tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/arcmt-test.cpp.o
219.111 [591/45/6544] Creating library symlink lib/libFIRSupport.so
219.115 [591/44/6545] Creating library symlink lib/libLLVMCFIVerify.so
219.123 [591/43/6546] Building Opts.inc...
219.137 [584/49/6547] Linking CXX shared library lib/libHLFIRDialect.so.20.0git
219.146 [583/49/6548] Creating library symlink lib/libHLFIRDialect.so
219.211 [583/48/6549] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/llvm-cov.cpp.o
219.215 [583/47/6550] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
/usr/local/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/flang/lib/Frontend -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/lib/Frontend -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/flang/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/include -I/home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/../mlir/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/mlir/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/tools/clang/include -isystem /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/llvm/../clang/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fPIC  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /home/tcwg-buildbot/worker/flang-aarch64-libcxx/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp
../llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp:42:29: error: call to non-static member function without an object argument
   42 |       clang::DiagnosticIDs::getWarningOptionForDiag(info.getID());
      |       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
219.217 [583/46/6551] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/gcov.cpp.o
219.233 [583/45/6552] Building CXX object tools/llvm-cgdata/CMakeFiles/llvm-cgdata.dir/llvm-cgdata-driver.cpp.o
219.243 [583/44/6553] Building CXX object tools/llvm-cgdata/CMakeFiles/llvm-cgdata.dir/llvm-cgdata.cpp.o
219.248 [583/43/6554] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageFilters.cpp.o
219.251 [583/42/6555] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageExporterLcov.cpp.o
219.252 [583/41/6556] Linking CXX executable bin/llvm-cat
219.254 [583/40/6557] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CoverageExporterJson.cpp.o
219.263 [583/39/6558] Linking CXX executable bin/llvm-cfi-verify
219.282 [583/38/6559] Building CXX object tools/llvm-cov/CMakeFiles/llvm-cov.dir/CodeCoverage.cpp.o
219.310 [583/37/6560] Linking CXX executable bin/llvm-c-test
219.347 [583/36/6561] Linking CXX executable bin/arcmt-test
219.671 [583/35/6562] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnostic.cpp.o
219.912 [583/34/6563] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticBuffer.cpp.o
219.954 [583/33/6564] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXType.cpp.o
220.013 [583/32/6565] Linking CXX shared library lib/libFortranEvaluate.so.20.0git
220.095 [583/31/6566] Building CXX object tools/clang/tools/clang-extdef-mapping/CMakeFiles/clang-extdef-mapping.dir/ClangExtDefMapGen.cpp.o
220.099 [583/30/6567] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXCursor.cpp.o
220.275 [583/29/6568] Building CXX object tools/clang/tools/clang-check/CMakeFiles/clang-check.dir/ClangCheck.cpp.o
221.870 [583/28/6569] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
222.034 [583/27/6570] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
222.423 [583/26/6571] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexCodeCompletion.cpp.o
222.881 [583/25/6572] Building CXX object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
224.231 [583/24/6573] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/NoUncountedMembersChecker.cpp.o
224.387 [583/23/6574] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/Indexing.cpp.o
224.637 [583/22/6575] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/ClangInstallAPI.cpp.o
225.563 [583/21/6576] Building CXX object tools/clang/tools/clang-rename/CMakeFiles/clang-rename.dir/ClangRename.cpp.o
227.970 [583/20/6577] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/IncrementalParser.cpp.o
227.974 [583/19/6578] Building CXX object tools/clang/tools/clang-repl/CMakeFiles/clang-repl.dir/ClangRepl.cpp.o
228.512 [583/18/6579] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXIndexDataConsumer.cpp.o
229.456 [583/17/6580] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Interpreter.cpp.o
230.778 [583/16/6581] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/LocalizationChecker.cpp.o
230.991 [583/15/6582] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/AnalysisConsumer.cpp.o
232.724 [583/14/6583] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndex.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 12, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-sles-build-only running on rocm-worker-hw-04-sles while building clang-tools-extra,clang at step 5 "compile-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/6429

Here is the relevant piece of the build log for the reference
Step 5 (compile-openmp) failure: build (failure)
...
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:74:58: warning: ‘clang::PointerAuthSchema::SelectedAuthenticationMode’ is too small to hold all values of ‘enum class clang::PointerAuthenticationMode’
   PointerAuthenticationMode SelectedAuthenticationMode : 2;
                                                          ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:75:39: warning: ‘clang::PointerAuthSchema::DiscriminationKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Discrimination’
   Discrimination DiscriminationKind : 2;
                                       ^
278.711 [687/32/6209] Linking CXX static library lib/libclangFrontendTool.a
278.718 [686/32/6210] Linking CXX executable bin/arcmt-test
278.957 [685/32/6211] Linking CXX executable bin/clang-import-test
279.036 [684/32/6212] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
ccache /usr/bin/c++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/flang/lib/Frontend -I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend -I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/include -Itools/flang/include -Iinclude -I/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/include -isystem /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/../mlir/include -isystem tools/mlir/include -isystem tools/clang/include -isystem /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++1z -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend/TextDiagnosticPrinter.cpp
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend/TextDiagnosticPrinter.cpp: In function ‘void printRemarkOption(llvm::raw_ostream&, clang::DiagnosticsEngine::Level, const clang::Diagnostic&)’:
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/flang/lib/Frontend/TextDiagnosticPrinter.cpp:42:65: error: cannot call member function ‘llvm::StringRef clang::DiagnosticIDs::getWarningOptionForDiag(unsigned int)’ without object
       clang::DiagnosticIDs::getWarningOptionForDiag(info.getID());
                                                                 ^
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-ctad-maybe-unsupported’
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-copy’
279.040 [684/31/6213] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXString.cpp.o
In file included from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/Type.h:31:0,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/CanonicalType.h:17,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/ASTContext.h:18,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Frontend/ASTUnit.h:17,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/tools/libclang/CXString.cpp:18:
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:70:18: warning: ‘clang::PointerAuthSchema::TheKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Kind’
   Kind TheKind : 2;
                  ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:74:58: warning: ‘clang::PointerAuthSchema::SelectedAuthenticationMode’ is too small to hold all values of ‘enum class clang::PointerAuthenticationMode’
   PointerAuthenticationMode SelectedAuthenticationMode : 2;
                                                          ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:75:39: warning: ‘clang::PointerAuthSchema::DiscriminationKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Discrimination’
   Discrimination DiscriminationKind : 2;
                                       ^
279.117 [684/30/6214] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXSourceLocation.cpp.o
In file included from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/Type.h:31:0,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/CanonicalType.h:17,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/AST/ASTContext.h:18,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/tools/libclang/CXSourceLocation.h:17,
                 from /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/tools/libclang/CXSourceLocation.cpp:13:
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:70:18: warning: ‘clang::PointerAuthSchema::TheKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Kind’
   Kind TheKind : 2;
                  ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:74:58: warning: ‘clang::PointerAuthSchema::SelectedAuthenticationMode’ is too small to hold all values of ‘enum class clang::PointerAuthenticationMode’
   PointerAuthenticationMode SelectedAuthenticationMode : 2;
                                                          ^
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/include/clang/Basic/PointerAuthOptions.h:75:39: warning: ‘clang::PointerAuthSchema::DiscriminationKind’ is too small to hold all values of ‘enum class clang::PointerAuthSchema::Discrimination’
   Discrimination DiscriminationKind : 2;
                                       ^

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 12, 2024

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building clang-tools-extra,clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/7578

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
27.827 [479/591/5483] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/Preprocessor.cpp.o
27.868 [479/590/5484] Building CXX object tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/ProgramPoint.cpp.o
27.916 [479/589/5485] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/DynamicAllocator.cpp.o
27.930 [479/588/5486] Building CXX object tools/clang/lib/InstallAPI/CMakeFiles/obj.clangInstallAPI.dir/DylibVerifier.cpp.o
27.957 [479/587/5487] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/MemberPointer.cpp.o
27.971 [479/586/5488] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/TemplateBase.cpp.o
28.145 [479/585/5489] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/AnalyzerOptions.cpp.o
28.162 [479/584/5490] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/DeclarationName.cpp.o
28.232 [479/583/5491] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ExprClassification.cpp.o
28.278 [479/582/5492] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.16.0.1/bin/clang++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/lib/Frontend -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticPrinter.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend/TextDiagnosticPrinter.cpp:42:29: error: call to non-static member function without an object argument
      clang::DiagnosticIDs::getWarningOptionForDiag(info.getID());
      ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
28.286 [479/581/5493] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Execution.cpp.o
28.378 [479/580/5494] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexer.cpp.o
28.448 [479/579/5495] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/JSONCompilationDatabase.cpp.o
28.582 [479/578/5496] Building CXX object tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/Dominators.cpp.o
28.628 [479/577/5497] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChain.cpp.o
28.647 [479/576/5498] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnostic.cpp.o
28.654 [479/575/5499] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CommonOptionsParser.cpp.o
28.811 [479/574/5500] Building CXX object tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/IntervalPartition.cpp.o
28.876 [479/573/5501] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTTypeTraits.cpp.o
28.969 [479/572/5502] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/CXXInheritance.cpp.o
29.087 [479/571/5503] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/MultiplexExternalSemaSource.cpp.o
29.144 [479/570/5504] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/Descriptor.cpp.o
29.158 [479/569/5505] Building CXX object lib/Object/CMakeFiles/LLVMObject.dir/IRSymtab.cpp.o
29.338 [479/568/5506] Building CXX object tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/AtomicChange.cpp.o
29.376 [479/567/5507] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/TextDiagnosticBuffer.cpp.o
29.519 [479/566/5508] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/Iterator.cpp.o
29.667 [479/565/5509] Building CXX object tools/clang/lib/Lex/CMakeFiles/obj.clangLex.dir/HeaderSearch.cpp.o
29.795 [479/564/5510] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1gen_reproducer_main.cpp.o
29.845 [479/563/5511] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/EvaluationResult.cpp.o
29.868 [479/562/5512] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DivZeroChecker.cpp.o
29.938 [479/561/5513] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ComputeDependence.cpp.o
29.966 [479/560/5514] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/WorkList.cpp.o
29.980 [479/559/5515] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/DelayedDiagnostic.cpp.o
30.092 [479/558/5516] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/SymbolManager.cpp.o
30.096 [479/557/5517] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ItaniumCXXABI.cpp.o
30.187 [479/556/5518] Building CXX object tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/RefactoringActions.cpp.o
30.213 [479/555/5519] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexingContext.cpp.o
30.238 [479/554/5520] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaSystemZ.cpp.o
30.272 [479/553/5521] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/PtrTypesSemantics.cpp.o
30.294 [479/552/5522] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CreateInvocationFromCommandLine.cpp.o
30.300 [479/551/5523] Building CXX object tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/InterpFrame.cpp.o
30.336 [479/550/5524] Building CXX object tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GeneratePCH.cpp.o
30.374 [479/549/5525] Building CXX object tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/CommentToXML.cpp.o

@kazutakahirata
Copy link
Contributor

The build bots seem to be complaining about the same spot:

flang/lib/Frontend/TextDiagnosticPrinter.cpp:42:29: error: call to non-static member function without an object argument
      clang::DiagnosticIDs::getWarningOptionForDiag(info.getID());

Maybe you need to update the call to getWarningOptionForDiag?

philnik777 added a commit to philnik777/llvm-project that referenced this pull request Sep 12, 2024
philnik777 added a commit that referenced this pull request Sep 13, 2024
…nformation (#70976)" (#108453)

This reverts commit e0cd11e.

Update the use of `getWarningOptionForDiag` in flang to use the
DiagnosticIDs.
fmayer added a commit that referenced this pull request Sep 13, 2024
…arning information (#70976)" (#108453)"

This reverts commit e7f782e.

This had UBSan failures:

[----------] 1 test from ConfigCompileTests
[ RUN      ] ConfigCompileTests.DiagnosticSuppression
Config fragment: compiling <unknown>:0 -> 0x00007B8366E2F7D8 (trusted=false)
/usr/local/google/home/fmayer/large/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:203:33: runtime error: reference binding to null pointer of type 'clang::DiagnosticIDs'

UndefinedBehaviorSanitizer: undefined-behavior /usr/local/google/home/fmayer/large/llvm-project/llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:203:33

Pull Request: #108645
philnik777 added a commit to philnik777/llvm-project that referenced this pull request Sep 14, 2024
…warning information (llvm#70976)" (llvm#108453)"

This reverts commit e1bd974.

Fixes incorrect use of the `DiagnosticsEngine` in the clangd tests.
philnik777 added a commit that referenced this pull request Sep 14, 2024
…warning information (#70976)" (#108453)"

This reverts commit e1bd974.

Fixes incorrect use of the `DiagnosticsEngine` in the clangd tests.
@mikaelholmen
Copy link
Collaborator

Hello,

I noticed that before this patch
clang empty.c -fsanitize=undefined -ffine-grained-bitfield-accesses -c -Werror
(on empty file empty.c) resulted in
warning: option '-ffine-grained-bitfield-accesses' cannot be enabled together with a sanitizer; flag ignored
but with the patch it results in
error: option '-ffine-grained-bitfield-accesses' cannot be enabled together with a sanitizer; flag ignored [-Werror]

Is this on purpose?

(I originally asked this in
#108453 (comment)
but I suppose this PR has a bit wider audience.)

@AaronBallman
Copy link
Collaborator

I think there are multiple bugs here, at least one seems to be preexisting. It seems that perhaps diagnostics issued early enough in the driver do not seem to honor diagnostic groups: https://godbolt.org/z/sh4e9noe1

Note how it's missing [-Woption-ignored] like you get in: https://godbolt.org/z/xvn59hEva

However, note how we're missing that diagnostic entirely now: https://godbolt.org/z/znr63dj6o

@whentojump
Copy link
Member

whentojump commented Sep 24, 2024

Hello,

I noticed that before this patch clang empty.c -fsanitize=undefined -ffine-grained-bitfield-accesses -c -Werror (on empty file empty.c) resulted in warning: option '-ffine-grained-bitfield-accesses' cannot be enabled together with a sanitizer; flag ignored but with the patch it results in error: option '-ffine-grained-bitfield-accesses' cannot be enabled together with a sanitizer; flag ignored [-Werror]

Is this on purpose?

(I originally asked this in #108453 (comment) but I suppose this PR has a bit wider audience.)

We are seeing similar changes in MC/DC-related warnings. Steps to reproduce:

cat > test.c << 'EOF'
int foo(int x) { return x; }
int main(void) {
    int a, b, c, d, e, f, g, h;
    a && b && c && d && e && f && g;
    a && foo( b && c );
    return 0;
}
EOF
clang -Xclang -fmcdc-max-conditions=6 -Werror -Wno-unused-value -fprofile-instr-generate -fcoverage-mapping -fcoverage-mcdc test.c -o test

Before

test.c:4:5: warning: unsupported MC/DC boolean expression; number of conditions (7) exceeds max (6). Expression will not be covered
    4 |     a && b && c && d && e && f && g;
      |     ^
test.c:5:5: warning: unsupported MC/DC boolean expression; contains an operation with a nested boolean expression. Expression will not be covered
    5 |     a && foo( b && c );
      |     ^
2 warnings generated.

After

test.c:4:5: error: unsupported MC/DC boolean expression; number of conditions (7) exceeds max (6). Expression will not be covered [-Werror]
    4 |     a && b && c && d && e && f && g;
      |     ^
test.c:5:5: error: unsupported MC/DC boolean expression; contains an operation with a nested boolean expression. Expression will not be covered [-Werror]
    5 |     a && foo( b && c );
      |     ^
2 errors generated.

@@ -489,13 +485,7 @@ static DiagnosticIDs::Level toLevel(diag::Severity SV) {
DiagnosticIDs::Level
DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, SourceLocation Loc,
const DiagnosticsEngine &Diag) const {
// Handle custom diagnostics, which cannot be mapped.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so despite this change making sense at a high level, this is a big behavior change that isn't really obvious in context of this PR.

before this change, clang didn't propagate -Werror like mappings into custom diagnostics. Hence some compilations that succeed now with custom warning (clang-plugins etc.), will start failing after this change as those will now turn into errors.
We're already seeing this internally and both #70976 (comment) and #70976 (comment) are mentioning this as well.

Since this is triggering a backward incompatible behavior, can we have this bit reverted and decide how/whether we're planning to move forward with this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is triggering a backward incompatible behavior, can we have this bit reverted and decide how/whether we're planning to move forward with this?

Afaict the author ( @philnik777 ) has neither responded to the post-commit comments/question here, neither in the PR related to the reapply at #108453 (comment) , and I don't know much about this to understand if there is an easy fix. But if we are suspecting "multiple bugs here" then maybe someone should just go ahead and revert this again.

Btw, it seems like the reapply already has been reverted once (e1bd974) and then reapplied a second time (e392056). And there are comments here e392056#commitcomment-146720911 about further fixups that might cause conflicts if reverting again.

PS. The commit message in e392056 is not very informative as it says that the commit msg body says that it is a revert, while it actually is a re-apply. Maybe that is another reason to revert this mess and reapply it using a new PR with an appropriate commit message describing the feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, let's revert if this is causing problems.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, putting together a revert for e392056

kadircet added a commit that referenced this pull request Sep 26, 2024
…formation (#70976)"

This reverts commit e392056.

There are further discussions in
#70976, happening for past two
weeks. Since there were no responses for couple weeks now, reverting
until author is back.
@mikaelholmen
Copy link
Collaborator

Thanks @kadircet

augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Sep 26, 2024
…formation (llvm#70976)"

This reverts commit e392056.

There are further discussions in
llvm#70976, happening for past two
weeks. Since there were no responses for couple weeks now, reverting
until author is back.
Sterling-Augustine pushed a commit to Sterling-Augustine/llvm-project that referenced this pull request Sep 27, 2024
…formation (llvm#70976)"

This reverts commit e392056.

There are further discussions in
llvm#70976, happening for past two
weeks. Since there were no responses for couple weeks now, reverting
until author is back.
xgupta pushed a commit to xgupta/llvm-project that referenced this pull request Oct 4, 2024
…formation (llvm#70976)"

This reverts commit e392056.

There are further discussions in
llvm#70976, happening for past two
weeks. Since there were no responses for couple weeks now, reverting
until author is back.
philnik777 added a commit to philnik777/llvm-project that referenced this pull request Dec 12, 2024
…n, take 2

This is take two of llvm#70976. This iteration of the patch makes sure that custom
diagnostics without any warning group don't get promoted by `-Werror` or
`-Wfatal-errors`.

This implements parts of the extension proposed in https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7.

Specifically, this makes it possible to specify a diagnostic group in an optional third argument.
philnik777 added a commit to philnik777/llvm-project that referenced this pull request Jan 24, 2025
…n, take 2

This is take two of llvm#70976. This iteration of the patch makes sure that custom
diagnostics without any warning group don't get promoted by `-Werror` or
`-Wfatal-errors`.

This implements parts of the extension proposed in https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7.

Specifically, this makes it possible to specify a diagnostic group in an optional third argument.
philnik777 added a commit to philnik777/llvm-project that referenced this pull request Jan 28, 2025
…n, take 2

This is take two of llvm#70976. This iteration of the patch makes sure that custom
diagnostics without any warning group don't get promoted by `-Werror` or
`-Wfatal-errors`.

This implements parts of the extension proposed in https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7.

Specifically, this makes it possible to specify a diagnostic group in an optional third argument.
philnik777 added a commit that referenced this pull request Jan 28, 2025
…n, take 2 (#119712)

This is take two of #70976. This iteration of the patch makes sure that
custom
diagnostics without any warning group don't get promoted by `-Werror` or
`-Wfatal-errors`.

This implements parts of the extension proposed in
https://discourse.llvm.org/t/exposing-the-diagnostic-engine-to-c/73092/7.

Specifically, this makes it possible to specify a diagnostic group in an
optional third argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang:static analyzer clang Clang issues not falling into any other category clang-tidy clang-tools-extra clangd enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.