@@ -40,100 +40,14 @@ Date: February 2016
4040
4141#include " cfg_info.h"
4242#include " havoc_assigns_clause_targets.h"
43+ #include " inlining_decorator.h"
4344#include " instrument_spec_assigns.h"
4445#include " memory_predicates.h"
4546#include " utils.h"
4647
4748#include < algorithm>
4849#include < map>
4950
50- // / Decorator for \ref message_handlert that keeps track of warnings
51- // / occuring when inlining a function.
52- // /
53- // / It counts the number of :
54- // / - recursive functions warnings
55- // / - missing functions warnings
56- // / - missing function body warnings
57- // / - missing function arguments warnings
58- class inlining_decoratort : public message_handlert
59- {
60- private:
61- message_handlert &wrapped;
62- unsigned int recursive_function_warnings_count = 0 ;
63-
64- void parse_message (const std::string &message)
65- {
66- if (message.find (" recursion is ignored on call" ) != std::string::npos)
67- recursive_function_warnings_count++;
68- }
69-
70- public:
71- explicit inlining_decoratort (message_handlert &_wrapped) : wrapped(_wrapped)
72- {
73- }
74-
75- unsigned int get_recursive_function_warnings_count ()
76- {
77- return recursive_function_warnings_count;
78- }
79-
80- void print (unsigned level, const std::string &message) override
81- {
82- parse_message (message);
83- wrapped.print (level, message);
84- }
85-
86- void print (unsigned level, const xmlt &xml) override
87- {
88- wrapped.print (level, xml);
89- }
90-
91- void print (unsigned level, const jsont &json) override
92- {
93- wrapped.print (level, json);
94- }
95-
96- void print (unsigned level, const structured_datat &data) override
97- {
98- wrapped.print (level, data);
99- }
100-
101- void print (
102- unsigned level,
103- const std::string &message,
104- const source_locationt &location) override
105- {
106- parse_message (message);
107- wrapped.print (level, message, location);
108- return ;
109- }
110-
111- void flush (unsigned i) override
112- {
113- return wrapped.flush (i);
114- }
115-
116- void set_verbosity (unsigned _verbosity)
117- {
118- wrapped.set_verbosity (_verbosity);
119- }
120-
121- unsigned get_verbosity () const
122- {
123- return wrapped.get_verbosity ();
124- }
125-
126- std::size_t get_message_count (unsigned level) const
127- {
128- return wrapped.get_message_count (level);
129- }
130-
131- std::string command (unsigned i) const override
132- {
133- return wrapped.command (i);
134- }
135- };
136-
13751void code_contractst::check_apply_loop_contracts (
13852 const irep_idt &function_name,
13953 goto_functionst::goto_functiont &goto_function,
@@ -1031,7 +945,7 @@ void code_contractst::apply_loop_contract(
1031945 goto_functions, function_name, ns, log.get_message_handler ());
1032946
1033947 INVARIANT (
1034- decorated.get_recursive_function_warnings_count () == 0 ,
948+ decorated.get_recursive_call_set (). size () == 0 ,
1035949 " Recursive functions found during inlining" );
1036950
1037951 // restore internal invariants
@@ -1301,9 +1215,7 @@ void code_contractst::check_frame_conditions_function(const irep_idt &function)
13011215 inlining_decoratort decorated (log.get_message_handler ());
13021216 goto_function_inline (goto_functions, function, ns, decorated);
13031217
1304- INVARIANT (
1305- decorated.get_recursive_function_warnings_count () == 0 ,
1306- " Recursive functions found during inlining" );
1218+ decorated.throw_on_recursive_calls (log, 0 );
13071219
13081220 // Clean up possible fake loops that are due to `IF 0!=0 GOTO i` instructions
13091221 simplify_gotos (function_body, ns);
0 commit comments