@@ -329,76 +329,73 @@ struct SILDynamicCastInst {
329
329
llvm_unreachable (" covered switch" );
330
330
}
331
331
332
- CanType getSourceType () const {
332
+ CanType getSourceFormalType () const {
333
333
switch (getKind ()) {
334
334
case SILDynamicCastKind::CheckedCastAddrBranchInst:
335
- return cast<CheckedCastAddrBranchInst>(inst)->getSourceType ();
335
+ return cast<CheckedCastAddrBranchInst>(inst)->getSourceFormalType ();
336
336
case SILDynamicCastKind::CheckedCastBranchInst:
337
- return cast<CheckedCastBranchInst>(inst)->getSourceType ();
337
+ return cast<CheckedCastBranchInst>(inst)->getSourceFormalType ();
338
338
case SILDynamicCastKind::CheckedCastValueBranchInst:
339
- return cast<CheckedCastValueBranchInst>(inst)->getSourceType ();
339
+ return cast<CheckedCastValueBranchInst>(inst)->getSourceFormalType ();
340
340
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
341
- return cast<UnconditionalCheckedCastAddrInst>(inst)->getSourceType ();
341
+ return cast<UnconditionalCheckedCastAddrInst>(inst)->getSourceFormalType ();
342
342
case SILDynamicCastKind::UnconditionalCheckedCastInst:
343
- return cast<UnconditionalCheckedCastInst>(inst)->getSourceType ();
343
+ return cast<UnconditionalCheckedCastInst>(inst)->getSourceFormalType ();
344
344
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
345
- llvm_unreachable ( " unsupported " );
345
+ return cast<UnconditionalCheckedCastValueInst>(inst)-> getSourceFormalType ( );
346
346
}
347
347
llvm_unreachable (" covered switch" );
348
348
}
349
349
350
- SILType getLoweredSourceType () const {
350
+ SILType getSourceLoweredType () const {
351
351
switch (getKind ()) {
352
352
case SILDynamicCastKind::CheckedCastAddrBranchInst:
353
+ return cast<CheckedCastAddrBranchInst>(inst)->getSourceLoweredType ();
353
354
case SILDynamicCastKind::CheckedCastBranchInst:
355
+ return cast<CheckedCastBranchInst>(inst)->getSourceLoweredType ();
354
356
case SILDynamicCastKind::CheckedCastValueBranchInst:
355
- llvm_unreachable (" unsupported" );
356
- case SILDynamicCastKind::UnconditionalCheckedCastAddrInst: {
357
- auto *uccai = cast<UnconditionalCheckedCastAddrInst>(inst);
358
- return uccai->getSrc ()->getType ();
359
- }
357
+ return cast<CheckedCastValueBranchInst>(inst)->getSourceLoweredType ();
358
+ case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
359
+ return cast<UnconditionalCheckedCastAddrInst>(inst)->getSourceLoweredType ();
360
360
case SILDynamicCastKind::UnconditionalCheckedCastInst:
361
- return cast<UnconditionalCheckedCastInst>(inst)->getOperand ()-> getType ();
361
+ return cast<UnconditionalCheckedCastInst>(inst)->getSourceLoweredType ();
362
362
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
363
- llvm_unreachable ( " unsupported " );
363
+ return cast<UnconditionalCheckedCastValueInst>(inst)-> getSourceLoweredType ( );
364
364
}
365
365
}
366
366
367
- CanType getTargetType () const {
367
+ CanType getTargetFormalType () const {
368
368
switch (getKind ()) {
369
369
case SILDynamicCastKind::CheckedCastAddrBranchInst:
370
- return cast<CheckedCastAddrBranchInst>(inst)->getTargetType ();
370
+ return cast<CheckedCastAddrBranchInst>(inst)->getTargetFormalType ();
371
371
case SILDynamicCastKind::CheckedCastBranchInst:
372
- return cast<CheckedCastBranchInst>(inst)->getTargetType ();
372
+ return cast<CheckedCastBranchInst>(inst)->getTargetFormalType ();
373
373
case SILDynamicCastKind::CheckedCastValueBranchInst:
374
- return cast<CheckedCastValueBranchInst>(inst)->getTargetType ();
374
+ return cast<CheckedCastValueBranchInst>(inst)->getTargetFormalType ();
375
375
case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
376
- return cast<UnconditionalCheckedCastAddrInst>(inst)->getTargetType ();
376
+ return cast<UnconditionalCheckedCastAddrInst>(inst)->getTargetFormalType ();
377
377
case SILDynamicCastKind::UnconditionalCheckedCastInst:
378
- return cast<UnconditionalCheckedCastInst>(inst)->getTargetType ();
378
+ return cast<UnconditionalCheckedCastInst>(inst)->getTargetFormalType ();
379
379
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
380
- llvm_unreachable ( " unimplemented " );
380
+ return cast<UnconditionalCheckedCastValueInst>(inst)-> getTargetFormalType ( );
381
381
}
382
382
llvm_unreachable (" covered switch" );
383
383
}
384
384
385
- SILType getLoweredTargetType () const {
385
+ SILType getTargetLoweredType () const {
386
386
switch (getKind ()) {
387
387
case SILDynamicCastKind::CheckedCastAddrBranchInst:
388
- llvm_unreachable ( " unsupported " );
388
+ return cast<CheckedCastAddrBranchInst>(inst)-> getDest ()-> getType ( );
389
389
case SILDynamicCastKind::CheckedCastBranchInst:
390
- return cast<CheckedCastBranchInst>(inst)->getCastType ();
390
+ return cast<CheckedCastBranchInst>(inst)->getTargetLoweredType ();
391
391
case SILDynamicCastKind::CheckedCastValueBranchInst:
392
- return cast<CheckedCastValueBranchInst>(inst)->getCastType ();
393
- case SILDynamicCastKind::UnconditionalCheckedCastAddrInst: {
394
- auto *uccai = dyn_cast<UnconditionalCheckedCastAddrInst>(inst);
395
- return uccai->getDest ()->getType ();
396
- }
397
- case SILDynamicCastKind::UnconditionalCheckedCastInst: {
398
- return cast<UnconditionalCheckedCastInst>(inst)->getType ();
399
- }
392
+ return cast<CheckedCastValueBranchInst>(inst)->getTargetLoweredType ();
393
+ case SILDynamicCastKind::UnconditionalCheckedCastAddrInst:
394
+ return cast<UnconditionalCheckedCastAddrInst>(inst)->getDest ()->getType ();
395
+ case SILDynamicCastKind::UnconditionalCheckedCastInst:
396
+ return cast<UnconditionalCheckedCastInst>(inst)->getTargetLoweredType ();
400
397
case SILDynamicCastKind::UnconditionalCheckedCastValueInst:
401
- llvm_unreachable ( " unsupported " );
398
+ return cast<UnconditionalCheckedCastValueInst>(inst)-> getTargetLoweredType ( );
402
399
}
403
400
llvm_unreachable (" covered switch" );
404
401
}
@@ -424,14 +421,15 @@ struct SILDynamicCastInst {
424
421
425
422
DynamicCastFeasibility classifyFeasibility (bool allowWholeModule) const {
426
423
return swift::classifyDynamicCast (
427
- getModule ().getSwiftModule (), getSourceType (), getTargetType (),
424
+ getModule ().getSwiftModule (),
425
+ getSourceFormalType (), getTargetFormalType (),
428
426
isSourceTypeExact (), allowWholeModule && getModule ().isWholeModule ());
429
427
}
430
428
431
429
bool isBridgingCast () const {
432
430
// Bridging casts cannot be further simplified.
433
- auto TargetIsBridgeable = getTargetType ()->isBridgeableObjectType ();
434
- auto SourceIsBridgeable = getSourceType ()->isBridgeableObjectType ();
431
+ auto TargetIsBridgeable = getTargetFormalType ()->isBridgeableObjectType ();
432
+ auto SourceIsBridgeable = getSourceFormalType ()->isBridgeableObjectType ();
435
433
return TargetIsBridgeable != SourceIsBridgeable;
436
434
}
437
435
@@ -441,7 +439,7 @@ struct SILDynamicCastInst {
441
439
CanType getBridgedSourceType () const {
442
440
SILModule &mod = getModule ();
443
441
Type t = mod.getASTContext ().getBridgedToObjC (mod.getSwiftModule (),
444
- getSourceType ());
442
+ getSourceFormalType ());
445
443
if (!t)
446
444
return CanType ();
447
445
return t->getCanonicalType ();
@@ -453,7 +451,7 @@ struct SILDynamicCastInst {
453
451
CanType getBridgedTargetType () const {
454
452
SILModule &mod = getModule ();
455
453
Type t = mod.getASTContext ().getBridgedToObjC (mod.getSwiftModule (),
456
- getTargetType ());
454
+ getTargetFormalType ());
457
455
if (!t)
458
456
return CanType ();
459
457
return t->getCanonicalType ();
@@ -491,7 +489,7 @@ struct SILDynamicCastInst {
491
489
492
490
bool canUseScalarCheckedCastInstructions () const {
493
491
return swift::canUseScalarCheckedCastInstructions (
494
- getModule (), getSourceType (), getTargetType ());
492
+ getModule (), getSourceFormalType (), getTargetFormalType ());
495
493
}
496
494
};
497
495
0 commit comments