File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
lib/SILOptimizer/Mandatory Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,30 @@ ConstructorDecl *DIMemoryObjectInfo::getActorInitSelf() const {
538
538
return nullptr ;
539
539
}
540
540
541
+ VarDecl *DIMemoryObjectInfo::getAsTypeWrapperLocalStorageVar () const {
542
+ if (!MemoryInst->isVar ())
543
+ return nullptr ;
544
+
545
+ if (!isa<TupleType>(getASTType ()))
546
+ return nullptr ;
547
+
548
+ auto *DC = MemoryInst->getFunction ()->getDeclContext ();
549
+ if (!DC)
550
+ return nullptr ;
551
+
552
+ auto *ctor = dyn_cast_or_null<ConstructorDecl>(DC->getAsDecl ());
553
+ if (!ctor || ctor->isImplicit ())
554
+ return nullptr ;
555
+
556
+ if (auto *var = getLoc ().getAsASTNode <VarDecl>()) {
557
+ auto &ctx = var->getASTContext ();
558
+ if (var->isImplicit () && var->getName () == ctx.Id_localStorageVar )
559
+ return var;
560
+ }
561
+
562
+ return nullptr ;
563
+ }
564
+
541
565
// ===----------------------------------------------------------------------===//
542
566
// DIMemoryUse Implementation
543
567
// ===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -164,6 +164,11 @@ class DIMemoryObjectInfo {
164
164
// / actor's initializer. Otherwise, returns nullptr.
165
165
ConstructorDecl *getActorInitSelf () const ;
166
166
167
+ // / If \c TheMemory is a temporary variable that is responsible for
168
+ // / member-by-member initialization of `$Storage` in a user-defined
169
+ // / initializer of a type wrapped type, return its declaration.
170
+ VarDecl *getAsTypeWrapperLocalStorageVar () const ;
171
+
167
172
// / True if this memory object is the 'self' of a derived class initializer.
168
173
bool isDerivedClassSelf () const { return MemoryInst->isDerivedClassSelf (); }
169
174
You can’t perform that action at this time.
0 commit comments