@@ -173,6 +173,10 @@ class SILArgument : public ValueBase {
173
173
// / is the enum itself (the operand of the switch_enum).
174
174
SILValue getSingleTerminatorOperand () const ;
175
175
176
+ // / If this SILArgument's parent block has a single predecessor whose
177
+ // / terminator has a single operand, return that terminator.
178
+ TermInst *getSingleTerminator () const ;
179
+
176
180
// / Return the SILArgumentKind of this argument.
177
181
SILArgumentKind getKind () const {
178
182
return SILArgumentKind (ValueBase::getKind ());
@@ -264,6 +268,10 @@ class SILPhiArgument : public SILArgument {
264
268
// / is the enum itself (the operand of the switch_enum).
265
269
SILValue getSingleTerminatorOperand () const ;
266
270
271
+ // / If this SILArgument's parent block has a single predecessor whose
272
+ // / terminator has a single operand, return that terminator.
273
+ TermInst *getSingleTerminator () const ;
274
+
267
275
static bool classof (const SILInstruction *) = delete;
268
276
static bool classof (const SILUndef *) = delete;
269
277
static bool classof (const SILNode *node) {
@@ -403,6 +411,16 @@ inline bool SILArgument::getSingleTerminatorOperands(
403
411
llvm_unreachable (" Covered switch is not covered?!" );
404
412
}
405
413
414
+ inline TermInst *SILArgument::getSingleTerminator () const {
415
+ switch (getKind ()) {
416
+ case SILArgumentKind::SILPhiArgument:
417
+ return cast<SILPhiArgument>(this )->getSingleTerminator ();
418
+ case SILArgumentKind::SILFunctionArgument:
419
+ return nullptr ;
420
+ }
421
+ llvm_unreachable (" Covered switch is not covered?!" );
422
+ }
423
+
406
424
} // end swift namespace
407
425
408
426
#endif
0 commit comments