Skip to content

# Analyzer Stabilization: const-correctness, cross-TU robustness, and app/CLI refactor #58

Description

@SizzleUnrlsd

Context

This change set improves analyzer stability on self-analysis runs, reduces inter-TU false negatives/false positives, and cleans up key architecture layers (app/CLI execution flow and C++ API quality).

Changes Delivered

1) Parameter debug binding refactor

  • Introduced a dedicated ParameterDebugBinding component (parameter name/type/location + confidence).
  • Centralized parameter debug binding logic instead of scattered local heuristics.
  • Integrated binding usage in ConstParamAnalysis and diagnostic emission.

2) ConstParamAnalysis hardening

  • Replaced boolean “may write” logic with a tri-state model:
    • NoWrite
    • Unknown
    • MayWrite
  • Improved use of LLVM metadata (ReadOnly, ReadNone, WriteOnly, etc.).
  • Added confidence scoring for findings.
  • Suppressed non-actionable cases (artificial/forwarding/callable patterns for specific rvalue-ref scenarios).
  • Made const-suggestion messages consistent with final resolved parameter binding.

3) Diagnostic emission improvements

  • DiagnosticEmitter now uses parameter binding data (name + line/column).
  • Confidence is propagated into diagnostics when available.

4) Cross-TU regression fix (resource summary cache)

  • Fixed root cause: cross-TU cache contamination after filtered runs (--only-function, --only-file, etc.).
  • Analysis filter context is now part of the resource cross-TU cache key.
  • Result: no reuse of partial summaries across different analysis contexts.

5) App execution flow refactor

  • Simplified runAnalyzerApp API (localized LLVMContext handling in execution path).
  • Cleaned execution strategy boundaries (SharedModuleLoading vs direct loading) with simpler interfaces.
  • Better separation of concerns between planning, execution, and output.

6) CLI SMT parsing cleanup

  • Refactored SMT option handlers to a unified optional<error> result model.
  • Reduced ad-hoc error paths and tightened parser consistency.

7) Const-correctness and C++20 hygiene

  • Applied const-correctness updates across multiple analyses/pipeline paths.
  • Updated CMake to include ParameterDebugBinding.cpp.
  • Observed local config change: warnings-only=false.

Architecture Rationale

  • Moving parameter debug resolution into a dedicated module improves reuse, testability, and maintainability.
  • Fixing cache identity (key design) is a generic, durable solution compared to rule-specific workarounds.
  • Separating plan/execution/output in the app layer reduces side effects and improves inter-TU pipeline evolvability.

Validation

  • Build: OK (cmake --build build -j4)
  • Repro (filtered run -> unfiltered run cache scenario): fixed
  • Full test campaign: Passed 1658/1658 with --no-cache
  • No test files were modified

Risks / Notes

  • warnings-only=false changes default output behavior; confirm whether this is intended product behavior or local preference.
  • Filter-aware cache partitioning increases cache entry count (expected tradeoff for correctness).

Acceptance Criteria

  • No cross-TU diagnostic loss after filtered runs.
  • Stable self-analysis behavior on regression suite.
  • Green build and full tests without test changes.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions