Skip to content

C++ forward declarations (class Foo;) index as phantom class nodes, masking the real definition #1093

Description

@luoyxy

What happens

In a large C++/Unreal-Engine codebase, codegraph_explore for a heavily used
class (e.g. APXCharacter) returns mostly forward-declaration sites and even
picks one as the blast-radius representative, while the real definition (with
members and callers) is crowded out.

Root cause

A class Foo; forward declaration parses as a bodiless class_specifier.
extractStruct (#831) and extractEnum skip their bodiless forms, but
extractClass does not — so every forward decl (repeated across dozens of
headers) mints a phantom bodiless class node that competes with the single
real definition.

Expected

Bodiless class specifiers in C/C++ should be skipped, exactly like bodiless
structs/enums, so only the real definition is indexed. Languages where a
bodiless class is a complete definition (Kotlin class Empty, Scala) must be
unaffected.

Repro

Index any C++ project where a class is forward-declared in many headers, then
codegraph_explore that class name — the results are dominated by
class Foo; sites instead of the definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions