aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-05-05 05:53:24 +0000
committerChris Lattner <sabre@nondot.org>2010-05-05 05:53:24 +0000
commitc3d26cc4eea5187ce13ed180b479ff8ef41015a7 (patch)
treef730c05d1009875274bad7309acab9ba9f4135a6 /lib/Driver/Driver.cpp
parentfb8cc253420e93cee33d29df5a2bdae6aaf16e39 (diff)
add a new --print-diagnostic-categories option, which causes the driver to
print out all of the category numbers with their description. This is useful for clients that want to map the numbers produced by --fdiagnostics-show-category=id to their human readable string form. The output is simple but utilitarian: $ clang --print-diagnostic-categories 1,Format String 2,Something Else This implements rdar://7928193 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103080 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 7371a930c3..0c1a5a3309 100644
--- a/lib/Driver/Driver.cpp
+++ b/lib/Driver/Driver.cpp
@@ -291,6 +291,14 @@ void Driver::PrintVersion(const Compilation &C, llvm::raw_ostream &OS) const {
OS << "Thread model: " << "posix" << '\n';
}
+/// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
+/// option.
+static void PrintDiagnosticCategories(llvm::raw_ostream &OS) {
+ for (unsigned i = 1; // Skip the empty category.
+ const char *CategoryName = Diagnostic::getCategoryNameFromID(i); ++i)
+ OS << i << ',' << CategoryName << '\n';
+}
+
bool Driver::HandleImmediateArgs(const Compilation &C) {
// The order these options are handled in in gcc is all over the place, but we
// don't expect inconsistencies w.r.t. that to matter in practice.
@@ -299,6 +307,11 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
llvm::outs() << CLANG_VERSION_STRING "\n";
return false;
}
+
+ if (C.getArgs().hasArg(options::OPT__print_diagnostic_categories)) {
+ PrintDiagnosticCategories(llvm::outs());
+ return false;
+ }
if (C.getArgs().hasArg(options::OPT__help) ||
C.getArgs().hasArg(options::OPT__help_hidden)) {