Skip to content

Commit c394f2a

Browse files
author
Daniel Kroening
committed
uninitialized_domaint now has bottom
1 parent 0769ea1 commit c394f2a

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

src/analyses/uninitialized_domain.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void uninitialized_domaint::transform(
3131
ai_baset &ai,
3232
const namespacet &ns)
3333
{
34+
if(is_bottom) return;
35+
3436
switch(from->type)
3537
{
3638
case DECL:
@@ -96,11 +98,13 @@ void uninitialized_domaint::output(
9698
const ai_baset &ai,
9799
const namespacet &ns) const
98100
{
99-
for(uninitializedt::const_iterator
100-
it=uninitialized.begin();
101-
it!=uninitialized.end();
102-
it++)
103-
out << *it << '\n';
101+
if(is_bottom)
102+
out << "BOTTOM";
103+
else
104+
{
105+
for(const auto & id : uninitialized)
106+
out << id << '\n';
107+
}
104108
}
105109

106110
/*******************************************************************\
@@ -120,11 +124,16 @@ bool uninitialized_domaint::merge(
120124
locationt from,
121125
locationt to)
122126
{
127+
bool old_is_bottom=is_bottom;
128+
129+
is_bottom=is_bottom && other.is_bottom;
130+
123131
unsigned old_uninitialized=uninitialized.size();
124132

125133
uninitialized.insert(
126134
other.uninitialized.begin(),
127135
other.uninitialized.end());
128136

129-
return old_uninitialized!=uninitialized.size();
137+
return old_is_bottom!=is_bottom ||
138+
old_uninitialized!=uninitialized.size();
130139
}

src/analyses/uninitialized_domain.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ Date: January 2010
1616
class uninitialized_domaint:public ai_domain_baset
1717
{
1818
public:
19-
// locals that are not initialized
19+
uninitialized_domaint():is_bottom(true)
20+
{
21+
}
22+
23+
bool is_bottom;
24+
25+
// Locals that are declared but may not be initialized
2026
typedef std::set<irep_idt> uninitializedt;
2127
uninitializedt uninitialized;
2228

@@ -33,17 +39,19 @@ class uninitialized_domaint:public ai_domain_baset
3339

3440
void make_top() override final
3541
{
36-
uninitialized.clear();
42+
// We don't have a proper 'top', and refuse to do this.
43+
assert(false);
3744
}
3845

3946
void make_bottom() override final
4047
{
4148
uninitialized.clear();
49+
is_bottom=true;
4250
}
4351

4452
void make_entry() override final
4553
{
46-
uninitialized.clear();
54+
make_top();
4755
}
4856

4957
// returns true iff there is s.th. new

0 commit comments

Comments
 (0)