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