File: call_bmc.cpp

package info (click to toggle)
cbmc 6.6.0-4
  • links: PTS
  • area: main
  • in suites: forky, trixie
  • size: 153,852 kB
  • sloc: cpp: 386,459; ansic: 114,466; java: 28,405; python: 6,003; yacc: 4,552; makefile: 4,041; lex: 2,487; xml: 2,388; sh: 2,050; perl: 557; pascal: 184; javascript: 163; ada: 36
file content (65 lines) | stat: -rw-r--r-- 1,962 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Author: Fotis Koutoulakis for Diffblue Ltd.

// Test file to try loading a GOTO-model into memory and running a sample verification run on it.
#include <util/exception_utils.h>

#include <libcprover-cpp/api.h>
#include <libcprover-cpp/api_options.h>

#include "goto_model.h"

#include <iostream>
#include <vector>

void print_messages_to_stdout(
  const api_messaget &message,
  api_call_back_contextt)
{
  std::cout << api_message_get_string(message) << std::endl;
}

int main(int argc, char *argv[])
{
  try
  {
    std::cout << "Hello from API stub" << std::endl;
    std::cout << "Working from C++ API version ";

    // Convert argv to vector of strings for initialize_goto_model
    std::vector<std::string> arguments(argv + 1, argv + argc);

    // Create API options object, to pass to initialiser of API object.
    auto api_options = api_optionst::create()
                         .simplify(false)
                         .validate_goto_model(true)
                         .drop_unused_functions(true);

    // Initialise API dependencies and global configuration in one step.
    api_sessiont api(api_options);
    std::cout << *api.get_api_version() << std::endl;

    // Demonstrate the loading of a goto-model from the command line arguments
    api.set_message_callback(print_messages_to_stdout, nullptr);
    api.load_model_from_files(arguments);

    std::cout << "Successfully initialised goto_model" << std::endl;

    // Demonstrate the validation of an already loaded goto-model
    api.validate_goto_model();

    std::cout << "Successfully validated goto_model" << std::endl;

    // Demonstrate the dropping of unused functions from an already loaded
    // goto-model
    api.drop_unused_functions();

    std::cout << "Successfully dropped unused functions from goto_model"
              << std::endl;

    return 0;
  }
  catch(const invalid_command_line_argument_exceptiont &e)
  {
    std::cout << e.what() << std::endl;
  }
}