Skip to content

Make namespacet references const where possible#8995

Merged
tautschnig merged 1 commit intodiffblue:developfrom
tautschnig:const-namespace
Apr 30, 2026
Merged

Make namespacet references const where possible#8995
tautschnig merged 1 commit intodiffblue:developfrom
tautschnig:const-namespace

Conversation

@tautschnig
Copy link
Copy Markdown
Collaborator

namespacet has no non-const member functions (other than constructors and assignment), so non-const references to it are misleading. The only legitimate non-const use is in goto_symext::symex_with_state where the namespacet object is reassigned via reset_namespacet.

Changes in src/:

  • linking_diagnosticst constructor: namespacet& -> const namespacet& (the member was already const)
  • cfg_visitort (wmm): namespacet& member and constructor parameter made const

Changes in unit/:

  • variable_sensitivity_test_helpers: all namespacet& parameters -> const
  • eval-member-access, assume, assume_prune, maximum_length, extremes-go-top: all namespacet& parameters and members -> const
  • 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.

@tautschnig tautschnig self-assigned this Apr 30, 2026
Copilot AI review requested due to automatic review settings April 30, 2026 20:27
Copy link
Copy Markdown

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 improves const-correctness by converting namespacet & parameters/members to const namespacet & in core code and variable-sensitivity unit tests, aligning the API with the fact that namespacet is effectively immutable after construction.

Changes:

  • Make linking_diagnosticst constructor accept const namespacet &.
  • Update WMM cfg_visitort to store a const namespacet &.
  • Update multiple variable-sensitivity unit-test helpers/tests to take/store const namespacet &.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
unit/analyses/variable-sensitivity/variable_sensitivity_test_helpers.h Update helper function signatures to const namespacet &.
unit/analyses/variable-sensitivity/variable_sensitivity_test_helpers.cpp Keep helper definitions in sync with const namespacet & signatures.
unit/analyses/variable-sensitivity/value_expression_evaluation/assume_prune.cpp Update helper functions to accept const namespacet &.
unit/analyses/variable-sensitivity/value_expression_evaluation/assume.cpp Make assume_testert store const namespacet & and update related helpers.
unit/analyses/variable-sensitivity/interval_abstract_value/extremes-go-top.cpp Update helper signature to const namespacet & (and reflow declaration).
unit/analyses/variable-sensitivity/full_array_abstract_object/maximum_length.cpp Update write_array helper signature to const namespacet &.
unit/analyses/variable-sensitivity/eval-member-access.cpp Update helper prototypes/definitions to const namespacet &.
src/linking/linking_diagnostics.h Make linking_diagnosticst ctor take const namespacet &.
src/goto-instrument/wmm/goto2graph.h Make cfg_visitort::ns a const namespacet &.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/linking/linking_diagnostics.h
Comment thread src/goto-instrument/wmm/goto2graph.h Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.51%. Comparing base (6d1956b) to head (954ca7b).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8995   +/-   ##
========================================
  Coverage    80.50%   80.51%           
========================================
  Files         1704     1704           
  Lines       188818   188821    +3     
  Branches        73       73           
========================================
+ Hits        152017   152022    +5     
+ Misses       36801    36799    -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.

namespacet has no non-const member functions (other than constructors
and assignment), so non-const references to it are misleading. The only
legitimate non-const use is in goto_symext::symex_with_state where the
namespacet object is reassigned via reset_namespacet.

Changes in src/:
- linking_diagnosticst constructor: namespacet& -> const namespacet&
  (the member was already const)
- cfg_visitort (wmm): namespacet& member and constructor parameter
  made const

Changes in unit/:
- variable_sensitivity_test_helpers: all namespacet& parameters -> const
- eval-member-access, assume, assume_prune, maximum_length,
  extremes-go-top: all namespacet& parameters and members -> const

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig tautschnig merged commit 453c863 into diffblue:develop Apr 30, 2026
43 checks passed
@tautschnig tautschnig deleted the const-namespace branch April 30, 2026 22:32
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.

3 participants