Problem
patchir-decomp currently has good black-box fixture coverage, but the new direct path still lacks an isolated harness for testing CFG construction and future structuring behavior before Clang emission.
That makes it hard to verify:
CGraphBuilder node/successor construction
- branch metadata extraction from
CBRANCH / BRANCHIND
- future
SNode fold/structuring rules
- negative cases that should fail before codegen
Proposed Work
Add a small AST/decomp unit-style harness that:
- deserializes a JSON fixture into the existing Ghidra in-memory model
- creates a
FunctionBuilder
- runs
BuildCGraph
- asserts directly on
CGraph contents before EmitClangAST
- when structuring is wired in, asserts on resulting
SNode kinds as well
Suggested Implementation
Recommended shape:
- new test target under the AST/decomp area, preferably gtest-based if that is already acceptable for host-side unit tests
- helper that constructs a minimal
clang::CompilerInstance / ASTContext once per test case
- fixture loader that reuses
patchestry::ghidra::JsonParser
- focused assertions on:
- entry node id
- node count
succs / preds
branch_cond
switch_cases
- collapsed/structured node metadata once fold rules are active
First Test To Add
A minimal conditional JSON fixture that proves:
CBRANCH is removed from block statements
BuildCGraph produces two outgoing edges
branch_cond is preserved on the CFG node
- the true/false target blocks are resolved in the expected order
Why This Matters
The current integration tests tell us whether final CIR/C/LLVM output looks reasonable, but they do not localize failures well when CFG structuring changes. This harness would let us test the direct path where the new architecture actually lives.
Problem
patchir-decompcurrently has good black-box fixture coverage, but the new direct path still lacks an isolated harness for testing CFG construction and future structuring behavior before Clang emission.That makes it hard to verify:
CGraphBuildernode/successor constructionCBRANCH/BRANCHINDSNodefold/structuring rulesProposed Work
Add a small AST/decomp unit-style harness that:
FunctionBuilderBuildCGraphCGraphcontents beforeEmitClangASTSNodekinds as wellSuggested Implementation
Recommended shape:
clang::CompilerInstance/ASTContextonce per test casepatchestry::ghidra::JsonParsersuccs/predsbranch_condswitch_casesFirst Test To Add
A minimal conditional JSON fixture that proves:
CBRANCHis removed from block statementsBuildCGraphproduces two outgoing edgesbranch_condis preserved on the CFG nodeWhy This Matters
The current integration tests tell us whether final CIR/C/LLVM output looks reasonable, but they do not localize failures well when CFG structuring changes. This harness would let us test the direct path where the new architecture actually lives.