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:
David Farler
2016-03-30 15:48:35 -07:00
parent 15467ac0e7
commit fc9e4938e1
3 changed files with 39 additions and 0 deletions

View File

@@ -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)