GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/main/main.cpp Lines: 18 24 75.0 %
Date: 2021-09-15 Branches: 39 106 36.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 <iostream>
18
19
#include "api/cpp/cvc5.h"
20
#include "base/configuration.h"
21
#include "main/command_executor.h"
22
#include "options/option_exception.h"
23
24
using namespace cvc5;
25
26
/**
27
 * cvc5's main() routine is just an exception-safe wrapper around runCvc5.
28
 */
29
8800
int main(int argc, char* argv[])
30
{
31
14953
  std::unique_ptr<api::Solver> solver = std::make_unique<api::Solver>();
32
  try
33
  {
34
8800
    return runCvc5(argc, argv, solver);
35
  }
36
2
  catch (cvc5::api::CVC5ApiOptionException& e)
37
  {
38
#ifdef CVC5_COMPETITION_MODE
39
    solver->getDriverOptions().out() << "unknown" << std::endl;
40
#endif
41
1
    std::cerr << "(error \"" << e.getMessage() << "\")" << std::endl
42
1
              << std::endl
43
1
              << "Please use --help to get help on command-line options."
44
1
              << std::endl;
45
  }
46
  catch (OptionException& e)
47
  {
48
#ifdef CVC5_COMPETITION_MODE
49
    solver->getDriverOptions().out() << "unknown" << std::endl;
50
#endif
51
    std::cerr << "(error \"" << e.getMessage() << "\")" << std::endl
52
              << std::endl
53
              << "Please use --help to get help on command-line options."
54
              << std::endl;
55
  }
56
40
  catch (Exception& e)
57
  {
58
#ifdef CVC5_COMPETITION_MODE
59
    solver->getDriverOptions().out() << "unknown" << std::endl;
60
#endif
61
20
    if (solver->getOption("output-language") == "LANG_SMTLIB_V2_6")
62
    {
63
32
      solver->getDriverOptions().out()
64
16
          << "(error \"" << e << "\")" << std::endl;
65
    }
66
    else
67
    {
68
8
      solver->getDriverOptions().err()
69
4
          << "(error \"" << e << "\")" << std::endl;
70
    }
71
60
    if (solver->getOptionInfo("stats").boolValue()
72
60
        && main::pExecutor != nullptr)
73
    {
74
      main::pExecutor->printStatistics(solver->getDriverOptions().err());
75
    }
76
  }
77
21
  exit(1);
78
26400
}