-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[libc++] Rename __construct_one_at_end to __emplace_back_assume_capacity #132276
Merged
ldionne
merged 2 commits into
llvm:main
from
ldionne:review/vector-replace-construct_one_at_end
Mar 25, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I analyzed the ASAN failure. It seems that the failure is caused by omitting an
__annotate_shrink
call when the element construction fails. Previously,~_ConstructTransaction()
ensured that when construction exception is thrown, this destructor would call__annotate_shrink(__new_end_ - __v_.__begin_);
. This omission might be the cause of the ASAN failure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a look! What seems to be actually happening is that if we fail to
__annotate_increase(1)
before we useconstruct_at
, Asan thinks that we're writing outside of the container and complains. So we need to use__annotate_increase
upon entry and then to use__anotate_shrink
if the operation failed.I'll return to the original implementation for now, but I still think the name change is an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new name
__emplace_back_assume_capacity
is much clearer and more descriptive. While__construct_at_end
is widely used in<vector>
,__construct_one_at_end
appears in 5 places. So I think we can replace the confusing name__construct_one_at_end
by__emplace_back_assume_capacity to improve clarity
.