Introduce the -fdiagnostics-format=xxx option to control how Clang
prints the file, line, and column of a diagnostic. We currently
support Clang's normal format, MSVC, and Vi formats.

Note that we no longer change the diagnostic format based on
-fms-extensions.

Patch by Andrew Fish!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131794 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 47c942c..46ebd18 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -819,16 +819,28 @@
         if (DiagOpts->ShowColors)
           OS.changeColor(savedColor, true);
 
-        // Emit a Visual Studio compatible line number syntax.
-        if (LangOpts && LangOpts->Microsoft) {
-          OS << PLoc.getFilename() << '(' << LineNo << ')';
-          OS << " : ";
-        } else {
-          OS << PLoc.getFilename() << ':' << LineNo << ':';
-          if (DiagOpts->ShowColumn)
-            if (unsigned ColNo = PLoc.getColumn())
-              OS << ColNo << ':';
+        OS << PLoc.getFilename();
+        switch (DiagOpts->Format) {
+        case DiagnosticOptions::Clang: OS << ':'  << LineNo; break;
+        case DiagnosticOptions::Msvc:  OS << '('  << LineNo; break;
+        case DiagnosticOptions::Vi:    OS << " +" << LineNo; break;
         }
+        if (DiagOpts->ShowColumn)
+          if (unsigned ColNo = PLoc.getColumn()) {
+            if (DiagOpts->Format == DiagnosticOptions::Msvc) {
+              OS << ',';
+              ColNo--;
+            } else 
+              OS << ':';
+            OS << ColNo;
+          }
+        switch (DiagOpts->Format) {
+        case DiagnosticOptions::Clang: 
+        case DiagnosticOptions::Vi:    OS << ':';    break;
+        case DiagnosticOptions::Msvc:  OS << ") : "; break;
+        }
+
+                
         if (DiagOpts->ShowSourceRanges && Info.getNumRanges()) {
           FileID CaretFileID =
             SM.getFileID(SM.getInstantiationLoc(Info.getLocation()));