feat(cpp-phase2): PR-05 transitive-include fallback for C resolver#683
Open
shivasurya wants to merge 1 commit intoshiva/cpp-phase2-pr04-resolution-qualityfrom
Open
Conversation
Mirrors the PR-04 C++ fix on the C resolver. lookupCStdlib now runs in two stages: 1. Direct system includes (existing fast path). 2. Manifest-wide scan when the direct walk doesn't yield a hit. Real C codebases route stdlib pulls through a project-internal header (redis includes <string.h>, <stdio.h>, <stdlib.h>, <pthread.h> from src/server.h, and every .c file just `#include "server.h"`). PR-02's direct-only walk meant strlen/memcpy/printf/malloc and friends never resolved when called from any file relying on that pattern. The fallback is bounded to the manifest's loaded headers — symbols not in the manifest can never bind, so there's no risk of a project-internal function accidentally resolving to a stdlib FQN. First hit wins; stdlib symbols are uniquely owned by one header in the real world so order doesn't affect correctness. The same path is exercised by C++ files that route stdlib calls through the C-fallthrough (printf/malloc/memcpy from .cpp), so the fix benefits both languages. Validation: - Redis full tree: 63.1% → 67.8% (+4.7 pp) - Proxygen tree: 17.1% → 25.4% (+8.3 pp, via C-fallthrough) - Smoke fixture: 100% → 100% (regression check) The PR-04 test that asserted "no direct include => unresolved" contradicts the new (intentional) contract; replaced with two tests: - transitive resolution works - unknown symbols stay unresolved (the safety guard) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
Code Pathfinder Security ScanNo security issues detected.
Powered by Code Pathfinder |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## shiva/cpp-phase2-pr04-resolution-quality #683 +/- ##
=========================================================================
Coverage 85.68% 85.69%
=========================================================================
Files 203 203
Lines 29209 29212 +3
=========================================================================
+ Hits 25029 25032 +3
Misses 3207 3207
Partials 973 973 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Single-fix follow-up to PR-04 — ports the transitive-include fallback (already shipped on the C++ resolver) to the C resolver. Stacked on PR-04; should merge after.
What's in here
lookupCStdlibnow runs in two stages instead of one:#include <…>list.Bounded to the manifest's loaded headers, so symbols not in the manifest can never bind. Stdlib symbols are uniquely owned by one header in the real world, so first-hit-wins is effectively the same as best-match.
Why this matters
Real C codebases route stdlib pulls through a project-internal header. Redis is the canonical example:
PR-02's resolver only walked DIRECT system includes, so when
redis-cli.ccalledstrlenit never looked in<string.h>because the include chain was indirect. The fix lets the resolver fall back to the full manifest when direct lookup misses — same shape PR-04 already shipped on the C++ side.The C-fallthrough in the C++ builder also benefits —
.cppfiles callingprintf/malloc/memcpyroute through this code path.Validation
testdata/c/stdlib)Top redis unresolveds before this fix that now resolve:
strcasecmp(952),memcpy(146),strlen(136),snprintf(128),strerror(119),memset(114),exit(104),strerror,malloc/free,pthread_mutex_*,ntohs/htons.Verification
gradle buildGo— cleango test ./...— all packages passgolangci-lint run ./...— 0 issuesTest plan
Related
Continues the gap analysis posted on #682. The remaining uplift (proxygen → ~30%) needs receiver-type inference for STL container methods (
vec.size(),str.empty()) — separate, larger effort.🤖 Generated with Claude Code