← Back to Pull requests

Preserve pointee aliases through owning-pointer get() #255

Closed
unknown closed this pull request without merging on Nov 02, 2026 18:47 UTC
View on GitHub
unknown unknown commented on Nov 02, 2026 10:30 UTC
Author

Bodyless std::shared_ptr<T>::get() and std::unique_ptr<T>::get() lost the pointee value already available through operator->. A callback read through p.get()->callback could therefore have no target while p->callback reached alpha. Keep a single extraction recognizer for result typing and value lowering, retaining the external getter call site and rejecting unrelated get methods and calls with arguments.

Reuse UnwrapPointer for raw-pointer extraction, resolving the destination's pointee declaration before applying the existing compatibility filter. This preserves aliases without introducing heap allocations, wrapper-object aliases or incompatible pointees, including when converting to void . Route assignments, arguments, dereferences, returns and chained accesses through the ordinary expression-value machinery.

Intern wrapper descriptors needed by isolated reference/pointer receivers. Record reference returns from declarations and definitions, share overload selection with result typing, and load a reference-returned wrapper before extracting its pointee. Preserve both interpretations when unresolved overloads allow reference and value returns; do not add a load for a known value return.

Settle executable getter definitions before expression lowering and retain visibility through type-only header imports, including later out-of-line and separately lowered definitions. Recheck provisional extraction flows after merging with the shared image-aware resolver. Keep excluded dependency bodies declaration-only and preserve ordinary implementation returns. File-scope initializers use the destination's target when no caller exists; an executable getter receives an ordinary CallReturn in that image instead of retaining a provisional unwrap. Preserve provenance and retained flow ranges when settling those facts.

Add a reduced fixture and isolated regressions covering both wrappers, qualified calls, reference-only/pointer-only receivers, fields, returned wrappers, reference returns, raw/dereferenced arguments, casts, constructor arguments, negative controls and pointee filtering. Check later/shared-header implementations and global/local extractions across independent link images, including implementations supplied by another TU in the same image.

Update the changelog, README, contributor guide, C++ roadmap, analysis rules and unwrap-edge documentation. Consolidate the evaluation report around the final measurements and remaining independent task/bind/template limits. Refresh only HiView's argument-flow expectation center and add focused HDF and HiView production probes.

Validation:

  • cargo test --workspace: 2,601 passed, 0 failed

  • cargo fmt --all --check and git diff --check: passed

  • Fresh pinned HDF, HiView and camera analyses: all 115 checks pass for jobs=1 and jobs=8; all 34 logical SQLite relations match across job counts

  • Named corpus call targets, function counts and diagnostics are unchanged from parent d23d70e; HiView gains 124 argument-flow rows (31924 -> 32048)

  • Unwrap edges: HDF 50 -> 54, HiView 486 -> 526, camera 2466 -> 2620
  • Preserve value-form reference returns in wrapper receivers

    Receiver normalization assumed that every reference-returned wrapper held its address and unconditionally loaded through it. ReturnFlow::Copy still represents named and field reference returns as wrapper values, so this load discarded concrete pointees that ref().lock() retained before #247. The same mismatch affected owning-pointer ref().get().

    Conservatively keep the original return value alongside the loaded value whenever a viable declaration returns a reference. This handles both address-form returns such as return p and value-form returns such as return global or return field, without changing return-flow lowering. Known value returns still receive no extra load. Subsequent owning-pointer unwraps retain their existing compatibility filter, excluding wrapper storage and incompatible objects. Simplify the overload helper to report whether a reference return is possible.

    Add exact-pointee regressions for shared_ptr and unique_ptr extraction, and verify that reference-returned std::weak_ptr::lock() and OHOS wptr::promote() preserve the concrete pointee without a subsequent get(). Cover named, qualified, const/rvalue, forwarded, implicit/explicit field, dereferenced and bound-reference returns, with value-returning controls. Update the analysis rules, changelog and evaluation report.

    Validation:

  • cargo test --workspace: 2,603 passed, 0 failed

  • cargo fmt --all --check and git diff --check: passed

  • Fresh pinned HDF, HiView and camera analyses: all 115 checks pass with jobs=1 and jobs=8; all 34 logical SQLite relations match across job counts

  • All corpus analysis rows match the preceding exports; only producer revision metadata and its derived database_identity hash differ
  • Resolve getter definitions through imported wrapper declarations

    Register owning-pointer class declarations before the getter-definition prepass resolves out-of-line owners through namespace directives. Interned tags alone were invisible to declared-class lookup, allowing provisional get() summaries to add stored pointees despite executable getter bodies.

    Register local shared_ptr/unique_ptr namesakes too so the shared resolver preserves namespace shadowing and unrelated getters cannot suppress the standard templates' extraction summaries.

    Add exact-pointee regressions for both owning wrappers, std and ::std namespace directives, definitions before/after callers, and local namesakes. Update the analysis documentation, changelog, and evaluation report.

    Validation: cargo test --workspace (2,637 passed), cargo fmt --all --check, and git diff --check. Fresh pinned-corpus checks and deterministic export comparisons are recorded in docs/EVAL_REPORT.md.

    Closes #247

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: ArcsinX Review duration: 496m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #255"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%