Skip to content

Commit ea16419

Browse files
committed
[Parse] Check the SourceFile for warning suppression
Move the logic for warning suppression out of the frontend and into `parseIntoSourceFile`.
1 parent f56b061 commit ea16419

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -970,16 +970,7 @@ void CompilerInstance::parseLibraryFile(
970970
SourceFileKind::Library, implicitImports.kind, BufferID);
971971
addAdditionalInitialImportsTo(NextInput, implicitImports);
972972

973-
auto IsPrimary = isWholeModuleCompilation() || isPrimaryInput(BufferID);
974-
975-
auto &Diags = NextInput->getASTContext().Diags;
976-
auto DidSuppressWarnings = Diags.getSuppressWarnings();
977-
Diags.setSuppressWarnings(DidSuppressWarnings || !IsPrimary);
978-
979973
parseIntoSourceFile(*NextInput, BufferID);
980-
981-
Diags.setSuppressWarnings(DidSuppressWarnings);
982-
983974
performNameBinding(*NextInput);
984975
}
985976

lib/ParseSIL/ParseSIL.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ void swift::parseIntoSourceFile(SourceFile &SF, unsigned int BufferID) {
128128
SF.SyntaxParsingCache, SF.getASTContext().getSyntaxArena());
129129
}
130130

131+
// If we've been asked to silence warnings, do so now. This is needed for
132+
// secondary files, which can be parsed multiple times.
133+
auto &diags = ctx.Diags;
134+
auto didSuppressWarnings = diags.getSuppressWarnings();
135+
auto shouldSuppress = SF.getParsingOptions().contains(
136+
SourceFile::ParsingFlags::SuppressWarnings);
137+
diags.setSuppressWarnings(didSuppressWarnings || shouldSuppress);
138+
SWIFT_DEFER { diags.setSuppressWarnings(didSuppressWarnings); };
139+
131140
// If this buffer is for code completion, hook up the state needed by its
132141
// second pass.
133142
PersistentParserState *state = nullptr;

0 commit comments

Comments
 (0)