Bug
When building the graph for a C++ codebase, functions defined with a qualified
name (ClassName::method) and a non-primitive return type (std::string,
bufferlist, custom types, etc.) have their function name incorrectly extracted
as the return type instead of the actual function name.
Example
std::string OSDMap::get_pool_name(int64_t pool_id) const { ... }
bufferlist OSDService::get_inc_map(epoch_t e) { ... }
string RGWDedupProcessor::get_obj_fingerprint(const rgw_obj& obj) { ... }
Extracted as:
┌────────────────────────────────────────────────────┬─────────────────────┬─────────────┐
│ Function │ Expected name │ Actual name │
├────────────────────────────────────────────────────┼─────────────────────┼─────────────┤
│ std::string OSDMap::get_pool_name(...) │ get_pool_name │ OSDMap │
├────────────────────────────────────────────────────┼─────────────────────┼─────────────┤
│ bufferlist OSDService::get_inc_map(...) │ get_inc_map │ bufferlist │
├────────────────────────────────────────────────────┼─────────────────────┼─────────────┤
│ string RGWDedupProcessor::get_obj_fingerprint(...) │ get_obj_fingerprint │ string │
└────────────────────────────────────────────────────┴─────────────────────┴─────────────┘
Functions with primitive return types (int, void, bool) are not affected.
Root Cause
In _get_name, the C++ branch recurses into function_declarator to find the
function name. For scoped definitions like Foo::bar, the name node inside
function_declarator is a qualified_identifier, which is not handled by the
generic identifier loop, so the recursion returns None. Control then falls
through to the outer generic loop on function_definition, which matches the
return type's type_identifier first.
Fix
In the C++ function_declarator handling, detect qualified_identifier
children and take the rightmost identifier/field_identifier (the actual
method name after the last ::).
Affected codebases
Any C++ project that defines class methods outside the class body (standard
.cpp file practice). Particularly impactful for large projects like Ceph
where most method definitions use custom return types with scoped names.
Bug
When building the graph for a C++ codebase, functions defined with a qualified
name (
ClassName::method) and a non-primitive return type (std::string,bufferlist, custom types, etc.) have their function name incorrectly extractedas the return type instead of the actual function name.
Example