mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Suppress warnings for non-primary inputs
Don't emit warnings if specified at the command line or when working on a non-primary input file. https://bugs.swift.org/browse/SR-1012 rdar://problem/25282622
This commit is contained in:
@@ -430,6 +430,10 @@ void CompilerInstance::performSema() {
|
||||
if (BufferID == PrimaryBufferID)
|
||||
setPrimarySourceFile(NextInput);
|
||||
|
||||
auto &Diags = NextInput->getASTContext().Diags;
|
||||
auto DidSuppressWarnings = Diags.getSuppressWarnings();
|
||||
Diags.setSuppressWarnings(DidSuppressWarnings || BufferID != PrimaryBufferID);
|
||||
|
||||
bool Done;
|
||||
do {
|
||||
// Parser may stop at some erroneous constructions like #else, #endif
|
||||
@@ -438,6 +442,8 @@ void CompilerInstance::performSema() {
|
||||
&PersistentState, DelayedCB.get());
|
||||
} while (!Done);
|
||||
|
||||
Diags.setSuppressWarnings(DidSuppressWarnings);
|
||||
|
||||
performNameBinding(*NextInput);
|
||||
}
|
||||
|
||||
@@ -471,6 +477,11 @@ void CompilerInstance::performSema() {
|
||||
|
||||
SourceFile &MainFile =
|
||||
MainModule->getMainSourceFile(Invocation.getSourceFileKind());
|
||||
|
||||
auto &Diags = MainFile.getASTContext().Diags;
|
||||
auto DidSuppressWarnings = Diags.getSuppressWarnings();
|
||||
Diags.setSuppressWarnings(DidSuppressWarnings || !mainIsPrimary);
|
||||
|
||||
SILParserState SILContext(TheSILModule.get());
|
||||
unsigned CurTUElem = 0;
|
||||
bool Done;
|
||||
@@ -488,6 +499,8 @@ void CompilerInstance::performSema() {
|
||||
}
|
||||
CurTUElem = MainFile.Decls.size();
|
||||
} while (!Done);
|
||||
|
||||
Diags.setSuppressWarnings(DidSuppressWarnings);
|
||||
|
||||
if (mainIsPrimary && !Context->hadError() &&
|
||||
Invocation.getFrontendOptions().PlaygroundTransform)
|
||||
|
||||
Reference in New Issue
Block a user