You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C++: a // ... class comment makes the export-macro rule blank the next line's return type (and the macro rules rewrite comments and strings) #5581
_normalize_cpp_export_macros blanks export macros with two raw-byte regexes (the class/struct MACRO Name rule from #3661 and the declaration rule from #5550). Neither skips comments or string literals, as noted on #5558. Most of the time this only rewrites bytes inside a comment, but the class/struct rule allows a newline between the keyword and the macro. So a // comment that ends in "class" or "struct" works as the keyword for the next line.
// Implementation of the Widget classDWORDWidget::run() { return0; }
The rule matches class + newline + DWORD + Widget + : and blanks DWORD. The function loses its return type: the references edge from Widget::run() to DWORD and the DWORD node are gone. Without the comment line both are there.
Win32-style code with ALL-CAPS return types (DWORD, HRESULT, BOOL) and out-of-line method definitions after a comment like this is common.
Steps to reproduce
printf'// Implementation of the Widget class\nDWORD Widget::run() { return 0; }\n'> g.cpp
printf'DWORD Widget::run() { return 0; }\n'> h.cpp
python - <<'PY'from pathlib import Pathfrom graphify.extract import extract_cppfor n in ("g.cpp", "h.cpp"): r = extract_cpp(Path(n).resolve()) print(n, sorted(x["label"] for x in r["nodes"]), sorted(e["relation"] for e in r["edges"]))PY
The declaration rule also changes bytes inside literals and comments ("see MYLIB_API docs" becomes "see docs", and the same happens in // MYLIB_EXPORT ... and inside a raw string), but I could not find a graph difference from that.
As suggested on #5558: get the comment and string/char/raw-string spans from the existing _cpp_conditional_tokens lexer (#5556) and leave a match alone when it starts inside one of them. Code-level matches stay as they are. Since this changes extraction output, the AST cache schema needs a bump.
Activity
github-actions commentedon Nov 28, 2026
Thanks for opening this issue, @leninworld. 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.
fix(cpp): keep export-macro blanking out of comments and literals