Skip to content

Commit 9c1b5ea

Browse files
authored
Merge pull request #6338 from tautschnig/fix-6330-part-2
goto-analyzer --(un)reachable-functions should not rely on base names
2 parents 76ff675 + ac069cf commit 9c1b5ea

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
static int foo(int x)
2+
{
3+
return x + 1;
4+
}
5+
6+
static int bar(int x)
7+
{
8+
return x + 2;
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int __CPROVER_file_local_project_c_foo(int x);
2+
3+
int main()
4+
{
5+
int x = __CPROVER_file_local_project_c_foo(1);
6+
assert(x == 2);
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
test.c
3+
--reachable-functions
4+
^.* foo 1 4$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^.* [a-zA-Z0-9_]+foo \d+ \d+$
9+
--
10+
This test checks that after building the goto binary (see test.sh) with
11+
--export-file-local-symbols function "foo" is still reported as reachable. Note,
12+
that the symbol representing "foo" has a mangled name in the goto binary, which
13+
makes the symbol name different from its base name.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
goto_cc=$1
5+
is_windows=$2
6+
7+
if [[ "${is_windows}" == "true" ]]; then
8+
${goto_cc} "/c" "/Foproject.gb" --export-file-local-symbols project.c
9+
${goto_cc} "/c" "/Foproof.gb" --export-file-local-symbols proof.c
10+
${goto_cc} "/Fetest.gb" project.gb proof.gb
11+
else
12+
${goto_cc} -o project.gb --export-file-local-symbols project.c
13+
${goto_cc} -o proof.gb --export-file-local-symbols proof.c
14+
${goto_cc} -o test.gb project.gb proof.gb
15+
fi

src/goto-analyzer/unreachable_instructions.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,8 @@ void unreachable_instructions(
179179

180180
const symbolt &decl = ns.lookup(gf_entry.first);
181181

182-
// gf_entry.first may be a link-time renamed version, use the
183-
// base_name instead; do not list inlined functions
184182
if(
185-
called.find(decl.base_name) != called.end() ||
183+
called.find(decl.name) != called.end() ||
186184
to_code_type(decl.type).get_inlined())
187185
{
188186
unreachable_instructions(goto_program, dead_map);
@@ -314,10 +312,8 @@ static void list_functions(
314312
{
315313
const symbolt &decl = ns.lookup(gf_entry.first);
316314

317-
// gf_entry.first may be a link-time renamed version, use the
318-
// base_name instead; do not list inlined functions
319315
if(
320-
unreachable == (called.find(decl.base_name) != called.end() ||
316+
unreachable == (called.find(decl.name) != called.end() ||
321317
to_code_type(decl.type).get_inlined()))
322318
{
323319
continue;

0 commit comments

Comments
 (0)