diff --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h index 664a1a3206fe..d48095670496 100644 --- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h +++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h @@ -140,11 +140,9 @@ public: // // ...apply reduce... // } llvm::ArrayRef getReduceRules(StateID State) const { - if (ReduceOffset[State] >= Reduces.size()) - return {}; - size_t Length = ReduceOffset[State + 1] - ReduceOffset[State]; - return llvm::makeArrayRef(&Reduces[ReduceOffset[State]], - Length); + assert(State + 1u < ReduceOffset.size()); + return llvm::makeArrayRef(Reduces.data() + ReduceOffset[State], + Reduces.data() + ReduceOffset[State+1]); } // Returns whether Terminal can follow Nonterminal in a valid source file. bool canFollow(SymbolID Nonterminal, SymbolID Terminal) const {