Examle:
struct test { char a; char b : 3; char c : 5; int d; int e : 27; };
Paths
| Differential D151128
[clangd] Show size, offset and padding for bit fields on hover ClosedPublic Authored by SR_team on May 22 2023, 11:24 AM.
Details Summary
Diff Detail Event TimelineHerald added subscribers: cfe-commits, MaskRay, ilya-biryukov. · View Herald TranscriptMay 22 2023, 11:24 AM Comment Actions I do see the appeal of making this work for bitfields, but I think silently rounding offset/size/padding to whole bytes is pretty misleading. I don't see a great sweet-spot design, maybe you/others have ideas (or can explain why the rounding behavior in this patch is reasonable. Comment Actions
We can store this fields in bits, and show in bytes on hover, when it's possible, and in bits, when showing in bytes impossible. Would such an implementation be good? This comment was removed by SR_team. Comment Actions Sorry for the delay, I've been out on vacation. Behavior looks great and isn't too complicated :-)
This revision is now accepted and ready to land.Jun 5 2023, 6:08 AM Comment Actions
Land it for me, please. Name: SR_team, email: me@sr.team This revision was landed with ongoing or failed builds.Jun 5 2023, 9:04 AM Closed by commit rG4cb5e436ae71: [clangd] Show size, offset and padding for bit fields on hover (authored by SR_team, committed by sammccall). · Explain Why This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 524946 clang-tools-extra/clangd/Hover.h
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
|
can you make this a separate (static) function rather than a lambda?
and the same for formatOffset()
(This is a long function as it is)