13
13
#ifndef SWIFT_SIL_SILARGUMENT_H
14
14
#define SWIFT_SIL_SILARGUMENT_H
15
15
16
+ #include " swift/AST/LifetimeAnnotation.h"
16
17
#include " swift/Basic/Compiler.h"
18
+ #include " swift/SIL/Lifetime.h"
17
19
#include " swift/SIL/SILArgumentConvention.h"
18
- #include " swift/SIL/SILValue.h"
19
20
#include " swift/SIL/SILFunctionConventions.h"
21
+ #include " swift/SIL/SILValue.h"
20
22
21
23
namespace swift {
22
24
@@ -327,14 +329,17 @@ class SILFunctionArgument : public SILArgument {
327
329
friend class SILBasicBlock ;
328
330
329
331
bool noImplicitCopy = false ;
332
+ LifetimeAnnotation lifetimeAnnotation = LifetimeAnnotation::None;
330
333
331
- SILFunctionArgument (SILBasicBlock *parentBlock, SILType type,
332
- ValueOwnershipKind ownershipKind,
333
- const ValueDecl *decl = nullptr ,
334
- bool isNoImplicitCopy = false )
334
+ SILFunctionArgument (
335
+ SILBasicBlock *parentBlock, SILType type,
336
+ ValueOwnershipKind ownershipKind, const ValueDecl *decl = nullptr ,
337
+ bool isNoImplicitCopy = false ,
338
+ LifetimeAnnotation lifetimeAnnotation = LifetimeAnnotation::None)
335
339
: SILArgument(ValueKind::SILFunctionArgument, parentBlock, type,
336
340
ownershipKind, decl),
337
- noImplicitCopy (isNoImplicitCopy) {}
341
+ noImplicitCopy (isNoImplicitCopy),
342
+ lifetimeAnnotation(lifetimeAnnotation) {}
338
343
// A special constructor, only intended for use in
339
344
// SILBasicBlock::replaceFunctionArg.
340
345
explicit SILFunctionArgument (SILType type, ValueOwnershipKind ownershipKind,
@@ -347,6 +352,20 @@ class SILFunctionArgument : public SILArgument {
347
352
348
353
void setNoImplicitCopy (bool newValue) { noImplicitCopy = newValue; }
349
354
355
+ LifetimeAnnotation getLifetimeAnnotation () const {
356
+ return lifetimeAnnotation;
357
+ }
358
+
359
+ void setLifetimeAnnotation (LifetimeAnnotation newValue) {
360
+ lifetimeAnnotation = newValue;
361
+ }
362
+
363
+ Lifetime getLifetime () const {
364
+ return getType ()
365
+ .getLifetime (*getFunction ())
366
+ .getLifetimeForAnnotatedValue (getLifetimeAnnotation ());
367
+ }
368
+
350
369
bool isIndirectResult () const ;
351
370
352
371
SILArgumentConvention getArgumentConvention () const ;
0 commit comments