@@ -43,11 +43,11 @@ enum class ModuleDependenciesKind : int8_t {
43
43
// / This class is mostly an implementation detail for \c ModuleDependencies.
44
44
class ModuleDependenciesStorageBase {
45
45
public:
46
- const bool isSwiftModule ;
46
+ const ModuleDependenciesKind dependencyKind ;
47
47
48
- ModuleDependenciesStorageBase (bool isSwiftModule ,
48
+ ModuleDependenciesStorageBase (ModuleDependenciesKind dependencyKind ,
49
49
const std::string &compiledModulePath)
50
- : isSwiftModule(isSwiftModule ),
50
+ : dependencyKind(dependencyKind ),
51
51
compiledModulePath (compiledModulePath) { }
52
52
53
53
virtual ModuleDependenciesStorageBase *clone () const = 0;
@@ -103,7 +103,8 @@ class SwiftModuleDependenciesStorage : public ModuleDependenciesStorageBase {
103
103
ArrayRef<StringRef> buildCommandLine,
104
104
ArrayRef<StringRef> extraPCMArgs,
105
105
StringRef contextHash
106
- ) : ModuleDependenciesStorageBase(/* isSwiftModule=*/ true , compiledModulePath),
106
+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::Swift,
107
+ compiledModulePath),
107
108
swiftInterfaceFile (swiftInterfaceFile),
108
109
compiledModuleCandidates(compiledModuleCandidates.begin(),
109
110
compiledModuleCandidates.end()),
@@ -116,7 +117,7 @@ class SwiftModuleDependenciesStorage : public ModuleDependenciesStorageBase {
116
117
}
117
118
118
119
static bool classof (const ModuleDependenciesStorageBase *base) {
119
- return base->isSwiftModule && !base-> isExternalSwiftModuleStub ;
120
+ return base->dependencyKind == ModuleDependenciesKind::Swift ;
120
121
}
121
122
};
122
123
@@ -143,7 +144,7 @@ class ClangModuleDependenciesStorage : public ModuleDependenciesStorageBase {
143
144
const std::string &contextHash,
144
145
const std::vector<std::string> &nonPathCommandLine,
145
146
const std::vector<std::string> &fileDependencies
146
- ) : ModuleDependenciesStorageBase(/* isSwiftModule= */ false ,
147
+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::Clang ,
147
148
compiledModulePath),
148
149
moduleMapFile (moduleMapFile),
149
150
contextHash(contextHash),
@@ -155,7 +156,35 @@ class ClangModuleDependenciesStorage : public ModuleDependenciesStorageBase {
155
156
}
156
157
157
158
static bool classof (const ModuleDependenciesStorageBase *base) {
158
- return !base->isSwiftModule ;
159
+ return base->dependencyKind == ModuleDependenciesKind::Clang;
160
+ }
161
+ };
162
+
163
+ // / Describes an external Swift module dependency module stub.
164
+ // /
165
+ // / This class is mostly an implementation detail for \c ModuleDependencies.
166
+ class ExternalSwiftModuleDependencyStorage : public ModuleDependenciesStorageBase {
167
+ public:
168
+ ExternalSwiftModuleDependencyStorage (const std::string &compiledModulePath,
169
+ const std::string &moduleDocPath,
170
+ const std::string &sourceInfoPath)
171
+ : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftExternal,
172
+ compiledModulePath),
173
+ moduleDocPath (moduleDocPath),
174
+ sourceInfoPath(sourceInfoPath) {}
175
+
176
+ ModuleDependenciesStorageBase *clone () const override {
177
+ return new ExternalSwiftModuleDependencyStorage (*this );
178
+ }
179
+
180
+ // / The path to the .swiftModuleDoc file.
181
+ const std::string moduleDocPath;
182
+
183
+ // / The path to the .swiftSourceInfo file.
184
+ const std::string sourceInfoPath;
185
+
186
+ static bool classof (const ModuleDependenciesStorageBase *base) {
187
+ return base->dependencyKind == ModuleDependenciesKind::SwiftExternal;
159
188
}
160
189
};
161
190
@@ -254,11 +283,7 @@ class ModuleDependencies {
254
283
bool isSwiftModule () const ;
255
284
256
285
ModuleDependenciesKind getKind () const {
257
- if (isExternalSwiftModuleStub ())
258
- return ModuleDependenciesKind::SwiftExternal;
259
- else
260
- return isSwiftModule () ? ModuleDependenciesKind::Swift
261
- : ModuleDependenciesKind::Clang;
286
+ return storage->dependencyKind ;
262
287
}
263
288
// / Retrieve the dependencies for a Swift module.
264
289
const SwiftModuleDependenciesStorage *getAsSwiftModule () const ;
0 commit comments