TextDiagnosticPrinter.cpp (207632) | TextDiagnosticPrinter.cpp (208600) |
---|---|
1//===--- TextDiagnosticPrinter.cpp - Diagnostic Printer -------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 4 unchanged lines hidden (view full) --- 13 14#include "clang/Frontend/TextDiagnosticPrinter.h" 15#include "clang/Basic/SourceManager.h" 16#include "clang/Frontend/DiagnosticOptions.h" 17#include "clang/Lex/Lexer.h" 18#include "llvm/Support/MemoryBuffer.h" 19#include "llvm/Support/raw_ostream.h" 20#include "llvm/ADT/SmallString.h" | 1//===--- TextDiagnosticPrinter.cpp - Diagnostic Printer -------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 4 unchanged lines hidden (view full) --- 13 14#include "clang/Frontend/TextDiagnosticPrinter.h" 15#include "clang/Basic/SourceManager.h" 16#include "clang/Frontend/DiagnosticOptions.h" 17#include "clang/Lex/Lexer.h" 18#include "llvm/Support/MemoryBuffer.h" 19#include "llvm/Support/raw_ostream.h" 20#include "llvm/ADT/SmallString.h" |
21#include "llvm/ADT/StringExtras.h" |
|
21#include <algorithm> 22using namespace clang; 23 24static const enum llvm::raw_ostream::Colors noteColor = 25 llvm::raw_ostream::BLACK; 26static const enum llvm::raw_ostream::Colors fixitColor = 27 llvm::raw_ostream::GREEN; 28static const enum llvm::raw_ostream::Colors caretColor = --- 785 unchanged lines hidden (view full) --- 814 } 815 816 if (DiagOpts->ShowColors) 817 OS.resetColor(); 818 819 llvm::SmallString<100> OutStr; 820 Info.FormatDiagnostic(OutStr); 821 | 22#include <algorithm> 23using namespace clang; 24 25static const enum llvm::raw_ostream::Colors noteColor = 26 llvm::raw_ostream::BLACK; 27static const enum llvm::raw_ostream::Colors fixitColor = 28 llvm::raw_ostream::GREEN; 29static const enum llvm::raw_ostream::Colors caretColor = --- 785 unchanged lines hidden (view full) --- 815 } 816 817 if (DiagOpts->ShowColors) 818 OS.resetColor(); 819 820 llvm::SmallString<100> OutStr; 821 Info.FormatDiagnostic(OutStr); 822 |
823 std::string OptionName; |
|
822 if (DiagOpts->ShowOptionNames) { 823 if (const char *Opt = Diagnostic::getWarningOptionForDiag(Info.getID())) { | 824 if (DiagOpts->ShowOptionNames) { 825 if (const char *Opt = Diagnostic::getWarningOptionForDiag(Info.getID())) { |
824 OutStr += " [-W"; 825 OutStr += Opt; 826 OutStr += ']'; | 826 OptionName = "-W"; 827 OptionName += Opt; 828 } else if (Info.getID() == diag::fatal_too_many_errors) { 829 OptionName = "-ferror-limit="; |
827 } else { 828 // If the diagnostic is an extension diagnostic and not enabled by default 829 // then it must have been turned on with -pedantic. 830 bool EnabledByDefault; 831 if (Diagnostic::isBuiltinExtensionDiag(Info.getID(), EnabledByDefault) && 832 !EnabledByDefault) | 830 } else { 831 // If the diagnostic is an extension diagnostic and not enabled by default 832 // then it must have been turned on with -pedantic. 833 bool EnabledByDefault; 834 if (Diagnostic::isBuiltinExtensionDiag(Info.getID(), EnabledByDefault) && 835 !EnabledByDefault) |
833 OutStr += " [-pedantic]"; | 836 OptionName = "-pedantic"; |
834 } 835 } | 837 } 838 } |
839 840 // If the user wants to see category information, include it too. 841 unsigned DiagCategory = 0; 842 if (DiagOpts->ShowCategories) 843 DiagCategory = Diagnostic::getCategoryNumberForDiag(Info.getID()); |
|
836 | 844 |
845 // If there is any categorization information, include it. 846 if (!OptionName.empty() || DiagCategory != 0) { 847 bool NeedsComma = false; 848 OutStr += " ["; 849 850 if (!OptionName.empty()) { 851 OutStr += OptionName; 852 NeedsComma = true; 853 } 854 855 if (DiagCategory) { 856 if (NeedsComma) OutStr += ','; 857 if (DiagOpts->ShowCategories == 1) 858 OutStr += llvm::utostr(DiagCategory); 859 else { 860 assert(DiagOpts->ShowCategories == 2 && "Invalid ShowCategories value"); 861 OutStr += Diagnostic::getCategoryNameFromID(DiagCategory); 862 } 863 } 864 865 OutStr += "]"; 866 } 867 868 |
|
837 if (DiagOpts->ShowColors) { 838 // Print warnings, errors and fatal errors in bold, no color 839 switch (Level) { 840 case Diagnostic::Warning: OS.changeColor(savedColor, true); break; 841 case Diagnostic::Error: OS.changeColor(savedColor, true); break; 842 case Diagnostic::Fatal: OS.changeColor(savedColor, true); break; 843 default: break; //don't bold notes 844 } --- 72 unchanged lines hidden --- | 869 if (DiagOpts->ShowColors) { 870 // Print warnings, errors and fatal errors in bold, no color 871 switch (Level) { 872 case Diagnostic::Warning: OS.changeColor(savedColor, true); break; 873 case Diagnostic::Error: OS.changeColor(savedColor, true); break; 874 case Diagnostic::Fatal: OS.changeColor(savedColor, true); break; 875 default: break; //don't bold notes 876 } --- 72 unchanged lines hidden --- |