[pseudo] Fix an out-of-bound issue in getReduceRules.

This commit is contained in:
Haojian Wu 2022-07-01 20:16:06 +02:00
parent 6e8ec13d3f
commit c998273499
1 changed files with 4 additions and 1 deletions

View File

@ -140,8 +140,11 @@ public:
// // ...apply reduce...
// }
llvm::ArrayRef<RuleID> getReduceRules(StateID State) const {
if (ReduceOffset[State] >= Reduces.size())
return {};
size_t Length = ReduceOffset[State + 1] - ReduceOffset[State];
return llvm::makeArrayRef(&Reduces[ReduceOffset[State]],
&Reduces[ReduceOffset[State + 1]]);
Length);
}
// Returns whether Terminal can follow Nonterminal in a valid source file.
bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const {