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+
1620vsd_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