Skip to content

Fix SILGen comments for isPlusOne and isPlusOneOrTrivial. #65634

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
May 4, 2023
Merged
Changes from all commits
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
26 changes: 18 additions & 8 deletions lib/SILGen/ManagedValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,30 @@ class ManagedValue {

/// Returns true if this managed value can be consumed.
///
/// This is true if either this value has a cleanup or if it is an
/// SSA value without ownership.
/// This is true if either this value has a cleanup or if it is a trivial
/// object value. For address values, this returns true only if the value has
/// a cleanup regardless of whether the type is trivial.
///
/// When an SSA value does not have ownership, it can be used by a consuming
/// operation without destroying it. Consuming a value by address, however,
/// deinitializes the memory regardless of whether the value has ownership.
/// When an object value is trivial, it can be passed to a consuming operation
/// without destroying it. Consuming a value by address, however, always
/// deinitializes the memory regardless of whether or not it is trivial.
///
/// Use this before emitting an operation that "takes" this value or passing
/// this value to a call that consumes the argument.
bool isPlusOne(SILGenFunction &SGF) const;

/// Returns true if this managed value can be forwarded without necessarilly
/// destroying the original.
///
/// This is true if either isPlusOne is true or the value is trivial. A
/// trivial value in memory can be forwarded as a +1 value without
/// deinitializing the memory.
/// This is true if either isPlusOne is true or the value is trivial. Unlike
/// isPlusOne(), this returns true for trivial address values regardless of
/// whether the value has a cleanup. A +1 value can be created from a trivial
/// value without consuming the original.
///
/// Use this when storing this value into a new location simply by forwarding
/// the cleanup without destroying the original value. If it's necessary to
/// "take" or otherwise immediately consume the original value, then use
/// isPlusOne() instead.
bool isPlusOneOrTrivial(SILGenFunction &SGF) const;

/// Returns true if this is an ManagedValue that can be used safely as a +0
Expand Down