mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Frontend: Honor warning suppression when parsing arguments from swiftinterfaces.
Diagnostics are suppressed when parsing swiftinterface files, since the warnings emitted from compiling the swiftinterface of a dependency would just be a nuisance. It follows that warnings generated when parsing the arguments in a swiftinterface file should also be suppressed, but that wasn't happening because the diagnostic engine of the main compile was used for parsing. Pass the diagnostic engine of the compiler subinstance instead, and proactively suppress warnings before parsing begins. Resolves rdar://142814164.
This commit is contained in:
@@ -1814,8 +1814,9 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
|
||||
}
|
||||
|
||||
bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
|
||||
CompilerInvocation &subInvocation, SwiftInterfaceInfo &interfaceInfo,
|
||||
StringRef interfacePath, SourceLoc diagnosticLoc) {
|
||||
CompilerInvocation &subInvocation, DiagnosticEngine &subInstanceDiags,
|
||||
SwiftInterfaceInfo &interfaceInfo, StringRef interfacePath,
|
||||
SourceLoc diagnosticLoc) {
|
||||
if (readSwiftInterfaceVersionAndArgs(SM, *Diags, ArgSaver, interfaceInfo,
|
||||
interfacePath, diagnosticLoc,
|
||||
subInvocation.getLangOptions().Target))
|
||||
@@ -1833,7 +1834,7 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
|
||||
}
|
||||
|
||||
SmallString<32> ExpectedModuleName = subInvocation.getModuleName();
|
||||
if (subInvocation.parseArgs(interfaceInfo.Arguments, *Diags)) {
|
||||
if (subInvocation.parseArgs(interfaceInfo.Arguments, subInstanceDiags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2236,11 +2237,25 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
|
||||
subInvocation.getFrontendOptions().InputsAndOutputs
|
||||
.setMainAndSupplementaryOutputs(outputFiles, ModuleOutputPaths);
|
||||
|
||||
CompilerInstance subInstance;
|
||||
ForwardingDiagnosticConsumer FDC(*Diags);
|
||||
NullDiagnosticConsumer noopConsumer;
|
||||
if (!silenceErrors) {
|
||||
subInstance.addDiagnosticConsumer(&FDC);
|
||||
} else {
|
||||
subInstance.addDiagnosticConsumer(&noopConsumer);
|
||||
}
|
||||
|
||||
// Eagerly suppress warnings if necessary, before parsing arguments.
|
||||
if (subInvocation.getDiagnosticOptions().SuppressWarnings)
|
||||
subInstance.getDiags().setSuppressWarnings(true);
|
||||
|
||||
SwiftInterfaceInfo interfaceInfo;
|
||||
// Extract compiler arguments from the interface file and use them to configure
|
||||
// the compiler invocation.
|
||||
if (extractSwiftInterfaceVersionAndArgs(subInvocation, interfaceInfo,
|
||||
interfacePath, diagLoc)) {
|
||||
if (extractSwiftInterfaceVersionAndArgs(subInvocation, subInstance.getDiags(),
|
||||
interfaceInfo, interfacePath,
|
||||
diagLoc)) {
|
||||
return std::make_error_code(std::errc::not_supported);
|
||||
}
|
||||
|
||||
@@ -2252,21 +2267,12 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
|
||||
subInvocation.getFrontendOptions().StrictImplicitModuleContext =
|
||||
StrictImplicitModuleContext;
|
||||
|
||||
CompilerInstance subInstance;
|
||||
SubCompilerInstanceInfo info;
|
||||
info.Instance = &subInstance;
|
||||
info.CompilerVersion = interfaceInfo.CompilerVersion;
|
||||
|
||||
subInstance.getSourceMgr().setFileSystem(SM.getFileSystem());
|
||||
|
||||
ForwardingDiagnosticConsumer FDC(*Diags);
|
||||
NullDiagnosticConsumer noopConsumer;
|
||||
if (!silenceErrors) {
|
||||
subInstance.addDiagnosticConsumer(&FDC);
|
||||
} else {
|
||||
subInstance.addDiagnosticConsumer(&noopConsumer);
|
||||
}
|
||||
|
||||
std::string InstanceSetupError;
|
||||
if (subInstance.setup(subInvocation, InstanceSetupError)) {
|
||||
return std::make_error_code(std::errc::not_supported);
|
||||
|
||||
Reference in New Issue
Block a user