From de876adab0cb43b79ffc7c5e66cc9053accbb074 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 31 Jan 2020 13:28:56 -0800 Subject: [PATCH] [diagtree] Use a different color for unimplemented GCC diagnostic flags instead of the "enabled by default" color. It may be technically correct to list unimplemented diagnostics as "enabled by default" but it's quite misleading. --- clang/tools/diagtool/DiagnosticNames.h | 4 ++-- clang/tools/diagtool/TreeView.cpp | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/clang/tools/diagtool/DiagnosticNames.h b/clang/tools/diagtool/DiagnosticNames.h index d8fd6401ef6b8..f541e88577cc5 100644 --- a/clang/tools/diagtool/DiagnosticNames.h +++ b/clang/tools/diagtool/DiagnosticNames.h @@ -76,11 +76,11 @@ namespace diagtool { return *this; } - bool operator==(group_iterator &Other) const { + bool operator==(const group_iterator &Other) const { return CurrentID == Other.CurrentID; } - bool operator!=(group_iterator &Other) const { + bool operator!=(const group_iterator &Other) const { return CurrentID != Other.CurrentID; } }; diff --git a/clang/tools/diagtool/TreeView.cpp b/clang/tools/diagtool/TreeView.cpp index 96951287cc4e8..843bd377e574c 100644 --- a/clang/tools/diagtool/TreeView.cpp +++ b/clang/tools/diagtool/TreeView.cpp @@ -36,6 +36,17 @@ class TreePrinter { return Diags.isIgnored(DiagID, SourceLocation()); } + static bool unimplemented(const GroupRecord &Group) { + if (!Group.diagnostics().empty()) + return false; + + for (const GroupRecord &GR : Group.subgroups()) + if (!unimplemented(GR)) + return false; + + return true; + } + static bool enabledByDefault(const GroupRecord &Group) { for (const DiagnosticRecord &DR : Group.diagnostics()) { if (isIgnored(DR.DiagID)) @@ -53,7 +64,9 @@ class TreePrinter { void printGroup(const GroupRecord &Group, unsigned Indent = 0) { out.indent(Indent * 2); - if (enabledByDefault(Group)) + if (unimplemented(Group)) + out << Colors::RED; + else if (enabledByDefault(Group)) out << Colors::GREEN; else out << Colors::YELLOW; @@ -117,7 +130,9 @@ class TreePrinter { void showKey() { out << '\n' << Colors::GREEN << "GREEN" << Colors::RESET - << " = enabled by default\n\n"; + << " = enabled by default"; + out << '\n' << Colors::RED << "RED" << Colors::RESET + << " = unimplemented (accepted for GCC compatibility)\n\n"; } };