ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
solidity_convert.h
Go to the documentation of this file.
1
10
11#ifndef SOLIDITY_FRONTEND_SOLIDITY_CONVERT_H_
12#define SOLIDITY_FRONTEND_SOLIDITY_CONVERT_H_
13
14#include <memory>
15#include <stack>
16#include <vector>
17#include <map>
18#include <queue>
19#include <util/symtab/context.h>
21#include <util/irep/std_types.h>
22#include <util/irep/std_code.h>
24#include <nlohmann/json.hpp>
28#include <util/expr/expr_util.h>
29
31{
32public:
34 contextt &_context,
35 nlohmann::json &_ast_json,
36 const std::string &_sol_cnts,
37 const std::string &_sol_func,
38 const std::string &_contract_path,
39 const std::string &_focus_func = std::string());
40 virtual ~solidity_convertert() = default;
41
42 bool convert();
43 static bool is_low_level_call(const std::string &name);
44 static bool is_low_level_property(const std::string &name);
45
46 // find reference
47 static const nlohmann::json &
48 find_last_parent(const nlohmann::json &json, const nlohmann::json &target);
49 static const nlohmann::json &find_parent_contract(
50 const nlohmann::json &json,
51 const nlohmann::json &target);
52
53 // Pure DFS: find node with matching "id" field in any JSON subtree.
54 static const nlohmann::json &
55 find_node_by_id(const nlohmann::json &subtree, int ref_id);
56
57 // Scoped declaration lookup: searches current_baseContractName + libraries
58 // + global scope. Handles virtual/override via overrideMap.
59 // After inheritance merging, node IDs are not unique across contracts,
60 // so this function restricts the search to the correct scope.
61 const nlohmann::json &find_decl_ref(int ref_id);
62
63 static const nlohmann::json &find_constructor_ref(int ref_decl_id);
64 static const nlohmann::json &
65 find_constructor_ref(const std::string &contract_name);
66
67 // Set/get SolType enum on a typet via the #sol_type irep attribute.
69 {
70 t.set("#sol_type", SolidityGrammar::sol_type_to_str(st));
71 }
73 {
74 return SolidityGrammar::str_to_sol_type(t.get("#sol_type").as_string());
75 }
76
77 // Set/get/test the Solidity array length carried on a typet via the
78 // #sol_array_size irep attribute. The size is stored in its decimal
79 // string form; an absent attribute reads back as the empty string.
80 static void set_sol_array_size(typet &t, const std::string &size)
81 {
82 t.set("#sol_array_size", size);
83 }
84 static std::string get_sol_array_size(const typet &t)
85 {
86 return t.get("#sol_array_size").as_string();
87 }
88 static bool has_sol_array_size(const typet &t)
89 {
90 return !t.get("#sol_array_size").empty();
91 }
92
93 // Set/get/test the Solidity fixed-bytes (bytesN) width carried on a typet
94 // via the #sol_bytesn_size irep attribute, stored in its decimal form. Two
95 // setter overloads mirror irept::set: integral widths use the long form,
96 // already-stringified widths (copied between types) use the irep_idt form.
97 static void set_sol_bytesn_size(typet &t, long size)
98 {
99 t.set("#sol_bytesn_size", size);
100 }
101 static void set_sol_bytesn_size(typet &t, const irep_idt &size)
102 {
103 t.set("#sol_bytesn_size", size);
104 }
105 static std::string get_sol_bytesn_size(const typet &t)
106 {
107 return t.get("#sol_bytesn_size").as_string();
108 }
109 static bool has_sol_bytesn_size(const typet &t)
110 {
111 return !t.get("#sol_bytesn_size").empty();
112 }
113
114 // The declaring contract of a contract type. No longer carried on the typet:
115 // see get_sol_contract below.
121 std::string get_sol_contract(const typet &t) const
122 {
123 const typet &sub = t.is_pointer() ? t.subtype() : t;
124 if (sub.id() != typet::t_symbol)
125 return "";
126
127 const std::string id = sub.identifier().as_string();
128 if (id.compare(0, prefix.size(), prefix) != 0)
129 return "";
130
131 const std::string cname = id.substr(prefix.size());
132 return linearizedBaseList.count(cname) ? cname : "";
133 }
134 bool has_sol_contract(const typet &t) const
135 {
136 return !get_sol_contract(t).empty();
137 }
138
139 // Set/get the Solidity "mapping-backed array" flag carried on a typet via
140 // the #sol_mapping_array irep attribute.
141 static void set_sol_mapping_array(typet &t, bool v)
142 {
143 t.set("#sol_mapping_array", v);
144 }
145 static bool get_sol_mapping_array(const typet &t)
146 {
147 return t.get_bool("#sol_mapping_array");
148 }
149
150 // Set/get the Solidity "state-variable dynamic array" flag carried on a
151 // typet via the #sol_dynarray_state irep attribute.
152 static void set_sol_dynarray_state(typet &t, bool v)
153 {
154 t.set("#sol_dynarray_state", v);
155 }
156 static bool get_sol_dynarray_state(const typet &t)
157 {
158 return t.get_bool("#sol_dynarray_state");
159 }
160
161 // Set/get the Solidity "state variable" flag carried on a typet via the
167 std::unordered_set<irep_idt> sol_state_vars;
168
170 {
171 if (v)
173 else
175 }
177 {
178 return sol_state_vars.count(symbol_id) != 0;
179 }
180
181 // json nodes that always empty
182 // used as the return value for find_constructor_ref when
183 // dealing with the implicit constructor call
184 // this is to avoid reference to stack memory associated with local variable
185 // returned
186 static const nlohmann::json empty_json;
189 static std::string current_baseContractName;
190
191 // json for Solidity AST. Use object for contract
192 static nlohmann::json src_ast_json;
193 // User-Defined Variable Mapping
194 // e.g. type UFixed256x18 is uint256;
195 static std::unordered_map<std::string, typet> UserDefinedVarMap;
196
197protected:
198 typedef struct func_sig
199 {
200 std::string name;
201 std::string id;
202 std::string visibility;
207
209 const std::string &name,
210 const std::string &id,
211 const std::string &visibility,
212 const code_typet &type,
213 bool is_payable,
214 bool is_inherit,
215 bool is_library)
216 : name(name),
217 id(id),
219 type(type),
223 {
224 }
225
226 bool operator==(const func_sig &other) const
227 {
228 return id == other.id;
229 }
231
232 void merge_multi_files();
233 void topological_sort(
234 std::unordered_map<std::string, std::unordered_set<std::string>> &graph,
235 std::unordered_map<std::string, nlohmann::json> &path_to_json,
236 nlohmann::json &sorted_files);
237 bool contract_precheck();
238 bool check_sol_ver();
240 bool
241 populate_function_signature(nlohmann::json &json, const std::string &cname);
242 bool populate_low_level_functions(const std::string &cname);
244 const nlohmann::json &contract_def,
245 const std::string &cname);
246 void get_cname_expr(const std::string &cname, exprt &new_expr);
247
248 // conversion functions
249 // get decl in rule contract-body-element
250 bool get_contract_definition(const std::string &c_name);
251 bool get_non_function_decl(const nlohmann::json &ast_node, exprt &new_expr);
252 bool get_function_decl(const nlohmann::json &ast_node);
253 bool get_var_decl(
254 const nlohmann::json &ast_node,
255 const nlohmann::json &initialValue,
256 exprt &new_expr);
257 bool get_var_decl(const nlohmann::json &ast_node, exprt &new_expr);
258 bool get_function_definition(const nlohmann::json &ast_node);
260 const std::string &c_name,
261 const locationt &loc,
262 exprt &body_exprt);
264 const nlohmann::json &ast_node,
265 const std::string &c_name,
266 const std::string &f_name,
267 const std::string &f_id,
268 const bool add_reentry,
269 exprt &body_exprt);
270 bool has_modifier_invocation(const nlohmann::json &ast_node);
272 const nlohmann::json &ast_node,
273 const std::string &cname,
274 const std::string &fname,
275 nlohmann::json *&modifier_def);
277 const std::string &cname,
278 const std::string &fname,
279 nlohmann::json *&modifier_def);
281 const std::string &cname,
282 const std::string &mod_name,
283 const std::string &func_name,
284 std::string &name,
285 std::string &id);
287 const nlohmann::json &pd,
288 const std::string &cname,
289 exprt &param);
291 const std::string &contract_name,
292 const std::string &ctor_id,
293 const std::string &debug_modulename,
294 const locationt &location_begin,
295 code_typet &type);
297 const std::string contractName,
298 code_function_callt &call);
300 const std::string c_name,
301 std::string &name,
302 std::string &id);
303 void add_static_contract_instance(const std::string c_name);
304 void
305 get_static_contract_instance_ref(const std::string &c_name, exprt &new_expr);
307 const std::string bs_c_name,
308 const std::string c_name,
309 std::string &name,
310 std::string &id);
312 const std::string bs_c_name,
313 const std::string c_name,
314 const nlohmann::json &args_list,
315 symbolt &sym);
316 void get_inherit_ctor_definition(const std::string c_name, exprt &new_expr);
318 const std::string c_name,
319 std::string &name,
320 std::string &id);
322 const std::string c_name,
323 std::string &name,
324 std::string &id);
326 const std::string c_name,
327 const exprt &this_expr,
328 exprt &expr);
330 const std::string c_name,
331 const exprt &this_expr,
332 exprt &front_block,
333 exprt &back_block);
334 bool is_sol_builin_symbol(const std::string &cname, const std::string &name);
335 nlohmann::json reorder_arguments(
336 const nlohmann::json &expr,
337 const nlohmann::json &callee_expr_json);
338
339 // handle the non-contract definition, including
340 // struct/enum/error/event/abstract/...
341 bool get_noncontract_defition(nlohmann::json &ast_node);
342 bool
343 get_noncontract_decl_ref(const nlohmann::json &ast_node, exprt &new_expr);
344 bool get_struct_class(const nlohmann::json &ast_node);
345 void add_enum_member_val(nlohmann::json &ast_node);
346 bool get_error_definition(const nlohmann::json &ast_node);
347 void add_empty_body_node(nlohmann::json &ast_node);
348
349 // handle inheritance
351 const std::string &c_name,
352 nlohmann::json &c_node,
353 std::set<std::string> &merged_list);
354 void add_inherit_label(nlohmann::json &node, const std::string &cname);
355
356 // handle constructor
357 bool get_constructor(
358 const nlohmann::json &ast_node,
359 const std::string &contract_name);
360 bool add_implicit_constructor(const std::string &contract_name);
362 const std::string &contract_name,
363 const bool is_object,
364 exprt &new_expr);
366 const std::string &contract_name,
367 exprt &new_expr);
368 void move_to_initializer(const exprt &expr);
370 const nlohmann::json *based_contracts,
371 const nlohmann::json &current_contract,
372 const std::string contract_name);
374 const nlohmann::json *based_contracts,
375 const nlohmann::json &current_contract,
376 const std::string contract_name,
377 bool is_aux_ctor);
378 bool move_initializer_to_main(codet &func_body);
380 const nlohmann::json *based_contracts,
381 const std::string contract_name,
382 std::string ctor_id,
383 symbolt &sym);
384 void move_to_front_block(const exprt &expr);
385 void move_to_back_block(const exprt &expr);
386
387 // Symbol id of a library function's formal parameter (pure — no reliance on
388 // current_functionName). Shared between the library function body builder
389 // and the call-site copy-back logic so the ID format stays in one place.
390 static std::string get_library_param_id(
391 const std::string &lib_cname,
392 const std::string &func_name,
393 const std::string &param_name,
394 int param_ast_id);
395
396 // handle contract variables and functions
397 bool
398 get_struct_class_fields(const nlohmann::json &ast_node, struct_typet &type);
399 bool
400 get_struct_class_method(const nlohmann::json &ast_node, struct_typet &type);
401
403 const nlohmann::json &ast_node,
405 bool get_block(
406 const nlohmann::json &expr,
407 exprt &new_expr); // For Solidity's mutually inclusive: rule block and rule
408 // statement
409 bool get_statement(const nlohmann::json &block, exprt &new_expr);
410 bool get_expr(const nlohmann::json &expr, exprt &new_expr);
411 bool get_expr(
412 const nlohmann::json &expr,
413 const nlohmann::json &expr_common_type,
414 exprt &new_expr);
415 bool get_init_expr(
416 const nlohmann::json &init_value,
417 const nlohmann::json &literal_type,
418 const typet &dest_type,
419 exprt &new_expr);
420 // Expression handlers (extracted from get_expr switch)
421 bool get_decl_ref_expr(const nlohmann::json &expr, exprt &new_expr);
422 bool get_literal_expr(
423 const nlohmann::json &expr,
424 const nlohmann::json &literal_type,
425 exprt &new_expr);
426 bool get_tuple_expr(
427 const nlohmann::json &expr,
428 const nlohmann::json &literal_type,
429 exprt &new_expr);
430 bool get_call_expr(
431 const nlohmann::json &expr,
432 const nlohmann::json &literal_type,
433 exprt &new_expr);
435 const nlohmann::json &expr,
436 const nlohmann::json &literal_type,
437 exprt &new_expr);
439 const nlohmann::json &expr,
440 const nlohmann::json &literal_type,
441 exprt &new_expr);
443 const nlohmann::json &expr,
444 const nlohmann::json &literal_type,
445 exprt &new_expr);
447 const nlohmann::json &expr,
448 const nlohmann::json &literal_type,
449 exprt &new_expr);
450
451 bool get_binary_operator_expr(const nlohmann::json &expr, exprt &new_expr);
453 exprt &lhs,
454 exprt &rhs,
455 const typet &common_type,
456 bool is_shift,
457 const nlohmann::json &expr);
459 const nlohmann::json &expr,
460 exprt &lhs,
461 exprt &rhs,
462 typet &common_type,
463 exprt &new_expr);
465 const nlohmann::json &expr,
466 const nlohmann::json &literal_type,
467 exprt &new_expr);
468 bool
469 get_conditional_operator_expr(const nlohmann::json &expr, exprt &new_expr);
470 bool get_cast_expr(
471 const nlohmann::json &cast_expr,
472 exprt &new_expr,
473 const nlohmann::json literal_type = nullptr);
474 bool get_var_decl_ref(
475 const nlohmann::json &decl,
476 const bool is_this_ptr,
477 exprt &new_expr);
479 const std::string &sym_name,
480 const std::string &sym_id,
481 const typet &t,
482 exprt &new_expr);
483 bool get_func_decl_ref(const nlohmann::json &decl, exprt &new_expr);
484 bool get_func_decl_this_ref(const nlohmann::json &decl, exprt &new_expr);
486 const std::string contract_name,
487 const std::string &func_id,
488 exprt &new_expr);
489 bool get_ctor_decl_this_ref(const nlohmann::json &caller, exprt &this_object);
490 bool get_ctor_decl_this_ref(const std::string &c_name, exprt &this_object);
491 bool get_enum_member_ref(const nlohmann::json &decl, exprt &new_expr);
492 bool get_esbmc_builtin_ref(const nlohmann::json &decl, exprt &new_expr);
493 bool get_type_description(const nlohmann::json &type_name, typet &new_type);
495 const nlohmann::json &decl,
496 const nlohmann::json &type_name,
497 typet &new_type);
498 bool get_func_decl_ref_type(const nlohmann::json &decl, typet &new_type);
499 bool get_array_to_pointer_type(const nlohmann::json &decl, typet &new_type);
500 bool
501 get_elementary_type_name(const nlohmann::json &type_name, typet &new_type);
502 bool get_parameter_list(const nlohmann::json &type_name, typet &new_type);
504 const nlohmann::json &ast_node,
505 const std::string &cname,
506 std::string &name,
507 std::string &id);
509 const nlohmann::json &ast_node,
510 const std::string &cname,
511 std::string &name,
512 std::string &id);
514 const nlohmann::json &ast_node,
515 std::string &name,
516 std::string &id);
518 const nlohmann::json &ast_node,
519 std::string &name,
520 std::string &id);
522 const nlohmann::json &decl,
523 std::string &name,
524 std::string &id);
526 const nlohmann::json &decl_ref,
527 const nlohmann::json &caller,
530 const nlohmann::json &member_access,
531 const nlohmann::json &call_expr,
532 exprt &new_expr);
533 std::string find_contract_name_for_id(int func_id);
534 bool get_ctor_call(
535 const nlohmann::json &decl_ref,
536 const nlohmann::json &epxr,
539 const nlohmann::json &ast_node,
540 const bool is_object,
541 exprt &new_expr);
543 const std::string &contract_name,
544 const nlohmann::json param_list,
545 const bool is_object,
546 exprt &new_expr);
548 const nlohmann::json &ast_node,
549 std::string &contract_name);
551 const nlohmann::json &decl_ref,
552 const nlohmann::json &caller,
554 bool skip_first_param = false);
556 const exprt &func,
557 const typet &t,
558 const nlohmann::json &decl_ref,
559 const nlohmann::json &caller,
561 bool skip_first_param = false);
563 const std::string &func_name,
564 const std::string &func_id,
565 const typet &t,
566 const locationt &l,
567 exprt &new_expr);
569 const locationt &loc,
572 const locationt &loc,
575 const locationt &loc,
578 const locationt &loc,
581 const locationt &loc,
583 bool is_esbmc_library_function(const std::string &id);
584 bool get_empty_array_ref(const nlohmann::json &ast_node, exprt &new_expr);
585 void get_unique_name(
586 const std::string &name_prefix,
587 const std::string &id_prefix,
588 std::string &aux_name,
589 std::string &aux_id);
590 void get_aux_array_name(std::string &aux_name, std::string &aux_id);
591 void
592 get_aux_array(const exprt &src_expr, const typet &sub_t, exprt &new_expr);
593 void get_aux_var(std::string &aux_name, std::string &aux_id);
594 void get_size_expr(const exprt &rhs, exprt &size_expr);
596 const exprt &dyn_arr,
597 const exprt &size_expr,
598 exprt &store_call);
599 bool check_array_push_pop_length(const nlohmann::json &node);
600
601 // tuple
602 bool get_tuple_definition(const nlohmann::json &ast_node);
603 bool get_tuple_instance(const nlohmann::json &ast_node, exprt &new_expr);
604 void get_tuple_name(
605 const nlohmann::json &ast_node,
606 std::string &name,
607 std::string &id);
609 const nlohmann::json &ast_node,
610 std::string &name,
611 std::string &id);
612 bool get_tuple_function_ref(const nlohmann::json &ast_node, exprt &new_expr);
614 const irep_idt instance_id,
615 const exprt &comp,
616 exprt &new_expr);
618 const nlohmann::json &ast_node,
619 const exprt &lhs,
620 const exprt &rhs);
622 const nlohmann::json &expr,
623 const nlohmann::json &lhs_json,
624 const nlohmann::json &rhs_json);
625 void
626 get_tuple_assignment(const nlohmann::json &expr, const exprt &lop, exprt rop);
627 void get_tuple_function_call(const exprt &op);
628 void get_llc_ret_tuple(symbolt &sym);
629
630 // string
631 void
632 get_string_assignment(const exprt &lhs, const exprt &rhs, exprt &new_expr);
633
634 // mapping
636 const std::string &cname,
637 const std::string &name,
638 std::string &arr_name,
639 std::string &arr_id);
640 bool is_mapping_set_lvalue(const nlohmann::json &json);
642 const nlohmann::json &map_node,
643 typet &key_t,
644 typet &value_t,
645 SolidityGrammar::SolType &key_sol_type,
646 SolidityGrammar::SolType &val_sol_type);
648 const std::string &c_name,
649 exprt &pos,
650 const locationt &l,
651 const typet &key_type);
654 const typet &value_t,
655 SolidityGrammar::SolType val_sol_type,
656 bool is_mapping_set,
657 const exprt &array,
658 const exprt &pos,
659 const locationt &location,
660 exprt &new_expr);
662 const typet &struct_t,
663 std::string &struct_contract_name,
664 const side_effect_expr_function_callt &gen_call,
665 exprt &new_expr);
667
668 // line number and locations
669 void
670 get_location_from_node(const nlohmann::json &ast_node, locationt &location);
672 const nlohmann::json &ast_node,
673 locationt &location);
675 const nlohmann::json &ast_node,
676 locationt &location);
677 unsigned int
678 get_line_number(const nlohmann::json &ast_node, bool final_position = false);
679 size_t add_offset(const std::string &src, size_t start_position);
680 std::string get_src_from_json(const nlohmann::json &ast_node);
681
683 bool multi_transaction_verification(const std::string &contractName);
684 bool multi_contract_verification_bound(std::set<std::string> &tgt_set);
685 bool multi_contract_verification_unbound(std::set<std::string> &tgt_set);
687 const std::set<std::string> &cname_set,
688 std::vector<const symbolt *> &entry_syms);
689 bool register_harness_main(const std::string &sol_id, const codet &func_body);
691
692 // auxiliary functions
693 std::string get_modulename_from_path(std::string path);
694 std::string get_filename_from_path(std::string path);
696 bool check_intrinsic_function(const nlohmann::json &ast_node);
697 nlohmann::json make_implicit_cast_expr(
698 const nlohmann::json &sub_expr,
699 std::string cast_type);
700 nlohmann::json make_return_type_from_typet(typet type);
701 nlohmann::json make_pointee_type(const nlohmann::json &sub_expr);
702 nlohmann::json make_array_elementary_type(const nlohmann::json &type_descrpt);
703 nlohmann::json make_array_to_pointer_type(const nlohmann::json &type_descrpt);
704 std::string get_array_size(const nlohmann::json &type_descrpt);
705 void get_size_of_expr(const typet &elem_type, exprt &size_of_expr);
706 bool is_dyn_array(const nlohmann::json &json_in);
707 bool is_func_sig_cover(const std::string &derived, const std::string &base);
709 const std::string &cname,
710 const std::string &tname,
711 const typet &ttype);
712
714 symbolt &symbol,
715 std::string module_name,
716 typet type,
717 std::string name,
718 std::string id,
719 locationt location);
720
721 bool get_constant_value(const int ref_id, std::string &value);
723 const nlohmann::json &decl,
724 const typet &base_type,
725 typet &new_type);
726
727 bool get_ctor_call_id(const std::string &contract_name, std::string &ctor_id);
728 std::string get_explicit_ctor_call_id(const std::string &contract_name);
729 std::string get_implict_ctor_call_id(const std::string &contract_name);
730 bool get_sol_builtin_ref(const nlohmann::json expr, exprt &new_expr);
731 void get_temporary_object(exprt &call, exprt &new_expr);
732 bool get_unbound_function(const std::string &c_name, symbolt &sym);
733 bool get_unbound_expr(
734 const nlohmann::json expr,
735 const std::string &cname,
736 exprt &new_expr);
738 exprt &new_expr,
739 const typet common_type,
740 const locationt &l);
742 const nlohmann::json &json,
743 const std::string contract_name);
745 const std::string name,
746 const std::string id,
747 const typet t,
748 const locationt &l,
749 const exprt &val,
750 const std::string c_name);
752 const std::string cname,
753 const exprt &sym,
754 bool is_method);
756 const std::string cname,
757 const exprt &sym,
758 const std::string &access,
759 bool is_method);
760 const nlohmann::json &
761 get_func_decl_ref(const std::string &c_name, const std::string &f_name);
763 const std::string &cname,
764 const std::string &name,
765 const exprt &base,
766 const locationt &loc,
767 exprt &new_expr);
769 const std::string &cname,
770 const exprt &addr,
771 const typet &return_t,
772 const locationt &loc,
773 const std::string &property_name,
774 exprt &new_expr);
775 void
776 get_addr_expr(const std::string &cname, const exprt &base, exprt &new_expr);
777 void get_new_object(const typet &t, exprt &this_object);
779 const nlohmann::json &expr,
780 const nlohmann::json &literal_type,
781 const exprt &base,
782 const exprt &member,
783 const exprt &_mem_call,
784 const bool is_func_call,
785 exprt &new_expr);
787 const nlohmann::json &expr,
788 const exprt &base,
789 const exprt &member,
790 const exprt &_mem_call,
791 const bool is_func_call,
792 exprt &new_expr);
794 const nlohmann::json &expr,
795 const nlohmann::json &literal_type,
796 const std::string &mem_name,
797 const exprt &base,
798 exprt &new_expr);
800 const nlohmann::json &expr,
801 const nlohmann::json &options,
802 const std::string mem_name,
803 const exprt &base,
804 const exprt &arg,
805 exprt &new_expr);
806 bool has_callable_func(const std::string &cname);
807 bool
808 has_target_function(const std::string &cname, const std::string func_name);
810 get_target_function(const std::string &cname, const std::string &func_name);
811 bool get_call_definition(const std::string &cname, exprt &new_expr);
812 bool get_call_value_definition(const std::string &cname, exprt &new_expr);
813 // Signature-based dispatch for .call(abi.encodeWithSignature(...)).
814 // Tries to extract a literal signature + arg list from the payload AST;
815 // on success builds an inline typed dispatch helper and fills new_expr.
816 // Returns true on failure (caller should fall back to the generic $call#0).
818 const nlohmann::json &expr,
819 const nlohmann::json &func_call,
820 const exprt &base,
821 exprt &new_expr);
822 // Storage-context shadow dispatch for
823 // .delegatecall(abi.encodeWithSignature(...)). Tries to locate the target
824 // function in each candidate contract, clone-and-rewrite its body to
825 // operate on the caller's state variables, and inline the dispatch chain
826 // at the current call site. Returns true on failure (caller should fall
827 // back to the generic $delegatecall#0 helper).
829 const nlohmann::json &expr,
830 const nlohmann::json &func_call,
831 const exprt &base,
832 exprt &new_expr);
833 // Pre-validate that every state-var reference inside target_body resolves
834 // by name and type to a state variable of caller_cname. Returns false
835 // when every referenced state var has an exact match in the caller.
837 const std::string &caller_cname,
838 const nlohmann::json &target_body);
839 // Walk an inlined delegate-shadow body and replace every `return X;` with
840 // { ret_lvalue = X; goto end_label; } so the return does not escape the
841 // enclosing caller function. A `return;` (void) becomes a bare goto.
843 exprt &node,
844 const exprt &ret_lvalue,
845 const std::string &end_label);
846 // Attempt to inline a call to an internal helper inside the currently
847 // inlined delegate-shadow body. Returns false on success (new_expr is
848 // set to the helper's $dl_ret local or to a skip for void returns, and
849 // the inlined body is pushed to front_block via a wrapper). Returns
850 // true on failure so the caller can fall back to the normal call path.
852 const nlohmann::json &call_expr,
853 const nlohmann::json &fdecl,
854 exprt &new_expr);
855 // Parse abi.encodeWithSignature("sig(T1,T2)", a1, a2) AST.
856 // Returns false and fills sig_literal + args_out on success.
858 const nlohmann::json &payload,
859 std::string &sig_literal,
860 std::vector<const nlohmann::json *> &args_out);
861 // Build canonical "name(T1,T2,...)" from a FunctionDefinition AST node,
862 // using the typeDescriptions.typeString of each parameter (spaces stripped).
863 // Returns empty string for ctor/fallback/unnamed or on missing info.
864 std::string build_canonical_signature(const nlohmann::json &func_def);
865 // Look up a function in a contract by its full canonical signature.
866 // Walks src_ast_json to find an external/public FunctionDefinition whose
867 // canonical signature matches. Returns empty_json if not found.
868 const nlohmann::json &find_function_by_signature(
869 const std::string &cname,
870 const std::string &target_sig);
871 // Lazily generate a per-caller helper that dispatches a typed low-level
872 // call to whichever contract's address matches. Helper is registered in
873 // the symbol table; out_sym is set to its symbol.
875 const std::string &caller_cname,
876 const std::string &target_sig,
877 const std::vector<exprt> &arg_exprs,
878 symbolt *&out_sym);
879 bool get_transfer_definition(const std::string &cname, exprt &new_expr);
880 bool get_send_definition(const std::string &cname, exprt &new_expr);
881 bool get_staticcall_definition(const std::string &cname, exprt &new_expr);
882 bool get_delegatecall_definition(const std::string &cname, exprt &new_expr);
884 const nlohmann::json &expr,
885 const exprt &this_expr,
886 const exprt &base,
887 const exprt &value,
888 const locationt &loc,
889 exprt &front_block,
890 exprt &back_block);
891
892 bool get_bind_cname_expr(const nlohmann::json &json, exprt &bind_cname_expr);
894 const std::string &cname,
895 std::string &fname,
896 std::string &fid);
897 void get_nondet_expr(const typet &t, exprt &new_expr);
898 bool assign_nondet_contract_name(const std::string &_cname, exprt &new_expr);
900 const nlohmann::json &decl_ref,
902 bool get_base_contract_name(const exprt &base, std::string &cname);
903
904 // literal conversion functions
906 const nlohmann::json &integer_literal,
907 std::string the_value,
908 exprt &dest);
910 const nlohmann::json &bool_literal,
911 std::string the_value,
912 exprt &dest);
913 bool convert_string_literal(std::string the_value, exprt &dest);
915 const namespacet &ns,
916 exprt &src_expr,
917 const typet &dest_type,
918 const nlohmann::json &expr);
920 const namespacet &ns,
921 exprt &src_expr,
922 const exprt &dest_expr,
923 const nlohmann::json &expr);
924 bool
925 convert_hex_literal(std::string the_value, exprt &dest, const int n = 256);
926 // check if it's a bytes type
927 bool is_byte_type(const typet &t);
928 bool is_bytes_type(const typet &t);
929 bool is_bytesN_type(const typet &t);
930 exprt make_aux_var(exprt &val, const locationt &location);
931 void get_bytesN_size(const exprt &src_expr, exprt &len_expr);
932 bool has_contract_bytes(const nlohmann::json &json);
933 bool get_dynamic_pool(const std::string &c_name, exprt &pool);
934 bool get_dynamic_pool(const nlohmann::json &expr, exprt &pool);
935
938 // json for Solidity AST. Use vector for multiple contracts
939 nlohmann::json src_ast_json_array = nlohmann::json::array();
940 // Solidity contracts/ function to be verified
941 const std::string &tgt_cnts;
942 std::set<std::string> tgt_cnt_set;
943 const std::string &tgt_func;
944 // focus function: when set, the harness for the target contract
945 // dispatches only this public/external function (constructor + state
946 // init still run). Empty means feature disabled.
947 std::string focus_func;
948 // smart contract source file
949 const std::string &contract_path;
950
951 std::string absolute_path;
952 std::string contract_contents = "";
953
954 const nlohmann::json *current_functionDecl;
955 const nlohmann::json *current_forStmt;
956 // store multiple exprt and flatten the block
961 // for tuple
964 // Use current level of BinOp type as the "anchor" type for numerical literal
965 // conversion: In order to remove the unnecessary implicit IntegralCast. We
966 // need type of current level of BinaryOperator. All numeric literals will be
967 // implicitly converted to this type. Pop it when finishing the current level
968 // of BinaryOperator.
969 // TODO: find a better way to deal with implicit type casting if it's not able
970 // to cope with complex rules
971 std::stack<const nlohmann::json *> current_BinOp_type;
973 // Track whether we are inside a Solidity "unchecked { ... }" block.
974 // When true, arithmetic overflow checks should be suppressed.
975 bool in_unchecked_block = false;
976
977 // Auxiliary data structures:
978 // Inheritance Order Record <contract_name, Contract_id>
979 std::unordered_map<std::string, std::vector<int>> linearizedBaseList;
980 // Who inherits from me?
981 std::unordered_map<std::string, std::unordered_set<std::string>>
983 // structural typing indentical
984 std::unordered_map<std::string, std::unordered_set<std::string>>
986 // virtual-override
987 std::unordered_map<std::string, std::unordered_map<int, int>> overrideMap;
988 // Storage reference aliases: maps a local storage variable's AST id
989 // to the AST id of its source (e.g. secondWrapper → wrapper).
990 std::unordered_map<int, int> storage_ref_aliases;
991
992 // Delegate-shadow parameter remap: when inlining a target function body
993 // at a .delegatecall(...) call site, references to the target function's
994 // formal parameters (looked up by AST id) are redirected to pre-declared
995 // local variables in the caller's scope. Cleared after each inline.
996 std::unordered_map<int, std::string> delegate_shadow_param_remap;
997 // When non-null, overrides `current_functionDecl["returnParameters"]` for
998 // return-statement conversion. Set while inlining a target function body
999 // into the caller's context so that `return X;` picks up the target's
1000 // return type, not the caller's (which may be void).
1001 const nlohmann::json *delegate_shadow_target_return_params = nullptr;
1002 // Name of the target contract currently being inlined by the delegate
1003 // shadow path. When non-empty, function calls inside the inlined body
1004 // that target internal/private functions of this contract are inlined
1005 // recursively instead of going through the normal call-path (which
1006 // would emit a `(TargetContract*)this` cast and silently depend on
1007 // struct layout coincidences).
1009
1010 // contract name list
1011 std::unordered_map<int, std::string> contractNamesMap;
1012 std::vector<std::string> contractNamesList;
1013 // for Library/Interface/Abstract Contract
1014 std::set<std::string> nonContractNamesList;
1015 // for mapping hack
1016 std::set<std::string> newContractSet;
1017 // Store the ast_node["id"] of struct/error
1018 // where entity contains "members": [{}, {}...]
1019 std::unordered_map<int, std::string> member_entity_scope;
1020 // Store state variables
1022
1023 static constexpr const char *mode = "C++";
1024
1025 std::unordered_map<std::string, std::vector<func_sig>> funcSignatures;
1026
1027 // The prefix for the id of each class (Solidity-defined structs)
1028 std::string prefix = "tag-";
1029
1030 // The prefix for c2goto library struct types (C frontend uses "struct" in
1031 // tag)
1032 std::string lib_prefix = "tag-struct ";
1033
1034 // for auxiliary var name
1036
1037 // bound setting
1039
1040 // Check if a contract should use "new" expression semantics (dynamic
1041 // allocation). In unbound mode with a single verification target,
1042 // new-expressions are optimized away (treated as static instances) to reduce
1043 // state space.
1044 bool should_treat_as_new(const std::string &contract_name) const
1045 {
1046 if (!newContractSet.count(contract_name))
1047 return false;
1048 if (
1049 !is_bound && tgt_cnt_set.count(contract_name) > 0 &&
1050 tgt_cnt_set.size() == 1)
1051 return false;
1052 return true;
1053 }
1054
1055 // reentry-check setting
1057
1058 // pointer-check setting
1060
1061 // NONDET
1065
1066 // type
1073
1074private:
1075 bool get_elementary_type_name_uint(
1077 typet &out);
1078 bool get_elementary_type_name_int(
1080 typet &out);
1081 bool get_elementary_type_name_bytesn(
1083 typet &out);
1084
1085 // RAII scope guards for global state variables.
1086 // Usage: ScopeGuard<T> guard(member, new_value);
1087 // Restores original value on destruction (including early
1088 // returns/exceptions).
1089 template <typename T>
1090 class ScopeGuard
1091 {
1092 T &ref;
1093 T saved;
1094
1095 public:
1096 ScopeGuard(T &target, const T &new_val) : ref(target), saved(target)
1097 {
1098 ref = new_val;
1099 }
1100 ~ScopeGuard()
1101 {
1102 ref = saved;
1103 }
1104 ScopeGuard(const ScopeGuard &) = delete;
1105 ScopeGuard &operator=(const ScopeGuard &) = delete;
1106 };
1107
1108 // Stack push guard: pushes on construction, pops on destruction.
1109 template <typename T>
1110 class StackGuard
1111 {
1112 std::stack<T> &stk;
1113
1114 public:
1115 StackGuard(std::stack<T> &s, const T &val) : stk(s)
1116 {
1117 stk.push(val);
1118 }
1119 ~StackGuard()
1120 {
1121 stk.pop();
1122 }
1123 StackGuard(const StackGuard &) = delete;
1124 StackGuard &operator=(const StackGuard &) = delete;
1125 };
1126};
1127
1128static inline void static_lifetime_init(const contextt &context, codet &dest)
1129{
1130 dest = code_blockt();
1131
1132 // call designated "initialization" functions
1133 context.foreach_operand_in_order([&dest](const symbolt &s) {
1134 if (s.get_type().initialization() && s.get_type().is_code())
1135 {
1139 }
1140 });
1141}
1142
1143#endif /* SOLIDITY_FRONTEND_SOLIDITY_CONVERT_H_ */
void base_type(type2tc &type, const namespacet &ns)
Definition base_type.cpp:6
static const twodig_t base
Definition bigint.cpp:28
bool is_shift(const expr2tc &expr)
The shifts clang_c_adjust routes through adjust_expr_shifts.
Definition clang_c_adjust_guards.h:36
Definition toml.hpp:6607
Definition std_code.h:49
A `switch' instruction */ class code_switcht : public codet { public: inline code_switcht() : codet("...
Definition std_code.h:574
exprt & function()
Definition std_code.h:593
Definition std_types.h:280
Definition std_code.h:8
Definition context.h:57
void foreach_operand_in_order(T &&t) const
Definition context.h:157
Definition expr.h:34
void move_to_operands(exprt &expr)
Definition expr.cpp:8
Definition irep_idt.h:12
const std::string & as_string() const
Definition irep_idt.h:138
bool empty() const
Definition irep_idt.h:54
bool get_bool(const irep_idt &name) const
Definition irep.cpp:142
bool is_pointer() const
Definition irep.h:1181
const irep_idt & identifier() const
Definition irep.h:167
const irep_idt & get(const irep_idt &name) const
Definition irep.cpp:127
bool initialization() const
Definition irep.h:568
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:141
bool is_code() const
Definition irep.h:1133
const irep_idt & id() const
Definition irep.h:109
Definition location.h:7
Definition namespace.h:10
Definition std_code.h:905
bool check_sol_ver()
Definition solidity_convert.cpp:535
void get_default_symbol(symbolt &symbol, std::string module_name, typet type, std::string name, std::string id, locationt location)
Definition solidity_convert_util.cpp:199
bool try_get_delegate_shadow_call(const nlohmann::json &expr, const nlohmann::json &func_call, const exprt &base, exprt &new_expr)
Definition solidity_convert_call.cpp:1968
bool get_ctor_call_id(const std::string &contract_name, std::string &ctor_id)
Definition solidity_convert_constructor.cpp:798
void get_unique_name(const std::string &name_prefix, const std::string &id_prefix, std::string &aux_name, std::string &aux_id)
Definition solidity_convert_util.cpp:615
bool is_byte_type(const typet &t)
Definition solidity_convert_type.cpp:1075
bool get_func_decl_ref_type(const nlohmann::json &decl, typet &new_type)
Definition solidity_convert_type.cpp:585
code_blockt expr_frontBlockDecl
Definition solidity_convert.h:957
static std::string get_library_param_id(const std::string &lib_cname, const std::string &func_name, const std::string &param_name, int param_ast_id)
Definition solidity_convert_call.cpp:3599
bool get_noncontract_decl_ref(const nlohmann::json &ast_node, exprt &new_expr)
Definition solidity_convert_decl.cpp:1075
std::set< std::string > newContractSet
Definition solidity_convert.h:1016
bool add_implicit_constructor(const std::string &contract_name)
Definition solidity_convert_constructor.cpp:67
void gen_mapping_key_typecast(const std::string &c_name, exprt &pos, const locationt &l, const typet &key_type)
Definition solidity_convert_mapping.cpp:227
void get_inherit_ctor_definition(const std::string c_name, exprt &new_expr)
Definition solidity_convert_contract.cpp:168
const std::string & contract_path
Definition solidity_convert.h:949
bool get_new_mapping_index_access(const typet &value_t, SolidityGrammar::SolType val_sol_type, bool is_mapping_set, const exprt &array, const exprt &pos, const locationt &location, exprt &new_expr)
index accesss could either be set or get: x[1] => map_uint_get(&m, 1) x[1] = 2 => map_uint_set(&x,...
Definition solidity_convert_mapping.cpp:328
bool get_non_function_decl(const nlohmann::json &ast_node, exprt &new_expr)
Definition solidity_convert_decl.cpp:22
bool multi_contract_verification_bound(std::set< std::string > &tgt_set)
Definition solidity_convert_contract.cpp:745
bool get_sol_state_var(const irep_idt &symbol_id) const
Definition solidity_convert.h:176
bool convert_integer_literal(const nlohmann::json &integer_literal, std::string the_value, exprt &dest)
Definition solidity_convert_literals.cpp:19
std::string get_sol_contract(const typet &t) const
Derived rather than read back from #sol_contract: a contract type is a pointer to the contract's own ...
Definition solidity_convert.h:121
side_effect_expr_function_callt nondet_bytes_dynamic_expr
Definition solidity_convert.h:1064
bool has_target_function(const std::string &cname, const std::string func_name)
Definition solidity_convert_call.cpp:494
static const nlohmann::json & find_last_parent(const nlohmann::json &json, const nlohmann::json &target)
Definition solidity_convert_util.cpp:813
void merge_multi_files()
Definition solidity_convert.cpp:357
void get_inherit_static_contract_instance_name(const std::string bs_c_name, const std::string c_name, std::string &name, std::string &id)
Definition solidity_convert_contract.cpp:149
void convert_expression_to_code(exprt &expr)
Definition solidity_convert_util.cpp:220
bool convert_string_literal(std::string the_value, exprt &dest)
Converts the string literal to a string_constt.
Definition solidity_convert_literals.cpp:100
bool in_unchecked_block
Definition solidity_convert.h:975
void add_static_contract_instance(const std::string c_name)
Definition solidity_convert_contract.cpp:66
bool get_delegatecall_definition(const std::string &cname, exprt &new_expr)
Definition solidity_convert_call.cpp:3489
bool get_statement(const nlohmann::json &block, exprt &new_expr)
Definition solidity_convert_stmt.cpp:197
void get_library_function_call_no_args(const std::string &func_name, const std::string &func_id, const typet &t, const locationt &l, exprt &new_expr)
Definition solidity_convert_mapping.cpp:620
bool get_decl_ref_expr(const nlohmann::json &expr, exprt &new_expr)
Definition solidity_convert_expr.cpp:706
bool get_index_access_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:1921
void get_inherit_static_contract_instance(const std::string bs_c_name, const std::string c_name, const nlohmann::json &args_list, symbolt &sym)
Definition solidity_convert_contract.cpp:306
unsigned int get_line_number(const nlohmann::json &ast_node, bool final_position=false)
Definition solidity_convert_util.cpp:81
typet addr_t
Definition solidity_convert.h:1067
bool get_unbound_funccall(const std::string contractName, code_function_callt &call)
Definition solidity_convert_contract.cpp:27
std::unordered_map< std::string, std::unordered_set< std::string > > structureTypingMap
Definition solidity_convert.h:985
bool is_mapping_set_lvalue(const nlohmann::json &json)
@target: target index access child json return true if it's a mapping_set, including assign,...
Definition solidity_convert_mapping.cpp:37
bool get_new_object_ctor_call(const nlohmann::json &ast_node, const bool is_object, exprt &new_expr)
Definition solidity_convert_constructor.cpp:944
bool get_send_definition(const std::string &cname, exprt &new_expr)
Definition solidity_convert_call.cpp:3090
bool get_dynamic_pool(const std::string &c_name, exprt &pool)
Definition solidity_convert_mapping.cpp:90
bool is_dyn_array(const nlohmann::json &json_in)
Definition solidity_convert_util.cpp:446
std::unordered_map< int, std::string > contractNamesMap
Definition solidity_convert.h:1011
void add_inherit_label(nlohmann::json &node, const std::string &cname)
Definition solidity_convert_inheritance.cpp:22
bool get_function_definition(const nlohmann::json &ast_node)
Definition solidity_convert_modifier.cpp:22
bool try_inline_delegate_shadow_helper_call(const nlohmann::json &call_expr, const nlohmann::json &fdecl, exprt &new_expr)
Definition solidity_convert_call.cpp:1814
bool has_contract_bytes(const nlohmann::json &json)
Definition solidity_convert_mapping.cpp:192
bool get_binary_operator_expr(const nlohmann::json &expr, exprt &new_expr)
Definition solidity_convert_expr.cpp:2452
static void set_sol_bytesn_size(typet &t, const irep_idt &size)
Definition solidity_convert.h:101
void get_function_definition_name(const nlohmann::json &ast_node, std::string &name, std::string &id)
Definition solidity_convert_decl.cpp:1499
void get_function_this_pointer_param(const std::string &contract_name, const std::string &ctor_id, const std::string &debug_modulename, const locationt &location_begin, code_typet &type)
Definition solidity_convert_decl.cpp:114
static const nlohmann::json empty_json
Definition solidity_convert.h:186
bool get_func_decl_this_ref(const nlohmann::json &decl, exprt &new_expr)
Definition solidity_convert_ref.cpp:209
void get_mapping_inf_arr_name(const std::string &cname, const std::string &name, std::string &arr_name, std::string &arr_id)
Definition solidity_convert_mapping.cpp:21
void get_inherit_ctor_definition_name(const std::string c_name, std::string &name, std::string &id)
Definition solidity_convert_contract.cpp:159
static std::string get_sol_array_size(const typet &t)
Definition solidity_convert.h:84
bool multi_contract_verification_unbound(std::set< std::string > &tgt_set)
Definition solidity_convert_contract.cpp:818
void get_error_definition_name(const nlohmann::json &ast_node, std::string &name, std::string &id)
Definition solidity_convert_decl.cpp:1483
const std::string & tgt_cnts
Definition solidity_convert.h:941
std::string get_modulename_from_path(std::string path)
Definition solidity_convert_util.cpp:155
bool multi_transaction_verification(const std::string &contractName)
Definition solidity_convert_contract.cpp:586
void get_mapping_struct_function(const typet &struct_t, std::string &struct_contract_name, const side_effect_expr_function_callt &gen_call, exprt &new_expr)
Definition solidity_convert_mapping.cpp:496
code_blockt ctor_frontBlockDecl
Definition solidity_convert.h:959
std::unordered_map< std::string, std::vector< func_sig > > funcSignatures
Definition solidity_convert.h:1025
bool get_base_contract_name(const exprt &base, std::string &cname)
Definition solidity_convert_call.cpp:324
side_effect_expr_function_callt nondet_uint_expr
Definition solidity_convert.h:1063
bool get_transfer_definition(const std::string &cname, exprt &new_expr)
Definition solidity_convert_call.cpp:2843
bool get_access_from_decl(const nlohmann::json &ast_node, struct_typet::componentt &comp)
Definition solidity_convert_decl.cpp:1366
void get_tuple_assignment(const nlohmann::json &expr, const exprt &lop, exprt rop)
Definition solidity_convert_tuple.cpp:629
void move_builtin_to_contract(const std::string cname, const exprt &sym, bool is_method)
Definition solidity_convert_builtin.cpp:223
bool current_rhsDecl
Definition solidity_convert.h:963
void get_temporary_object(exprt &call, exprt &new_expr)
Definition solidity_convert_constructor.cpp:111
void get_current_contract_name(const nlohmann::json &ast_node, std::string &contract_name)
Definition solidity_convert_expr.cpp:2393
nlohmann::json make_array_elementary_type(const nlohmann::json &type_descrpt)
Definition solidity_convert_util.cpp:361
bool get_low_level_member_accsss(const nlohmann::json &expr, const nlohmann::json &options, const std::string mem_name, const exprt &base, const exprt &arg, exprt &new_expr)
@options: val
Definition solidity_convert_call.cpp:1040
nlohmann::json make_pointee_type(const nlohmann::json &sub_expr)
Definition solidity_convert_util.cpp:262
static void set_sol_array_size(typet &t, const std::string &size)
Definition solidity_convert.h:80
void get_modifier_function_name(const std::string &cname, const std::string &mod_name, const std::string &func_name, std::string &name, std::string &id)
Definition solidity_convert_modifier.cpp:430
bool get_parameter_list(const nlohmann::json &type_name, typet &new_type)
Definition solidity_convert_type.cpp:965
bool get_call_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:1262
std::set< std::string > tgt_cnt_set
Definition solidity_convert.h:942
static bool get_sol_mapping_array(const typet &t)
Definition solidity_convert.h:145
code_blockt ctor_backBlockDecl
Definition solidity_convert.h:960
void get_aux_property_function(const std::string &cname, const exprt &addr, const typet &return_t, const locationt &loc, const std::string &property_name, exprt &new_expr)
Definition solidity_convert_builtin.cpp:322
bool get_ctor_call(const nlohmann::json &decl_ref, const nlohmann::json &epxr, side_effect_expr_function_callt &call)
Definition solidity_convert_constructor.cpp:900
bool check_array_push_pop_length(const nlohmann::json &node)
Recursively checks whether a Solidity AST node contains any usage of array-specific operations: push,...
Definition solidity_convert_mapping.cpp:137
std::unordered_map< std::string, std::unordered_set< std::string > > inheritanceMap
Definition solidity_convert.h:982
static bool has_sol_bytesn_size(const typet &t)
Definition solidity_convert.h:109
void topological_sort(std::unordered_map< std::string, std::unordered_set< std::string > > &graph, std::unordered_map< std::string, nlohmann::json > &path_to_json, nlohmann::json &sorted_files)
Definition solidity_convert.cpp:430
symbolt * move_symbol_to_context(symbolt &symbol)
Definition solidity_convert_util.cpp:215
bool populate_function_signature(nlohmann::json &json, const std::string &cname)
initialize the function signature set.
Definition solidity_convert.cpp:1138
void get_bytesN_size(const exprt &src_expr, exprt &len_expr)
Definition solidity_convert_mapping.cpp:76
bool get_call_value_definition(const std::string &cname, exprt &new_expr)
Definition solidity_convert_call.cpp:2587
void get_bind_cname_func_name(const std::string &cname, std::string &fname, std::string &fid)
Definition solidity_convert_call.cpp:1204
void get_llc_ret_tuple(symbolt &sym)
Definition solidity_convert_tuple.cpp:311
bool get_tuple_function_ref(const nlohmann::json &ast_node, exprt &new_expr)
Definition solidity_convert_tuple.cpp:225
std::string current_functionName
Definition solidity_convert.h:972
bool get_function_params(const nlohmann::json &pd, const std::string &cname, exprt &param)
Definition solidity_convert_stmt.cpp:31
void rewrite_returns_for_delegate_shadow(exprt &node, const exprt &ret_lvalue, const std::string &end_label)
Definition solidity_convert_call.cpp:1775
bool get_esbmc_builtin_ref(const nlohmann::json &decl, exprt &new_expr)
Definition solidity_convert_ref.cpp:274
bool move_initializer_to_main(codet &func_body)
Definition solidity_convert_constructor.cpp:391
void xor_fold_key_to_64bit(exprt &key)
Definition solidity_convert_mapping.cpp:293
bool get_bound_low_level_call(const nlohmann::json &expr, const nlohmann::json &literal_type, const std::string &mem_name, const exprt &base, exprt &new_expr)
Resolve a low-level call (.call/.send/.transfer/.delegatecall/.staticcall) in bound mode by finding t...
Definition solidity_convert_call.cpp:975
std::string get_implict_ctor_call_id(const std::string &contract_name)
Definition solidity_convert_constructor.cpp:836
code_blockt initializers
Definition solidity_convert.h:1021
bool is_reentry_check
Definition solidity_convert.h:1056
bool get_expr(const nlohmann::json &expr, exprt &new_expr)
Definition solidity_convert_expr.cpp:21
bool model_transaction(const nlohmann::json &expr, const exprt &this_expr, const exprt &base, const exprt &value, const locationt &loc, exprt &front_block, exprt &back_block)
e.g.
Definition solidity_convert_call.cpp:2493
bool try_get_signature_dispatched_call(const nlohmann::json &expr, const nlohmann::json &func_call, const exprt &base, exprt &new_expr)
Definition solidity_convert_call.cpp:2227
const nlohmann::json & find_function_by_signature(const std::string &cname, const std::string &target_sig)
Definition solidity_convert_call.cpp:1324
void get_final_location_from_stmt(const nlohmann::json &ast_node, locationt &location)
Definition solidity_convert_util.cpp:62
static bool is_low_level_call(const std::string &name)
Definition solidity_convert_builtin.cpp:23
static const nlohmann::json & find_parent_contract(const nlohmann::json &json, const nlohmann::json &target)
Definition solidity_convert_util.cpp:858
code_blockt expr_backBlockDecl
Definition solidity_convert.h:958
bool get_super_function_call(const nlohmann::json &member_access, const nlohmann::json &call_expr, exprt &new_expr)
Definition solidity_convert_call.cpp:3642
static void set_sol_type(typet &t, SolidityGrammar::SolType st)
Definition solidity_convert.h:68
const std::string & tgt_func
Definition solidity_convert.h:943
bool contract_precheck()
Definition solidity_convert.cpp:488
bool get_unary_operator_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:3287
static SolidityGrammar::SolType get_sol_type(const typet &t)
Definition solidity_convert.h:72
void get_memcpy_function_call(const locationt &loc, side_effect_expr_function_callt &_call)
Definition solidity_convert_mapping.cpp:692
static bool is_low_level_property(const std::string &name)
Definition solidity_convert_builtin.cpp:33
void move_to_back_block(const exprt &expr)
Definition solidity_convert_constructor.cpp:580
bool get_tuple_instance(const nlohmann::json &ast_node, exprt &new_expr)
Definition solidity_convert_tuple.cpp:109
bool get_contract_member_call_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:1629
void get_symbol_decl_ref(const std::string &sym_name, const std::string &sym_id, const typet &t, exprt &new_expr)
Definition solidity_convert_ref.cpp:22
void move_to_front_block(const exprt &expr)
Definition solidity_convert_constructor.cpp:572
bool get_unbound_expr(const nlohmann::json expr, const std::string &cname, exprt &new_expr)
Definition solidity_convert_constructor.cpp:159
bool get_literal_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:834
bool get_type_description(const nlohmann::json &type_name, typet &new_type)
Definition solidity_convert_type.cpp:21
void add_enum_member_val(nlohmann::json &ast_node)
Definition solidity_convert_decl.cpp:1236
static const nlohmann::json & find_constructor_ref(int ref_decl_id)
Definition solidity_convert_constructor.cpp:843
bool add_auxiliary_members(const nlohmann::json &json, const std::string contract_name)
Definition solidity_convert_builtin.cpp:56
bool populate_auxiliary_vars()
Definition solidity_convert.cpp:708
solidity_convertert(contextt &_context, nlohmann::json &_ast_json, const std::string &_sol_cnts, const std::string &_sol_func, const std::string &_contract_path, const std::string &_focus_func=std::string())
Definition solidity_convert.cpp:30
bool check_intrinsic_function(const nlohmann::json &ast_node)
Definition solidity_convert_util.cpp:232
bool get_new_object_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:2194
std::string prefix
Definition solidity_convert.h:1028
exprt make_aux_var(exprt &val, const locationt &location)
Definition solidity_convert_util.cpp:782
bool validate_delegate_shadow_compatible(const std::string &caller_cname, const nlohmann::json &target_body)
Definition solidity_convert_call.cpp:1677
bool get_tuple_instance_name(const nlohmann::json &ast_node, std::string &name, std::string &id)
Definition solidity_convert_tuple.cpp:206
static void set_sol_mapping_array(typet &t, bool v)
Definition solidity_convert.h:141
void get_arrcpy_function_call(const locationt &loc, side_effect_expr_function_callt &calc_call)
Definition solidity_convert_mapping.cpp:670
void get_aux_array(const exprt &src_expr, const typet &sub_t, exprt &new_expr)
Definition solidity_convert_util.cpp:643
bool assign_nondet_contract_name(const std::string &_cname, exprt &new_expr)
Definition solidity_convert_call.cpp:353
void get_calloc_function_call(const locationt &loc, side_effect_expr_function_callt &_call)
Definition solidity_convert_mapping.cpp:659
nlohmann::json make_implicit_cast_expr(const nlohmann::json &sub_expr, std::string cast_type)
Definition solidity_convert_util.cpp:243
typet addrp_t
Definition solidity_convert.h:1068
bool is_func_sig_cover(const std::string &derived, const std::string &base)
Definition solidity_convert_util.cpp:481
bool convert()
Definition solidity_convert.cpp:138
bool get_array_pointer_type(const nlohmann::json &decl, const typet &base_type, typet &new_type)
Definition solidity_convert_type.cpp:1030
void set_sol_state_var(const irep_idt &symbol_id, bool v)
Definition solidity_convert.h:169
bool get_array_to_pointer_type(const nlohmann::json &decl, typet &new_type)
Definition solidity_convert_type.cpp:685
bool get_high_level_member_access(const nlohmann::json &expr, const nlohmann::json &literal_type, const exprt &base, const exprt &member, const exprt &_mem_call, const bool is_func_call, exprt &new_expr)
Conversion: constructor() { this->_ESBMC_bind_cname = get_nondet_cname(); // unless we have a new Bas...
Definition solidity_convert_call.cpp:590
bool is_bytes_type(const typet &t)
Definition solidity_convert_type.cpp:1096
bool get_func_decl_ref(const nlohmann::json &decl, exprt &new_expr)
Definition solidity_convert_ref.cpp:142
const nlohmann::json * current_forStmt
Definition solidity_convert.h:955
std::string focus_func
Definition solidity_convert.h:947
bool has_sol_contract(const typet &t) const
Definition solidity_convert.h:134
typet byte_dynamic_t
Definition solidity_convert.h:1071
void get_static_contract_instance_name(const std::string c_name, std::string &name, std::string &id)
Definition solidity_convert_contract.cpp:44
void convert_unboundcall_nondet(exprt &new_expr, const typet common_type, const locationt &l)
Definition solidity_convert_constructor.cpp:122
std::string lib_prefix
Definition solidity_convert.h:1032
bool get_constant_value(const int ref_id, std::string &value)
Definition solidity_convert_util.cpp:174
bool get_library_function_call(const nlohmann::json &decl_ref, const nlohmann::json &caller, side_effect_expr_function_callt &call, bool skip_first_param=false)
Definition solidity_convert_call.cpp:24
std::unordered_map< int, int > storage_ref_aliases
Definition solidity_convert.h:990
size_t add_offset(const std::string &src, size_t start_position)
Definition solidity_convert_util.cpp:118
void get_local_var_decl_name(const nlohmann::json &ast_node, const std::string &cname, std::string &name, std::string &id)
Definition solidity_convert_decl.cpp:1422
bool has_modifier_invocation(const nlohmann::json &ast_node)
Definition solidity_convert_modifier.cpp:441
typet byte_static_t
Definition solidity_convert.h:1072
std::string build_canonical_signature(const nlohmann::json &func_def)
Definition solidity_convert_call.cpp:1296
bool get_ctor_decl_this_ref(const nlohmann::json &caller, exprt &this_object)
Definition solidity_convert_constructor.cpp:778
void get_str_assign_function_call(const locationt &loc, side_effect_expr_function_callt &_call)
Definition solidity_convert_mapping.cpp:681
bool get_block(const nlohmann::json &expr, exprt &new_expr)
Definition solidity_convert_stmt.cpp:86
bool get_compound_assign_expr(const nlohmann::json &expr, exprt &lhs, exprt &rhs, typet &common_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:3131
contextt & context
Definition solidity_convert.h:936
static constexpr const char * mode
Definition solidity_convert.h:1023
void get_aux_var(std::string &aux_name, std::string &aux_id)
Definition solidity_convert_util.cpp:629
bool current_lhsDecl
Definition solidity_convert.h:962
bool is_pointer_check
Definition solidity_convert.h:1059
void get_builtin_symbol(const std::string name, const std::string id, const typet t, const locationt &l, const exprt &val, const std::string c_name)
Definition solidity_convert_builtin.cpp:292
bool get_tuple_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:1067
bool get_implicit_ctor_ref(const std::string &contract_name, const bool is_object, exprt &new_expr)
Definition solidity_convert_constructor.cpp:1010
bool get_call_definition(const std::string &cname, exprt &new_expr)
Definition solidity_convert_call.cpp:2324
const nlohmann::json & find_decl_ref(int ref_id)
Definition solidity_convert_util.cpp:962
void get_new_object(const typet &t, exprt &this_object)
symbol
Definition solidity_convert_call.cpp:1262
bool get_struct_class(const nlohmann::json &ast_node)
Definition solidity_convert_decl.cpp:762
bool populate_low_level_functions(const std::string &cname)
Definition solidity_convert.cpp:1091
std::unordered_map< int, std::string > member_entity_scope
Definition solidity_convert.h:1019
bool get_staticcall_definition(const std::string &cname, exprt &new_expr)
Definition solidity_convert_call.cpp:3326
bool get_tuple_definition(const nlohmann::json &ast_node)
Definition solidity_convert_tuple.cpp:21
static void set_sol_dynarray_state(typet &t, bool v)
Definition solidity_convert.h:152
bool get_conditional_operator_expr(const nlohmann::json &expr, exprt &new_expr)
Definition solidity_convert_expr.cpp:3396
bool get_typed_call_definition(const std::string &caller_cname, const std::string &target_sig, const std::vector< exprt > &arg_exprs, symbolt *&out_sym)
Definition solidity_convert_call.cpp:1507
static std::string current_baseContractName
Definition solidity_convert.h:189
bool get_empty_array_ref(const nlohmann::json &ast_node, exprt &new_expr)
Definition solidity_convert_util.cpp:737
const nlohmann::json * delegate_shadow_target_return_params
Definition solidity_convert.h:1001
std::string get_array_size(const nlohmann::json &type_descrpt)
Definition solidity_convert_util.cpp:428
std::string find_contract_name_for_id(int func_id)
Definition solidity_convert_call.cpp:3611
nlohmann::json make_return_type_from_typet(typet type)
Definition solidity_convert_util.cpp:344
bool get_struct_class_fields(const nlohmann::json &ast_node, struct_typet &type)
Definition solidity_convert_decl.cpp:1005
bool get_elementary_type_name(const nlohmann::json &type_name, typet &new_type)
Definition solidity_convert_type.cpp:754
void move_to_initializer(const exprt &expr)
Definition solidity_convert_constructor.cpp:352
void get_malloc_function_call(const locationt &loc, side_effect_expr_function_callt &_call)
Definition solidity_convert_mapping.cpp:648
bool construct_tuple_assigments(const nlohmann::json &ast_node, const exprt &lhs, const exprt &rhs)
Definition solidity_convert_tuple.cpp:398
std::string absolute_path
Definition solidity_convert.h:951
bool get_enum_member_ref(const nlohmann::json &decl, exprt &new_expr)
Definition solidity_convert_ref.cpp:258
std::vector< std::string > contractNamesList
Definition solidity_convert.h:1012
bool get_high_level_call_wrapper(const std::string c_name, const exprt &this_expr, exprt &front_block, exprt &back_block)
Definition solidity_convert_contract.cpp:453
bool register_harness_main(const std::string &sol_id, const codet &func_body)
Definition solidity_convert_contract.cpp:702
bool get_noncontract_defition(nlohmann::json &ast_node)
Definition solidity_convert_decl.cpp:1128
nlohmann::json src_ast_json_array
Definition solidity_convert.h:939
func_sig get_target_function(const std::string &cname, const std::string &func_name)
Definition solidity_convert_call.cpp:508
bool get_unbound_function(const std::string &c_name, symbolt &sym)
Definition solidity_convert_constructor.cpp:213
bool get_cast_expr(const nlohmann::json &cast_expr, exprt &new_expr, const nlohmann::json literal_type=nullptr)
Definition solidity_convert_expr.cpp:3424
bool delete_modifier_json(const std::string &cname, const std::string &fname, nlohmann::json *&modifier_def)
Definition solidity_convert_modifier.cpp:337
static bool has_sol_array_size(const typet &t)
Definition solidity_convert.h:88
std::unordered_map< std::string, std::unordered_map< int, int > > overrideMap
Definition solidity_convert.h:987
static const nlohmann::json & find_node_by_id(const nlohmann::json &subtree, int ref_id)
Definition solidity_convert_util.cpp:916
bool has_callable_func(const std::string &cname)
Definition solidity_convert_call.cpp:481
bool get_error_definition(const nlohmann::json &ast_node)
Definition solidity_convert_decl.cpp:1273
static std::string get_sol_bytesn_size(const typet &t)
Definition solidity_convert.h:105
void get_tuple_name(const nlohmann::json &ast_node, std::string &name, std::string &id)
Definition solidity_convert_tuple.cpp:197
const nlohmann::json * current_functionDecl
Definition solidity_convert.h:954
void get_location_from_node(const nlohmann::json &ast_node, locationt &location)
Definition solidity_convert_util.cpp:26
bool get_constructor(const nlohmann::json &ast_node, const std::string &contract_name)
Definition solidity_convert_constructor.cpp:22
void get_string_assignment(const exprt &lhs, const exprt &rhs, exprt &new_expr)
Definition solidity_convert_tuple.cpp:353
bool get_sol_builtin_ref(const nlohmann::json expr, exprt &new_expr)
Definition solidity_convert_ref.cpp:343
void get_size_expr(const exprt &rhs, exprt &size_expr)
Definition solidity_convert_util.cpp:685
bool flatten_nested_tuple_assignment(const nlohmann::json &expr, const nlohmann::json &lhs_json, const nlohmann::json &rhs_json)
Definition solidity_convert_tuple.cpp:506
bool get_var_decl(const nlohmann::json &ast_node, const nlohmann::json &initialValue, exprt &new_expr)
Definition solidity_convert_decl.cpp:162
bool extract_abi_encode_signature(const nlohmann::json &payload, std::string &sig_literal, std::vector< const nlohmann::json * > &args_out)
Definition solidity_convert_call.cpp:1392
void reset_auxiliary_vars()
Definition solidity_convert_stmt.cpp:22
void add_empty_body_node(nlohmann::json &ast_node)
Definition solidity_convert_decl.cpp:1193
int aux_counter
Definition solidity_convert.h:1035
void extract_new_contracts()
Definition solidity_convert_call.cpp:266
bool get_mapping_key_value_type(const nlohmann::json &map_node, typet &key_t, typet &value_t, SolidityGrammar::SolType &key_sol_type, SolidityGrammar::SolType &val_sol_type)
Definition solidity_convert_mapping.cpp:44
bool get_instantiation_ctor_call(const std::string &contract_name, exprt &new_expr)
bool get_init_expr(const nlohmann::json &init_value, const nlohmann::json &literal_type, const typet &dest_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:2375
std::string get_explicit_ctor_call_id(const std::string &contract_name)
Definition solidity_convert_constructor.cpp:819
bool get_contract_definition(const std::string &c_name)
Definition solidity_convert_decl.cpp:910
void store_update_dyn_array(const exprt &dyn_arr, const exprt &size_expr, exprt &store_call)
Definition solidity_convert_util.cpp:717
bool convert_bool_literal(const nlohmann::json &bool_literal, std::string the_value, exprt &dest)
Definition solidity_convert_literals.cpp:65
bool get_function_decl(const nlohmann::json &ast_node)
Definition solidity_convert_decl.cpp:71
static void set_sol_bytesn_size(typet &t, long size)
Definition solidity_convert.h:97
void get_nondet_expr(const typet &t, exprt &new_expr)
Definition solidity_convert_call.cpp:340
static bool get_sol_dynarray_state(const typet &t)
Definition solidity_convert.h:156
bool insert_modifier_json(const nlohmann::json &ast_node, const std::string &cname, const std::string &fname, nlohmann::json *&modifier_def)
Definition solidity_convert_modifier.cpp:371
void get_tuple_function_call(const exprt &op)
Definition solidity_convert_tuple.cpp:300
bool get_struct_class_method(const nlohmann::json &ast_node, struct_typet &type)
Definition solidity_convert_decl.cpp:1054
static nlohmann::json src_ast_json
Definition solidity_convert.h:192
bool get_bind_cname_expr(const nlohmann::json &json, exprt &bind_cname_expr)
Definition solidity_convert_call.cpp:1214
bool get_index_range_access_expr(const nlohmann::json &expr, const nlohmann::json &literal_type, exprt &new_expr)
Definition solidity_convert_expr.cpp:2168
std::string delegate_shadow_target_cname
Definition solidity_convert.h:1008
bool add_reentry_check(const std::string &c_name, const locationt &loc, exprt &body_exprt)
Definition solidity_convert_modifier.cpp:466
typet bool_t
Definition solidity_convert.h:1070
bool is_bytesN_type(const typet &t)
Definition solidity_convert_type.cpp:1086
void get_static_contract_instance_ref(const std::string &c_name, exprt &new_expr)
Definition solidity_convert_contract.cpp:53
void get_cname_expr(const std::string &cname, exprt &new_expr)
Definition solidity_convert.cpp:1084
bool get_tuple_member_call(const irep_idt instance_id, const exprt &comp, exprt &new_expr)
Definition solidity_convert_tuple.cpp:284
bool assign_param_nondet(const nlohmann::json &decl_ref, side_effect_expr_function_callt &call)
Definition solidity_convert_call.cpp:422
bool is_esbmc_library_function(const std::string &id)
Definition solidity_convert_mapping.cpp:704
void get_start_location_from_stmt(const nlohmann::json &ast_node, locationt &location)
Definition solidity_convert_util.cpp:43
struct solidity_convertert::func_sig func_sig
bool should_treat_as_new(const std::string &contract_name) const
Definition solidity_convert.h:1044
bool convert_hex_literal(std::string the_value, exprt &dest, const int n=256)
convert hex-string to uint constant : the bit width, default 256 (unsignedbv_typet(256))
Definition solidity_convert_literals.cpp:132
bool is_sol_builin_symbol(const std::string &cname, const std::string &name)
Definition solidity_convert_contract.cpp:431
bool get_non_library_function_call(const nlohmann::json &decl_ref, const nlohmann::json &caller, side_effect_expr_function_callt &call)
call to a non-library function: this.func(); // func(&this)
Definition solidity_convert_call.cpp:155
std::unordered_map< std::string, std::vector< int > > linearizedBaseList
Definition solidity_convert.h:979
bool get_func_modifier(const nlohmann::json &ast_node, const std::string &c_name, const std::string &f_name, const std::string &f_id, const bool add_reentry, exprt &body_exprt)
Definition solidity_convert_modifier.cpp:513
bool get_var_decl_ref(const nlohmann::json &decl, const bool is_this_ptr, exprt &new_expr)
This function can return expr with either id::symbol or id::member id::memebr can only be the case wh...
Definition solidity_convert_ref.cpp:46
bool prepare_harness_entry_functions(const std::set< std::string > &cname_set, std::vector< const symbolt * > &entry_syms)
Definition solidity_convert_contract.cpp:675
nlohmann::json make_array_to_pointer_type(const nlohmann::json &type_descrpt)
Definition solidity_convert_util.cpp:411
bool get_var_decl_name(const nlohmann::json &decl, std::string &name, std::string &id)
Definition solidity_convert_decl.cpp:1399
void convert_type_expr(const namespacet &ns, exprt &src_expr, const typet &dest_type, const nlohmann::json &expr)
Definition solidity_convert_type.cpp:1107
std::set< std::string > nonContractNamesList
Definition solidity_convert.h:1014
bool is_var_getter_matched(const std::string &cname, const std::string &tname, const typet &ttype)
Definition solidity_convert_util.cpp:562
void get_contract_mutex_name(const std::string c_name, std::string &name, std::string &id)
Definition solidity_convert_contract.cpp:403
bool convert_ast_nodes(const nlohmann::json &contract_def, const std::string &cname)
Definition solidity_convert.cpp:1229
void get_builtin_property_expr(const std::string &cname, const std::string &name, const exprt &base, const locationt &loc, exprt &new_expr)
Definition solidity_convert_builtin.cpp:478
std::stack< const nlohmann::json * > current_BinOp_type
Definition solidity_convert.h:971
bool move_inheritance_to_ctor(const nlohmann::json *based_contracts, const std::string contract_name, std::string ctor_id, symbolt &sym)
Definition solidity_convert_constructor.cpp:588
typet string_t
Definition solidity_convert.h:1069
namespacet ns
Definition solidity_convert.h:937
bool move_initializer_to_ctor(const nlohmann::json *based_contracts, const nlohmann::json &current_contract, const std::string contract_name)
Definition solidity_convert_constructor.cpp:381
std::unordered_map< int, std::string > delegate_shadow_param_remap
Definition solidity_convert.h:996
void get_addr_expr(const std::string &cname, const exprt &base, exprt &new_expr)
static std::unordered_map< std::string, typet > UserDefinedVarMap
Definition solidity_convert.h:195
void merge_inheritance_ast(const std::string &c_name, nlohmann::json &c_node, std::set< std::string > &merged_list)
Definition solidity_convert_inheritance.cpp:52
std::string contract_contents
Definition solidity_convert.h:952
bool is_bound
Definition solidity_convert.h:1038
std::string get_filename_from_path(std::string path)
Definition solidity_convert_util.cpp:165
void get_aux_array_name(std::string &aux_name, std::string &aux_id)
Definition solidity_convert_util.cpp:636
virtual ~solidity_convertert()=default
void convert_operand_types(exprt &lhs, exprt &rhs, const typet &common_type, bool is_shift, const nlohmann::json &expr)
Definition solidity_convert_expr.cpp:3267
void get_state_var_decl_name(const nlohmann::json &ast_node, const std::string &cname, std::string &name, std::string &id)
Definition solidity_convert_decl.cpp:1381
std::string get_src_from_json(const nlohmann::json &ast_node)
Definition solidity_convert_util.cpp:128
void get_contract_mutex_expr(const std::string c_name, const exprt &this_expr, exprt &expr)
Definition solidity_convert_contract.cpp:413
void get_size_of_expr(const typet &elem_type, exprt &size_of_expr)
Definition solidity_convert_util.cpp:456
side_effect_expr_function_callt nondet_bool_expr
Definition solidity_convert.h:1062
std::unordered_set< irep_idt > sol_state_vars
Whether a declared variable is a contract state variable.
Definition solidity_convert.h:167
nlohmann::json reorder_arguments(const nlohmann::json &expr, const nlohmann::json &callee_expr_json)
Definition solidity_convert_contract.cpp:517
Definition std_types.h:232
Definition std_types.h:87
Definition symbol_id.h:6
Definition symbol.h:12
const typet & get_type() const
Definition symbol.cpp:106
Definition type.h:9
const typet & subtype() const
Definition type.h:17
static irep_idt t_symbol
Definition type.h:92
Definition toml.hpp:1531
@ other
Definition converter_compare.cpp:887
#define T
Definition exp2f.c:24
exprt symbol_expr(const symbolt &symbol)
Definition expr_util.cpp:239
@ function_call
Definition irep2_expr.h:82
nlohmann::json json
Definition json.cpp:12
literalt pos(literalt a)
Definition literal.h:130
const char * sol_type_to_str(SolType t)
Definition solidity_grammar.cpp:1313
SolType
Definition solidity_grammar.h:489
SolType str_to_sol_type(const std::string &s)
Definition solidity_grammar.cpp:1441
ElementaryTypeNameT
Definition solidity_grammar.h:102
Definition path.py:1
Pattern-based vulnerability detection for Solidity contracts.
static void static_lifetime_init(const contextt &context, codet &dest)
Definition solidity_convert.h:1128
Solidity grammar enumerations and classification helpers.
address_t addr
Definition solidity_mapping.c:0
uint256_t key
Definition solidity_mapping.c:1
Definition solidity_convert.h:199
code_typet type
Definition solidity_convert.h:203
std::string visibility
Definition solidity_convert.h:202
std::string id
Definition solidity_convert.h:201
std::string name
Definition solidity_convert.h:200
func_sig(const std::string &name, const std::string &id, const std::string &visibility, const code_typet &type, bool is_payable, bool is_inherit, bool is_library)
Definition solidity_convert.h:208
bool is_library
Definition solidity_convert.h:206
bool is_payable
Definition solidity_convert.h:204
bool operator==(const func_sig &other) const
Definition solidity_convert.h:226
bool is_inherit
Definition solidity_convert.h:205