Skip to content

Commit

Permalink
Add DK_Remark to SMDiagnostic
Browse files Browse the repository at this point in the history
Swift uses SMDiagnostic for diagnostic messages. For
apple/swift#12294, we need remark support.

I picked the color that clang uses to display them.

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

llvm-svn: 315642
  • Loading branch information
anemet committed Oct 12, 2017
1 parent 0e8211e commit 01104ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/include/llvm/Support/SourceMgr.h
Expand Up @@ -43,7 +43,8 @@ class SourceMgr {
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
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/CodeGen/MIRParser/MIRParser.cpp
Expand Up @@ -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));
}
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Support/SourceMgr.cpp
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions llvm/unittests/Support/SourceMgrTest.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 01104ae

Please sign in to comment.