Skip to content

Commit c9f7060

Browse files
committed
Use ASTGen with the new Swift parser when requested
When the experimental flag `ParserASTGen` is enabled, the compiler has ASTGen built, we're not performing code completion, and we're not parsing SIL... go through the new parser and ASTGen to build the abstract syntax tree.
1 parent 4da85ea commit c9f7060

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,15 @@ void Parser::parseTopLevel(SmallVectorImpl<Decl *> &decls) {
185185
StringRef contents =
186186
SourceMgr.extractText(SourceMgr.getRangeForBuffer(L->getBufferID()));
187187

188-
if (Context.LangOpts.hasFeature(Feature::ParserASTGen)) {
188+
#ifdef SWIFT_SWIFT_PARSER
189+
if (Context.LangOpts.hasFeature(Feature::ParserASTGen) &&
190+
!SourceMgr.hasCodeCompletionBuffer() &&
191+
SF.Kind != SourceFileKind::SIL) {
189192
parseTopLevelSwift(contents.data(), CurDeclContext, &Context, &decls, appendToVector);
190-
191-
for (auto decl : decls) {
192-
decl->dump();
193-
194-
if (auto fn = dyn_cast<FuncDecl>(decl))
195-
fn->getBody()->dump();
196-
}
197-
198193
return;
199194
}
200-
195+
#endif
196+
201197
// Prime the lexer.
202198
if (Tok.is(tok::NUM_TOKENS))
203199
consumeTokenWithoutFeedingReceiver();

0 commit comments

Comments
 (0)