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
This commit is contained in:
Chris Lattner 2010-05-05 05:53:24 +00:00
Родитель fb8cc25342
Коммит c3d26cc4ee
2 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -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>;

Просмотреть файл

@ -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)) {