Skip to content

Commit 51cef3c

Browse files
committed
Fix escape analysis
has_value was previously constant true.
1 parent 5c65731 commit 51cef3c

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdlib.h>
2+
3+
void foo()
4+
{
5+
int *leaked1=malloc(sizeof(int));
6+
int *leaked2=malloc(sizeof(int));
7+
}
8+
9+
int main()
10+
{
11+
foo();
12+
return 0;
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--show-escape-analysis
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^Aliases:.*(malloc.*leaked|leaked.*malloc)
7+
--
8+
^warning: ignoring

src/analyses/escape_analysis.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,8 @@ bool escape_domaint::merge(
305305
locationt from,
306306
locationt to)
307307
{
308-
if(b.has_values.is_false())
309-
return false; // no change
310-
311-
if(has_values.is_false())
312-
{
313-
*this=b;
314-
return true; // change
315-
}
316-
317-
bool changed=false;
308+
bool changed=has_values.is_false();
309+
has_values=tvt::unknown();
318310

319311
for(const auto &cleanup : b.cleanup_map)
320312
{

0 commit comments

Comments
 (0)