@@ -98,6 +98,9 @@ ResourceDir("resource-dir",
9898static llvm::cl::list<std::string>
9999FrameworkPaths (" F" , llvm::cl::desc(" add a directory to the framework search path" ));
100100
101+ static llvm::cl::list<std::string>
102+ ModuleInputPaths (" I" , llvm::cl::desc(" add a module for input" ));
103+
101104static llvm::cl::opt<bool >
102105AbortOnModuleLoadFailure (" abort-on-module-fail" ,
103106 llvm::cl::desc (" Abort if a module failed to load" ));
@@ -258,6 +261,7 @@ struct SDKNodeInitInfo {
258261 StringRef Location;
259262 StringRef ModuleName;
260263 bool IsThrowing = false ;
264+ bool IsMutating = false ;
261265 Optional<uint8_t > SelfIndex;
262266 std::vector<SDKDeclAttrKind> DeclAttrs;
263267 std::vector<TypeAttrKind> TypeAttrs;
@@ -680,15 +684,18 @@ class SDKNodeVar : public SDKNodeDecl {
680684
681685class SDKNodeAbstractFunc : public SDKNodeDecl {
682686 const bool IsThrowing;
687+ const bool IsMutating;
683688 const Optional<uint8_t > SelfIndex;
684689
685690protected:
686691 SDKNodeAbstractFunc (SDKNodeInitInfo Info, SDKNodeKind Kind) :
687692 SDKNodeDecl (Info, Kind),
688693 IsThrowing (Info.IsThrowing),
694+ IsMutating (Info.IsMutating),
689695 SelfIndex (Info.SelfIndex){}
690696public:
691697 bool isThrowing () const { return IsThrowing; }
698+ bool isMutating () const { return IsMutating; }
692699 uint8_t getSelfIndex () const { return SelfIndex.getValue (); }
693700 Optional<uint8_t > getSelfIndexOptional () const { return SelfIndex; }
694701 bool hasSelfIndex () const { return SelfIndex.hasValue (); }
@@ -797,6 +804,8 @@ NodeUniquePtr SDKNode::constructSDKNode(llvm::yaml::MappingNode *Node) {
797804 Info.ModuleName = GetScalarString (Pair.getValue ());
798805 } else if (Key == Key_throwing) {
799806 Info.IsThrowing = true ;
807+ } else if (Key == Key_mutating) {
808+ Info.IsMutating = true ;
800809 } else if (Key == Key_typeAttributes) {
801810 auto *Seq = cast<llvm::yaml::SequenceNode>(Pair.getValue ());
802811 for (auto It = Seq->begin (); It != Seq->end (); ++ It) {
@@ -943,6 +952,13 @@ static bool isFuncThrowing(ValueDecl *VD) {
943952 return false ;
944953}
945954
955+ static bool isFuncMutating (ValueDecl *VD) {
956+ if (auto AF = dyn_cast<FuncDecl>(VD)) {
957+ return AF->isMutating ();
958+ }
959+ return false ;
960+ }
961+
946962static Optional<uint8_t > getSelfIndex (ValueDecl *VD) {
947963 if (auto AF = dyn_cast<AbstractFunctionDecl>(VD)) {
948964 if (AF->isImportAsInstanceMember ())
@@ -962,7 +978,8 @@ SDKNodeInitInfo::SDKNodeInitInfo(ValueDecl *VD) :
962978 PrintedName(getPrintedName(VD)), DKind(VD->getKind ()),
963979 USR(calculateUsr(VD)), Location(calculateLocation(VD)),
964980 ModuleName(VD->getModuleContext ()->getName().str()),
965- IsThrowing(isFuncThrowing(VD)), SelfIndex(getSelfIndex(VD)) {
981+ IsThrowing(isFuncThrowing(VD)), IsMutating(isFuncMutating(VD)),
982+ SelfIndex(getSelfIndex(VD)) {
966983 if (VD->getAttrs ().getDeprecated (VD->getASTContext ()))
967984 DeclAttrs.push_back (SDKDeclAttrKind::DAK_deprecated);
968985}
@@ -1293,6 +1310,8 @@ namespace swift {
12931310 if (auto F = dyn_cast<SDKNodeAbstractFunc>(value.get ())) {
12941311 if (bool isThrowing = F->isThrowing ())
12951312 out.mapRequired (Key_throwing, isThrowing);
1313+ if (bool isMutating = F->isMutating ())
1314+ out.mapRequired (Key_mutating, isMutating);
12961315 if (F->hasSelfIndex ()) {
12971316 auto Index = F->getSelfIndex ();
12981317 out.mapRequired (Key_selfIndex, Index);
@@ -3303,6 +3322,7 @@ static int prepareForDump(const char *Main,
33033322 InitInvok.setRuntimeResourcePath (options::ResourceDir);
33043323 }
33053324 InitInvok.setFrameworkSearchPaths (options::FrameworkPaths);
3325+ InitInvok.setImportSearchPaths (options::ModuleInputPaths);
33063326
33073327 if (!options::ModuleList.empty ()) {
33083328 if (readFileLineByLine (options::ModuleList, Modules))
0 commit comments