@@ -34,7 +34,8 @@ class Identifier;
34
34
35
35
// / Which kind of module dependencies we are looking for.
36
36
enum class ModuleDependenciesKind : int8_t {
37
- Swift,
37
+ SwiftTextual,
38
+ SwiftBinary,
38
39
// Placeholder dependencies are a kind of dependencies used only by the
39
40
// dependency scanner. They are swift modules that the scanner will not be
40
41
// able to locate in its search paths and which are the responsibility of the
@@ -68,26 +69,22 @@ class ModuleDependenciesStorageBase {
68
69
public:
69
70
const ModuleDependenciesKind dependencyKind;
70
71
71
- ModuleDependenciesStorageBase (ModuleDependenciesKind dependencyKind,
72
- const std::string &compiledModulePath)
73
- : dependencyKind(dependencyKind),
74
- compiledModulePath (compiledModulePath) { }
72
+ ModuleDependenciesStorageBase (ModuleDependenciesKind dependencyKind)
73
+ : dependencyKind(dependencyKind) { }
75
74
76
75
virtual ModuleDependenciesStorageBase *clone () const = 0;
77
76
78
77
virtual ~ModuleDependenciesStorageBase ();
79
78
80
- // / The path to the compiled module file.
81
- const std::string compiledModulePath;
82
-
83
79
// / The set of modules on which this module depends.
84
80
std::vector<std::string> moduleDependencies;
85
81
};
86
82
87
83
// / Describes the dependencies of a Swift module.
88
84
// /
89
85
// / This class is mostly an implementation detail for \c ModuleDependencies.
90
- class SwiftModuleDependenciesStorage : public ModuleDependenciesStorageBase {
86
+ class SwiftTextualModuleDependenciesStorage :
87
+ public ModuleDependenciesStorageBase {
91
88
public:
92
89
// / The Swift interface file, if it can be used to generate the module file.
93
90
const Optional<std::string> swiftInterfaceFile;
@@ -122,16 +119,14 @@ class SwiftModuleDependenciesStorage : public ModuleDependenciesStorageBase {
122
119
// / (Clang) modules on which the bridging header depends.
123
120
std::vector<std::string> bridgingModuleDependencies;
124
121
125
- SwiftModuleDependenciesStorage (
126
- const std::string &compiledModulePath,
122
+ SwiftTextualModuleDependenciesStorage (
127
123
const Optional<std::string> &swiftInterfaceFile,
128
124
ArrayRef<std::string> compiledModuleCandidates,
129
125
ArrayRef<StringRef> buildCommandLine,
130
126
ArrayRef<StringRef> extraPCMArgs,
131
127
StringRef contextHash,
132
128
bool isFramework
133
- ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::Swift,
134
- compiledModulePath),
129
+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftTextual),
135
130
swiftInterfaceFile (swiftInterfaceFile),
136
131
compiledModuleCandidates(compiledModuleCandidates.begin(),
137
132
compiledModuleCandidates.end()),
@@ -140,11 +135,47 @@ class SwiftModuleDependenciesStorage : public ModuleDependenciesStorageBase {
140
135
contextHash(contextHash), isFramework(isFramework) { }
141
136
142
137
ModuleDependenciesStorageBase *clone () const override {
143
- return new SwiftModuleDependenciesStorage (*this );
138
+ return new SwiftTextualModuleDependenciesStorage (*this );
139
+ }
140
+
141
+ static bool classof (const ModuleDependenciesStorageBase *base) {
142
+ return base->dependencyKind == ModuleDependenciesKind::SwiftTextual;
144
143
}
144
+ };
145
+
146
+ // / Describes the dependencies of a pre-built Swift module (with no .swiftinterface).
147
+ // /
148
+ // / This class is mostly an implementation detail for \c ModuleDependencies.
149
+ class SwiftBinaryModuleDependencyStorage : public ModuleDependenciesStorageBase {
150
+ public:
151
+ SwiftBinaryModuleDependencyStorage (const std::string &compiledModulePath,
152
+ const std::string &moduleDocPath,
153
+ const std::string &sourceInfoPath,
154
+ const bool isFramework)
155
+ : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftBinary),
156
+ compiledModulePath (compiledModulePath),
157
+ moduleDocPath(moduleDocPath),
158
+ sourceInfoPath(sourceInfoPath),
159
+ isFramework(isFramework) {}
160
+
161
+ ModuleDependenciesStorageBase *clone () const override {
162
+ return new SwiftBinaryModuleDependencyStorage (*this );
163
+ }
164
+
165
+ // / The path to the .swiftmodule file.
166
+ const std::string compiledModulePath;
167
+
168
+ // / The path to the .swiftModuleDoc file.
169
+ const std::string moduleDocPath;
170
+
171
+ // / The path to the .swiftSourceInfo file.
172
+ const std::string sourceInfoPath;
173
+
174
+ // / A flag that indicates this dependency is a framework
175
+ const bool isFramework;
145
176
146
177
static bool classof (const ModuleDependenciesStorageBase *base) {
147
- return base->dependencyKind == ModuleDependenciesKind::Swift ;
178
+ return base->dependencyKind == ModuleDependenciesKind::SwiftBinary ;
148
179
}
149
180
};
150
181
@@ -166,13 +197,11 @@ class ClangModuleDependenciesStorage : public ModuleDependenciesStorageBase {
166
197
const std::vector<std::string> fileDependencies;
167
198
168
199
ClangModuleDependenciesStorage (
169
- const std::string &compiledModulePath,
170
200
const std::string &moduleMapFile,
171
201
const std::string &contextHash,
172
202
const std::vector<std::string> &nonPathCommandLine,
173
203
const std::vector<std::string> &fileDependencies
174
- ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::Clang,
175
- compiledModulePath),
204
+ ) : ModuleDependenciesStorageBase(ModuleDependenciesKind::Clang),
176
205
moduleMapFile (moduleMapFile),
177
206
contextHash(contextHash),
178
207
nonPathCommandLine(nonPathCommandLine),
@@ -190,20 +219,24 @@ class ClangModuleDependenciesStorage : public ModuleDependenciesStorageBase {
190
219
// / Describes an placeholder Swift module dependency module stub.
191
220
// /
192
221
// / This class is mostly an implementation detail for \c ModuleDependencies.
193
- class PlaceholderSwiftModuleDependencyStorage : public ModuleDependenciesStorageBase {
222
+
223
+ class SwiftPlaceholderModuleDependencyStorage : public ModuleDependenciesStorageBase {
194
224
public:
195
- PlaceholderSwiftModuleDependencyStorage (const std::string &compiledModulePath,
196
- const std::string &moduleDocPath,
197
- const std::string &sourceInfoPath)
198
- : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftPlaceholder,
199
- compiledModulePath),
225
+ SwiftPlaceholderModuleDependencyStorage (const std::string &compiledModulePath,
226
+ const std::string &moduleDocPath,
227
+ const std::string &sourceInfoPath)
228
+ : ModuleDependenciesStorageBase(ModuleDependenciesKind::SwiftPlaceholder) ,
229
+ compiledModulePath ( compiledModulePath),
200
230
moduleDocPath(moduleDocPath),
201
231
sourceInfoPath(sourceInfoPath) {}
202
232
203
233
ModuleDependenciesStorageBase *clone () const override {
204
- return new PlaceholderSwiftModuleDependencyStorage (*this );
234
+ return new SwiftPlaceholderModuleDependencyStorage (*this );
205
235
}
206
236
237
+ // / The path to the .swiftmodule file.
238
+ const std::string compiledModulePath;
239
+
207
240
// / The path to the .swiftModuleDoc file.
208
241
const std::string moduleDocPath;
209
242
@@ -248,43 +281,41 @@ class ModuleDependencies {
248
281
ArrayRef<StringRef> extraPCMArgs,
249
282
StringRef contextHash,
250
283
bool isFramework) {
251
- std::string compiledModulePath;
252
284
return ModuleDependencies (
253
- std::make_unique<SwiftModuleDependenciesStorage >(
254
- compiledModulePath, swiftInterfaceFile, compiledCandidates, buildCommands,
285
+ std::make_unique<SwiftTextualModuleDependenciesStorage >(
286
+ swiftInterfaceFile, compiledCandidates, buildCommands,
255
287
extraPCMArgs, contextHash, isFramework));
256
288
}
257
289
258
290
// / Describe the module dependencies for a serialized or parsed Swift module.
259
- static ModuleDependencies forSwiftModule (
260
- const std::string &compiledModulePath, bool isFramework) {
291
+ static ModuleDependencies forSwiftBinaryModule (
292
+ const std::string &compiledModulePath,
293
+ const std::string &moduleDocPath,
294
+ const std::string &sourceInfoPath,
295
+ bool isFramework) {
261
296
return ModuleDependencies (
262
- std::make_unique<SwiftModuleDependenciesStorage>(
263
- compiledModulePath, None, ArrayRef<std::string>(), ArrayRef<StringRef>(),
264
- ArrayRef<StringRef>(), StringRef (), isFramework));
297
+ std::make_unique<SwiftBinaryModuleDependencyStorage>(
298
+ compiledModulePath, moduleDocPath, sourceInfoPath, isFramework));
265
299
}
266
300
267
301
// / Describe the main Swift module.
268
302
static ModuleDependencies forMainSwiftModule (ArrayRef<StringRef> extraPCMArgs) {
269
- std::string compiledModulePath;
270
303
return ModuleDependencies (
271
- std::make_unique<SwiftModuleDependenciesStorage >(
272
- compiledModulePath, None, ArrayRef<std::string>(),
273
- ArrayRef<StringRef>(), extraPCMArgs, StringRef (), false ));
304
+ std::make_unique<SwiftTextualModuleDependenciesStorage >(
305
+ None, ArrayRef<std::string>(), ArrayRef<StringRef >(),
306
+ extraPCMArgs, StringRef (), false ));
274
307
}
275
308
276
309
// / Describe the module dependencies for a Clang module that can be
277
310
// / built from a module map and headers.
278
311
static ModuleDependencies forClangModule (
279
- const std::string &compiledModulePath,
280
312
const std::string &moduleMapFile,
281
313
const std::string &contextHash,
282
314
const std::vector<std::string> &nonPathCommandLine,
283
315
const std::vector<std::string> &fileDependencies) {
284
316
return ModuleDependencies (
285
317
std::make_unique<ClangModuleDependenciesStorage>(
286
- compiledModulePath, moduleMapFile, contextHash, nonPathCommandLine,
287
- fileDependencies));
318
+ moduleMapFile, contextHash, nonPathCommandLine, fileDependencies));
288
319
}
289
320
290
321
// / Describe a placeholder dependency swift module.
@@ -293,38 +324,45 @@ class ModuleDependencies {
293
324
const std::string &moduleDocPath,
294
325
const std::string &sourceInfoPath) {
295
326
return ModuleDependencies (
296
- std::make_unique<PlaceholderSwiftModuleDependencyStorage >(
327
+ std::make_unique<SwiftPlaceholderModuleDependencyStorage >(
297
328
compiledModulePath, moduleDocPath, sourceInfoPath));
298
329
}
299
330
300
- // / Retrieve the path to the compiled module.
301
- const std::string getCompiledModulePath () const {
302
- return storage->compiledModulePath ;
303
- }
304
-
305
331
// / Retrieve the module-level dependencies.
306
332
ArrayRef<std::string> getModuleDependencies () const {
307
333
return storage->moduleDependencies ;
308
334
}
309
335
310
- // / Whether the dependencies are for a Swift module.
336
+ // / Whether the dependencies are for a Swift module: either Textual, Binary, or Placeholder .
311
337
bool isSwiftModule () const ;
312
338
339
+ // / Whether the dependencies are for a textual Swift module.
340
+ bool isSwiftTextualModule () const ;
341
+
342
+ // / Whether the dependencies are for a binary Swift module.
343
+ bool isSwiftBinaryModule () const ;
344
+
313
345
// / Whether this represents a placeholder module stub
314
- bool isPlaceholderSwiftModule () const ;
346
+ bool isSwiftPlaceholderModule () const ;
347
+
348
+ // / Whether the dependencies are for a Clang module.
349
+ bool isClangModule () const ;
315
350
316
351
ModuleDependenciesKind getKind () const {
317
352
return storage->dependencyKind ;
318
353
}
319
354
// / Retrieve the dependencies for a Swift module.
320
- const SwiftModuleDependenciesStorage *getAsSwiftModule () const ;
355
+ const SwiftTextualModuleDependenciesStorage *getAsSwiftTextualModule () const ;
356
+
357
+ // / Retrieve the dependencies for a binary Swift module.
358
+ const SwiftBinaryModuleDependencyStorage *getAsSwiftBinaryModule () const ;
321
359
322
360
// / Retrieve the dependencies for a Clang module.
323
361
const ClangModuleDependenciesStorage *getAsClangModule () const ;
324
362
325
363
// / Retrieve the dependencies for a placeholder dependency module stub.
326
- const PlaceholderSwiftModuleDependencyStorage *
327
- getAsPlaceholderDependencyModule () const ;
364
+ const SwiftPlaceholderModuleDependencyStorage *
365
+ getAsPlaceholderDependencyModule () const ;
328
366
329
367
// / Add a dependency on the given module, if it was not already in the set.
330
368
void addModuleDependency (StringRef module ,
@@ -363,11 +401,14 @@ class ModuleDependenciesCache {
363
401
// / encountered.
364
402
std::vector<ModuleDependencyID> AllModules;
365
403
366
- // / Dependencies for Swift modules that have already been computed.
367
- llvm::StringMap<ModuleDependencies> SwiftModuleDependencies ;
404
+ // / Dependencies for Textual Swift modules that have already been computed.
405
+ llvm::StringMap<ModuleDependencies> SwiftTextualModuleDependencies ;
368
406
369
- // / Dependencies for Swift placeholder dependency modules.
370
- llvm::StringMap<ModuleDependencies> PlaceholderSwiftModuleDependencies;
407
+ // / Dependencies for Binary Swift modules that have already been computed.
408
+ llvm::StringMap<ModuleDependencies> SwiftBinaryModuleDependencies;
409
+
410
+ // / Dependencies for Swift placeholder dependency modules that have already been computed.
411
+ llvm::StringMap<ModuleDependencies> SwiftPlaceholderModuleDependencies;
371
412
372
413
// / Dependencies for Clang modules that have already been computed.
373
414
llvm::StringMap<ModuleDependencies> ClangModuleDependencies;
@@ -429,8 +470,7 @@ class ModuleDependenciesCache {
429
470
430
471
// / Record dependencies for the given module.
431
472
void recordDependencies (StringRef moduleName,
432
- ModuleDependencies dependencies,
433
- ModuleDependenciesKind kind);
473
+ ModuleDependencies dependencies);
434
474
435
475
// / Update stored dependencies for the given module.
436
476
void updateDependencies (ModuleDependencyID moduleID,
0 commit comments