File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -306,6 +306,7 @@ struct SILDeclRef {
306306 AutoClosureExpr *getAutoClosureExpr () const ;
307307 FuncDecl *getFuncDecl () const ;
308308 AbstractFunctionDecl *getAbstractFunctionDecl () const ;
309+ AccessorDecl *getAccessorDecl () const ;
309310 FileUnit *getFileUnit () const { return cast<FileUnit *>(loc); }
310311
311312 // / Get ModuleDecl that contains the SILDeclRef
@@ -387,6 +388,10 @@ struct SILDeclRef {
387388
388389 // / True if the SILDeclRef references an init accessor declaration.
389390 bool isInitAccessor () const ;
391+ // / True if the SILDeclRef references an borrow accessor declaration.
392+ bool isBorrowAccessor () const ;
393+ // / True if the SILDeclRef references an mutate accessor declaration.
394+ bool isMutateAccessor () const ;
390395
391396 // / True if the function should be treated as transparent.
392397 bool isTransparent () const ;
Original file line number Diff line number Diff line change @@ -804,16 +804,31 @@ AbstractFunctionDecl *SILDeclRef::getAbstractFunctionDecl() const {
804804 return dyn_cast_or_null<AbstractFunctionDecl>(getDecl ());
805805}
806806
807- bool SILDeclRef::isInitAccessor () const {
807+ AccessorDecl * SILDeclRef::getAccessorDecl () const {
808808 if (kind != Kind::Func || !hasDecl ())
809- return false ;
809+ return nullptr ;
810+ return dyn_cast_or_null<AccessorDecl>(getDecl ());
811+ }
810812
811- if (auto accessor = dyn_cast<AccessorDecl>(getDecl ()))
813+ bool SILDeclRef::isInitAccessor () const {
814+ if (auto *accessor = getAccessorDecl ())
812815 return accessor->getAccessorKind () == AccessorKind::Init;
813816
814817 return false ;
815818}
816819
820+ bool SILDeclRef::isMutateAccessor () const {
821+ if (auto *accessor = getAccessorDecl ())
822+ return accessor->getAccessorKind () == AccessorKind::Mutate;
823+ return false ;
824+ }
825+
826+ bool SILDeclRef::isBorrowAccessor () const {
827+ if (auto *accessor = getAccessorDecl ())
828+ return accessor->getAccessorKind () == AccessorKind::Borrow;
829+ return false ;
830+ }
831+
817832// / True if the function should be treated as transparent.
818833bool SILDeclRef::isTransparent () const {
819834 if (isEnumElement ())
You can’t perform that action at this time.
0 commit comments