Skip to content

[sil] When parsing if we find an error when parsing a SILBasicBlock emit a misc error showing the block that failed. #34699

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

Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ ERROR(sil_basicblock_redefinition,none,
"redefinition of basic block %0", (Identifier))
ERROR(sil_basicblock_arg_rparen,none,
"expected ')' in basic block argument list", ())
// A backup error in case we are returned that we have an error but a diagnostic
// was not emitted.
ERROR(sil_failed_parse_basicblock, none, "Failed to parse SIL basic block", ())

// SIL Functions
ERROR(expected_sil_function_name,none,
Expand Down
5 changes: 4 additions & 1 deletion lib/SIL/Parser/ParseSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5880,8 +5880,11 @@ bool SILParserState::parseDeclSIL(Parser &P) {
};

do {
if (FunctionState.parseSILBasicBlock(B))
auto startLoc = P.Tok.getLoc();
if (FunctionState.parseSILBasicBlock(B)) {
P.Diags.diagnose(startLoc, diag::sil_failed_parse_basicblock);
return true;
}
} while (P.Tok.isNot(tok::r_brace) && P.Tok.isNot(tok::eof));

SourceLoc RBraceLoc;
Expand Down