feat(cfg+scan+output): wire C/C++ pipeline end-to-end#677
Merged
shivasurya merged 2 commits intomainfrom May 3, 2026
Merged
Conversation
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 @@
## main #677 +/- ##
==========================================
+ Coverage 85.37% 85.43% +0.06%
==========================================
Files 187 187
Lines 27164 27276 +112
==========================================
+ Hits 23190 23303 +113
+ Misses 3083 3082 -1
Partials 891 891 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced May 3, 2026
Owner
Author
This was referenced May 3, 2026
Owner
Author
Merge activity
|
Three integration changes that bring C/C++ analysis into the full
scan pipeline:
1. CFG: add processSwitch and processDoWhile handlers. Switch
emits a BlockTypeSwitch header with one case-block fan-out per
case_statement, fallthrough edges between consecutive cases,
and a merge block reachable from every case. Do-while emits
`[pred] -> [body] -> [cond]` with the cond block looping back
to the body and a fall-through to the after-block, matching
the "execute body at least once" semantics.
2. cmd/scan.go: build the C call graph after the Go block when the
CodeGraph carries any node tagged Language="c"; same for C++.
The hasLanguageNodes helper gates each builder so non-C/C++
projects skip the work entirely. Build failures log a warning
and let the scan continue with whatever languages did build.
3. output/enricher.go: extractFunctionFromFQN and fallbackLocation
learn to handle C/C++ scope-resolved FQNs ("relpath::funcname",
"relpath::ns::Class::method"). The existing dot-separated path
for Python/Go/Java is preserved; the "::" branch is only taken
when the FQN contains it.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Pull the C/C++ build-and-merge block out of the scanCmd.RunE closure into three small helpers: buildClikeCallGraphs — entry point gated by hasLanguageNodes buildCCallGraphAndMerge — C-only build + merge with warning path buildCppCallGraphAndMerge — C++-only build + merge The closure now reads as one line. The helpers take *CallGraph, *CodeGraph, projectPath, and *Logger explicitly so they're unit-testable, which lifts patch coverage on this PR back above the 85% threshold. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
b3fad0e to
e2ae095
Compare
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
Three integration changes that bring C/C++ analysis into the full
pathfinder scanpipeline.1. CFG handlers (
graph/callgraph/cfg/builder.go)Adds
processSwitchandprocessDoWhileso C/C++ control-flow surfaces in the CFG instead of falling through to the generic statement handler.switch (x) { case 1: ...; case 2: ...; default: ... }[BlockTypeSwitch header]fans out to one case block percase_statement, with fallthrough edges between consecutive cases and a merge block reachable from every case.do { body } while (cond);[pred] -> [body] -> [BlockTypeLoop cond], cond loops back to body and falls through to an after-block.The do-while shape (no header gate before the first iteration) preserves the "execute body at least once" semantics that distinguishes it from a plain
while.2. Scan integration (
cmd/scan.go)After the existing Go block, the scan now:
BuildCModuleRegistry+BuildCCallGraphwhen the parsedCodeGraphcarries any C-tagged node, then merges the result viaMergeCallGraphs.BuildCppModuleRegistry+BuildCppCallGraph.Each step is gated by the new
hasLanguageNodes(codeGraph, language)helper so a Python-only or Go-only project skips the C/C++ work entirely. Build failures log a warning and let the scan continue with whatever languages did build — matching the Go path.3. Enricher (
output/enricher.go)extractFunctionFromFQNandfallbackLocationlearn to handle C/C++ scope-resolved FQNs:src/main.c::mainmainsrc/main.csrc/socket.cpp::mylib::Socket::connectconnectSocketsrc/socket.cppmyapp.auth.login(regression)loginauthThe dot-separated branch for Python / Go / Java is preserved; the
::branch only fires when the FQN actually contains::.Test plan
go build ./...go test ./...— full suite greengo vet ./...golangci-lint run ./graph/callgraph/cfg/ ./cmd/ ./output/— 0 issuesprocessSwitch92.3%,processDoWhile100%,hasLanguageNodes100%,fallbackLocation100%,extractFunctionFromFQN85.7% (the unreachable terminalreturnis pre-existing dead code)Stacked on
shiva/cpp-statements(#676)