feat(callgraph): C/C++ explicit type inference engines#673
Open
shivasurya wants to merge 1 commit intoshiva/cpp-module-registryfrom
Open
feat(callgraph): C/C++ explicit type inference engines#673shivasurya wants to merge 1 commit intoshiva/cpp-module-registryfrom
shivasurya wants to merge 1 commit intoshiva/cpp-module-registryfrom
Conversation
Add CTypeInferenceEngine and CppTypeInferenceEngine under the
resolution package. The engines index types that appear verbatim in
C/C++ source — function return types, variable declarations, class
method return types, and class field types — with Confidence=1.0 and
Source="declaration". No inference, deduction, or propagation; later
phases layer those on top.
Highlights:
- Function-scoped variable bindings track reassignment history; the
latest binding wins on lookup.
- C++ engine embeds the C engine by value so callers can use
ExtractReturnType / GetScope / GetVariable uniformly.
- C++ `auto` is recognised by exact match and stored with
Confidence=0.0, Source="unresolved_auto" so resolvers skip it
until Phase 2 deduces a concrete type.
- Thread-safe via two RWMutex pairs on the C engine and two
additional pairs for class-method and class-field maps; verified
under `go test -race`.
Sets up the typed receiver lookups consumed by PR-07 (C call graph)
and PR-08 (C++ call graph).
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-module-registry #673 +/- ##
=============================================================
+ Coverage 85.18% 85.28% +0.09%
=============================================================
Files 180 182 +2
Lines 26237 26399 +162
=============================================================
+ Hits 22351 22515 +164
+ Misses 3024 3023 -1
+ Partials 862 861 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6 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 explicit type-tracking foundation for C/C++ call-graph resolution.
graph/callgraph/resolution/c_types.go—CTypeInferenceEngine,CFunctionScope,CVariableBinding. Tracks return types and per-function variable scopes drawn directly from source declarations.graph/callgraph/resolution/cpp_types.go—CppTypeInferenceEngineembeds the C engine and adds class method / class field indices, plusautohandling.TypeInfo contract
declarationunresolved_autoauto x = ...placeholders awaiting Phase 2 deductionDesign notes
CppTypeInferenceEngineembedsCTypeInferenceEngineby value, so every C-engine method (ExtractReturnType,GetScope,GetVariable, etc.) is callable on the C++ engine. The embeddedRegistryfield aliases the C++ registry'sCModuleRegistryfacet so updates propagate.GetVariablereturns the latest.GetAllBindingsexposes the history for future flow analysis.autodetection: exact equality on\"auto\". Modifiers likeauto*andauto&are concrete types and keep full confidence — they survive the override branch and route through the C engine unchanged.GetReturnType != nil).sync.RWMutexinstances guardScopes,ReturnTypes,ClassMethods,ClassFields. Snapshot accessors (GetAllReturnTypes,GetAllScopes) return defensive copies.ExtractVariableTypecreates the scope on first use; callers do not need to callAddScopebefore the first variable.Test plan
go build ./...go test ./...— full suite green (25 packages)go test -race ./graph/callgraph/resolution/...— cleango vet ./...golangci-lint run ./graph/callgraph/resolution/— 0 issuesc_types.go100%,cpp_types.go100%autozero-confidence,auto*/auto&exact-match, complex C types (pointer/const/struct), complex C++ types (templates / refs / nested templates).Stacked on
shiva/cpp-module-registry(#672)