This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix a hover crash on unsigned 64bit value
ClosedPublic

Authored by zyounan on Mar 25 2023, 8:41 AM.

Details

Summary

This patch adapts to D140059, which makes an assumption that the
caller of APSInt::getExtValue promises no narrowing conversion
happens, i.e., from unsigned int64 to signed int64.

It also fixes clangd/clangd#1557.

Diff Detail

Event Timeline

zyounan created this revision.Mar 25 2023, 8:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2023, 8:41 AM
zyounan requested review of this revision.Mar 25 2023, 8:41 AM
zyounan edited the summary of this revision. (Show Details)Mar 25 2023, 8:45 AM
zyounan updated this revision to Diff 508316.Mar 25 2023, 9:14 AM

Fix comment

nridge added inline comments.Mar 26 2023, 1:07 AM
clang-tools-extra/clangd/Hover.cpp
403

Just to make sure I'm not missing anything: this comment change is just fixing a pre-existing mistake in the comment (-2^32 was already printed as 0xffffffff00000000), right? i.e. this patch doesn't change how any number is printed

clang-tools-extra/clangd/unittests/HoverTests.cpp
3051

you can just write va^lue and access it as T.point()

zyounan marked 2 inline comments as done.Mar 26 2023, 5:04 AM

Thank you!

clang-tools-extra/clangd/Hover.cpp
403

No, the patch doesn't change the behavior of the function. 0xfffffffeffffffff actually stands for -(2**32 + 1). :D

zyounan updated this revision to Diff 508401.Mar 26 2023, 5:04 AM
zyounan marked an inline comment as done.

Address comments

nridge accepted this revision.Mar 26 2023, 2:15 PM

Thanks!

This revision is now accepted and ready to land.Mar 26 2023, 2:15 PM
This revision was automatically updated to reflect the committed changes.