Detect export-macro class/struct .h headers as C++, not C (#1159)#1175
Open
nftmago wants to merge 1 commit into
Open
Detect export-macro class/struct .h headers as C++, not C (#1159)#1175nftmago wants to merge 1 commit into
nftmago wants to merge 1 commit into
Conversation
…ry#1159) A `.h` whose only C++ tell is an all-caps export macro between the keyword and the type name — the ubiquitous UE / library form `class ENGINE_API Foo : Base` — was misclassified as C by looksLikeCpp, so the file fell back to the C grammar and its whole class definition (node, members, base clause) vanished from the graph. The existing colbymchenry#1061 macro-blanking never got a chance to run because detection had already routed the header to C, one step upstream. - looksLikeCpp: the class/struct signal now tolerates an optional all-caps macro between the keyword and the name. `struct` is matched only in its base-clause form (`struct X : Base`) — that `:` is C++-exclusive, whereas plain `struct X { … }` is valid C and stays C. - Tests: detection for macro class (with/without base), macro struct, plus regression guards (plain class:base stays cpp, plain C struct{} stays c); and an end-to-end case proving a macro-only header now recovers the class node and its `extends` edge. Verified: full vitest suite green (124 files, 2121 passed).
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.
Fixes #1159.
Problem
A
.hwhose only C++ tell is an all-caps export/visibility macro between the keyword and the type name — the ubiquitous Unreal Engine / library formclass ENGINE_API Foo : public Bar— was classified as C bylooksLikeCpp. Parsed with the C grammar, the whole class definition (node, members, base clause) never materialized in the graph, breaking type-hierarchy, callers, and blast-radius queries through that type.This sits one step upstream of the existing #1061 export-macro blanking: that recovery never runs, because detection has already routed the header to C.
Note the issue's minimal repro also has
public:, whichlooksLikeCppalready catches via another branch — so the truly-failing case is a macro class carrying no other C++ tell in the first 8 KB. Confirmed empirically before/after:Fix
looksLikeCpp'sclass/structsignal now tolerates an optional all-caps macro between the keyword and the name.structis matched only in its base-clause form (struct X : Base) — that:is C++-exclusive, whereas a plainstruct X { … }is valid C and must stayc.Tests
Added to
extraction.test.ts: detection for macro class (with/without base) and macro struct; regression guards (plainclass:basestays cpp, plain Cstruct{}stays c); and an end-to-end case proving a macro-only header now recovers the class node and itsextendsedge (detection + #1061 blanking together).Full suite green (124 files, 2121 passed).