diff options
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/InitPreprocessor.cpp | 11 | ||||
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 1 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/PrintParserCallbacks.cpp | 1 | ||||
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 56 |
5 files changed, 62 insertions, 9 deletions
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index e3a45d42cf55..01729fad5e72 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -23,8 +23,8 @@ namespace clang { // Append a #define line to Buf for Macro. Macro should be of the form XXX, // in which case we emit "#define XXX 1" or "XXX=Y z W" in which case we emit // "#define XXX Y z W". To get a #define with no value, use "XXX=". -static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro, - const char *Command = "#define ") { +static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) { + const char *Command = "#define "; Buf.insert(Buf.end(), Command, Command+strlen(Command)); if (const char *Equal = strchr(Macro, '=')) { // Turn the = into ' '. @@ -367,7 +367,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI, sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0)); DefineBuiltinMacro(Buf, MacroBuf); - if (!TI.isCharSigned()) + if (!LangOpts.CharIsSigned) DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__"); // Define fixed-sized integer types for stdint.h @@ -403,11 +403,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI, // command line options or something. DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0"); - if (LangOpts.Static) - DefineBuiltinMacro(Buf, "__STATIC__=1"); - else - DefineBuiltinMacro(Buf, "__DYNAMIC__=1"); - if (LangOpts.GNUInline) DefineBuiltinMacro(Buf, "__GNUC_GNU_INLINE__=1"); else diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 63e4337c8861..87fc8394c8db 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1521,6 +1521,7 @@ bool PCHReader::ParseLanguageOptions( PARSE_LANGOPT_IMPORTANT(GNUInline, diag::warn_pch_gnu_inline); PARSE_LANGOPT_IMPORTANT(NoInline, diag::warn_pch_no_inline); PARSE_LANGOPT_IMPORTANT(AccessControl, diag::warn_pch_access_control); + PARSE_LANGOPT_IMPORTANT(CharIsSigned, diag::warn_pch_char_signed); if ((LangOpts.getGCMode() != 0) != (Record[Idx] != 0)) { Diag(diag::warn_pch_gc_mode) << (unsigned)Record[Idx] << LangOpts.getGCMode(); diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 80e863bd7110..765fecbf852f 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -556,6 +556,8 @@ void PCHWriter::WriteLanguageOptions(const LangOptions &LangOpts) { Record.push_back(LangOpts.NoInline); // Should __NO_INLINE__ be defined. Record.push_back(LangOpts.AccessControl); // Whether C++ access control should // be enabled. + Record.push_back(LangOpts.CharIsSigned); // Whether char is a signed or + // unsigned type Record.push_back(LangOpts.getGCMode()); Record.push_back(LangOpts.getVisibilityMode()); Record.push_back(LangOpts.InstantiationDepth); diff --git a/lib/Frontend/PrintParserCallbacks.cpp b/lib/Frontend/PrintParserCallbacks.cpp index f02d5d469c64..b9fe0680afd0 100644 --- a/lib/Frontend/PrintParserCallbacks.cpp +++ b/lib/Frontend/PrintParserCallbacks.cpp @@ -220,6 +220,7 @@ namespace { } virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart, + DeclPtrTy IntfDecl, Declarator &D, ExprTy *BitfieldWidth, tok::ObjCKeywordKind visibility) { Out << __FUNCTION__ << "\n"; diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index b1c05336c239..6699c65f52de 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -20,6 +20,20 @@ #include <algorithm> using namespace clang; +static const enum llvm::raw_ostream::Colors noteColor = + llvm::raw_ostream::BLACK; +static const enum llvm::raw_ostream::Colors fixitColor = + llvm::raw_ostream::GREEN; +static const enum llvm::raw_ostream::Colors caretColor = + llvm::raw_ostream::GREEN; +static const enum llvm::raw_ostream::Colors warningColor = + llvm::raw_ostream::MAGENTA; +static const enum llvm::raw_ostream::Colors errorColor = llvm::raw_ostream::RED; +static const enum llvm::raw_ostream::Colors fatalColor = llvm::raw_ostream::RED; +// used for changing only the bold attribute +static const enum llvm::raw_ostream::Colors savedColor = + llvm::raw_ostream::SAVEDCOLOR; + /// \brief Number of spaces to indent when word-wrapping. const unsigned WordWrapIndentation = 6; @@ -396,12 +410,22 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, // Emit what we have computed. OS << SourceLine << '\n'; + + if (UseColors) + OS.changeColor(caretColor, true); OS << CaretLine << '\n'; + if (UseColors) + OS.resetColor(); if (!FixItInsertionLine.empty()) { + if (UseColors) + // Print fixit line in color + OS.changeColor(fixitColor, false); if (PrintRangeInfo) OS << ' '; OS << FixItInsertionLine << '\n'; + if (UseColors) + OS.resetColor(); } } @@ -598,6 +622,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, // Compute the column number. if (ShowLocation) { + if (UseColors) + OS.changeColor(savedColor, true); OS << PLoc.getFilename() << ':' << LineNo << ':'; if (ShowColumn) if (unsigned ColNo = PLoc.getColumn()) @@ -638,6 +664,19 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, OS << ':'; } OS << ' '; + if (UseColors) + OS.resetColor(); + } + } + + if (UseColors) { + // Print diagnostic category in bold and color + switch (Level) { + case Diagnostic::Ignored: assert(0 && "Invalid diagnostic type"); + case Diagnostic::Note: OS.changeColor(noteColor, true); break; + case Diagnostic::Warning: OS.changeColor(warningColor, true); break; + case Diagnostic::Error: OS.changeColor(errorColor, true); break; + case Diagnostic::Fatal: OS.changeColor(fatalColor, true); break; } } @@ -648,7 +687,10 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, case Diagnostic::Error: OS << "error: "; break; case Diagnostic::Fatal: OS << "fatal error: "; break; } - + + if (UseColors) + OS.resetColor(); + llvm::SmallString<100> OutStr; Info.FormatDiagnostic(OutStr); @@ -659,6 +701,16 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, OutStr += ']'; } + if (UseColors) { + // Print warnings, errors and fatal errors in bold, no color + switch (Level) { + case Diagnostic::Warning: OS.changeColor(savedColor, true); break; + case Diagnostic::Error: OS.changeColor(savedColor, true); break; + case Diagnostic::Fatal: OS.changeColor(savedColor, true); break; + default: break; //don't bold notes + } + } + if (MessageLength) { // We will be word-wrapping the error message, so compute the // column number where we currently are (after printing the @@ -669,6 +721,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, OS.write(OutStr.begin(), OutStr.size()); } OS << '\n'; + if (UseColors) + OS.resetColor(); // If caret diagnostics are enabled and we have location, we want to // emit the caret. However, we only do this if the location moved |