@@ -98,6 +98,9 @@ ResourceDir("resource-dir",
98
98
static llvm::cl::list<std::string>
99
99
FrameworkPaths (" F" , llvm::cl::desc(" add a directory to the framework search path" ));
100
100
101
+ static llvm::cl::list<std::string>
102
+ ModuleInputPaths (" I" , llvm::cl::desc(" add a module for input" ));
103
+
101
104
static llvm::cl::opt<bool >
102
105
AbortOnModuleLoadFailure (" abort-on-module-fail" ,
103
106
llvm::cl::desc (" Abort if a module failed to load" ));
@@ -258,6 +261,7 @@ struct SDKNodeInitInfo {
258
261
StringRef Location;
259
262
StringRef ModuleName;
260
263
bool IsThrowing = false ;
264
+ bool IsMutating = false ;
261
265
Optional<uint8_t > SelfIndex;
262
266
std::vector<SDKDeclAttrKind> DeclAttrs;
263
267
std::vector<TypeAttrKind> TypeAttrs;
@@ -680,15 +684,18 @@ class SDKNodeVar : public SDKNodeDecl {
680
684
681
685
class SDKNodeAbstractFunc : public SDKNodeDecl {
682
686
const bool IsThrowing;
687
+ const bool IsMutating;
683
688
const Optional<uint8_t > SelfIndex;
684
689
685
690
protected:
686
691
SDKNodeAbstractFunc (SDKNodeInitInfo Info, SDKNodeKind Kind) :
687
692
SDKNodeDecl (Info, Kind),
688
693
IsThrowing (Info.IsThrowing),
694
+ IsMutating (Info.IsMutating),
689
695
SelfIndex (Info.SelfIndex){}
690
696
public:
691
697
bool isThrowing () const { return IsThrowing; }
698
+ bool isMutating () const { return IsMutating; }
692
699
uint8_t getSelfIndex () const { return SelfIndex.getValue (); }
693
700
Optional<uint8_t > getSelfIndexOptional () const { return SelfIndex; }
694
701
bool hasSelfIndex () const { return SelfIndex.hasValue (); }
@@ -797,6 +804,8 @@ NodeUniquePtr SDKNode::constructSDKNode(llvm::yaml::MappingNode *Node) {
797
804
Info.ModuleName = GetScalarString (Pair.getValue ());
798
805
} else if (Key == Key_throwing) {
799
806
Info.IsThrowing = true ;
807
+ } else if (Key == Key_mutating) {
808
+ Info.IsMutating = true ;
800
809
} else if (Key == Key_typeAttributes) {
801
810
auto *Seq = cast<llvm::yaml::SequenceNode>(Pair.getValue ());
802
811
for (auto It = Seq->begin (); It != Seq->end (); ++ It) {
@@ -943,6 +952,13 @@ static bool isFuncThrowing(ValueDecl *VD) {
943
952
return false ;
944
953
}
945
954
955
+ static bool isFuncMutating (ValueDecl *VD) {
956
+ if (auto AF = dyn_cast<FuncDecl>(VD)) {
957
+ return AF->isMutating ();
958
+ }
959
+ return false ;
960
+ }
961
+
946
962
static Optional<uint8_t > getSelfIndex (ValueDecl *VD) {
947
963
if (auto AF = dyn_cast<AbstractFunctionDecl>(VD)) {
948
964
if (AF->isImportAsInstanceMember ())
@@ -962,7 +978,8 @@ SDKNodeInitInfo::SDKNodeInitInfo(ValueDecl *VD) :
962
978
PrintedName(getPrintedName(VD)), DKind(VD->getKind ()),
963
979
USR(calculateUsr(VD)), Location(calculateLocation(VD)),
964
980
ModuleName(VD->getModuleContext ()->getName().str()),
965
- IsThrowing(isFuncThrowing(VD)), SelfIndex(getSelfIndex(VD)) {
981
+ IsThrowing(isFuncThrowing(VD)), IsMutating(isFuncMutating(VD)),
982
+ SelfIndex(getSelfIndex(VD)) {
966
983
if (VD->getAttrs ().getDeprecated (VD->getASTContext ()))
967
984
DeclAttrs.push_back (SDKDeclAttrKind::DAK_deprecated);
968
985
}
@@ -1293,6 +1310,8 @@ namespace swift {
1293
1310
if (auto F = dyn_cast<SDKNodeAbstractFunc>(value.get ())) {
1294
1311
if (bool isThrowing = F->isThrowing ())
1295
1312
out.mapRequired (Key_throwing, isThrowing);
1313
+ if (bool isMutating = F->isMutating ())
1314
+ out.mapRequired (Key_mutating, isMutating);
1296
1315
if (F->hasSelfIndex ()) {
1297
1316
auto Index = F->getSelfIndex ();
1298
1317
out.mapRequired (Key_selfIndex, Index);
@@ -3303,6 +3322,7 @@ static int prepareForDump(const char *Main,
3303
3322
InitInvok.setRuntimeResourcePath (options::ResourceDir);
3304
3323
}
3305
3324
InitInvok.setFrameworkSearchPaths (options::FrameworkPaths);
3325
+ InitInvok.setImportSearchPaths (options::ModuleInputPaths);
3306
3326
3307
3327
if (!options::ModuleList.empty ()) {
3308
3328
if (readFileLineByLine (options::ModuleList, Modules))
0 commit comments