fix(extract): attribute calls inside out-of-line C++ methods to the method#621
Open
KerseyFabrications wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
This was converted to draft until #463 is merged. |
4ffc1ab to
c9189cc
Compare
…ethod
A call inside a C++ out-of-line method definition (void Foo::Bar() { ... })
attributes to the File node instead of the enclosing method, including when the
definition is wrapped in a namespace block (reported on DeusData#463).
Root cause is not namespace context (absent from the C++ QN scheme) but a dropped
class qualifier: the call-side enclosing-QN computation produced t.path.Bar instead
of t.path.Foo.Bar for out-of-line definitions (no enclosing class AST node / no
class scope on the walk stack), so the pipeline's exact-QN source match fell back
to __file__. Same for the global (using-namespace) and namespace-block forms.
The out-of-line class resolution existed in the defs extractor but had two
divergent, incomplete copies on the call side -- the drift that caused DeusData#438.
Consolidate instead of adding a fourth copy:
- cbm_cpp_out_of_line_parent_class: promoted from extract_defs.c into helpers.
- cbm_cpp_out_of_line_method_qn: new shared helper that builds the class-scoped QN,
used by both compute_func_qn (CALLS, unified walk) and cbm_enclosing_func_qn
(cached path: USAGES/THROWS/CONFIGURES/type-assigns).
Fixes attribution for every edge type inside out-of-line methods, not just CALLS.
Tests: cpp_out_of_line_enclosing_qn (extraction QN match for global/block/nested)
and pipeline_cpp_out_of_line_call_attribution (full index: both forms source the
CALLS edge from a Method node). Full suite green apart from an unrelated, pre-existing
ASan RSS-budget flake.
Signed-off-by: Kris Kersey <kris@kerseyfabrications.com>
c9189cc to
1e50b5f
Compare
Contributor
Author
|
All conflicts resolved. All tests should pass. |
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.
Follow-up to #463 (out-of-line attribution gap reported there).
Problem
A call inside a C++ out-of-line method definition attributes to the File node instead of the enclosing method — including when the definition is
wrapped in a
namespace {}block.Root cause
Not namespace context (which never enters the C++ QN scheme —
namespace_nameis null and the namespace appears in no QN), but a dropped classqualifier. The call-side enclosing-QN computation produced
project.path.Barinstead ofproject.path.Foo.Barfor out-of-line defs (no enclosing classAST node / no class scope on the walk stack). The pipeline resolves a call's source by exact QN (
calls_find_source→find_by_qn), so the mismatch fallsstraight back to the
__file__node. Identical for the global (using namespace) and namespace-block forms.Fix
The out-of-line class resolution lived in the defs extractor but had two divergent, incomplete copies on the call side — the same drift behind #438.
Consolidated rather than adding a fourth copy:
cbm_cpp_out_of_line_parent_class— promoted fromextract_defs.cintohelpers.cbm_cpp_out_of_line_method_qn— new shared helper building the class-scoped QN, used by bothcompute_func_qn(CALLS, unified walk) andcbm_enclosing_func_qn(cached path: USAGES/THROWS/CONFIGURES/type-assigns).Corrects attribution for every edge type inside out-of-line methods, not just CALLS.
Tests
cpp_out_of_line_enclosing_qn— extraction-level QN match for global / namespace-block / nested-namespace forms.pipeline_cpp_out_of_line_call_attribution— full index of a header +using namespace.cc +namespace {}.cc; bothBaz()calls source from theMethodnode, not the file.Full suite green apart from a pre-existing, unrelated ASan RSS-budget flake.
Note on stacking
Based on the #463 branch tip, so until #463 merges this PR shows both commits; the first is #463's dedup and drops automatically once #463 lands. #463
itself is unchanged.