]> granicus.if.org Git - clang/commitdiff
Integrate the following from the 'objective-rewrite' branch:
authorSteve Naroff <snaroff@apple.com>
Sat, 5 Dec 2009 02:14:08 +0000 (02:14 +0000)
committerSteve Naroff <snaroff@apple.com>
Sat, 5 Dec 2009 02:14:08 +0000 (02:14 +0000)
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

include/clang/Basic/Diagnostic.h
lib/Basic/Diagnostic.cpp
lib/Frontend/TextDiagnosticPrinter.cpp
tools/clang-cc/clang-cc.cpp

index d3744326a3dd0c37c7ce271f5cb73844d84ab80c..b9d19674af08b897aa0a03890f4ad423d412a3f1 100644 (file)
@@ -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();
index 8a0b858ba9ac834798d57da0cd96fe500b0dfe07..1f5179146b6bec97bdbdd82cf26e04d8c61b7dfd 100644 (file)
@@ -210,7 +210,8 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
   ErrorOccurred = false;
   FatalErrorOccurred = false;
   NumDiagnostics = 0;
-
+  LangOpts = 0;
+  
   NumErrors = 0;
   CustomDiagInfo = 0;
   CurDiagID = ~0U;
index 52a0f48363842a48498cba6bfe4ca5f6372e5802..eeca97d62a815eef75b1618f574ff692367a412c 100644 (file)
@@ -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()));
index 123b5a0136784db84e467e6b3e3c65834de1e958..fbc2847a9290089fba26be00e35a2a533526c403 100644 (file)
@@ -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,