feat(callgraph): C/C++ module registry and include resolution#672
Open
shivasurya wants to merge 1 commit intoshiva/cpp-parserfrom
Open
feat(callgraph): C/C++ module registry and include resolution#672shivasurya wants to merge 1 commit intoshiva/cpp-parserfrom
shivasurya wants to merge 1 commit intoshiva/cpp-parserfrom
Conversation
Add CModuleRegistry and CppModuleRegistry types under callgraph/core plus build helpers under callgraph/registry. The registries map source files to project-relative FQN prefixes, index every function under its bare name for cross-file resolution, and resolve project-local #include "..." directives via a fixed search order (same dir, include/, src/, project root). C++ adds namespace-qualified and class-qualified indices, with method-to-class association via byte-range containment so the registry stays decoupled from parser-internal context tracking. Establishes the FQN foundation for the C/C++ call-graph builder: PR-07 (C) and PR-08 (C++) consume FunctionIndex, NamespaceIndex, ClassIndex, and Includes to compute caller/callee FQNs and follow header-to-source edges. 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## shiva/cpp-parser #672 +/- ##
====================================================
+ Coverage 85.17% 85.18% +0.01%
====================================================
Files 178 180 +2
Lines 26064 26237 +173
====================================================
+ Hits 22199 22351 +152
- Misses 3015 3024 +9
- Partials 850 862 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7 tasks
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
Adds the FQN foundation for the C/C++ call-graph builder.
graph/callgraph/core/c_module_types.go—CModuleRegistry(file-prefix, includes, function index) andCppModuleRegistry(embeds C registry plus namespace and class indices).graph/callgraph/registry/c_module.go—BuildCModuleRegistry,BuildCppModuleRegistry, andBuildCIncludeMapwalk the parsedCodeGraphand produce read-only registries.FQN format
src/net/socket.c::connect_to_serversrc/utils.cpp::mylib::processsrc/socket.cpp::mylib::Socket::connectsrc/app.cpp::App::runsrc/main.cpp::mainInclude resolution order
For
#include \"...\", first match wins:<projectRoot>/include/<header><projectRoot>/src/<header><projectRoot>/<header>System includes (
#include <...>) are skipped — they are owned by a future stdlib registry.Design notes
..-prefixed relative paths) are dropped at registry-build time.FunctionIndexdeliberately preserves duplicates across header and source files so the call-graph builder can choose between declaration and definition.appendUniquededupes per-key entries within a single file (defensive against repeated graph visits).Test plan
go build ./...go test ./...— full suite green (25 packages)go vet ./...golangci-lint run ./graph/callgraph/registry/ ./graph/callgraph/core/— 0 issuescore94.3%,registry91.7% on the new filesStacked on
shiva/cpp-parser(#671)