Skip to content

Commit 32fd50f

Browse files
smowtonpeterschrammel
authored andcommitted
Permit static analysis to recurse
A subclass can now override get_allow_recursion in order to allow recursive calls to be handled as usual, rather than assuming they have no effects as was previously the case.
1 parent 8157141 commit 32fd50f

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/analyses/static_analysis.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,19 +518,21 @@ void static_analysis_baset::do_function_call_rec(
518518
}
519519
return;
520520
}
521-
521+
522522
if(function.id()==ID_symbol)
523523
{
524524
const irep_idt &identifier=function.get(ID_identifier);
525525

526-
if(recursion_set.find(identifier)!=recursion_set.end())
526+
if(ignore_recursion)
527527
{
528-
// recursion detected!
529-
return;
528+
if(recursion_set.find(identifier)!=recursion_set.end())
529+
{
530+
// recursion detected!
531+
return;
532+
}
533+
else
534+
recursion_set.insert(identifier);
530535
}
531-
else
532-
recursion_set.insert(identifier);
533-
534536
goto_functionst::function_mapt::const_iterator it=
535537
goto_functions.function_map.find(identifier);
536538

@@ -544,7 +546,8 @@ void static_analysis_baset::do_function_call_rec(
544546
arguments,
545547
new_state);
546548

547-
recursion_set.erase(identifier);
549+
if(ignore_recursion)
550+
recursion_set.erase(identifier);
548551
}
549552
else if(function.id()==ID_if)
550553
{

src/analyses/static_analysis.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class static_analysis_baset
9898
ns(_ns),
9999
initialized(false)
100100
{
101+
ignore_recursion=get_ignore_recursion();
101102
}
102103

103104
virtual void initialize(
@@ -260,6 +261,10 @@ class static_analysis_baset
260261
locationt l,
261262
const exprt &expr,
262263
std::list<exprt> &dest)=0;
264+
265+
bool ignore_recursion;
266+
virtual bool get_ignore_recursion() { return true; }
267+
263268
};
264269

265270
// T is expected to be derived from domain_baset

0 commit comments

Comments
 (0)