@@ -109,6 +109,8 @@ package final class ClangModuleDependencyGraph {
109
109
/// for example, when using `-save-temps`.
110
110
package let commands : [ CompileCommand ]
111
111
112
+ package let scanningCommandLine : [ String ]
113
+
112
114
package let transitiveIncludeTreeIDs : OrderedSet < String >
113
115
package let transitiveCompileCommandCacheKeys : OrderedSet < String >
114
116
@@ -121,6 +123,7 @@ package final class ClangModuleDependencyGraph {
121
123
moduleDependencies: OrderedSet < Path > ,
122
124
workingDirectory: Path ,
123
125
commands: [ CompileCommand ] ,
126
+ scanningCommandLine: [ String ] ,
124
127
transitiveIncludeTreeIDs: OrderedSet < String > ,
125
128
transitiveCompileCommandCacheKeys: OrderedSet < String > ,
126
129
usesSerializedDiagnostics: Bool
@@ -131,6 +134,7 @@ package final class ClangModuleDependencyGraph {
131
134
self . modules = moduleDependencies
132
135
self . workingDirectory = workingDirectory
133
136
self . commands = commands
137
+ self . scanningCommandLine = scanningCommandLine
134
138
self . transitiveIncludeTreeIDs = transitiveIncludeTreeIDs
135
139
self . transitiveCompileCommandCacheKeys = transitiveCompileCommandCacheKeys
136
140
self . usesSerializedDiagnostics = usesSerializedDiagnostics
@@ -143,6 +147,7 @@ package final class ClangModuleDependencyGraph {
143
147
moduleDependencies: OrderedSet < Path > ,
144
148
workingDirectory: Path ,
145
149
command: CompileCommand ,
150
+ scanningCommandLine: [ String ] ,
146
151
transitiveIncludeTreeIDs: OrderedSet < String > ,
147
152
transitiveCompileCommandCacheKeys: OrderedSet < String > ,
148
153
usesSerializedDiagnostics: Bool
@@ -153,33 +158,36 @@ package final class ClangModuleDependencyGraph {
153
158
self . modules = moduleDependencies
154
159
self . workingDirectory = workingDirectory
155
160
self . commands = [ command]
161
+ self . scanningCommandLine = scanningCommandLine
156
162
self . transitiveIncludeTreeIDs = transitiveIncludeTreeIDs
157
163
self . transitiveCompileCommandCacheKeys = transitiveCompileCommandCacheKeys
158
164
self . usesSerializedDiagnostics = usesSerializedDiagnostics
159
165
}
160
166
161
167
package func serialize< T> ( to serializer: T ) where T : Serializer {
162
- serializer. serializeAggregate ( 9 ) {
168
+ serializer. serializeAggregate ( 10 ) {
163
169
serializer. serialize ( kind)
164
170
serializer. serialize ( files)
165
171
serializer. serialize ( includeTreeID)
166
172
serializer. serialize ( modules)
167
173
serializer. serialize ( workingDirectory)
168
174
serializer. serialize ( commands)
175
+ serializer. serialize ( scanningCommandLine)
169
176
serializer. serialize ( transitiveIncludeTreeIDs)
170
177
serializer. serialize ( transitiveCompileCommandCacheKeys)
171
178
serializer. serialize ( usesSerializedDiagnostics)
172
179
}
173
180
}
174
181
175
182
package init ( from deserializer: any Deserializer ) throws {
176
- try deserializer. beginAggregate ( 9 )
183
+ try deserializer. beginAggregate ( 10 )
177
184
self . kind = try deserializer. deserialize ( )
178
185
self . files = try deserializer. deserialize ( )
179
186
self . includeTreeID = try deserializer. deserialize ( )
180
187
self . modules = try deserializer. deserialize ( )
181
188
self . workingDirectory = try deserializer. deserialize ( )
182
189
self . commands = try deserializer. deserialize ( )
190
+ self . scanningCommandLine = try deserializer. deserialize ( )
183
191
self . transitiveIncludeTreeIDs = try deserializer. deserialize ( )
184
192
self . transitiveCompileCommandCacheKeys = try deserializer. deserialize ( )
185
193
self . usesSerializedDiagnostics = try deserializer. deserialize ( )
@@ -334,12 +342,13 @@ package final class ClangModuleDependencyGraph {
334
342
var moduleTransitiveCacheKeys : [ String : OrderedSet < String > ] = [ : ]
335
343
336
344
let fileDeps : DependencyScanner . FileDependencies
345
+ let scanningCommandLine = [ compiler] + originalFileArgs
337
346
let modulesCallbackErrors = LockedValue < [ any Error ] > ( [ ] )
338
347
let dependencyPaths = LockedValue < Set < Path > > ( [ ] )
339
348
let requiredTargetDependencies = LockedValue < Set < ScanResult . RequiredDependency > > ( [ ] )
340
349
do {
341
350
fileDeps = try clangWithScanner. scanner. scanDependencies (
342
- commandLine: [ compiler ] + originalFileArgs ,
351
+ commandLine: scanningCommandLine ,
343
352
workingDirectory: workingDirectory. str,
344
353
lookupOutput: { name, contextHash, kind in
345
354
let moduleOutputPath = outputPathForModule ( name, contextHash)
@@ -432,6 +441,7 @@ package final class ClangModuleDependencyGraph {
432
441
// Cached builds do not rely on the process working directory, and different scanner working directories should not inhibit task deduplication. The same is true if the scanner reports the working directory can be ignored.
433
442
workingDirectory: module. cache_key != nil || module. is_cwd_ignored ? Path . root : workingDirectory,
434
443
command: DependencyInfo . CompileCommand ( cacheKey: module. cache_key, arguments: commandLine) ,
444
+ scanningCommandLine: scanningCommandLine,
435
445
transitiveIncludeTreeIDs: transitiveIncludeTreeIDs,
436
446
transitiveCompileCommandCacheKeys: transitiveCommandCacheKeys,
437
447
usesSerializedDiagnostics: usesSerializedDiagnostics)
@@ -513,6 +523,7 @@ package final class ClangModuleDependencyGraph {
513
523
// Cached builds do not rely on the process working directory, and different scanner working directories should not inhibit task deduplication
514
524
workingDirectory: fileDeps. commands. allSatisfy { $0. cache_key != nil } ? Path . root : workingDirectory,
515
525
commands: commands,
526
+ scanningCommandLine: scanningCommandLine,
516
527
transitiveIncludeTreeIDs: transitiveIncludeTreeIDs,
517
528
transitiveCompileCommandCacheKeys: transitiveCommandCacheKeys,
518
529
usesSerializedDiagnostics: usesSerializedDiagnostics)
@@ -549,6 +560,21 @@ package final class ClangModuleDependencyGraph {
549
560
return clangWithScanner. casDBs
550
561
}
551
562
563
+ package func generateReproducer( forFailedDependency dependency: DependencyInfo ,
564
+ libclangPath: Path , casOptions: CASOptions ? ) throws -> String ? {
565
+ let clangWithScanner = try libclangWithScanner (
566
+ forPath: libclangPath,
567
+ casOptions: casOptions,
568
+ cacheFallbackIfNotAvailable: false ,
569
+ core: core
570
+ )
571
+ guard clangWithScanner. libclang. supportsReproducerGeneration else {
572
+ return nil
573
+ }
574
+ return try clangWithScanner. scanner. generateReproducer (
575
+ commandLine: dependency. scanningCommandLine, workingDirectory: dependency. workingDirectory. str)
576
+ }
577
+
552
578
package var isEmpty : Bool {
553
579
recordedDependencyInfoRegistry. isEmpty
554
580
}
0 commit comments