diff options
-rw-r--r-- | include/clang/Driver/Options.td | 1 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 0a489c3d5d..414551beac 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -668,6 +668,7 @@ def _pipe : Flag<"--pipe">, Alias<pipe>, Flags<[DriverOption]>; def _prefix_EQ : Joined<"--prefix=">, Alias<B>, Flags<[RenderSeparate]>; def _prefix : Separate<"--prefix">, Alias<B>; def _preprocess : Flag<"--preprocess">, Alias<E>; +def _print_diagnostic_categories : Flag<"--print-diagnostic-categories">; def _print_file_name_EQ : Joined<"--print-file-name=">, Alias<print_file_name_EQ>; def _print_file_name : Separate<"--print-file-name">, Alias<print_file_name_EQ>; def _print_libgcc_file_name : Flag<"--print-libgcc-file-name">, Alias<print_libgcc_file_name>; 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)) { |