Fix --nondet-static-exclude to handle symbol names and report errors#8752
Fix --nondet-static-exclude to handle symbol names and report errors#8752tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8752 +/- ##
===========================================
- Coverage 80.41% 80.41% -0.01%
===========================================
Files 1703 1703
Lines 188398 188407 +9
Branches 73 73
===========================================
+ Hits 151498 151505 +7
- Misses 36900 36902 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
`--nondet-static-exclude` previously silently failed or crashed when using certain variable name formats. Fixes: diffblue#8225
33306c4 to
066c016
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes --nondet-static-exclude handling in goto-instrument so symbol identifiers containing :: (e.g., f::1::bar) are no longer misinterpreted as file:var inputs, and adds explicit error reporting when a non-file:... exclude value can’t be found in the symbol table.
Changes:
- Refine parsing to distinguish
file:variableexcludes from scoped symbol names containing::. - When given a non-
file:...exclude value, look it up in the symbol table and throw a command-line exception if missing. - Add a regression test covering excludes using a scoped static symbol name and a global name.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/goto-instrument/nondet_static.cpp |
Fixes exclude parsing for :: names and adds explicit error reporting for missing symbols. |
regression/goto-instrument/nondet_static_exclude_symbol_name/test.desc |
Adds a regression driver for excluding f::1::bar and foo. |
regression/goto-instrument/nondet_static_exclude_symbol_name/main.c |
Test program exercising global + function-local static exclusion. |
Comments suppressed due to low confidence (1)
src/goto-instrument/nondet_static.cpp:177
- In the
file:variablebranch, the option value is accepted without validating that it actually matches any symbol. This means--nondet-static-exclude somefile.c:typowill still silently do nothing, which seems to contradict the goal of reporting invalid exclude arguments. Consider checking that eachfile:...exclude matches at least onequalified_namein the symbol table (and throw aninvalid_command_line_argument_exceptiontif not).
if(file_prefix_found)
{
// This is in file:variable format
to_exclude.insert(except);
if(has_prefix(except, "./"))
{
to_exclude.insert(except.substr(2, except.length() - 2));
}
else
{
to_exclude.insert("./" + except);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Symbol not found, report an error | ||
| throw invalid_command_line_argument_exceptiont( | ||
| "symbol '" + except + "' not found in symbol table", | ||
| "--nondet-static-exclude"); | ||
| } |
| int foo = 0; | ||
|
|
||
| int f() | ||
| { | ||
| static int bar = 0; | ||
| return bar; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| assert(foo == 0); | ||
| assert(f() == 0); |
--nondet-static-excludepreviously silently failed or crashed when using certain variable name formats.Fixes: #8225