Skip to content

Commit eff4b71

Browse files
lucasccordeiropeterschrammel
authored andcommitted
a goal should be identified by a source_locationt
Signed-off-by: Lucas Cordeiro <[email protected]>
1 parent f70eadf commit eff4b71

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/goto-instrument/cover.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Date: May 2016
88
99
\*******************************************************************/
1010

11+
#include <iostream>
12+
1113
#include <algorithm>
1214
#include <iterator>
1315
#include <unordered_set>
@@ -114,6 +116,7 @@ void coverage_goalst::get_coverage(const std::string &coverage,
114116
message_handlert &message_handler)
115117
{
116118
jsont json;
119+
source_locationt source_location;
117120

118121
//check coverage file
119122
if(parse_json(coverage, message_handler, json))
@@ -133,6 +136,7 @@ void coverage_goalst::get_coverage(const std::string &coverage,
133136
exit(0);
134137
}
135138

139+
irep_idt line_number;
136140
for(jsont::arrayt::const_iterator
137141
it=json.array.begin();
138142
it!=json.array.end();
@@ -147,8 +151,9 @@ void coverage_goalst::get_coverage(const std::string &coverage,
147151
itg++)
148152
{
149153
//get the line of each existing goal
150-
const std::string line=(*itg)["sourceLocation"]["line"].value;
151-
set_goals(line);
154+
line_number=(*itg)["sourceLocation"]["line"].value;
155+
source_location.set_line(line_number);
156+
set_goals(source_location);
152157
}
153158
}
154159
}
@@ -166,7 +171,7 @@ Function: coverage_goalst::set_goals
166171
167172
\*******************************************************************/
168173

169-
void coverage_goalst::set_goals(std::string goal)
174+
void coverage_goalst::set_goals(source_locationt goal)
170175
{
171176
existing_goals.push_back(goal);
172177
}
@@ -185,10 +190,13 @@ Function: coverage_goalst::is_existing_goal
185190

186191
bool coverage_goalst::is_existing_goal(source_locationt source_location)
187192
{
188-
std::vector<std::string>::iterator it;
189-
it = find (existing_goals.begin(), existing_goals.end(),
190-
source_location.get_line().c_str());
191-
193+
std::vector<source_locationt>::iterator it = existing_goals.begin();
194+
while (it!=existing_goals.end())
195+
{
196+
if (!source_location.get_line().compare(it->get_line()))
197+
break;
198+
++it;
199+
}
192200
if(it == existing_goals.end())
193201
return true;
194202
else

src/goto-instrument/cover.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class coverage_goalst
1818
public:
1919
void get_coverage(const std::string &coverage,
2020
message_handlert &message_handler);
21-
void set_goals(std::string goal);
21+
void set_goals(source_locationt goal);
2222
bool is_existing_goal(source_locationt source_location);
2323

2424
private:
25-
std::vector<std::string> existing_goals;
25+
std::vector<source_locationt> existing_goals;
2626
};
2727

2828
enum class coverage_criteriont

0 commit comments

Comments
 (0)