Skip to content

Commit 42e2652

Browse files
committed
Fix SILGen comments for isPlusOne and isPlusOneOrTrivial.
1 parent 38e8ec8 commit 42e2652

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

lib/SILGen/ManagedValue.h

+18-8
Original file line numberDiff line numberDiff line change
@@ -219,20 +219,30 @@ class ManagedValue {
219219

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

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

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

0 commit comments

Comments
 (0)