Skip to content

Fix --nondet-static-exclude to handle symbol names and report errors#8752

Open
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-8225-nondet-static-exclude
Open

Fix --nondet-static-exclude to handle symbol names and report errors#8752
tautschnig wants to merge 1 commit intodiffblue:developfrom
tautschnig:fix-8225-nondet-static-exclude

Conversation

@tautschnig
Copy link
Collaborator

--nondet-static-exclude previously silently failed or crashed when using certain variable name formats.

Fixes: #8225

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.41%. Comparing base (85c204f) to head (066c016).

Files with missing lines Patch % Lines
src/goto-instrument/nondet_static.cpp 76.92% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tautschnig tautschnig self-assigned this Feb 24, 2026
`--nondet-static-exclude` previously silently failed or crashed when
using certain variable name formats.

Fixes: diffblue#8225
@tautschnig tautschnig force-pushed the fix-8225-nondet-static-exclude branch from 33306c4 to 066c016 Compare March 18, 2026 12:23
@tautschnig tautschnig marked this pull request as ready for review March 18, 2026 12:23
Copilot AI review requested due to automatic review settings March 18, 2026 12:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:variable excludes 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:variable branch, the option value is accepted without validating that it actually matches any symbol. This means --nondet-static-exclude somefile.c:typo will still silently do nothing, which seems to contradict the goal of reporting invalid exclude arguments. Consider checking that each file:... exclude matches at least one qualified_name in the symbol table (and throw an invalid_command_line_argument_exceptiont if 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.

Comment on lines +195 to +199
// Symbol not found, report an error
throw invalid_command_line_argument_exceptiont(
"symbol '" + except + "' not found in symbol table",
"--nondet-static-exclude");
}
Comment on lines +1 to +12
int foo = 0;

int f()
{
static int bar = 0;
return bar;
}

int main()
{
assert(foo == 0);
assert(f() == 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--nondet-static-exclude silently fails

2 participants