CBMC
verification_result.cpp
Go to the documentation of this file.
1 // Copyright (c) 2023 Fotis Koutoulakis for Diffblue Ltd.
2 
5 // in a structured form.
6 
7 #include "verification_result.h"
8 
9 #include <util/exit_codes.h>
10 #include <util/invariant.h>
11 
13 
14 #include <algorithm>
15 #include <string>
16 #include <vector>
17 
19 {
22 
23 public:
27 
28  void set_properties(propertiest &properties);
29  void set_result(resultt &verification_result);
30 
32  const propertiest &get_properties();
33 };
34 
35 // Impl
36 
38  propertiest &properties)
39 {
40  _properties = properties;
41 }
42 
44  resultt &result)
45 {
46  _verifier_result = result;
47 }
48 
50 {
51  return _verifier_result;
52 }
53 
54 const propertiest &
56 {
57  return _properties;
58 }
59 
60 // Verification_result
61 
64 {
65 }
66 
68 {
69 }
70 
72  : _impl(std::make_unique<verification_result_implt>(*other._impl))
73 {
74 }
75 
80 {
81  *_impl = *other._impl;
82  return *this;
83 }
84 
86 {
87  _impl->set_properties(properties);
88 }
89 
91 {
92  _impl->set_result(result);
93 }
94 
96 {
97  switch(_impl->get_result())
98  {
99  case resultt::ERROR:
101  case resultt::FAIL:
102  return verifier_resultt::FAIL;
103  case resultt::PASS:
104  return verifier_resultt::PASS;
105  case resultt::UNKNOWN:
107  }
108  // Required to silence compiler warnings that are promoted as errors!
109  UNREACHABLE;
110 }
111 
112 std::vector<std::string> verification_resultt::get_property_ids() const
113 {
114  std::vector<std::string> result;
115  for(const auto &props : _impl->get_properties())
116  {
117  result.push_back(id2string(props.first));
118  }
119  return result;
120 }
121 
123  const std::string &property_id) const
124 {
125  auto irepidt_property = irep_idt(property_id);
126  const auto description =
127  _impl->get_properties().at(irepidt_property).description;
128  return description;
129 }
130 
132 verification_resultt::get_property_status(const std::string &property_id) const
133 {
134  auto irepidt_property = irep_idt(property_id);
135  switch(_impl->get_properties().at(irepidt_property).status)
136  {
138  return prop_statust::ERROR;
140  return prop_statust::FAIL;
146  return prop_statust::PASS;
148  return prop_statust::UNKNOWN;
149  }
150  UNREACHABLE;
151 }
152 
153 // FOTIS' note: Modelled after `result_to_exit_code` in
154 // `src/goto-checker/properties.cpp`.
156 {
157  switch(result)
158  {
167  }
168  UNREACHABLE;
169 }
verification_result_implt(const verification_result_implt &other)=default
void set_result(resultt &verification_result)
Document and give macros for the exit codes of CPROVER binaries.
#define CPROVER_EXIT_INTERNAL_ERROR
An error has been encountered during processing the requested analysis.
Definition: exit_codes.h:45
#define CPROVER_EXIT_VERIFICATION_SAFE
Verification successful indicates the analysis has been performed without error AND the software is s...
Definition: exit_codes.h:21
#define CPROVER_EXIT_VERIFICATION_INCONCLUSIVE
Verification inconclusive indicates the analysis has been performed without error AND the software is...
Definition: exit_codes.h:30
#define CPROVER_EXIT_VERIFICATION_UNSAFE
Verification successful indicates the analysis has been performed without error AND the software is n...
Definition: exit_codes.h:25
const std::string & id2string(const irep_idt &d)
Definition: irep.h:44
Properties.
@ UNKNOWN
The checker was unable to determine the status of the property.
@ NOT_REACHABLE
The property was proven to be unreachable.
@ PASS
The property was not violated.
@ ERROR
An error occurred during goto checking.
@ FAIL
The property was violated.
@ NOT_CHECKED
The property was not checked (also used for initialization)
std::map< irep_idt, property_infot > propertiest
A map of property IDs to property infos.
Definition: properties.h:76
resultt
The result of goto verifying.
Definition: properties.h:45
@ UNKNOWN
No property was violated, neither was there an error.
@ PASS
No properties were violated.
@ ERROR
An error occurred during goto checking.
@ FAIL
Some properties were violated.
#define UNREACHABLE
This should be used to mark dead code.
Definition: invariant.h:525
verification_resultt & operator=(verification_resultt &&)
std::vector< std::string > get_property_ids() const
void set_result(resultt &result)
std::unique_ptr< verification_result_implt > _impl
std::string get_property_description(const std::string &property_id) const
void set_properties(propertiest &properties)
prop_statust get_property_status(const std::string &property_id) const
verifier_resultt final_result() const
int verifier_result_to_exit_code(verifier_resultt result)
Interface for the various verification engines providing results.
dstringt irep_idt
verifier_resultt
@ PASS
No properties were violated.
@ ERROR
An error occurred during goto checking.
@ FAIL
Some properties were violated.
prop_statust
@ UNKNOWN
The checker was unable to determine the status of the property.
@ NOT_REACHABLE
The property was proven to be unreachable.
@ PASS
The property was not violated.
@ ERROR
An error occurred during goto checking.
@ FAIL
The property was violated.
@ NOT_CHECKED
The property was not checked (also used for initialization)