]> granicus.if.org Git - llvm/commitdiff
Add DK_Remark to SMDiagnostic
authorAdam Nemet <anemet@apple.com>
Thu, 12 Oct 2017 23:56:02 +0000 (23:56 +0000)
committerAdam Nemet <anemet@apple.com>
Thu, 12 Oct 2017 23:56:02 +0000 (23:56 +0000)
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.

Differential Revision: https://reviews.llvm.org/D38865

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315642 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 399f8dcd76fca6002cfa990e8b664e8b73c492a7..c08bf858760a1cf82f6701b3abe9f31ebc06c387 100644 (file)
@@ -43,7 +43,8 @@ public:
   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
index db56696391804ec44383a1373bae1e309a346000..c91255f959283006c50aade5e599d716b6ca8109 100644 (file)
@@ -214,6 +214,9 @@ void MIRParserImpl::reportDiagnostic(const SMDiagnostic &Diag) {
   case SourceMgr::DK_Note:
     Kind = DS_Note;
     break;
+  case SourceMgr::DK_Remark:
+    llvm_unreachable("remark unexpected");
+    break;
   }
   Context.diagnose(DiagnosticInfoMIRParser(Kind, Diag));
 }
index b0609d4fe047c1e89b961fab998a57b11f0ca342..a8f6208a558c96577cf37b8cf9aaa0e198c4cc6d 100644 (file)
@@ -384,6 +384,11 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &S, bool ShowColors,
         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 79c2d7278f129fa660be5de22994bd571d61d5e9..2a84a89912ad66214ef99dd33d76f0fcee065130 100644 (file)
@@ -67,6 +67,16 @@ TEST_F(SourceMgrTest, BasicWarning) {
             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);