File tree 2 files changed +51
-2
lines changed 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,55 @@ class basic_blockst
102
102
}
103
103
};
104
104
105
+ coverage_goalst coverage_goalst::get_coverage_goals (const std::string &coverage,
106
+ message_handlert &message_handler)
107
+ {
108
+ jsont json;
109
+ coverage_goalst goals;
110
+ source_locationt source_location;
111
+
112
+ // check coverage file
113
+ if (parse_json (coverage, message_handler, json))
114
+ {
115
+ messaget message (message_handler);
116
+ message.error () << coverage << " file is not a valid json file"
117
+ << messaget::eom;
118
+ exit (0 );
119
+ }
120
+
121
+ // make sure that we have an array of elements
122
+ if (!json.is_array ())
123
+ {
124
+ messaget message (message_handler);
125
+ message.error () << " expecting an array in the " << coverage << " file, but got "
126
+ << json << messaget::eom;
127
+ exit (0 );
128
+ }
129
+
130
+ irep_idt line_number;
131
+ for (jsont::arrayt::const_iterator
132
+ it=json.array .begin ();
133
+ it!=json.array .end ();
134
+ it++)
135
+ {
136
+ // get the goals array
137
+ if ((*it)[" goals" ].is_array ())
138
+ {
139
+ for (jsont::arrayt::const_iterator
140
+ itg=(*it)[" goals" ].array .begin ();
141
+ itg!=(*it)[" goals" ].array .end ();
142
+ itg++)
143
+ {
144
+ // get the line of each existing goal
145
+ line_number=(*itg)[" sourceLocation" ][" line" ].value ;
146
+ source_location.set_line (line_number);
147
+ goals.set_goals (source_location);
148
+ }
149
+ }
150
+ }
151
+ return goals;
152
+ }
153
+
105
154
bool coverage_goalst::is_existing_goal (source_locationt source_location)
106
155
{
107
156
std::vector<source_locationt>::iterator it = existing_goals.begin ();
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ class message_handlert;
22
22
class coverage_goalst
23
23
{
24
24
public:
25
- void get_coverage (const std::string &coverage,
26
- message_handlert &message_handler);
25
+ static coverage_goalst get_coverage_goals (const std::string &coverage,
26
+ message_handlert &message_handler);
27
27
void set_goals (source_locationt goal);
28
28
bool is_existing_goal (source_locationt source_location);
29
29
You can’t perform that action at this time.
0 commit comments