Skip to content

Commit 81dc7d8

Browse files
committed
[Parse] Remove TypeChecker and SIL options parameter from ParserUnit
Providing these is a bit of a layering violation, the parser shouldn't care about these options (there does seem to be one current use of `TypeCheckerOpts` in the parser for designated operator types, but that's a legacy feature that was never officially supported).
1 parent 389202e commit 81dc7d8

File tree

6 files changed

+16
-27
lines changed

6 files changed

+16
-27
lines changed

include/swift/Subsystems.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ namespace swift {
327327
class ParserUnit {
328328
public:
329329
ParserUnit(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID,
330-
const LangOptions &LangOpts, const TypeCheckerOptions &TyOpts,
331-
const SILOptions &SILOpts, StringRef ModuleName);
330+
const LangOptions &LangOpts, StringRef ModuleName);
332331
ParserUnit(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID);
333332
ParserUnit(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID,
334333
unsigned Offset, unsigned EndOffset);

lib/Parse/ParseDecl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ AvailabilityMacroMap &Parser::parseAllAvailabilityMacroArguments() {
21352135
for (unsigned bufferID: bufferIDs) {
21362136
// Create temporary parser.
21372137
swift::ParserUnit PU(SM, SourceFileKind::Main, bufferID, LangOpts,
2138-
TypeCheckerOptions(), SILOptions(), "unknown");
2138+
"unknown");
21392139

21402140
ForwardingDiagnosticConsumer PDC(Context.Diags);
21412141
PU.getDiagnosticEngine().addConsumer(PDC);

lib/Parse/Parser.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -1132,9 +1132,9 @@ struct ParserUnit::Implementation {
11321132
std::unique_ptr<Parser> TheParser;
11331133

11341134
Implementation(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID,
1135-
const LangOptions &Opts, const TypeCheckerOptions &TyOpts,
1136-
const SILOptions &silOpts, StringRef ModuleName)
1137-
: LangOpts(Opts), TypeCheckerOpts(TyOpts), SILOpts(silOpts), Diags(SM),
1135+
const LangOptions &Opts, StringRef ModuleName)
1136+
: LangOpts(Opts), TypeCheckerOpts(TypeCheckerOptions()),
1137+
SILOpts(SILOptions()), Diags(SM),
11381138
Ctx(*ASTContext::get(LangOpts, TypeCheckerOpts, SILOpts, SearchPathOpts,
11391139
clangImporterOpts, symbolGraphOpts, CASOpts, SM,
11401140
Diags)) {
@@ -1156,23 +1156,19 @@ struct ParserUnit::Implementation {
11561156

11571157
ParserUnit::ParserUnit(SourceManager &SM, SourceFileKind SFKind,
11581158
unsigned BufferID)
1159-
: ParserUnit(SM, SFKind, BufferID, LangOptions(), TypeCheckerOptions(),
1160-
SILOptions(), "input") {}
1159+
: ParserUnit(SM, SFKind, BufferID, LangOptions(), "input") {}
11611160

11621161
ParserUnit::ParserUnit(SourceManager &SM, SourceFileKind SFKind,
11631162
unsigned BufferID, const LangOptions &LangOpts,
1164-
const TypeCheckerOptions &TypeCheckOpts,
1165-
const SILOptions &SILOpts, StringRef ModuleName)
1166-
: Impl(*new Implementation(SM, SFKind, BufferID, LangOpts, TypeCheckOpts,
1167-
SILOpts, ModuleName)) {
1163+
StringRef ModuleName)
1164+
: Impl(*new Implementation(SM, SFKind, BufferID, LangOpts, ModuleName)) {
11681165
Impl.TheParser.reset(new Parser(BufferID, *Impl.SF, /*SIL=*/nullptr,
11691166
/*PersistentState=*/nullptr));
11701167
}
11711168

11721169
ParserUnit::ParserUnit(SourceManager &SM, SourceFileKind SFKind,
11731170
unsigned BufferID, unsigned Offset, unsigned EndOffset)
1174-
: Impl(*new Implementation(SM, SFKind, BufferID, LangOptions(),
1175-
TypeCheckerOptions(), SILOptions(), "input")) {
1171+
: Impl(*new Implementation(SM, SFKind, BufferID, LangOptions(), "input")) {
11761172

11771173
std::unique_ptr<Lexer> Lex;
11781174
Lex.reset(new Lexer(Impl.LangOpts, SM,

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,9 @@ class SwiftDocumentSyntaxInfo {
745745

746746
BufferID = SM.addNewSourceBuffer(std::move(BufCopy));
747747

748-
Parser.reset(new ParserUnit(
749-
SM, SourceFileKind::Main, BufferID, CompInv.getLangOptions(),
750-
CompInv.getTypeCheckerOptions(), CompInv.getSILOptions(),
751-
CompInv.getModuleName()));
748+
Parser.reset(new ParserUnit(SM, SourceFileKind::Main, BufferID,
749+
CompInv.getLangOptions(),
750+
CompInv.getModuleName()));
752751

753752
registerTypeCheckerRequestFunctions(
754753
Parser->getParser().Context.evaluator);

tools/swift-ide-test/swift-ide-test.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -2000,10 +2000,8 @@ static int doSyntaxColoring(const CompilerInvocation &InitInvok,
20002000
SourceManager SM;
20012001
unsigned BufferID = SM.addNewSourceBuffer(std::move(FileBuf));
20022002

2003-
ParserUnit Parser(
2004-
SM, SourceFileKind::Main, BufferID, Invocation.getLangOptions(),
2005-
Invocation.getTypeCheckerOptions(), Invocation.getSILOptions(),
2006-
Invocation.getModuleName());
2003+
ParserUnit Parser(SM, SourceFileKind::Main, BufferID,
2004+
Invocation.getLangOptions(), Invocation.getModuleName());
20072005

20082006
registerTypeCheckerRequestFunctions(Parser.getParser().Context.evaluator);
20092007
registerClangImporterRequestFunctions(Parser.getParser().Context.evaluator);
@@ -2229,9 +2227,7 @@ static int doStructureAnnotation(const CompilerInvocation &InitInvok,
22292227
unsigned BufferID = SM.addNewSourceBuffer(std::move(FileBuf));
22302228

22312229
ParserUnit Parser(SM, SourceFileKind::Main, BufferID,
2232-
Invocation.getLangOptions(),
2233-
Invocation.getTypeCheckerOptions(),
2234-
Invocation.getSILOptions(), Invocation.getModuleName());
2230+
Invocation.getLangOptions(), Invocation.getModuleName());
22352231

22362232
registerTypeCheckerRequestFunctions(
22372233
Parser.getParser().Context.evaluator);

unittests/Parse/TokenizerTests.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class TokenizerTest : public ::testing::Test {
8282
}
8383

8484
std::vector<Token> parseAndGetSplitTokens(unsigned BufID) {
85-
swift::ParserUnit PU(SM, SourceFileKind::Main, BufID, LangOpts,
86-
TypeCheckerOptions(), SILOptions(), "unknown");
85+
swift::ParserUnit PU(SM, SourceFileKind::Main, BufID, LangOpts, "unknown");
8786
SmallVector<ASTNode, 8> items;
8887
PU.getParser().parseTopLevelItems(items);
8988
return PU.getParser().getSplitTokens();

0 commit comments

Comments
 (0)