Skip to content

[ADT] Fix an empty BitVector call getData assert `idx < size()' failed #65505

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 1 commit into from
Sep 8, 2023

Conversation

wingrez
Copy link
Contributor

@wingrez wingrez commented Sep 6, 2023

Fixes #65500

@zero9178
Copy link
Member

zero9178 commented Sep 6, 2023

Looks good!

Could you add a test exercising this code in https://github.com/llvm/llvm-project/blob/622354a522073b0a048a88c957b161fb376a40eb/llvm/unittests/ADT/BitVectorTest.cpp as well?
While you cannot do a lot with the result, checking that no assert is trigerred probably makes sense.
So I think just calling .data() and putting a comment that says something like "Make sure calling .data() is legal even on an empty BitVector" to make sure that we do not regress would be great.

Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

+1 to @zero9178's request

So I think just calling .data() and putting a comment that says something like "Make sure calling .data() is legal even on an empty BitVector" to make sure that we do not regress would be great.

We can also assert that that the arrayref is .empty().

Make sure calling getData() is legal even on an empty BitVector.
Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty BitVector call getData() got "Assertion `idx < size()' failed."
3 participants