Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gardening][Parse] Dead code elimination #5041

Merged
merged 1 commit into from
Sep 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions lib/Parse/ParseStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,21 +392,6 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
Result, Result.getEndLoc());
TLCD->setBody(Brace);
Entries.push_back(TLCD);

// If the parsed stmt was a GuardStmt, push the VarDecls into the
// Entries list, so that they can be found by unqual name lookup later.
if (!IsTopLevel) {
auto resultStmt = Result.dyn_cast<Stmt*>();
if (auto guard = dyn_cast_or_null<GuardStmt>(resultStmt)) {
for (const auto &elt : guard->getCond()) {
if (!elt.getPatternOrNull()) continue;

elt.getPattern()->forEachVariable([&](VarDecl *VD) {
Entries.push_back(VD);
});
}
}
}
}
} else if (Tok.is(tok::kw_init) && isa<ConstructorDecl>(CurDeclContext)) {
SourceLoc StartLoc = Tok.getLoc();
Expand All @@ -422,15 +407,6 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
if (ExprOrStmtStatus.isError())
NeedParseErrorRecovery = true;
diagnoseDiscardedClosure(*this, Result);
if (ExprOrStmtStatus.isSuccess() && IsTopLevel) {
// If this is a normal library, you can't have expressions or
// statements outside at the top level.
diagnose(Tok.getLoc(),
Result.is<Stmt*>() ? diag::illegal_top_level_stmt
: diag::illegal_top_level_expr);
Result = ASTNode();
}

if (!Result.isNull())
Entries.push_back(Result);
}
Expand Down