Skip to content

Commit 09f91ee

Browse files
authored
Merge pull request #6996 from tautschnig/cleanup/comma-separated-command-lines
Use cmdlinet::get_comma_separated_values where possible
2 parents e104827 + e12b764 commit 09f91ee

File tree

9 files changed

+18
-24
lines changed

9 files changed

+18
-24
lines changed

jbmc/src/jbmc/jbmc_parse_options.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options)
203203
options.set_option("depth", cmdline.get_value("depth"));
204204

205205
if(cmdline.isset("unwindset"))
206-
options.set_option("unwindset", cmdline.get_value("unwindset"));
206+
{
207+
options.set_option(
208+
"unwindset", cmdline.get_comma_separated_values("unwindset"));
209+
}
207210

208211
// constant propagation
209212
if(cmdline.isset("no-propagation"))

regression/goto-instrument/unwind-unwindset4/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--unwindset main.0:10,f.0:10,g.0:10,g.1:10 --unwinding-assertions
3+
--unwindset main.0:10,f.0:10 --unwindset g.0:10,g.1:10 --unwinding-assertions
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CORE
22
main.gb
3-
--breakpoint checkpoint --symbols p1,x,p2
3+
--breakpoint checkpoint --symbols p1,x --symbols p2
44
^EXIT=0$
55
^SIGNAL=0$

src/cbmc/cbmc_parse_options.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
255255
}
256256

257257
if(cmdline.isset("unwindset"))
258-
options.set_option("unwindset", cmdline.get_values("unwindset"));
258+
{
259+
options.set_option(
260+
"unwindset", cmdline.get_comma_separated_values("unwindset"));
261+
}
259262

260263
// constant propagation
261264
if(cmdline.isset("no-propagation"))

src/goto-instrument/goto_instrument_parse_options.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ int goto_instrument_parse_optionst::doit()
186186
if(unwindset_given)
187187
{
188188
unwindset.parse_unwindset(
189-
cmdline.get_values("unwindset"), ui_message_handler);
189+
cmdline.get_comma_separated_values("unwindset"),
190+
ui_message_handler);
190191
}
191192

192193
bool unwinding_assertions=cmdline.isset("unwinding-assertions");

src/goto-instrument/unwindset.cpp

+1-7
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,7 @@ void unwindsett::parse_unwindset(
179179
message_handlert &message_handler)
180180
{
181181
for(auto &element : unwindset)
182-
{
183-
std::vector<std::string> unwindset_elements =
184-
split_string(element, ',', true, true);
185-
186-
for(auto &element : unwindset_elements)
187-
parse_unwindset_one_loop(element, message_handler);
188-
}
182+
parse_unwindset_one_loop(element, message_handler);
189183
}
190184

191185
optionalt<unsigned>

src/memory-analyzer/analyze_symbol.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ mp_integer gdb_value_extractort::get_type_size(const typet &type) const
106106
return *maybe_size / CHAR_BIT;
107107
}
108108

109-
void gdb_value_extractort::analyze_symbols(const std::vector<irep_idt> &symbols)
109+
void gdb_value_extractort::analyze_symbols(
110+
const std::list<std::string> &symbols)
110111
{
111112
// record addresses of given symbols
112113
for(const auto &id : symbols)

src/memory-analyzer/analyze_symbol.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class gdb_value_extractort
4444
/// \ref symbol_exprt (via the `values` map) and then call
4545
/// \ref analyze_symbol on it.
4646
/// \param symbols: names of symbols to be analysed
47-
void analyze_symbols(const std::vector<irep_idt> &symbols);
47+
void analyze_symbols(const std::list<std::string> &symbols);
4848

4949
/// Get memory snapshot as C code
5050
/// \return converted block of code with the collected assignments

src/memory-analyzer/memory_analyzer_parse_options.cpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Author: Malte Mues <[email protected]>
1515
#include <util/config.h>
1616
#include <util/exit_codes.h>
1717
#include <util/message.h>
18-
#include <util/string_utils.h>
1918
#include <util/version.h>
2019

2120
#include <goto-programs/goto_model.h>
@@ -103,9 +102,6 @@ int memory_analyzer_parse_optionst::doit()
103102

104103
std::string binary = cmdline.args.front();
105104

106-
const std::string symbol_list(cmdline.get_value("symbols"));
107-
std::vector<std::string> result = split_string(symbol_list, ',', true, true);
108-
109105
auto opt = read_goto_binary(binary, ui_message_handler);
110106

111107
if(!opt.has_value())
@@ -131,12 +127,8 @@ int memory_analyzer_parse_optionst::doit()
131127
gdb_value_extractor.run_gdb_to_breakpoint(breakpoint);
132128
}
133129

134-
std::vector<irep_idt> result_ids(result.size());
135-
std::transform(
136-
result.begin(), result.end(), result_ids.begin(), [](std::string &name) {
137-
return irep_idt{name};
138-
});
139-
gdb_value_extractor.analyze_symbols(result_ids);
130+
gdb_value_extractor.analyze_symbols(
131+
cmdline.get_comma_separated_values("symbols"));
140132

141133
std::ofstream file;
142134

0 commit comments

Comments
 (0)