[clang-tools-extra] c998273 - [pseudo] Fix an out-of-bound issue in getReduceRules.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 1 11:17:10 PDT 2022
Author: Haojian Wu
Date: 2022-07-01T20:16:06+02:00
New Revision: c99827349927a44334f2b04139168efd0bc87cd3
URL: https://github.com/llvm/llvm-project/commit/c99827349927a44334f2b04139168efd0bc87cd3
DIFF: https://github.com/llvm/llvm-project/commit/c99827349927a44334f2b04139168efd0bc87cd3.diff
LOG: [pseudo] Fix an out-of-bound issue in getReduceRules.
Added:
Modified:
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
Removed:
################################################################################
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 70ce52924f110..664a1a3206fe6 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
@@ -140,8 +140,11 @@ class LRTable {
// // ...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 {
More information about the cfe-commits
mailing list