@@ -261,6 +261,7 @@ struct SDKNodeInitInfo {
261261 StringRef Location;
262262 StringRef ModuleName;
263263 bool IsThrowing = false ;
264+ bool IsMutating = false ;
264265 Optional<uint8_t > SelfIndex;
265266 std::vector<SDKDeclAttrKind> DeclAttrs;
266267 std::vector<TypeAttrKind> TypeAttrs;
@@ -683,15 +684,18 @@ class SDKNodeVar : public SDKNodeDecl {
683684
684685class SDKNodeAbstractFunc : public SDKNodeDecl {
685686 const bool IsThrowing;
687+ const bool IsMutating;
686688 const Optional<uint8_t > SelfIndex;
687689
688690protected:
689691 SDKNodeAbstractFunc (SDKNodeInitInfo Info, SDKNodeKind Kind) :
690692 SDKNodeDecl (Info, Kind),
691693 IsThrowing (Info.IsThrowing),
694+ IsMutating (Info.IsMutating),
692695 SelfIndex (Info.SelfIndex){}
693696public:
694697 bool isThrowing () const { return IsThrowing; }
698+ bool isMutating () const { return IsMutating; }
695699 uint8_t getSelfIndex () const { return SelfIndex.getValue (); }
696700 Optional<uint8_t > getSelfIndexOptional () const { return SelfIndex; }
697701 bool hasSelfIndex () const { return SelfIndex.hasValue (); }
@@ -800,6 +804,8 @@ NodeUniquePtr SDKNode::constructSDKNode(llvm::yaml::MappingNode *Node) {
800804 Info.ModuleName = GetScalarString (Pair.getValue ());
801805 } else if (Key == Key_throwing) {
802806 Info.IsThrowing = true ;
807+ } else if (Key == Key_mutating) {
808+ Info.IsMutating = true ;
803809 } else if (Key == Key_typeAttributes) {
804810 auto *Seq = cast<llvm::yaml::SequenceNode>(Pair.getValue ());
805811 for (auto It = Seq->begin (); It != Seq->end (); ++ It) {
@@ -946,6 +952,13 @@ static bool isFuncThrowing(ValueDecl *VD) {
946952 return false ;
947953}
948954
955+ static bool isFuncMutating (ValueDecl *VD) {
956+ if (auto AF = dyn_cast<FuncDecl>(VD)) {
957+ return AF->isMutating ();
958+ }
959+ return false ;
960+ }
961+
949962static Optional<uint8_t > getSelfIndex (ValueDecl *VD) {
950963 if (auto AF = dyn_cast<AbstractFunctionDecl>(VD)) {
951964 if (AF->isImportAsInstanceMember ())
@@ -965,7 +978,8 @@ SDKNodeInitInfo::SDKNodeInitInfo(ValueDecl *VD) :
965978 PrintedName(getPrintedName(VD)), DKind(VD->getKind ()),
966979 USR(calculateUsr(VD)), Location(calculateLocation(VD)),
967980 ModuleName(VD->getModuleContext ()->getName().str()),
968- IsThrowing(isFuncThrowing(VD)), SelfIndex(getSelfIndex(VD)) {
981+ IsThrowing(isFuncThrowing(VD)), IsMutating(isFuncMutating(VD)),
982+ SelfIndex(getSelfIndex(VD)) {
969983 if (VD->getAttrs ().getDeprecated (VD->getASTContext ()))
970984 DeclAttrs.push_back (SDKDeclAttrKind::DAK_deprecated);
971985}
@@ -1296,6 +1310,8 @@ namespace swift {
12961310 if (auto F = dyn_cast<SDKNodeAbstractFunc>(value.get ())) {
12971311 if (bool isThrowing = F->isThrowing ())
12981312 out.mapRequired (Key_throwing, isThrowing);
1313+ if (bool isMutating = F->isMutating ())
1314+ out.mapRequired (Key_mutating, isMutating);
12991315 if (F->hasSelfIndex ()) {
13001316 auto Index = F->getSelfIndex ();
13011317 out.mapRequired (Key_selfIndex, Index);
0 commit comments