Commit 9e0439d1 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by V8 LUCI CQ

[torque] Only check ParseResultIterator after non-exceptional control flow

We sometimes use ReportError() inside of Torque parser actions.
The resulting exception prevented the ParseResultIterator from being
consumed completely, which in turn triggered a CHECK failure instead
of the correct error message.

Change-Id: Ie8dcdf67094e5ad5d68934e8a2921d5f52bd3092
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3306973
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Auto-Submit: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78184}
parent 5ab1ec1e
......@@ -54,7 +54,10 @@ base::Optional<ParseResult> Rule::RunAction(const Item* completed_item,
MatchedInput matched_input = completed_item->GetMatchedInput(tokens);
CurrentSourcePosition::Scope pos_scope(matched_input.pos);
ParseResultIterator iterator(std::move(results), matched_input);
return action_(&iterator);
auto result = action_(&iterator);
// Make sure the parse action consumed all the child results.
CHECK(!iterator.HasNext());
return result;
}
Symbol& Symbol::operator=(std::initializer_list<Rule> rules) {
......
......@@ -163,10 +163,7 @@ class ParseResultIterator {
explicit ParseResultIterator(std::vector<ParseResult> results,
MatchedInput matched_input)
: results_(std::move(results)), matched_input_(matched_input) {}
~ParseResultIterator() {
// Check that all parse results have been used.
CHECK_EQ(results_.size(), i_);
}
ParseResultIterator(const ParseResultIterator&) = delete;
ParseResultIterator& operator=(const ParseResultIterator&) = delete;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment