File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
regression/goto-analyzer/reachable-functions-stdio-empty Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+
3+ int main ()
4+ {
5+ return 0 ;
6+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ test.c
3+ --reachable-functions
4+ ^test\.c main [0-9]+ [0-9]+$
5+ ^<built-in-additions> __CPROVER_initialize [0-9]+ [0-9]+$
6+ ^EXIT=0$
7+ ^SIGNAL=0$
8+ --
9+ ^warning: ignoring
10+ __sputc
Original file line number Diff line number Diff line change @@ -181,9 +181,12 @@ void unreachable_instructions(
181181
182182 const symbolt &decl = ns.lookup (gf_entry.first );
183183
184- if (
185- called.find (decl.name ) != called.end () ||
186- to_code_type (decl.type ).get_inlined ())
184+ // Only consider functions reachable if they're actually called.
185+ // Previously, functions marked as "inline" were automatically treated as
186+ // reachable, but this caused false positives on systems (like MacOS) where
187+ // system headers contain uncalled inline functions that reference other
188+ // functions, making those referenced functions appear reachable.
189+ if (called.find (decl.name ) != called.end ())
187190 {
188191 unreachable_instructions (goto_program, dead_map);
189192 }
@@ -314,9 +317,9 @@ static void list_functions(
314317 {
315318 const symbolt &decl = ns.lookup (gf_entry.first );
316319
317- if (
318- unreachable == (called. find (decl. name ) != called. end () ||
319- to_code_type ( decl.type ). get_inlined ()))
320+ // Only consider functions reachable if they're actually called.
321+ // See comment in unreachable_instructions() for rationale.
322+ if (unreachable == (called. find ( decl.name ) != called. end ()))
320323 {
321324 continue ;
322325 }
You can’t perform that action at this time.
0 commit comments