fix: extract correct function name for C++ scoped definitions#403
Open
yetf1025-dev wants to merge 1 commit intotirth8205:mainfrom
Open
fix: extract correct function name for C++ scoped definitions#403yetf1025-dev wants to merge 1 commit intotirth8205:mainfrom
yetf1025-dev wants to merge 1 commit intotirth8205:mainfrom
Conversation
When a C++ function definition uses a qualified name (e.g. `ClassName::method_name`) and has a non-primitive return type (`std::string`, custom types like `bufferlist`, etc.), the parser incorrectly extracts the return type as the function name. Root cause: `_get_name` recurses into `function_declarator` for C++, but `qualified_identifier` nodes (used for scoped names) are not handled by the generic identifier loop. The recursion returns None and the outer loop matches the return type's `type_identifier` first. Fix: detect `qualified_identifier` inside `function_declarator` and take the rightmost `identifier`/`field_identifier` (the actual method name after the last `::`). Also add `field_identifier` to the generic name loop for C++ class member function declarations. Closes tirth8205#395 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
dpesch
added a commit
to 11com7/code-review-graph
that referenced
this pull request
May 3, 2026
Adds field_identifier to the node types checked when extracting function names, so C++ class member functions defined with scoped declarators (e.g. virtual std::string get_name() = 0) are now correctly indexed.
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
ClassName::method_name) where the return type is a non-primitive type. Previously, the return type was incorrectly extracted as the function name.field_identifierto the generic name loop for C++ class member function declarations.Problem
std::string OSDMap::get_pool_name(...)OSDMap❌get_pool_name✅bufferlist OSDService::get_inc_map(...)bufferlist❌get_inc_map✅string RGWDedupProcessor::get_obj_fingerprint(...)string❌get_obj_fingerprint✅int OSD::handle_osd_map(...)handle_osd_map✅handle_osd_map✅Root Cause
_get_namerecurses intofunction_declaratorfor C++, butqualified_identifiernodes (used for scoped names likeFoo::bar) are not handled by the generic identifier loop. The recursion returnsNoneand the outer loop matches the return type'stype_identifierfirst.Fix
Detect
qualified_identifierinsidefunction_declaratorand take the rightmostidentifier/field_identifier(the actual method name after the last::).Test plan
TestCppScopedFunctionNamecovering scoped functions withtype_identifier,qualified_identifier,primitive_typereturn types, and unscoped functionstest_multilang.py,test_parser.py,test_visualization.cpp)Closes #395
🤖 Generated with Claude Code