Skip to content

Commit 4726941

Browse files
committed
writer-cov: write <unknown>: for unknown locations
... so that `csdiff` can parse the output when processing it later on
1 parent be42568 commit 4726941

5 files changed

+2282
-9
lines changed

Diff for: src/lib/writer-cov.cc

+15-9
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,8 @@ void CovWriter::handleDef(const Defect &def)
6565
if (!isKeyEvt)
6666
str << d->cw.setColor(C_DARK_GRAY);
6767

68-
if (!evt.fileName.empty())
69-
str << evt.fileName << ":";
70-
71-
if (0 < evt.line)
72-
str << evt.line << ":";
73-
74-
if (0 < evt.column)
75-
str << evt.column << ":";
76-
7768
if (evt.event == "#") {
69+
// comment --> ignore location info
7870
str << d->cw.setColor(C_LIGHT_CYAN) << "#";
7971

8072
static CtxEventDetector detector;
@@ -86,6 +78,20 @@ void CovWriter::handleDef(const Defect &def)
8678
}
8779
}
8880
else {
81+
// write file name
82+
std::string fn = evt.fileName;
83+
if (fn.empty())
84+
fn = "<unknown>";
85+
str << fn << ":";
86+
87+
// write line/col
88+
if (0 < evt.line) {
89+
str << evt.line << ":";
90+
if (0 < evt.column)
91+
str << evt.column << ":";
92+
}
93+
94+
// write event
8995
str << " ";
9096
if (!evt.event.empty())
9197
str << d->cw.setColorIf(isKeyEvt, C_WHITE) << evt.event

Diff for: tests/csgrep/0127-cov-writer-noloc-args.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)