Skip to content

ruff_cpp_spo: keep callee resolution status and namespaces - #136

Merged
AdaWorldAPI merged 3 commits into
mainfrom
claude/sgr-cpp-call-identity
Nov 2, 2026
Merged

AdaWorldAPI merged 3 commits into
mainfrom
claude/sgr-cpp-call-identity

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

Producer-side fix from the Semantic Grammar Recovery map (operator decision S2, item B9).

A libclang fixture showed three hazards in walk_free_functions before this change:

Function calls before Hazard
use_ns ["f"] a::f and b::f collapsed to one callee
use_broken ["g"] an unresolved overload set reported as a resolved call
via_ptr ["fp"] a call through a function pointer reported as a call to fp

The calls of a body are now split by how far libclang resolved them:

  • calls: resolved calls only.
    • Methods stay class-qualified (A::reset).
    • Free functions carry their enclosing scopes (a::f), the same key as CppFunction::qualified_name.
    • At global scope a free function stays bare, so C-library manifests are unchanged.
  • unresolved_calls: unresolved lookup sets (OverloadedDeclRef) as LookupSet { name, candidates }. Candidates are scope-qualified with their signature (g(int), g(double)), so overloads stay distinct.
  • dynamic_calls: calls through a pointer, parameter or field. Only the count is kept.

Re-pinned: the out-of-line fixture's free_helper (the makerow.cpp make_baseline_spline shape) is now an unresolved lookup set with candidate free_helper(int), not a resolved call. Overload resolution did not happen there.

Test plan

  • The libclang fixture was committed red first.

  • With --features libclang (LIBCLANG_PATH=/usr/lib/llvm-18/lib): 76/76 lib tests pass, and clippy --all-targets -D warnings is clean.

  • Disable runs, each red:

    Disable Tests that fail
    Free function left bare the identity test
    Lookup set treated as resolved 2 tests
    Pointer call named the identity test

    The lookup-set disable first failed to apply after cargo fmt reflowed the line. The anchor assertion caught it, and the run was repeated against the formatted text.

Remaining

  • Methods of same-named classes in different namespaces still collide (ns1::A::reset vs ns2::A::reset). Fixing that changes method keys in banked manifests; the decision is open.
  • The no-feature clippy build fails on main before this change (large_enum_variant at lib.rs, and CppFunction used in tests without the feature). It is unchanged here.

Not to be merged automatically.


Generated by Claude Code

Today a::f and b::f collapse to 'f', an unresolved lookup set 'g' is
reported as a resolved call, and a call through a function pointer 'fp' is
reported as a call to 'fp'. The test fails on all three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
…er side)

`walk_free_functions` now splits a body's calls by how far libclang resolved
them:
- `calls`: resolved only. Methods stay class-qualified (`A::reset`); free
  functions carry their enclosing scopes (`a::f`, the same key as
  `CppFunction::qualified_name`; bare at global scope, so C manifests are
  unchanged).
- `unresolved_calls`: unresolved lookup sets (`OverloadedDeclRef`) as
  `LookupSet { name, candidates }`, candidates scope-qualified with their
  signature (`g(int)`, `g(double)`). Never reported as a resolved call.
- `dynamic_calls`: calls through a pointer, parameter or field (count only;
  the variable's name is not a callee).

Re-pinned: the out-of-line fixture's `free_helper` (the makerow.cpp shape) is
now an unresolved lookup set, not a resolved call.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9cad0342-07a3-45c8-8b63-31bbfb673d2a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T20:13:21.684311Z 164edbd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 164edbde60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/ruff_cpp_spo/src/clang_walker.rs Resolved
Comment thread crates/ruff_cpp_spo/src/clang_walker.rs Resolved
…ters are dynamic

A constructor or destructor CallExpr references a Constructor/Destructor
declaration; it now resolves like a method (A::A) instead of counting as a
dynamic call. A call whose callee expression is another call to a function
returning a function pointer (factory()(1)) is dynamic even though libclang
reports the inner function as its reference; the inner call keeps its own
edge. Both conditions are required, so an operator call or a constructor
whose first child is a call stays resolved. Codex P2 x2 on #136.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X6y3drwKSE2zSgoexheLFX
@AdaWorldAPI
AdaWorldAPI merged commit 667936e into main Nov 2, 2026
36 of 37 checks passed
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.

2 participants