ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
read_cbmc_goto_object.h
Go to the documentation of this file.
1#pragma once
2
3#include <istream>
4#include <map>
5#include <string>
6#include <vector>
7#include <util/irep/irep.h>
8
9class contextt;
10class goto_functionst;
11
14bool is_cbmc_goto_magic(const unsigned char header[4]);
15
22{
23public:
24 explicit cbmc_irep_readert(std::istream &in) : in(in)
25 {
26 }
27
29 unsigned read_word();
30
32 std::string read_string();
33
36
38 void read_reference(irept &dest);
39
44 bool failed() const
45 {
46 return failed_;
47 }
48
49private:
50 void read_irep(irept &dest);
51
52 std::istream &in;
53 bool failed_ = false;
54 std::map<unsigned, irept> irep_cache;
55 std::map<unsigned, irep_idt> string_cache;
56};
57
61{
62 irept stype; // CBMC "type"; renamed to avoid the C++ keyword clash Rust hit
65 std::string name;
66 std::string module;
67 std::string base_name;
68 std::string mode;
69 std::string pretty_name;
70 unsigned flags = 0;
71 bool is_type = false;
72 bool is_weak = false;
73 bool is_property = false;
74 bool is_macro = false;
75 bool is_exported = false;
76 bool is_input = false;
77 bool is_output = false;
78 bool is_state_var = false;
79 bool is_parameter = false;
80 bool is_auxiliary = false;
81 bool binding = false;
82 bool is_lvalue = false;
83 bool is_static_lifetime = false;
84 bool is_thread_local = false;
85 bool is_file_local = false;
86 bool is_extern = false;
87 bool is_volatile = false;
88};
89
94{
98 unsigned instr_type = 0;
99 unsigned target_number = 0;
100 std::vector<unsigned> targets;
101 std::vector<std::string> labels;
102};
103
105{
106 std::string name;
107 std::vector<cbmc_instructiont> instructions;
108};
109
111{
112 std::vector<cbmc_symbolt> symbols;
113 std::vector<cbmc_functiont> functions;
114};
115
119bool parse_cbmc_goto(
120 std::istream &in,
121 const std::string &filename,
122 cbmc_parse_resultt &result);
123
128 std::istream &in,
129 const std::string &filename,
130 contextt &context,
131 goto_functionst &goto_functions);
void read_reference(irept &dest)
Reads a word-tagged, cached irep reference (with S/N/C children).
Definition read_cbmc_goto_object.cpp:108
bool failed() const
True once a malformed encoding was hit.
Definition read_cbmc_goto_object.h:44
irep_idt read_string_ref()
Reads a word-tagged, cached string reference.
Definition read_cbmc_goto_object.cpp:93
cbmc_irep_readert(std::istream &in)
Definition read_cbmc_goto_object.h:24
unsigned read_word()
CBMC encodes words as little-endian 7-bit varints (continuation bit 0x80).
Definition read_cbmc_goto_object.cpp:23
std::string read_string()
Reads a NUL-terminated string with backslash escaping (same as ESBMC).
Definition read_cbmc_goto_object.cpp:67
Definition context.h:57
Definition goto_functions.h:56
Definition irep_idt.h:12
Definition irep.h:36
bool is_cbmc_goto_magic(const unsigned char header[4])
True if the 4-byte header is the CBMC goto-binary magic (0x7f 'G' 'B' 'F').
Definition read_cbmc_goto_object.cpp:17
bool read_cbmc_goto_object(std::istream &in, const std::string &filename, contextt &context, goto_functionst &goto_functions)
Reads a CBMC goto-binary, adapts it to ESBMC irep conventions, and populates the symbol table and got...
Definition read_cbmc_goto_object.cpp:348
bool parse_cbmc_goto(std::istream &in, const std::string &filename, cbmc_parse_resultt &result)
Parses a CBMC goto-binary stream (header 0x7f 'G' 'B' 'F', version 6) into the intermediate,...
Definition read_cbmc_goto_object.cpp:189
Definition read_cbmc_goto_object.h:105
std::string name
Definition read_cbmc_goto_object.h:106
std::vector< cbmc_instructiont > instructions
Definition read_cbmc_goto_object.h:107
Intermediate parse of a CBMC instruction (mirrors cbmc.rs CBMCInstruction).
Definition read_cbmc_goto_object.h:94
unsigned target_number
Definition read_cbmc_goto_object.h:99
unsigned instr_type
Definition read_cbmc_goto_object.h:98
irept source_location
Definition read_cbmc_goto_object.h:96
irept code
Definition read_cbmc_goto_object.h:95
std::vector< unsigned > targets
Definition read_cbmc_goto_object.h:100
irept guard
Definition read_cbmc_goto_object.h:97
std::vector< std::string > labels
Definition read_cbmc_goto_object.h:101
Definition read_cbmc_goto_object.h:111
std::vector< cbmc_symbolt > symbols
Definition read_cbmc_goto_object.h:112
std::vector< cbmc_functiont > functions
Definition read_cbmc_goto_object.h:113
Intermediate, pre-adaptation parse of a CBMC symbol (mirrors cbmc.rs CBMCSymbol).
Definition read_cbmc_goto_object.h:61
std::string base_name
Definition read_cbmc_goto_object.h:67
irept location
Definition read_cbmc_goto_object.h:64
std::string name
Definition read_cbmc_goto_object.h:65
irept value
Definition read_cbmc_goto_object.h:63
bool is_auxiliary
Definition read_cbmc_goto_object.h:80
bool is_output
Definition read_cbmc_goto_object.h:77
unsigned flags
Definition read_cbmc_goto_object.h:70
bool is_macro
Definition read_cbmc_goto_object.h:74
bool is_parameter
Definition read_cbmc_goto_object.h:79
bool is_lvalue
Definition read_cbmc_goto_object.h:82
bool is_exported
Definition read_cbmc_goto_object.h:75
bool is_state_var
Definition read_cbmc_goto_object.h:78
bool binding
Definition read_cbmc_goto_object.h:81
std::string pretty_name
Definition read_cbmc_goto_object.h:69
bool is_weak
Definition read_cbmc_goto_object.h:72
bool is_volatile
Definition read_cbmc_goto_object.h:87
bool is_extern
Definition read_cbmc_goto_object.h:86
bool is_thread_local
Definition read_cbmc_goto_object.h:84
bool is_static_lifetime
Definition read_cbmc_goto_object.h:83
std::string module
Definition read_cbmc_goto_object.h:66
bool is_file_local
Definition read_cbmc_goto_object.h:85
bool is_property
Definition read_cbmc_goto_object.h:73
bool is_input
Definition read_cbmc_goto_object.h:76
irept stype
Definition read_cbmc_goto_object.h:62
bool is_type
Definition read_cbmc_goto_object.h:71
std::string mode
Definition read_cbmc_goto_object.h:68