From: Steve Naroff Date: Sat, 5 Dec 2009 02:14:08 +0000 (+0000) Subject: Integrate the following from the 'objective-rewrite' branch: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0c4d895ffe4320aa4e29485711ad7d154f2cc2b;p=clang Integrate the following from the 'objective-rewrite' branch: http://llvm.org/viewvc/llvm-project?view=rev&revision=71086 Note - This commit only includes the fix for: slightly different error message format for Visual Studio. The fix for from protocol to template. is separate/forthcoming. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90642 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index d3744326a3..b9d19674af 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -182,6 +182,7 @@ private: bool SuppressAllDiagnostics; // Suppress all diagnostics. ExtensionHandling ExtBehavior; // Map extensions onto warnings or errors? DiagnosticClient *Client; + LangOptions *LangOpts; /// DiagMappings - Mapping information for diagnostics. Mapping info is /// packed into four bits per diagnostic. The low three bits are the mapping @@ -238,7 +239,9 @@ public: DiagnosticClient *getClient() { return Client; } const DiagnosticClient *getClient() const { return Client; } - + LangOptions *getLangOpts() const { return LangOpts; } + void setLangOpts(LangOptions *LOpts) { LangOpts = LOpts; } + /// pushMappings - Copies the current DiagMappings and pushes the new copy /// onto the top of the stack. void pushMappings(); diff --git a/lib/Basic/Diagnostic.cpp b/lib/Basic/Diagnostic.cpp index 8a0b858ba9..1f5179146b 100644 --- a/lib/Basic/Diagnostic.cpp +++ b/lib/Basic/Diagnostic.cpp @@ -210,7 +210,8 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) { ErrorOccurred = false; FatalErrorOccurred = false; NumDiagnostics = 0; - + LangOpts = 0; + NumErrors = 0; CustomDiagInfo = 0; CurDiagID = ~0U; diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 52a0f48363..eeca97d62a 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -653,11 +653,19 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, if (DiagOpts->ShowLocation) { if (DiagOpts->ShowColors) OS.changeColor(savedColor, true); - OS << PLoc.getFilename() << ':' << LineNo << ':'; - if (DiagOpts->ShowColumn) - if (unsigned ColNo = PLoc.getColumn()) - OS << ColNo << ':'; - + + // Emit a Visual Studio compatible line number syntax. + // This check is a bit paranoid (in case LangOpts isn't set). + if (Info.getDiags() && Info.getDiags()->getLangOpts() && + Info.getDiags()->getLangOpts()->Microsoft) { + OS << PLoc.getFilename() << '(' << LineNo << ')'; + OS << " : "; + } else { + OS << PLoc.getFilename() << ':' << LineNo << ':'; + if (DiagOpts->ShowColumn) + if (unsigned ColNo = PLoc.getColumn()) + OS << ColNo << ':'; + } if (DiagOpts->ShowSourceRanges && Info.getNumRanges()) { FileID CaretFileID = SM.getFileID(SM.getInstantiationLoc(Info.getLocation())); diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 123b5a0136..fbc2847a92 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -237,6 +237,8 @@ int main(int argc, char **argv) { if (!Clang.hasDiagnostics()) return 1; + Clang.getDiagnostics().setLangOpts(&Clang.getLangOpts()); + // Set an error handler, so that any LLVM backend diagnostics go through our // error handler. llvm::llvm_install_error_handler(LLVMErrorHandler,