[PATCH] D120723: [pseudo] Fix an out-of-bound error in LRTable::find.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 3 07:30:48 PST 2022
sammccall added inline comments.
================
Comment at: clang/lib/Tooling/Syntax/Pseudo/LRTable.cpp:115
TargetedStates, [&Src](LRTable::StateID S) { return S < Src; });
- if (It == TargetedStates.end())
+ if (Start == TargetedStates.end())
return {};
----------------
hokein wrote:
> sammccall wrote:
> > I think this check is no longer needed
> sorry, should have thought more carefully on this comment, we need this check to make sure we don't access `Actions[Actions.end()]` on Line120 below.
Sorry about that.
You're right, we formally do &*Actions[Actions.size()], which is invalid.
However we don't actually need a runtime check, just a change of syntax to avoid the dereference:
`return llvm::makeArrayRef(Actions.data() + (Start - States.data()), End - Start);`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120723/new/
https://reviews.llvm.org/D120723
More information about the cfe-commits
mailing list