mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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).
This commit is contained in:
@@ -327,8 +327,7 @@ namespace swift {
|
||||
class ParserUnit {
|
||||
public:
|
||||
ParserUnit(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID,
|
||||
const LangOptions &LangOpts, const TypeCheckerOptions &TyOpts,
|
||||
const SILOptions &SILOpts, StringRef ModuleName);
|
||||
const LangOptions &LangOpts, StringRef ModuleName);
|
||||
ParserUnit(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID);
|
||||
ParserUnit(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID,
|
||||
unsigned Offset, unsigned EndOffset);
|
||||
|
||||
@@ -2135,7 +2135,7 @@ AvailabilityMacroMap &Parser::parseAllAvailabilityMacroArguments() {
|
||||
for (unsigned bufferID: bufferIDs) {
|
||||
// Create temporary parser.
|
||||
swift::ParserUnit PU(SM, SourceFileKind::Main, bufferID, LangOpts,
|
||||
TypeCheckerOptions(), SILOptions(), "unknown");
|
||||
"unknown");
|
||||
|
||||
ForwardingDiagnosticConsumer PDC(Context.Diags);
|
||||
PU.getDiagnosticEngine().addConsumer(PDC);
|
||||
|
||||
@@ -1132,9 +1132,9 @@ struct ParserUnit::Implementation {
|
||||
std::unique_ptr<Parser> TheParser;
|
||||
|
||||
Implementation(SourceManager &SM, SourceFileKind SFKind, unsigned BufferID,
|
||||
const LangOptions &Opts, const TypeCheckerOptions &TyOpts,
|
||||
const SILOptions &silOpts, StringRef ModuleName)
|
||||
: LangOpts(Opts), TypeCheckerOpts(TyOpts), SILOpts(silOpts), Diags(SM),
|
||||
const LangOptions &Opts, StringRef ModuleName)
|
||||
: LangOpts(Opts), TypeCheckerOpts(TypeCheckerOptions()),
|
||||
SILOpts(SILOptions()), Diags(SM),
|
||||
Ctx(*ASTContext::get(LangOpts, TypeCheckerOpts, SILOpts, SearchPathOpts,
|
||||
clangImporterOpts, symbolGraphOpts, CASOpts, SM,
|
||||
Diags)) {
|
||||
@@ -1156,23 +1156,19 @@ struct ParserUnit::Implementation {
|
||||
|
||||
ParserUnit::ParserUnit(SourceManager &SM, SourceFileKind SFKind,
|
||||
unsigned BufferID)
|
||||
: ParserUnit(SM, SFKind, BufferID, LangOptions(), TypeCheckerOptions(),
|
||||
SILOptions(), "input") {}
|
||||
: ParserUnit(SM, SFKind, BufferID, LangOptions(), "input") {}
|
||||
|
||||
ParserUnit::ParserUnit(SourceManager &SM, SourceFileKind SFKind,
|
||||
unsigned BufferID, const LangOptions &LangOpts,
|
||||
const TypeCheckerOptions &TypeCheckOpts,
|
||||
const SILOptions &SILOpts, StringRef ModuleName)
|
||||
: Impl(*new Implementation(SM, SFKind, BufferID, LangOpts, TypeCheckOpts,
|
||||
SILOpts, ModuleName)) {
|
||||
StringRef ModuleName)
|
||||
: Impl(*new Implementation(SM, SFKind, BufferID, LangOpts, ModuleName)) {
|
||||
Impl.TheParser.reset(new Parser(BufferID, *Impl.SF, /*SIL=*/nullptr,
|
||||
/*PersistentState=*/nullptr));
|
||||
}
|
||||
|
||||
ParserUnit::ParserUnit(SourceManager &SM, SourceFileKind SFKind,
|
||||
unsigned BufferID, unsigned Offset, unsigned EndOffset)
|
||||
: Impl(*new Implementation(SM, SFKind, BufferID, LangOptions(),
|
||||
TypeCheckerOptions(), SILOptions(), "input")) {
|
||||
: Impl(*new Implementation(SM, SFKind, BufferID, LangOptions(), "input")) {
|
||||
|
||||
std::unique_ptr<Lexer> Lex;
|
||||
Lex.reset(new Lexer(Impl.LangOpts, SM,
|
||||
|
||||
@@ -745,10 +745,9 @@ public:
|
||||
|
||||
BufferID = SM.addNewSourceBuffer(std::move(BufCopy));
|
||||
|
||||
Parser.reset(new ParserUnit(
|
||||
SM, SourceFileKind::Main, BufferID, CompInv.getLangOptions(),
|
||||
CompInv.getTypeCheckerOptions(), CompInv.getSILOptions(),
|
||||
CompInv.getModuleName()));
|
||||
Parser.reset(new ParserUnit(SM, SourceFileKind::Main, BufferID,
|
||||
CompInv.getLangOptions(),
|
||||
CompInv.getModuleName()));
|
||||
|
||||
registerTypeCheckerRequestFunctions(
|
||||
Parser->getParser().Context.evaluator);
|
||||
|
||||
@@ -2000,10 +2000,8 @@ static int doSyntaxColoring(const CompilerInvocation &InitInvok,
|
||||
SourceManager SM;
|
||||
unsigned BufferID = SM.addNewSourceBuffer(std::move(FileBuf));
|
||||
|
||||
ParserUnit Parser(
|
||||
SM, SourceFileKind::Main, BufferID, Invocation.getLangOptions(),
|
||||
Invocation.getTypeCheckerOptions(), Invocation.getSILOptions(),
|
||||
Invocation.getModuleName());
|
||||
ParserUnit Parser(SM, SourceFileKind::Main, BufferID,
|
||||
Invocation.getLangOptions(), Invocation.getModuleName());
|
||||
|
||||
registerTypeCheckerRequestFunctions(Parser.getParser().Context.evaluator);
|
||||
registerClangImporterRequestFunctions(Parser.getParser().Context.evaluator);
|
||||
@@ -2229,9 +2227,7 @@ static int doStructureAnnotation(const CompilerInvocation &InitInvok,
|
||||
unsigned BufferID = SM.addNewSourceBuffer(std::move(FileBuf));
|
||||
|
||||
ParserUnit Parser(SM, SourceFileKind::Main, BufferID,
|
||||
Invocation.getLangOptions(),
|
||||
Invocation.getTypeCheckerOptions(),
|
||||
Invocation.getSILOptions(), Invocation.getModuleName());
|
||||
Invocation.getLangOptions(), Invocation.getModuleName());
|
||||
|
||||
registerTypeCheckerRequestFunctions(
|
||||
Parser.getParser().Context.evaluator);
|
||||
|
||||
@@ -82,8 +82,7 @@ public:
|
||||
}
|
||||
|
||||
std::vector<Token> parseAndGetSplitTokens(unsigned BufID) {
|
||||
swift::ParserUnit PU(SM, SourceFileKind::Main, BufID, LangOpts,
|
||||
TypeCheckerOptions(), SILOptions(), "unknown");
|
||||
swift::ParserUnit PU(SM, SourceFileKind::Main, BufID, LangOpts, "unknown");
|
||||
SmallVector<ASTNode, 8> items;
|
||||
PU.getParser().parseTopLevelItems(items);
|
||||
return PU.getParser().getSplitTokens();
|
||||
|
||||
Reference in New Issue
Block a user