36 std::optional<unsigned> thread_nr;
39 auto c_pos = val.find(
':');
40 if(c_pos != std::string::npos)
42 std::string nr = val.substr(0, c_pos);
44 val.erase(0, nr.size() + 1);
48 auto last_c_pos = val.rfind(
':');
49 if(last_c_pos != std::string::npos)
51 std::string
id = val.substr(0, last_c_pos);
59 if(maybe_fn && maybe_fn->
type.
id() == ID_code)
65 auto last_dot_pos = val.rfind(
'.');
66 if(last_dot_pos == std::string::npos)
69 "invalid loop identifier " + id,
"unwindset"};
72 std::string function_id =
id.substr(0, last_dot_pos);
73 std::string loop_nr_label =
id.substr(last_dot_pos + 1);
75 if(loop_nr_label.empty())
78 "invalid loop identifier " + id,
"unwindset"};
81 if(!
goto_model.can_produce_function(function_id))
84 log.
warning() <<
"loop identifier " <<
id
85 <<
" for non-existent function provided with unwindset"
92 if(isdigit(loop_nr_label[0]))
98 "invalid loop identifier " + id,
"unwindset"};
101 bool found = std::any_of(
105 return instruction.is_backwards_goto() &&
106 instruction.loop_number == nr;
111 log.
warning() <<
"loop identifier " <<
id
112 <<
" provided with unwindset does not match any loop"
119 std::optional<unsigned> nr;
120 std::optional<source_locationt> location;
125 instruction.labels.begin(),
126 instruction.labels.end(),
127 loop_nr_label) != instruction.labels.end())
129 location = instruction.source_location();
132 location->remove(ID_hide);
135 location.has_value() && instruction.is_backwards_goto() &&
136 instruction.source_location() == *location)
142 <<
"loop identifier " <<
id
145 nr = instruction.loop_number;
151 log.
warning() <<
"loop identifier " <<
id
152 <<
" provided with unwindset does not match any loop"
157 id = function_id +
"." + std::to_string(*nr);
161 std::string uw_string = val.substr(last_c_pos + 1);
164 std::optional<unsigned> uw(0);
166 if(uw_string.empty())
171 if(thread_nr.has_value())
std::optional< unsigned > string2optional_unsigned(const std::string &str, int base)
Convert string to unsigned similar to the stoul or stoull functions, return nullopt when the conversi...