GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/main/main.cpp Lines: 14 20 70.0 %
Date: 2021-08-20 Branches: 31 80 38.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Morgan Deters, Aina Niemetz, Gereon Kremer
4
 *
5
 * This file is part of the cvc5 project.
6
 *
7
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
8
 * in the top-level source directory and their institutional affiliations.
9
 * All rights reserved.  See the file COPYING in the top-level source
10
 * directory for licensing information.
11
 * ****************************************************************************
12
 *
13
 * Main driver for cvc5 executable.
14
 */
15
#include "main/main.h"
16
17
#include <stdio.h>
18
#include <unistd.h>
19
20
#include <cstdlib>
21
#include <cstring>
22
#include <fstream>
23
#include <iostream>
24
25
#include "base/configuration.h"
26
#include "base/output.h"
27
#include "main/command_executor.h"
28
#include "main/interactive_shell.h"
29
#include "options/base_options.h"
30
#include "options/language.h"
31
#include "options/option_exception.h"
32
#include "options/options.h"
33
#include "parser/parser.h"
34
#include "parser/parser_builder.h"
35
#include "parser/parser_exception.h"
36
#include "util/result.h"
37
38
using namespace std;
39
using namespace cvc5;
40
using namespace cvc5::main;
41
using namespace cvc5::language;
42
43
/**
44
 * cvc5's main() routine is just an exception-safe wrapper around cvc5.
45
 * Please don't construct anything here.  Even if the constructor is
46
 * inside the try { }, an exception during destruction can cause
47
 * problems.  That's why main() wraps runCvc5() in the first place.
48
 * Put everything in runCvc5().
49
 */
50
8746
int main(int argc, char* argv[])
51
{
52
14861
  Options opts;
53
  try
54
  {
55
8746
    return runCvc5(argc, argv, opts);
56
  }
57
  catch (cvc5::api::CVC5ApiOptionException& e)
58
  {
59
#ifdef CVC5_COMPETITION_MODE
60
    *opts.base.out << "unknown" << endl;
61
#endif
62
    cerr << "(error \"" << e.getMessage() << "\")" << endl
63
         << endl
64
         << "Please use --help to get help on command-line options." << endl;
65
  }
66
2
  catch (cvc5::OptionException& e)
67
  {
68
#ifdef CVC5_COMPETITION_MODE
69
    *opts.base.out << "unknown" << endl;
70
#endif
71
2
    cerr << "(error \"" << e.getMessage() << "\")" << endl
72
1
         << endl
73
1
         << "Please use --help to get help on command-line options." << endl;
74
  }
75
40
  catch (Exception& e)
76
  {
77
#ifdef CVC5_COMPETITION_MODE
78
    *opts.base.out << "unknown" << endl;
79
#endif
80
20
    if (language::isOutputLang_smt2(opts.base.outputLanguage))
81
    {
82
16
      *opts.base.out << "(error \"" << e << "\")" << endl;
83
    }
84
    else
85
    {
86
4
      *opts.base.err << "(error \"" << e << "\")" << endl;
87
    }
88
20
    if (opts.base.statistics && pExecutor != nullptr)
89
    {
90
      totalTime.reset();
91
      pExecutor->printStatistics(*opts.base.err);
92
    }
93
  }
94
21
  exit(1);
95
26238
}