Skip to content

Commit

Permalink
[diagtree] Use a different color for unimplemented GCC diagnostic flags
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zygoloid committed Jan 31, 2020
1 parent d02fb00 commit de876ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions clang/tools/diagtool/DiagnosticNames.h
Expand Up @@ -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;
}
};
Expand Down
19 changes: 17 additions & 2 deletions clang/tools/diagtool/TreeView.cpp
Expand Up @@ -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))
Expand All @@ -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;
Expand Down Expand Up @@ -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";
}
};

Expand Down

0 comments on commit de876ad

Please sign in to comment.