From: Adam Nemet Date: Thu, 12 Oct 2017 23:56:02 +0000 (+0000) Subject: Add DK_Remark to SMDiagnostic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18264d1854a52e0ef36d7c17d331a6f899783a7a;p=llvm Add DK_Remark to SMDiagnostic 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 --- diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index 399f8dcd76f..c08bf858760 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -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 diff --git a/lib/CodeGen/MIRParser/MIRParser.cpp b/lib/CodeGen/MIRParser/MIRParser.cpp index db566963918..c91255f9592 100644 --- a/lib/CodeGen/MIRParser/MIRParser.cpp +++ b/lib/CodeGen/MIRParser/MIRParser.cpp @@ -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)); } diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index b0609d4fe04..a8f6208a558 100644 --- a/lib/Support/SourceMgr.cpp +++ b/lib/Support/SourceMgr.cpp @@ -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) { diff --git a/unittests/Support/SourceMgrTest.cpp b/unittests/Support/SourceMgrTest.cpp index 79c2d7278f1..2a84a89912a 100644 --- a/unittests/Support/SourceMgrTest.cpp +++ b/unittests/Support/SourceMgrTest.cpp @@ -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);