Incorrect definition is shown in tooltip when hovering over a non-preamble macro definition.
In the example below the definition will have 'namespace ns {}' instead of correct '#define FOO 1'.
namespace ns {
#define [[FO^O]] 1
}
Differential D85253
[clangd] Show correct hover tooltip for non-preamble macro definition. ilya-golovenko on Aug 4 2020, 3:35 PM. Authored by
Details
Diff Detail
Event TimelineComment Actions I'm not quite sure my fix is the best way to fix the issue, so any advices are appreciated. Comment Actions Sigh, (I think) this is working for macros defined in preamble region as a side effect of preamble being loaded separately and before anything in the main file. E.g. #define FO^O 1 #define FOO 2 void foo() { int x = FOO; }; hovering over the first definition of FOO (at carrot) will yield #define FOO 2, because that's the latest definition before main file. That being said, I don't really think there's much value in showing the hovercard at definition of a macro, as that's what we show anyways. (showing the surrounding namespace is even worse, but that's a different problem and i thought we've solved it recently, are you sure you are seeing that behaviour with a build from head?). WDYT? Comment Actions I agree the fix is not correct. I will check how it currently works with clangd built from master branch. I'm not quite sure there should be no tooltip for a #define. Such tooltip is not really useful, but at the same time clangd shows tooltips for function declarations/defnitions, namespaces, variables, etc. and not showing it for macro definition will be a little bit inconsistent from my point of view. Comment Actions
We actually had a couple users saying those are redundant too. I agree with them mostly, i suppose these are only useful because we talk about the associated namespace/class/accesspecifer. E.g. you can easily figure out what's the class owning a field, and whether it is private/public without worrying traversing upwards. |