13
13
#include < limits>
14
14
#include < util/options.h>
15
15
16
+ static void check_one_of_options (
17
+ const optionst &options,
18
+ const std::vector<std::string> &names);
19
+
16
20
vsd_configt vsd_configt::from_options (const optionst &options)
17
21
{
18
22
vsd_configt config{};
@@ -37,6 +41,7 @@ vsd_configt vsd_configt::from_options(const optionst &options)
37
41
config.context_tracking .data_dependency_context =
38
42
options.get_bool_option (" data-dependencies" );
39
43
config.context_tracking .liveness = options.get_bool_option (" liveness" );
44
+ check_one_of_options (options, {" data-dependencies" , " liveness" });
40
45
41
46
config.flow_sensitivity = (options.get_bool_option (" flow-insensitive" ))
42
47
? flow_sensitivityt::insensitive
@@ -166,3 +171,26 @@ size_t vsd_configt::option_to_size(
166
171
}
167
172
return selected->second ;
168
173
}
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