Repository navigation
fix(hover): expand every attribute of a macro nesting a specifier - #1090
DarkSharpness wants to merge 1 commit into
Conversation
A macro whose expansion writes a specifier names no attribute, but the check ran per attribute along its own macro chain: in `#define DEVICE __forceinline__ __device__`, `always_inline` passes `__forceinline__`'s `__inline__` and printed expanded, while `device` did not and printed as `DEVICE` with a note listing only itself. Decide once per macro use.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Related issue
#1089: this fixes the nested case it reports. The forms listed below stay wrong, so the PR does not close the issue on merge.
What changed
A macro use whose expansion writes a specifier names no attribute on hover (
FORCE_INLINEin05_written_attributes), butwritten()decided that per attribute, fromattributes_only()along the attribute's own macro chain. With#define DEVICE __forceinline__ __device__,always_inlinecomes through__forceinline__(__inline__ __attribute__((always_inline))) and printed expanded, whiledevicenever passes__forceinline__'s body and printed asDEVICE, with a note listingdevicealone.written()now makes the decision once per macro use: any attribute of the use coming out of a macro that writes a specifier makes the whole use print expanded. This is the usual CUDA spelling of device qualifiers (CUTLASS_DEVICE,CUTE_HOST_DEVICEand the like are__forceinline__ __device__ ...).Forms still shown wrong, and why they are not in this PR
attributes_only()judges a macro by the#definetext on each attribute's chain, so it cannot see tokens that reach the expansion another way:#define INL __inline__,#define M INL __attribute__((cold))M inline int f, "Mis__attribute__((cold))"#define SPEC(x) x __attribute__((cold)),SPEC(inline)SPEC(inline) inline int f##PASTE(inl, ine)PASTE(inl, ine) inline int f#define WITH_TYPE my_int __attribute__((cold))WITH_TYPE my_int fJudging these needs the macro use's expanded tokens, and neither source available is a small change:
TokenMapholds the expanded stream, but not the text a preamble PCH parsed, where the declarations hovered most (those of included headers) live.CompilationUnit::macro_definitionsreaches every macro, preamble ones included, but using it means a small expander (arguments,##, nested macros) indisplayand passing the lookup throughdisplay::definition()to its hover callers: an API change to agree on first.A scan of the CUDA 13.2 toolkit, CUTLASS/CuTe, PyTorch and libstdc++ headers found one use of these forms (
__DEVICE_FP128_FUNCTIONS_DECL__in the CUDA toolkit, the first form) and none of the others, so this PR leaves them as they are. If the expander approach is wanted, it can follow as its own PR.Tests
nested_macro_with_specifiersintests/hover/attributes/05_written_attributes: it fails on v1.0.0 (__attribute__((always_inline)) NESTED_INLINEwith a note forhot) and passes here.pixi run teston Linux x64 (RelWithDebInfo): 2125 unit tests and 2587 cases pass.pixi run formatleaves the tree unchanged.🤖 Generated with Claude Code