[diagtool] Add a new "tree" command to shows warnings activated by a flag.
% diagtool tree -Wunused-value
-Wunused-value
-Wunused-comparison
warn_unused_comparison
-Wunused-result
warn_unused_result
warn_unused_call
warn_unused_container_subscript_expr
warn_unused_expr
warn_unused_property_expr
warn_unused_voidptr
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159093 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/diagtool/ShowEnabledWarnings.cpp b/tools/diagtool/ShowEnabledWarnings.cpp
index 2bc5124..7162451 100644
--- a/tools/diagtool/ShowEnabledWarnings.cpp
+++ b/tools/diagtool/ShowEnabledWarnings.cpp
@@ -21,6 +21,7 @@
ShowEnabledWarnings)
using namespace clang;
+using namespace diagtool;
namespace {
struct PrettyDiag {
@@ -109,10 +110,12 @@
// which ones are turned on.
// FIXME: It would be very nice to print which flags are turning on which
// diagnostics, but this can be done with a diff.
+ ArrayRef<DiagnosticRecord> AllDiagnostics = getBuiltinDiagnosticsByName();
std::vector<PrettyDiag> Active;
- for (const diagtool::DiagnosticRecord *I = diagtool::BuiltinDiagnostics,
- *E = I + diagtool::BuiltinDiagnosticsCount; I != E; ++I) {
+ for (ArrayRef<DiagnosticRecord>::iterator I = AllDiagnostics.begin(),
+ E = AllDiagnostics.end();
+ I != E; ++I) {
unsigned DiagID = I->DiagID;
if (DiagnosticIDs::isBuiltinNote(DiagID))
@@ -130,8 +133,6 @@
Active.push_back(PrettyDiag(I->getName(), WarningOpt, DiagLevel));
}
- std::sort(Active.begin(), Active.end());
-
// Print them all out.
for (std::vector<PrettyDiag>::const_iterator I = Active.begin(),
E = Active.end(); I != E; ++I) {