graphify icon indicating copy to clipboard operation
graphify copied to clipboard

[Bug]: C++: a class's constructor and destructor (and _x/x_ member twins) share one node id

Open rohit-jsfreaky opened this issue 2 weeks ago • 2 comments

Pre-flight checks

  • [x] I have checked the Troubleshooting section in the README

What happened?

In C++, two members whose names differ only by a leading _ (_bar() / bar()), or only by case, get one node id. One of them disappears from the graph, and its calls are credited to the other.

The biggest case is constructor/destructor pairs (Foo() / ~Foo()): the destructor has no node, and its calls are credited to the constructor. _x/x_/x member twins hit the same id rule.

This is the same bug fixed for Solidity in #5058 and Java in #5152; Python and C# already keep such twins apart (#3302, #4415).

The answer key is a separate tree-sitter scan that counts declarations per class/type.

Only classes graphify actually extracts:

repo groups no node: v8 -> this PR nodes gained calls fixed v8 ids changed
abseil-cpp 37 (all ctor/dtor) 37 -> 0 41 28 1 (Rep()/rep(), both public)
folly 434 (415 ctor/dtor, 18 _x/x_, 1 case-only) 437 -> 6 500 191 6, all inside groups

Steps to reproduce

// foo.cpp
class Foo {
public:
  Foo() { a(); }
  ~Foo() { b(); }
  void find_() { a(); }
  void find() { b(); }
  void caller() { find(); find_(); }
};

Run graphify update . and list the nodes and calls edges.

Error output or graph output

v8: .Foo() calls both a and b; there is no .~Foo() and no .find() node; caller only reaches .find_().

Expected: every twin has its own node and every call lands on the right one.

Graphify version

0.9.108 (v8 at 52cb2821)

Operating System

Windows (also seen on Linux)

Python Version

3.12

Installation Method

uv tool install (recommended)

rohit-jsfreaky avatar Nov 13 '26 17:11 rohit-jsfreaky

Thanks for opening this issue, @rohit-jsfreaky. A maintainer will take a look soon.

If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

github-actions[bot] avatar Nov 13 '26 17:11 github-actions[bot]

Fixed by #5202 (8511aff1), released in graphify 0.9.109. Thanks @rohit-jsfreaky.

safishamsi avatar Nov 14 '26 22:11 safishamsi