Skip to content

Commit f14bb31

Browse files
committed
[ASTGen] Update swift_parse_test_main for ParseSourceFileRequest change
1 parent 9930101 commit f14bb31

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lib/DriverTool/swift_parse_test_main.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "swift/Basic/LLVM.h"
1919
#include "swift/Basic/LangOptions.h"
2020
#include "swift/Bridging/ASTGen.h"
21-
#include "swift/Parse/Parser.h"
2221
#include "swift/Subsystems.h"
2322
#include "llvm/Support/CommandLine.h"
2423
#include "llvm/Support/Error.h"
@@ -86,6 +85,9 @@ struct LibParseExecutor {
8685
std::unique_ptr<ASTContext> ctx(ASTContext::get(
8786
langOpts, typeckOpts, silOpts, searchPathOpts, clangOpts, symbolOpts,
8887
casOpts, serializationOpts, SM, diagEngine));
88+
auto &eval = ctx->evaluator;
89+
registerParseRequestFunctions(eval);
90+
registerTypeCheckerRequestFunctions(eval);
8991

9092
SourceFile::ParsingOptions parseOpts;
9193
parseOpts |= SourceFile::ParsingFlags::DisablePoundIfEvaluation;
@@ -96,13 +98,9 @@ struct LibParseExecutor {
9698
SourceFile *SF =
9799
new (*ctx) SourceFile(*M, SourceFileKind::Library, bufferID, parseOpts);
98100

99-
Parser parser(bufferID, *SF, /*SILParserState=*/nullptr);
100-
SmallVector<ASTNode> items;
101-
parser.parseTopLevelItems(items);
101+
auto items = evaluateOrDefault(eval, ParseSourceFileRequest{SF}, {}).TopLevelItems;
102102

103103
if (opts.contains(ExecuteOptionFlag::Dump)) {
104-
registerParseRequestFunctions(ctx->evaluator);
105-
registerTypeCheckerRequestFunctions(ctx->evaluator);
106104
for (auto &item : items) {
107105
item.dump(llvm::outs());
108106
}
@@ -163,8 +161,9 @@ struct ASTGenExecutor {
163161
std::unique_ptr<ASTContext> ctx(ASTContext::get(
164162
langOpts, typeckOpts, silOpts, searchPathOpts, clangOpts, symbolOpts,
165163
casOpts, serializationOpts, SM, diagEngine));
166-
registerParseRequestFunctions(ctx->evaluator);
167-
registerTypeCheckerRequestFunctions(ctx->evaluator);
164+
auto &eval = ctx->evaluator;
165+
registerParseRequestFunctions(eval);
166+
registerTypeCheckerRequestFunctions(eval);
168167

169168
SourceFile::ParsingOptions parseOpts;
170169
parseOpts |= SourceFile::ParsingFlags::DisablePoundIfEvaluation;
@@ -175,9 +174,7 @@ struct ASTGenExecutor {
175174
SourceFile *SF =
176175
new (*ctx) SourceFile(*M, SourceFileKind::Library, bufferID, parseOpts);
177176

178-
Parser P(bufferID, *SF, nullptr);
179-
SmallVector<ASTNode> items;
180-
P.parseTopLevelItems(items);
177+
auto items = evaluateOrDefault(eval, ParseSourceFileRequest{SF}, {}).TopLevelItems;
181178

182179
if (opts.contains(ExecuteOptionFlag::Dump)) {
183180
for (auto &item : items) {

0 commit comments

Comments
 (0)