Skip to content

[LLDB] Add more helper functions to ValueObject class. #87197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lldb/source/Core/ValueObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3141,15 +3141,15 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
val_byte_size = temp.value();

if (is_pointer) {
if (!type.IsInteger()) {
m_error.SetErrorString("target type must be an integer");
return GetSP();
}
if (!type.IsBoolean() && type_byte_size < val_byte_size) {
Copy link
Collaborator

@jimingham jimingham Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what the original code intended with that type.IsBoolean? Makes no sense we would only return the "too small" error when the incoming type is Boolean.

But with this code, if I pass 32 bit float (on a 64 bit pointers system), the error I'll get is that it's too small. OTOH, if I pass a 64 bit float, I'll get "must be integer". That's confusing. If you aren't planning to take anything but integers, it seems like you should check that first, then check the size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better, but now the type.IsBoolean is entirely pointless, since you would never get to this code in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! Good catch; I've fixed that now.

m_error.SetErrorString(
"target type cannot be smaller than the pointer type");
return GetSP();
}
if (!type.IsInteger()) {
m_error.SetErrorString("target type must be an integer");
return GetSP();
}
}

if (type.IsBoolean()) {
Expand Down
Loading