aboutsummaryrefslogtreecommitdiff
path: root/tools/diagtool/TreeView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/diagtool/TreeView.cpp')
-rw-r--r--tools/diagtool/TreeView.cpp59
1 files changed, 35 insertions, 24 deletions
diff --git a/tools/diagtool/TreeView.cpp b/tools/diagtool/TreeView.cpp
index 07af944ffc4e..b4846b557444 100644
--- a/tools/diagtool/TreeView.cpp
+++ b/tools/diagtool/TreeView.cpp
@@ -32,10 +32,10 @@ class TreePrinter {
public:
llvm::raw_ostream &out;
const bool ShowColors;
- bool FlagsOnly;
+ bool Internal;
TreePrinter(llvm::raw_ostream &out)
- : out(out), ShowColors(hasColors(out)), FlagsOnly(false) {}
+ : out(out), ShowColors(hasColors(out)), Internal(false) {}
void setColor(llvm::raw_ostream::Colors Color) {
if (ShowColors)
@@ -54,28 +54,42 @@ public:
return Diags.isIgnored(DiagID, SourceLocation());
}
+ static bool enabledByDefault(const GroupRecord &Group) {
+ for (const DiagnosticRecord &DR : Group.diagnostics()) {
+ if (isIgnored(DR.DiagID))
+ return false;
+ }
+
+ for (const GroupRecord &GR : Group.subgroups()) {
+ if (!enabledByDefault(GR))
+ return false;
+ }
+
+ return true;
+ }
+
void printGroup(const GroupRecord &Group, unsigned Indent = 0) {
out.indent(Indent * 2);
- setColor(llvm::raw_ostream::YELLOW);
+ if (enabledByDefault(Group))
+ setColor(llvm::raw_ostream::GREEN);
+ else
+ setColor(llvm::raw_ostream::YELLOW);
+
out << "-W" << Group.getName() << "\n";
resetColor();
++Indent;
- for (GroupRecord::subgroup_iterator I = Group.subgroup_begin(),
- E = Group.subgroup_end();
- I != E; ++I) {
- printGroup(*I, Indent);
+ for (const GroupRecord &GR : Group.subgroups()) {
+ printGroup(GR, Indent);
}
- if (!FlagsOnly) {
- for (GroupRecord::diagnostics_iterator I = Group.diagnostics_begin(),
- E = Group.diagnostics_end();
- I != E; ++I) {
- if (ShowColors && !isIgnored(I->DiagID))
+ if (Internal) {
+ for (const DiagnosticRecord &DR : Group.diagnostics()) {
+ if (ShowColors && !isIgnored(DR.DiagID))
setColor(llvm::raw_ostream::GREEN);
out.indent(Indent * 2);
- out << I->getName();
+ out << DR.getName();
resetColor();
out << "\n";
}
@@ -107,12 +121,9 @@ public:
ArrayRef<GroupRecord> AllGroups = getDiagnosticGroups();
llvm::DenseSet<unsigned> NonRootGroupIDs;
- for (ArrayRef<GroupRecord>::iterator I = AllGroups.begin(),
- E = AllGroups.end();
- I != E; ++I) {
- for (GroupRecord::subgroup_iterator SI = I->subgroup_begin(),
- SE = I->subgroup_end();
- SI != SE; ++SI) {
+ for (const GroupRecord &GR : AllGroups) {
+ for (auto SI = GR.subgroup_begin(), SE = GR.subgroup_end(); SI != SE;
+ ++SI) {
NonRootGroupIDs.insert((unsigned)SI.getID());
}
}
@@ -139,16 +150,16 @@ public:
};
static void printUsage() {
- llvm::errs() << "Usage: diagtool tree [--flags-only] [<diagnostic-group>]\n";
+ llvm::errs() << "Usage: diagtool tree [--internal] [<diagnostic-group>]\n";
}
int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
// First check our one flag (--flags-only).
- bool FlagsOnly = false;
+ bool Internal = false;
if (argc > 0) {
StringRef FirstArg(*argv);
- if (FirstArg.equals("--flags-only")) {
- FlagsOnly = true;
+ if (FirstArg.equals("--internal")) {
+ Internal = true;
--argc;
++argv;
}
@@ -175,7 +186,7 @@ int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
}
TreePrinter TP(out);
- TP.FlagsOnly = FlagsOnly;
+ TP.Internal = Internal;
TP.showKey();
return ShowAll ? TP.showAll() : TP.showGroup(RootGroup);
}