Skip to content

Commit 07e66a4

Browse files
authored
[Parse] Dead code elimination (#5041)
1 parent 1a03db4 commit 07e66a4

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

lib/Parse/ParseStmt.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -392,21 +392,6 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
392392
Result, Result.getEndLoc());
393393
TLCD->setBody(Brace);
394394
Entries.push_back(TLCD);
395-
396-
// If the parsed stmt was a GuardStmt, push the VarDecls into the
397-
// Entries list, so that they can be found by unqual name lookup later.
398-
if (!IsTopLevel) {
399-
auto resultStmt = Result.dyn_cast<Stmt*>();
400-
if (auto guard = dyn_cast_or_null<GuardStmt>(resultStmt)) {
401-
for (const auto &elt : guard->getCond()) {
402-
if (!elt.getPatternOrNull()) continue;
403-
404-
elt.getPattern()->forEachVariable([&](VarDecl *VD) {
405-
Entries.push_back(VD);
406-
});
407-
}
408-
}
409-
}
410395
}
411396
} else if (Tok.is(tok::kw_init) && isa<ConstructorDecl>(CurDeclContext)) {
412397
SourceLoc StartLoc = Tok.getLoc();
@@ -422,15 +407,6 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
422407
if (ExprOrStmtStatus.isError())
423408
NeedParseErrorRecovery = true;
424409
diagnoseDiscardedClosure(*this, Result);
425-
if (ExprOrStmtStatus.isSuccess() && IsTopLevel) {
426-
// If this is a normal library, you can't have expressions or
427-
// statements outside at the top level.
428-
diagnose(Tok.getLoc(),
429-
Result.is<Stmt*>() ? diag::illegal_top_level_stmt
430-
: diag::illegal_top_level_expr);
431-
Result = ASTNode();
432-
}
433-
434410
if (!Result.isNull())
435411
Entries.push_back(Result);
436412
}

0 commit comments

Comments
 (0)