@@ -137,8 +137,11 @@ void ModuleInterfaceBuilder::configureSubInvocation(
137
137
bool ModuleInterfaceBuilder::extractSwiftInterfaceVersionAndArgs (
138
138
swift::version::Version &Vers, StringRef &CompilerVersion,
139
139
llvm::StringSaver &SubArgSaver, SmallVectorImpl<const char *> &SubArgs) {
140
+ llvm::vfs::FileSystem &fs = *sourceMgr.getFileSystem ();
140
141
auto FileOrError = swift::vfs::getFileOrSTDIN (fs, interfacePath);
141
142
if (!FileOrError) {
143
+ // Don't use this->diagnose() because it'll just try to re-open
144
+ // interfacePath.
142
145
diags.diagnose (diagnosticLoc, diag::error_open_input_file,
143
146
interfacePath, FileOrError.getError ().message ());
144
147
return true ;
@@ -149,17 +152,16 @@ bool ModuleInterfaceBuilder::extractSwiftInterfaceVersionAndArgs(
149
152
auto FlagRe = getSwiftInterfaceModuleFlagsRegex ();
150
153
SmallVector<StringRef, 1 > VersMatches, FlagMatches, CompMatches;
151
154
if (!VersRe.match (SB, &VersMatches)) {
152
- diags.diagnose (diagnosticLoc,
153
- diag::error_extracting_version_from_module_interface);
155
+ diagnose (diag::error_extracting_version_from_module_interface);
154
156
return true ;
155
157
}
156
158
if (!FlagRe.match (SB, &FlagMatches)) {
157
- diags.diagnose (diagnosticLoc,
158
- diag::error_extracting_flags_from_module_interface);
159
+ diagnose (diag::error_extracting_flags_from_module_interface);
159
160
return true ;
160
161
}
161
162
assert (VersMatches.size () == 2 );
162
163
assert (FlagMatches.size () == 2 );
164
+ // FIXME We should diagnose this at a location that makes sense:
163
165
Vers = swift::version::Version (VersMatches[1 ], SourceLoc (), &diags);
164
166
llvm::cl::TokenizeGNUCommandLine (FlagMatches[1 ], SubArgSaver, SubArgs);
165
167
@@ -178,6 +180,8 @@ bool ModuleInterfaceBuilder::extractSwiftInterfaceVersionAndArgs(
178
180
bool ModuleInterfaceBuilder::collectDepsForSerialization (
179
181
CompilerInstance &SubInstance, SmallVectorImpl<FileDependency> &Deps,
180
182
bool IsHashBased) {
183
+ llvm::vfs::FileSystem &fs = *sourceMgr.getFileSystem ();
184
+
181
185
auto &Opts = SubInstance.getASTContext ().SearchPathOpts ;
182
186
SmallString<128 > SDKPath (Opts.SDKPath );
183
187
path::native (SDKPath);
@@ -267,6 +271,8 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
267
271
llvm::RestorePrettyStackState (savedInnerPrettyStackState);
268
272
};
269
273
274
+ llvm::vfs::FileSystem &fs = *sourceMgr.getFileSystem ();
275
+
270
276
// Note that we don't assume cachePath is the same as the Clang
271
277
// module cache path at this point.
272
278
if (!moduleCachePath.empty ())
@@ -296,9 +302,8 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
296
302
// minor versions might be interesting for debugging, or special-casing a
297
303
// compatible field variant.
298
304
if (Vers.asMajorVersion () != InterfaceFormatVersion.asMajorVersion ()) {
299
- diags.diagnose (diagnosticLoc,
300
- diag::unsupported_version_of_module_interface,
301
- interfacePath, Vers);
305
+ diagnose (diag::unsupported_version_of_module_interface, interfacePath,
306
+ Vers);
302
307
SubError = true ;
303
308
return ;
304
309
}
@@ -313,8 +318,7 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
313
318
auto DiagKind = diag::serialization_name_mismatch;
314
319
if (subInvocation.getLangOptions ().DebuggerSupport )
315
320
DiagKind = diag::serialization_name_mismatch_repl;
316
- diags.diagnose (diagnosticLoc, DiagKind, subInvocation.getModuleName (),
317
- ExpectedModuleName);
321
+ diagnose (DiagKind, subInvocation.getModuleName (), ExpectedModuleName);
318
322
SubError = true ;
319
323
return ;
320
324
}
@@ -341,9 +345,9 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
341
345
auto builtByCompiler =
342
346
getSwiftInterfaceCompilerVersionForCurrentCompiler (
343
347
SubInstance.getASTContext ());
344
- diags. diagnose (diagnosticLoc, diag::module_interface_build_failed,
345
- moduleName, emittedByCompiler == builtByCompiler,
346
- emittedByCompiler, builtByCompiler);
348
+ diagnose (diag::module_interface_build_failed, moduleName ,
349
+ emittedByCompiler == builtByCompiler, emittedByCompiler ,
350
+ builtByCompiler);
347
351
}
348
352
};
349
353
@@ -439,8 +443,7 @@ bool ModuleInterfaceBuilder::buildSwiftModule(StringRef OutPath,
439
443
// necessary for performance. Fallback to building the module in case of any lock
440
444
// related errors.
441
445
if (RemarkRebuild) {
442
- diags.diagnose (SourceLoc (), diag::interface_file_lock_failure,
443
- interfacePath);
446
+ diagnose (diag::interface_file_lock_failure, interfacePath);
444
447
}
445
448
// Clear out any potential leftover.
446
449
Locked.unsafeRemoveLockFile ();
@@ -472,8 +475,7 @@ bool ModuleInterfaceBuilder::buildSwiftModule(StringRef OutPath,
472
475
// another process to complete the build so swift does not do it done
473
476
// twice. If case of timeout, build it ourselves.
474
477
if (RemarkRebuild) {
475
- diags.diagnose (SourceLoc (), diag::interface_file_lock_timed_out,
476
- interfacePath);
478
+ diagnose (diag::interface_file_lock_timed_out, interfacePath);
477
479
}
478
480
// Clear the lock file so that future invocations can make progress.
479
481
Locked.unsafeRemoveLockFile ();
0 commit comments