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:
<rdar://problem/6309338> slightly different error message format for Visual Studio.
The fix for <rdar://problem/6845623> 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 d374432..b9d1967 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -182,6 +182,7 @@
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 @@
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 8a0b858..1f51791 100644
--- a/lib/Basic/Diagnostic.cpp
+++ b/lib/Basic/Diagnostic.cpp
@@ -210,7 +210,8 @@
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 52a0f48..eeca97d 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -653,11 +653,19 @@
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 123b5a0..fbc2847 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -237,6 +237,8 @@
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,