Skip to content

Commit e886689

Browse files
committed
fixup! parser-json-gcc: read endLine/endColumn if available
1 parent 10afff8 commit e886689

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/lib/parser-json-gcc.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "parser-gcc.hh" // for GccPostProcessor
2323

24+
using std::string;
25+
2426
struct GccTreeDecoder::Private {
2527
GccPostProcessor postProc;
2628
};
@@ -34,23 +36,23 @@ GccTreeDecoder::~GccTreeDecoder() = default;
3436

3537
static bool gccReadLocRegion(
3638
DefEvent *pEvt,
37-
const pt::ptree &beg,
38-
const pt::ptree &end)
39+
const pt::ptree &start,
40+
const pt::ptree &finish)
3941
{
4042
// read file name
41-
pEvt->fileName = valueOf<std::string>(beg, "file", "<unknown>");
42-
if (pEvt->fileName != valueOf<std::string>(end, "file", "<unknown>"))
43+
pEvt->fileName = valueOf<string>(start, "file", "<unknown>");
44+
if (pEvt->fileName != valueOf<string>(finish, "file", "<unknown>"))
4345
return false;
4446

4547
// read line
46-
if ((pEvt->line = valueOf<int>(beg, "line"))) {
47-
const int endLine = valueOf<int>(end, "line");
48+
if ((pEvt->line = valueOf<int>(start, "line"))) {
49+
const int endLine = valueOf<int>(finish, "line");
4850
pEvt->vSize = diffNums(pEvt->line, endLine);
4951
}
5052

5153
// read column
52-
if ((pEvt->column = valueOf<int>(beg, "byte-column"))) {
53-
const int endColumn = valueOf<int>(end, "byte-column");
54+
if ((pEvt->column = valueOf<int>(start, "byte-column"))) {
55+
const int endColumn = valueOf<int>(finish, "byte-column");
5456
pEvt->hSize = diffNums(pEvt->column, endColumn);
5557
}
5658

@@ -59,18 +61,16 @@ static bool gccReadLocRegion(
5961

6062
static void gccReadLocation(DefEvent *pEvt, const pt::ptree *locs)
6163
{
62-
using std::string;
63-
6464
if (locs->empty())
6565
return;
6666

6767
const pt::ptree &firstLoc = locs->begin()->second;
6868

6969
// try to read a region between start..finish
70-
const pt::ptree *beg, *end;
71-
if (findChildOf(&beg, firstLoc, "start")
72-
&& findChildOf(&end, firstLoc, "finish")
73-
&& gccReadLocRegion(pEvt, *beg, *end))
70+
const pt::ptree *start, *finish;
71+
if (findChildOf(&start, firstLoc, "start")
72+
&& findChildOf(&finish, firstLoc, "finish")
73+
&& gccReadLocRegion(pEvt, *start, *finish))
7474
return;
7575

7676
// fallback to caret
@@ -84,8 +84,6 @@ static void gccReadLocation(DefEvent *pEvt, const pt::ptree *locs)
8484

8585
static bool gccReadEvent(DefEvent *pEvt, const pt::ptree &evtNode)
8686
{
87-
using std::string;
88-
8987
// read kind (error, warning, note)
9088
string &evtName = pEvt->event;
9189
evtName = valueOf<string>(evtNode, "kind");

0 commit comments

Comments
 (0)