When pretty printing the value of an expression, we cannot infer from
the type of the expression the type of the constant that the expression
evaluates to, as the expression might contain a type cast.
Details
- Reviewers
sammccall
Diff Detail
Event Timeline
Oh wow, my mental model of these was all wrong.
Thank you! Do you want me to land this for you?
Sorry, can you provide an email address for attribution?
(Normally I can pick this up with arc patch, but not this time apparently)
Maybe because I didn't upload the patch with the arc tooling.
You can attribute the patch to: gkll@mailbox.org
Landed as ce5ebf0b9113df8ccaec1bcfd6804fb16cdef69d but I had to revert due to test failures on windows:
- https://buildkite.com/llvm-project/premerge-checks/builds/94783
- http://45.33.8.238/win/59124/step_9.txt
Unfortunately neither of these give a stack trace, so I'm not yet sure what's wrong, beyond "some Optional is null when it shouldn't be".
A wild guess: long is shorter than a pointer on 64-bit windows, so that code doesn't even parse.
Indeed (int)&global_var doesn't parse for me on a 64-bit linux machine (32-bit int, 64-bit pointer).
The mystery in that case, though, is why the test output doesn't show parse error before crashing (TestTU is supposed to dump this unless you set ErrorOK).
It's late, but I'll try fixing and re-landing tomorrow.
Use uintptr_t instead of unsigned long for the casts, to ensure the pointer always fits into the integer type.
For example on Windows x64 that was previously not the case, because there unsigned long is only 32-bits wide.
Thus the pointer got truncated during the cast, which resulted in getHover() returning None instead of &global_var.
Neat, looks like the pre-merge windows buildbot at least is happy!
I'll land this tomorrow.
clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
---|---|---|
3221 | As an alternative (just to avoid adding this option), I think adding "-target=x86_64-pc-linux-gnu" would force intptr_t to be long. | |
clang-tools-extra/clangd/unittests/TestTU.h | ||
63 | If you do add this option, please invert the sense, i.e. bool PredefineMacros = false; (The double negative of Omit = false is a bit confusing to read) And please expand the comment slightly: "... such as __INTPTR_TYPE__" |
Thank you, and sorry for the chaos, this is my first submission to llvm :D
clang-tools-extra/clangd/unittests/HoverTests.cpp | ||
---|---|---|
3221 | I prefer using the predefine. |
As an alternative (just to avoid adding this option), I think adding "-target=x86_64-pc-linux-gnu" would force intptr_t to be long.
Up to you.