[PATCH] D38865: Add DK_Remark to SMDiagnostic

Adam Nemet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 16:48:51 PDT 2017


anemet created this revision.
Herald added a subscriber: fhahn.

Swift uses SMDiagnostic for diagnostic messages. For
https://github.com/apple/swift/pull/12294, we need remark support.

I picked the color that clang uses to display them.


https://reviews.llvm.org/D38865

Files:
  include/llvm/Support/SourceMgr.h
  lib/CodeGen/MIRParser/MIRParser.cpp
  lib/Support/SourceMgr.cpp
  unittests/Support/SourceMgrTest.cpp


Index: unittests/Support/SourceMgrTest.cpp
===================================================================
--- unittests/Support/SourceMgrTest.cpp
+++ unittests/Support/SourceMgrTest.cpp
@@ -67,6 +67,16 @@
             Output);
 }
 
+TEST_F(SourceMgrTest, BasicRemark) {
+  setMainBuffer("aaa bbb\nccc ddd\n", "file.in");
+  printMessage(getLoc(4), SourceMgr::DK_Remark, "message", None, None);
+
+  EXPECT_EQ("file.in:1:5: remark: message\n"
+            "aaa bbb\n"
+            "    ^\n",
+            Output);
+}
+
 TEST_F(SourceMgrTest, BasicNote) {
   setMainBuffer("aaa bbb\nccc ddd\n", "file.in");
   printMessage(getLoc(4), SourceMgr::DK_Note, "message", None, None);
Index: lib/Support/SourceMgr.cpp
===================================================================
--- lib/Support/SourceMgr.cpp
+++ lib/Support/SourceMgr.cpp
@@ -384,6 +384,11 @@
         S.changeColor(raw_ostream::BLACK, true);
       S << "note: ";
       break;
+    case SourceMgr::DK_Remark:
+      if (ShowColors)
+        S.changeColor(raw_ostream::BLUE, true);
+      S << "remark: ";
+      break;
     }
 
     if (ShowColors) {
Index: lib/CodeGen/MIRParser/MIRParser.cpp
===================================================================
--- lib/CodeGen/MIRParser/MIRParser.cpp
+++ lib/CodeGen/MIRParser/MIRParser.cpp
@@ -214,6 +214,9 @@
   case SourceMgr::DK_Note:
     Kind = DS_Note;
     break;
+  case SourceMgr::DK_Remark:
+    llvm_unreachable("remark unexpected");
+    break;
   }
   Context.diagnose(DiagnosticInfoMIRParser(Kind, Diag));
 }
Index: include/llvm/Support/SourceMgr.h
===================================================================
--- include/llvm/Support/SourceMgr.h
+++ include/llvm/Support/SourceMgr.h
@@ -43,7 +43,8 @@
   enum DiagKind {
     DK_Error,
     DK_Warning,
-    DK_Note
+    DK_Remark,
+    DK_Note,
   };
 
   /// Clients that want to handle their own diagnostics in a custom way can


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38865.118861.patch
Type: text/x-patch
Size: 1926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171012/46b74593/attachment.bin>


More information about the llvm-commits mailing list