@@ -3433,7 +3433,14 @@ class AnyFunctionType : public TypeBase {
34333433 Type getGlobalActor () const ;
34343434 Type getThrownError () const ;
34353435
3436- LifetimeDependenceInfo getLifetimeDependenceInfo () const ;
3436+ const LifetimeDependenceInfo *getLifetimeDependenceInfoOrNull () const ;
3437+
3438+ LifetimeDependenceInfo getLifetimeDependenceInfo () const {
3439+ if (auto *depInfo = getLifetimeDependenceInfoOrNull ()) {
3440+ return *depInfo;
3441+ }
3442+ return LifetimeDependenceInfo ();
3443+ }
34373444
34383445 FunctionTypeIsolation getIsolation () const {
34393446 if (hasExtInfo ())
@@ -3765,14 +3772,19 @@ class FunctionType final
37653772 return getTrailingObjects<Type>()[hasGlobalActor ()];
37663773 }
37673774
3768- LifetimeDependenceInfo getLifetimeDependenceInfo () const {
3769- if (! hasLifetimeDependenceInfo ()) {
3770- return LifetimeDependenceInfo () ;
3775+ inline LifetimeDependenceInfo getLifetimeDependenceInfo () const {
3776+ if (auto *depInfo = getLifetimeDependenceInfoOrNull ()) {
3777+ return *depInfo ;
37713778 }
3779+ return LifetimeDependenceInfo ();
3780+ }
3781+
3782+ // / Returns nullptr for an empty dependence list.
3783+ const LifetimeDependenceInfo *getLifetimeDependenceInfoOrNull () const {
37723784 auto *info = getTrailingObjects<LifetimeDependenceInfo>();
37733785 assert (!info->empty () && " If the LifetimeDependenceInfo was empty, we "
37743786 " shouldn't have stored it." );
3775- return * info;
3787+ return info;
37763788 }
37773789
37783790 void Profile (llvm::FoldingSetNodeID &ID) {
@@ -3914,14 +3926,19 @@ class GenericFunctionType final
39143926 return getTrailingObjects<Type>()[hasGlobalActor ()];
39153927 }
39163928
3917- LifetimeDependenceInfo getLifetimeDependenceInfo () const {
3918- if (! hasLifetimeDependenceInfo ()) {
3919- return LifetimeDependenceInfo () ;
3929+ inline LifetimeDependenceInfo getLifetimeDependenceInfo () const {
3930+ if (auto *depInfo = getLifetimeDependenceInfoOrNull ()) {
3931+ return *depInfo ;
39203932 }
3933+ return LifetimeDependenceInfo ();
3934+ }
3935+
3936+ // / Returns nullptr for an empty dependence list.
3937+ const LifetimeDependenceInfo *getLifetimeDependenceInfoOrNull () const {
39213938 auto *info = getTrailingObjects<LifetimeDependenceInfo>();
39223939 assert (!info->empty () && " If the LifetimeDependenceInfo was empty, we "
39233940 " shouldn't have stored it." );
3924- return * info;
3941+ return info;
39253942 }
39263943
39273944 // / Retrieve the generic signature of this function type.
0 commit comments