@@ -33,6 +33,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3333#include < getopt.h>
3434#include < iostream>
3535#include < unistd.h>
36+ #include < string>
3637
3738#define opensmt_error_ () { std::cerr << " # Error (triggered at " << __FILE__ << " , " << __LINE__ << " )" << std::endl; assert (false ); ::exit ( 1 ); }
3839#define opensmt_error ( S ) { std::cerr << " ; Error: " << S << " (triggered at " << __FILE__ << " , " << __LINE__ << " )" << std::endl; ::exit ( 1 ); }
@@ -49,7 +50,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4950
5051namespace opensmt {
5152
52- inline bool pipeExecution = false ;
53+ using namespace std ::string_literals;
54+
55+ namespace {
56+ std::optional<int64_t > optTimeLimit;
57+
58+ bool pipeExecution = false ;
59+ }
5360
5461SMTConfig parseCMDLineArgs (int argc, char * argv[ ]);
5562
@@ -85,8 +92,13 @@ int main( int argc, char * argv[] )
8592 FILE * fin = NULL ;
8693
8794 SMTConfig c = parseCMDLineArgs (argc,argv);
95+
8896 Interpret interpreter (c);
8997
98+ if (optTimeLimit) {
99+ interpreter.setTimeLimit (*optTimeLimit);
100+ }
101+
90102 if (argc - optind == 0 ) {
91103 c.setInstanceName (" stdin" );
92104 if (pipeExecution) {
@@ -225,6 +237,7 @@ void printHelp()
225237 " --minimal-unsat-cores produced unsat cores must be irreducible\n "
226238 " --print-cores-full produced unsat cores are agnostic to the smt2 attribute ':named'\n "
227239 " --produce-interpolants [-i] enables interpolant computation\n "
240+ " --time-limit [-t] <ms> sets wall-clock time limit in milliseconds\n "
228241 " --pipe [-p] for execution within a pipe\n " ;
229242 std::cerr << help_string;
230243}
@@ -247,14 +260,15 @@ SMTConfig parseCMDLineArgs( int argc, char * argv[ ] )
247260 {" minimal-unsat-cores" , no_argument, &selectedLongOpt, minUcoreLongOpt},
248261 {" print-cores-full" , no_argument, &selectedLongOpt, fullUcoreLongOpt},
249262 {" produce-interpolants" , no_argument, nullptr , ' i' },
263+ {" time-limit" , required_argument, nullptr , ' t' },
250264 {" pipe" , no_argument, nullptr , ' p' },
251265 {0 , 0 , 0 , 0 }
252266 };
253267
254268 const char * msg;
255269 while (true ) {
256270 int option_index = 0 ;
257- int c = getopt_long (argc, argv, " r:hdivp " , long_options, &option_index);
271+ int c = getopt_long (argc, argv, " r:hdivpt: " , long_options, &option_index);
258272 if (c == -1 ) { break ; }
259273
260274 switch (c) {
@@ -289,6 +303,15 @@ SMTConfig parseCMDLineArgs( int argc, char * argv[ ] )
289303 case ' i' :
290304 res.setOption (SMTConfig::o_produce_inter, SMTOption (true ), msg);
291305 break ;
306+ case ' t' : {
307+ try {
308+ optTimeLimit = std::stoll (optarg);
309+ } catch (std::out_of_range const & e) {
310+ throw std::invalid_argument{" Invalid argument of time-limit: " s + e.what ()};
311+ }
312+
313+ break ;
314+ }
292315 case ' p' :
293316 pipeExecution = true ;
294317 break ;
0 commit comments