Skip to content

Commit

Permalink
[fix] Improve parseTraceEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
misonijnik committed Dec 13, 2022
1 parent 35fd8bc commit 0aa8b15
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/Runner/parse_static_analysis_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ReachWithError parseError(json &traceEvent) {
return ReachWithError::None;
}

LocatedEvent *parseTraceEvent(json &traceEvent, unsigned id) {
LocatedEvent *parseTraceEvent(json &traceEvent, unsigned id, bool last = false) {
auto location = traceEvent.at("location");
std::string file = location.at("file");
auto error = parseError(traceEvent);
Expand All @@ -147,6 +147,9 @@ LocatedEvent *parseTraceEvent(json &traceEvent, unsigned id) {
loc = new Location(file, reportLine);
}
auto le = new LocatedEvent(loc, error, id);
if (last) {
le->setErrorReachableIfNone();
}
return locatedEvent(le);
}

Expand Down Expand Up @@ -180,11 +183,14 @@ std::vector<LocatedEvent *> *parseTrace(json &trace, unsigned id) {
auto out = new std::vector<LocatedEvent *>();
out->reserve(trace.size() + 1);
out->push_back(entryPoint);
for (auto traceEvent : trace) {
auto le = parseTraceEvent(traceEvent, id);
for (unsigned i = 0; i < trace.size() - 1; ++i) {
auto le = parseTraceEvent(trace[i], id);
out->push_back(le);
}
if (trace.size() > 0) {
auto le = parseTraceEvent(trace.back(), id, true);
out->push_back(le);
}
out->back()->setErrorReachableIfNone();
return out;
}

Expand Down

0 comments on commit 0aa8b15

Please sign in to comment.