diff options
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r-- | lib/Driver/Driver.cpp | 13 |
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)) { |