@@ -52,6 +52,9 @@ namespace opensmt {
5252
5353using namespace std ::string_literals;
5454
55+ template <typename ...>
56+ constexpr bool falseTp = false ;
57+
5558namespace {
5659 bool pipeExecution = false ;
5760}
@@ -244,11 +247,27 @@ void printHelp()
244247 " --minimal-unsat-cores produced unsat cores must be irreducible\n "
245248 " --print-cores-full produced unsat cores are agnostic to the smt2 attribute ':named'\n "
246249 " --produce-interpolants [-i] enables interpolant computation\n "
247- " --time-limit [-t] <ms> sets wall-clock time limit in milliseconds\n "
250+ " --time-limit [-t] <ms> sets wall-clock time limit in milliseconds since first query\n "
251+ " --time-limit-per-query <ms> sets wall-clock time limit in milliseconds per each query\n "
248252 " --pipe [-p] for execution within a pipe\n " ;
249253 std::cerr << help_string;
250254}
251255
256+ template <typename IntT>
257+ IntT parseInt (std::string const & msg) try {
258+ if constexpr (std::is_same_v<IntT, int >) {
259+ return std::stoi (optarg);
260+ } else if constexpr (std::is_same_v<IntT, long >) {
261+ return std::stol (optarg);
262+ } else if constexpr (std::is_same_v<IntT, long long >) {
263+ return std::stoll (optarg);
264+ } else {
265+ static_assert (falseTp<IntT>);
266+ }
267+ } catch (std::logic_error const & e) {
268+ throw std::invalid_argument{msg + e.what ()};
269+ }
270+
252271SMTConfig parseCMDLineArgs ( int argc, char * argv[ ] )
253272{
254273 enum class LongOpt {
@@ -258,6 +277,7 @@ SMTConfig parseCMDLineArgs( int argc, char * argv[ ] )
258277 getUcore,
259278 minUcore,
260279 fullUcore,
280+ timeLimitPerQuery,
261281 };
262282
263283 SMTConfig res;
@@ -278,6 +298,7 @@ SMTConfig parseCMDLineArgs( int argc, char * argv[ ] )
278298 {" print-cores-full" , no_argument, &selectedLongOpt, to_underlying (LongOpt::fullUcore)},
279299 {" produce-interpolants" , no_argument, nullptr , ' i' },
280300 {" time-limit" , required_argument, nullptr , ' t' },
301+ {" time-limit-per-query" , required_argument, &selectedLongOpt, to_underlying (LongOpt::timeLimitPerQuery)},
281302 {" pipe" , no_argument, nullptr , ' p' },
282303 {0 , 0 , 0 , 0 }
283304 };
@@ -310,6 +331,10 @@ SMTConfig parseCMDLineArgs( int argc, char * argv[ ] )
310331 case LongOpt::fullUcore:
311332 res.setOption (SMTConfig::o_print_cores_full, SMTOption (true ), msg);
312333 break ;
334+ case LongOpt::timeLimitPerQuery:
335+ auto timeLimit = parseInt<int64_t >(" Invalid argument of time-limit-per-query: " );
336+ ok &= res.setOption (SMTConfig::o_time_limit_per_query, SMTOption{timeLimit}, msg);
337+ break ;
313338 }
314339 break ;
315340 case ' h' :
@@ -334,13 +359,7 @@ SMTConfig parseCMDLineArgs( int argc, char * argv[ ] )
334359 res.setOption (SMTConfig::o_produce_inter, SMTOption{true }, msg);
335360 break ;
336361 case ' t' : {
337- int64_t timeLimit;
338- try {
339- timeLimit = std::stoll (optarg);
340- } catch (std::logic_error const & e) {
341- throw std::invalid_argument{" Invalid argument of time-limit: " s + e.what ()};
342- }
343-
362+ auto timeLimit = parseInt<int64_t >(" Invalid argument of time-limit: " );
344363 ok &= res.setOption (SMTConfig::o_time_limit, SMTOption{timeLimit}, msg);
345364 break ;
346365 }
0 commit comments