@@ -106,8 +106,10 @@ class ModuleDependencyInfoStorageBase {
106
106
const ModuleDependencyKind dependencyKind;
107
107
108
108
ModuleDependencyInfoStorageBase (ModuleDependencyKind dependencyKind,
109
+ StringRef moduleCacheKey = " " ,
109
110
bool resolved = false )
110
- : dependencyKind(dependencyKind), resolved(resolved) { }
111
+ : dependencyKind(dependencyKind), moduleCacheKey(moduleCacheKey.str()),
112
+ resolved (resolved) {}
111
113
112
114
virtual ModuleDependencyInfoStorageBase *clone () const = 0;
113
115
@@ -124,18 +126,18 @@ class ModuleDependencyInfoStorageBase {
124
126
// / The set of modules on which this module depends, resolved
125
127
// / to Module IDs, qualified by module kind: Swift, Clang, etc.
126
128
std::vector<ModuleDependencyID> resolvedModuleDependencies;
129
+
130
+ // / The cache key for the produced module.
131
+ std::string moduleCacheKey;
132
+
127
133
bool resolved;
128
134
};
129
135
130
136
struct CommonSwiftTextualModuleDependencyDetails {
131
137
CommonSwiftTextualModuleDependencyDetails (
132
138
ArrayRef<StringRef> extraPCMArgs, ArrayRef<StringRef> buildCommandLine,
133
- ArrayRef<StringRef> bridgingHeaderBuildCommandLine,
134
139
const std::string &CASFileSystemRootID)
135
140
: extraPCMArgs(extraPCMArgs.begin(), extraPCMArgs.end()),
136
- buildCommandLine (buildCommandLine.begin(), buildCommandLine.end()),
137
- bridgingHeaderBuildCommandLine(bridgingHeaderBuildCommandLine.begin(),
138
- bridgingHeaderBuildCommandLine.end()),
139
141
CASFileSystemRootID (CASFileSystemRootID) {}
140
142
141
143
// / To build a PCM to be used by this Swift module, we need to append these
@@ -160,14 +162,11 @@ struct CommonSwiftTextualModuleDependencyDetails {
160
162
// / interface.
161
163
std::vector<std::string> buildCommandLine;
162
164
163
- // / The Swift frontend invocation arguments to build bridging header.
164
- std::vector<std::string> bridgingHeaderBuildCommandLine;
165
-
166
165
// / CASID for the Root of CASFS. Empty if CAS is not used.
167
166
std::string CASFileSystemRootID;
168
167
169
168
// / CASID for the Root of bridgingHeaderClangIncludeTree. Empty if not used.
170
- std::string bridgingHeaderIncludeTreeRoot ;
169
+ std::string CASBridgingHeaderIncludeTreeRootID ;
171
170
};
172
171
173
172
// / Describes the dependencies of a Swift module described by an Swift interface file.
@@ -194,28 +193,21 @@ class SwiftInterfaceModuleDependenciesStorage :
194
193
// / Details common to Swift textual (interface or source) modules
195
194
CommonSwiftTextualModuleDependencyDetails textualModuleDetails;
196
195
197
- // / The cache key for the produced module.
198
- std::string moduleCacheKey;
199
-
200
196
SwiftInterfaceModuleDependenciesStorage (
201
197
const std::string &moduleOutputPath,
202
198
const std::string &swiftInterfaceFile,
203
199
ArrayRef<std::string> compiledModuleCandidates,
204
- ArrayRef<StringRef> buildCommandLine,
205
- ArrayRef<StringRef> extraPCMArgs,
206
- StringRef contextHash,
207
- bool isFramework,
208
- const std::string &RootID,
209
- const std::string &ModuleCacheKey
210
- ) : ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftInterface),
211
- moduleOutputPath (moduleOutputPath),
212
- swiftInterfaceFile(swiftInterfaceFile),
213
- compiledModuleCandidates(compiledModuleCandidates.begin(),
214
- compiledModuleCandidates.end()),
215
- contextHash(contextHash), isFramework(isFramework),
216
- textualModuleDetails(extraPCMArgs, buildCommandLine, {}, RootID),
217
- moduleCacheKey(ModuleCacheKey)
218
- {}
200
+ ArrayRef<StringRef> buildCommandLine, ArrayRef<StringRef> extraPCMArgs,
201
+ StringRef contextHash, bool isFramework, const std::string &RootID,
202
+ const std::string &moduleCacheKey)
203
+ : ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftInterface,
204
+ moduleCacheKey),
205
+ moduleOutputPath (moduleOutputPath),
206
+ swiftInterfaceFile(swiftInterfaceFile),
207
+ compiledModuleCandidates(compiledModuleCandidates.begin(),
208
+ compiledModuleCandidates.end()),
209
+ contextHash(contextHash), isFramework(isFramework),
210
+ textualModuleDetails(extraPCMArgs, buildCommandLine, RootID) {}
219
211
220
212
ModuleDependencyInfoStorageBase *clone () const override {
221
213
return new SwiftInterfaceModuleDependenciesStorage (*this );
@@ -228,10 +220,6 @@ class SwiftInterfaceModuleDependenciesStorage :
228
220
void updateCommandLine (const std::vector<std::string> &newCommandLine) {
229
221
textualModuleDetails.buildCommandLine = newCommandLine;
230
222
}
231
-
232
- void updateModuleCacheKey (const std::string &Key) {
233
- moduleCacheKey = Key;
234
- }
235
223
};
236
224
237
225
// / Describes the dependencies of a Swift module
@@ -250,14 +238,18 @@ class SwiftSourceModuleDependenciesStorage :
250
238
// / Collection of module imports that were detected to be `@Testable`
251
239
llvm::StringSet<> testableImports;
252
240
241
+ // / The Swift frontend invocation arguments to build bridging header.
242
+ std::vector<std::string> bridgingHeaderBuildCommandLine;
243
+
253
244
SwiftSourceModuleDependenciesStorage (
254
245
const std::string &RootID, ArrayRef<StringRef> buildCommandLine,
255
246
ArrayRef<StringRef> bridgingHeaderBuildCommandLine,
256
247
ArrayRef<StringRef> extraPCMArgs)
257
248
: ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftSource),
258
- textualModuleDetails (extraPCMArgs, buildCommandLine,
259
- bridgingHeaderBuildCommandLine, RootID),
260
- testableImports(llvm::StringSet<>()) {}
249
+ textualModuleDetails (extraPCMArgs, buildCommandLine, RootID),
250
+ testableImports(llvm::StringSet<>()),
251
+ bridgingHeaderBuildCommandLine(bridgingHeaderBuildCommandLine.begin(),
252
+ bridgingHeaderBuildCommandLine.end()) {}
261
253
262
254
ModuleDependencyInfoStorageBase *clone () const override {
263
255
return new SwiftSourceModuleDependenciesStorage (*this );
@@ -273,7 +265,7 @@ class SwiftSourceModuleDependenciesStorage :
273
265
274
266
void updateBridgingHeaderCommandLine (
275
267
const std::vector<std::string> &newCommandLine) {
276
- textualModuleDetails. bridgingHeaderBuildCommandLine = newCommandLine;
268
+ bridgingHeaderBuildCommandLine = newCommandLine;
277
269
}
278
270
279
271
void addTestableImport (ImportPath::Module module) {
@@ -290,11 +282,11 @@ class SwiftBinaryModuleDependencyStorage : public ModuleDependencyInfoStorageBas
290
282
const std::string &moduleDocPath,
291
283
const std::string &sourceInfoPath,
292
284
const bool isFramework,
293
- const std::string ModuleCacheKey)
294
- : ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftBinary),
285
+ const std::string &moduleCacheKey)
286
+ : ModuleDependencyInfoStorageBase(ModuleDependencyKind::SwiftBinary,
287
+ moduleCacheKey),
295
288
compiledModulePath (compiledModulePath), moduleDocPath(moduleDocPath),
296
- sourceInfoPath(sourceInfoPath), isFramework(isFramework),
297
- moduleCacheKey(ModuleCacheKey) {}
289
+ sourceInfoPath(sourceInfoPath), isFramework(isFramework) {}
298
290
299
291
ModuleDependencyInfoStorageBase *clone () const override {
300
292
return new SwiftBinaryModuleDependencyStorage (*this );
@@ -312,16 +304,9 @@ class SwiftBinaryModuleDependencyStorage : public ModuleDependencyInfoStorageBas
312
304
// / A flag that indicates this dependency is a framework
313
305
const bool isFramework;
314
306
315
- // / The cache key for the produced module.
316
- std::string moduleCacheKey;
317
-
318
307
static bool classof (const ModuleDependencyInfoStorageBase *base) {
319
308
return base->dependencyKind == ModuleDependencyKind::SwiftBinary;
320
309
}
321
-
322
- void updateModuleCacheKey (const std::string &Key) {
323
- moduleCacheKey = Key;
324
- }
325
310
};
326
311
327
312
// / Describes the dependencies of a Clang module.
@@ -339,7 +324,7 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
339
324
const std::string contextHash;
340
325
341
326
// / Partial (Clang) command line that can be used to build this module.
342
- std::vector<std::string> nonPathCommandLine ;
327
+ std::vector<std::string> buildCommandLine ;
343
328
344
329
// / The file dependencies
345
330
const std::vector<std::string> fileDependencies;
@@ -352,31 +337,24 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
352
337
std::string CASFileSystemRootID;
353
338
354
339
// / CASID for the Root of ClangIncludeTree. Empty if not used.
355
- std::string clangIncludeTreeRoot;
356
-
357
- // / The cache key for the produced module.
358
- std::string moduleCacheKey;
359
-
360
- ClangModuleDependencyStorage (
361
- const std::string &pcmOutputPath,
362
- const std::string &moduleMapFile,
363
- const std::string &contextHash,
364
- const std::vector<std::string> &nonPathCommandLine,
365
- const std::vector<std::string> &fileDependencies,
366
- const std::vector<std::string> &capturedPCMArgs,
367
- const std::string &CASFileSystemRootID,
368
- const std::string &clangIncludeTreeRoot,
369
- const std::string &ModuleCacheKey
370
- ) : ModuleDependencyInfoStorageBase(ModuleDependencyKind::Clang),
371
- pcmOutputPath (pcmOutputPath),
372
- moduleMapFile(moduleMapFile),
373
- contextHash(contextHash),
374
- nonPathCommandLine(nonPathCommandLine),
375
- fileDependencies(fileDependencies),
376
- capturedPCMArgs(capturedPCMArgs),
377
- CASFileSystemRootID(CASFileSystemRootID),
378
- clangIncludeTreeRoot(clangIncludeTreeRoot),
379
- moduleCacheKey(ModuleCacheKey) {}
340
+ std::string CASClangIncludeTreeRootID;
341
+
342
+ ClangModuleDependencyStorage (const std::string &pcmOutputPath,
343
+ const std::string &moduleMapFile,
344
+ const std::string &contextHash,
345
+ const std::vector<std::string> &buildCommandLine,
346
+ const std::vector<std::string> &fileDependencies,
347
+ const std::vector<std::string> &capturedPCMArgs,
348
+ const std::string &CASFileSystemRootID,
349
+ const std::string &clangIncludeTreeRoot,
350
+ const std::string &moduleCacheKey)
351
+ : ModuleDependencyInfoStorageBase(ModuleDependencyKind::Clang,
352
+ moduleCacheKey),
353
+ pcmOutputPath (pcmOutputPath), moduleMapFile(moduleMapFile),
354
+ contextHash(contextHash), buildCommandLine(buildCommandLine),
355
+ fileDependencies(fileDependencies), capturedPCMArgs(capturedPCMArgs),
356
+ CASFileSystemRootID(CASFileSystemRootID),
357
+ CASClangIncludeTreeRootID(clangIncludeTreeRoot) {}
380
358
381
359
ModuleDependencyInfoStorageBase *clone () const override {
382
360
return new ClangModuleDependencyStorage (*this );
@@ -387,12 +365,7 @@ class ClangModuleDependencyStorage : public ModuleDependencyInfoStorageBase {
387
365
}
388
366
389
367
void updateCommandLine (const std::vector<std::string> &newCommandLine) {
390
- nonPathCommandLine = newCommandLine;
391
- }
392
-
393
- void updateModuleCacheKey (const std::string &Key) {
394
- assert (moduleCacheKey.empty ());
395
- moduleCacheKey = Key;
368
+ buildCommandLine = newCommandLine;
396
369
}
397
370
};
398
371
@@ -543,28 +516,11 @@ class ModuleDependencyInfo {
543
516
544
517
std::string getModuleCacheKey () const {
545
518
assert (storage->resolved );
546
- if (auto *dep = getAsSwiftInterfaceModule ())
547
- return dep->moduleCacheKey ;
548
- else if (auto *dep = getAsSwiftBinaryModule ())
549
- return dep->moduleCacheKey ;
550
- else if (auto *dep = getAsClangModule ())
551
- return dep->moduleCacheKey ;
552
-
553
- llvm_unreachable (" Unexpected type" );
519
+ return storage->moduleCacheKey ;
554
520
}
555
521
556
522
void updateModuleCacheKey (const std::string &key) {
557
- if (isSwiftInterfaceModule ())
558
- return cast<SwiftInterfaceModuleDependenciesStorage>(storage.get ())
559
- ->updateModuleCacheKey (key);
560
- else if (isSwiftBinaryModule ())
561
- return cast<SwiftBinaryModuleDependencyStorage>(storage.get ())
562
- ->updateModuleCacheKey (key);
563
- else if (isClangModule ())
564
- return cast<ClangModuleDependencyStorage>(storage.get ())
565
- ->updateModuleCacheKey (key);
566
-
567
- llvm_unreachable (" Unexpected type" );
523
+ storage->moduleCacheKey = key;
568
524
}
569
525
570
526
// / Resolve a dependency's set of `imports` with qualified Module IDs
@@ -590,7 +546,7 @@ class ModuleDependencyInfo {
590
546
591
547
std::vector<std::string> getCommandline () const {
592
548
if (auto *detail = getAsClangModule ())
593
- return detail->nonPathCommandLine ;
549
+ return detail->buildCommandLine ;
594
550
else if (auto *detail = getAsSwiftInterfaceModule ())
595
551
return detail->textualModuleDetails .buildCommandLine ;
596
552
else if (auto *detail = getAsSwiftSourceModule ())
@@ -613,7 +569,7 @@ class ModuleDependencyInfo {
613
569
614
570
std::vector<std::string> getBridgingHeaderCommandline () const {
615
571
if (auto *detail = getAsSwiftSourceModule ())
616
- return detail->textualModuleDetails . bridgingHeaderBuildCommandLine ;
572
+ return detail->bridgingHeaderBuildCommandLine ;
617
573
return {};
618
574
}
619
575
0 commit comments