Skip to content

Commit 2aafefa

Browse files
committed
Prevent simultaneous data-dependencies and liveness options
1 parent 0a3b7e3 commit 2aafefa

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/analyses/variable-sensitivity/variable_sensitivity_configuration.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#include <limits>
1414
#include <util/options.h>
1515

16+
static void check_one_of_options(
17+
const optionst &options,
18+
const std::vector<std::string> &names);
19+
1620
vsd_configt vsd_configt::from_options(const optionst &options)
1721
{
1822
vsd_configt config{};
@@ -37,6 +41,7 @@ vsd_configt vsd_configt::from_options(const optionst &options)
3741
config.context_tracking.data_dependency_context =
3842
options.get_bool_option("data-dependencies");
3943
config.context_tracking.liveness = options.get_bool_option("liveness");
44+
check_one_of_options(options, {"data-dependencies", "liveness"});
4045

4146
config.flow_sensitivity = (options.get_bool_option("flow-insensitive"))
4247
? flow_sensitivityt::insensitive
@@ -166,3 +171,26 @@ size_t vsd_configt::option_to_size(
166171
}
167172
return selected->second;
168173
}
174+
175+
void check_one_of_options(
176+
const optionst &options,
177+
const std::vector<std::string> &names)
178+
{
179+
int how_many = 0;
180+
for(auto &name : names)
181+
how_many += options.get_bool_option(name);
182+
183+
if(how_many <= 1)
184+
return;
185+
186+
auto choices = std::string("");
187+
for(auto &name : names)
188+
{
189+
choices += (!choices.empty() ? "|" : "");
190+
auto option = "--vsd-" + name;
191+
choices += option;
192+
}
193+
194+
throw invalid_command_line_argument_exceptiont{"Conflicting arguments",
195+
"Can only use of " + choices};
196+
}

0 commit comments

Comments
 (0)