Skip to content

Improve C++ Level-2 call-graph resolution (+7.8pp recall, +9.7pp resolution recall, 99.0% precision) - #9299

Merged
squid-protocol merged 1 commit into
mainfrom
feat/cpp-call-graph-epic
Nov 25, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feat/cpp-call-graph-epic

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Improves C++ Level-2 call-graph resolution using general, AST-free C++ semantics across detector.py, call_resolver.py, receiver_types.py, and return_types.py.

Key Improvements

  1. Cross-directory include/ ↔ src/ constructor linking: Matches C++ constructors declared in headers (e.g. include/fmt/os.h) to out-of-line definitions in src/ (src/os.cc) when stems match and the implementation includes the header.
  2. C++ using alias constructor & wrapper return-type resolution: Resolves calls/constructions through C++ type aliases (e.g. memory_buffer(), appender(buf), string_view(...)) to their underlying repo class, and unwraps C++ smart-pointer/wrapper aliases (expected<T, E>, optional<T>, unique_ptr<T>, shared_ptr<T>) on -> / factory chains.
  3. C++ const vs non-const member overload disambiguation: Detects const-qualified receivers (const T&, T const&, const auto&, and this inside const methods) to narrow const / non-const member overloads (data(), begin(), end()).
  4. Header-to-.cc class field propagation & 1-hop struct field chains: Propagates C++ class member field types from headers into out-of-line .cc methods and resolves 1-hop struct field receivers (pipe.read_end.descriptor(), pipe.read_end.fdopen("r").get()).
  5. Template <...> call chains & namespace-qualified factory chains: Skips balanced C++ template argument lists before ( in extract_expr_chain and falls back cleanly on namespace-qualified factory calls (fmt::scan<T>(...)->value()).
  6. C++ free-function header default-argument arities: Extracts C++ header free-function declarations with default arguments/variadics (open_buffered_file(FILE** fp = nullptr)) and widens matching .cc implementations (stem-scoped so unrelated overloads are untouched).
  7. C++ overload narrowing (arg0_kind & char_width): Enforces arity-first filtering, disambiguates compiled-string vs string-literal vs non-string first arguments (ignoring C++ user-defined string literals like ""_cf and mixed call sites), and narrows wchar / utf_wide / narrow overloads while preserving generic Char templates and propagating call-site widths through macro expansions.

C++ (fmtlib/fmt, libclang 18.1.1) Results

Metric Before After Delta
Confident Precision 98.9% 99.0% +0.1pp
Overload-Blind Precision 99.4% 99.5% +0.1pp
Strict Precision 90.5% 91.3% +0.8pp
Ambiguous Precision 45.4% 52.9% +7.5pp
Total Recall 43.2% 51.0% +7.8pp
Overload-Blind Recall 43.5% 51.4% +7.9pp
Resolution Recall 71.2% 80.9% +9.7pp
Confident Judged 1,442 1,700 +258

Golden Master Updates

Regenerated tests/golden_master_audit/ and tests/golden_master_zero_dep_audit/ via tests/tools/crucible_check.py --update --yes because the C++ call-resolver improvements resolve additional C++ call edges (updating fan-in, fan-out, and PageRank on C++ corpus files).

Verification

  • Added unit tests in tests/core_engine/test_cpp_call_resolution_epic.py (260/260 call-resolver tests passing).
  • ruff_audit.py --ci, mypy_audit.py --ci, dead_key_audit.py --ci, and doc_refs_audit.py --ci all pass with 0 new findings.
  • Updated tests/call_graph_resolution_cpp_baseline.json.

@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

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.

1 participant