diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-05-27 15:17:06 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-05-27 15:17:06 +0000 |
commit | 53992adde3eda3ccf9da63bc7e45673f043de18f (patch) | |
tree | 3558f327a6f9ab59c5d7a06528d84e1560445247 /lib/Frontend/TextDiagnosticPrinter.cpp | |
parent | 7e411337c0ed226dace6e07f1420486768161308 (diff) | |
download | FreeBSD-src-53992adde3eda3ccf9da63bc7e45673f043de18f.zip FreeBSD-src-53992adde3eda3ccf9da63bc7e45673f043de18f.tar.gz |
Update clang to r104832.
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 66ed956..6ccf4f1 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -18,6 +18,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" #include <algorithm> using namespace clang; @@ -819,21 +820,52 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, llvm::SmallString<100> OutStr; Info.FormatDiagnostic(OutStr); + std::string OptionName; if (DiagOpts->ShowOptionNames) { if (const char *Opt = Diagnostic::getWarningOptionForDiag(Info.getID())) { - OutStr += " [-W"; - OutStr += Opt; - OutStr += ']'; + OptionName = "-W"; + OptionName += Opt; + } else if (Info.getID() == diag::fatal_too_many_errors) { + OptionName = "-ferror-limit="; } else { // If the diagnostic is an extension diagnostic and not enabled by default // then it must have been turned on with -pedantic. bool EnabledByDefault; if (Diagnostic::isBuiltinExtensionDiag(Info.getID(), EnabledByDefault) && !EnabledByDefault) - OutStr += " [-pedantic]"; + OptionName = "-pedantic"; } } + + // If the user wants to see category information, include it too. + unsigned DiagCategory = 0; + if (DiagOpts->ShowCategories) + DiagCategory = Diagnostic::getCategoryNumberForDiag(Info.getID()); + + // If there is any categorization information, include it. + if (!OptionName.empty() || DiagCategory != 0) { + bool NeedsComma = false; + OutStr += " ["; + + if (!OptionName.empty()) { + OutStr += OptionName; + NeedsComma = true; + } + + if (DiagCategory) { + if (NeedsComma) OutStr += ','; + if (DiagOpts->ShowCategories == 1) + OutStr += llvm::utostr(DiagCategory); + else { + assert(DiagOpts->ShowCategories == 2 && "Invalid ShowCategories value"); + OutStr += Diagnostic::getCategoryNameFromID(DiagCategory); + } + } + + OutStr += "]"; + } + if (DiagOpts->ShowColors) { // Print warnings, errors and fatal errors in bold, no color switch (Level) { |