goto-analyzer: fix reachable-functions analysis for inline functions#8788
Open
tautschnig wants to merge 1 commit intodiffblue:developfrom
Open
goto-analyzer: fix reachable-functions analysis for inline functions#8788tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
We now only consider functions reachable when they are actually called, and don't automatically consider `inline` functions reachable. Fixes: diffblue#5173
c4dafa2 to
491d307
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8788 +/- ##
===========================================
- Coverage 79.93% 79.93% -0.01%
===========================================
Files 1698 1698
Lines 187698 187694 -4
Branches 73 73
===========================================
- Hits 150034 150030 -4
Misses 37664 37664 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Fixes goto-analyzer --reachable-functions reporting inline functions as reachable even when not reachable from the entry point (e.g., inline helpers from macOS system headers), addressing #5173.
Changes:
- Stop treating
inline-marked functions as reachable purely due to the inline attribute; reachability is now based on the computed reachable/called set. - Apply the same reachability criterion in both
--reachable-functionsand--unreachable-instructionspaths. - Add a regression test covering an “empty” program that includes
<stdio.h>to ensure__sputcis not reported as reachable.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/goto-analyzer/unreachable_instructions.cpp |
Updates reachability checks to ignore the inline attribute for both instruction and function reachability reporting. |
regression/goto-analyzer/reachable-functions-stdio-empty/test.c |
Minimal reproducer including <stdio.h> with an empty main. |
regression/goto-analyzer/reachable-functions-stdio-empty/test.desc |
Regression expectations: only main and __CPROVER_initialize are reachable; __sputc must not appear. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+184
to
+189
| // Only consider functions reachable if they're actually called. | ||
| // Previously, functions marked as "inline" were automatically treated as | ||
| // reachable, but this caused false positives on systems (like MacOS) where | ||
| // system headers contain uncalled inline functions that reference other | ||
| // functions, making those referenced functions appear reachable. | ||
| if(called.find(decl.name) != called.end()) |
Comment on lines
+320
to
+321
| // Only consider functions reachable if they're actually called. | ||
| // See comment in unreachable_instructions() for rationale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We now only consider functions reachable when they are actually called, and don't automatically consider
inlinefunctions reachable.Fixes: #5173