[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations
Ziqing Luo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 28 13:07:51 PST 2022
ziqingluo-90 added a comment.
> One test case I'd like to see is: `sizeof(p[0])` -- should code in an unevaluated context be warned?
I think they should NOT be warned. We haven't addressed the issue of unevaluated context in our patches. I'm adding a test for code in unevaluated context so that we don't forget about it later.
> Can you also add tests for function declarations like:
>
> void foo(int not_really_an_array[10]) { ... }
>
> template <int N>
> void bar(int (&actually_an_array)[N]) { ... }
>
> // Using a dependent type but we know it's a pointer.
> template <typename Ty>
> void baz(Ty *ptr) { ... }
>
> // Using a dependent type where we have no idea if it's a pointer.
> template <typename Ty>
> void quux(Ty ptr) { ... }
Thanks for suggesting these test cases. They have been added in one of the following patches (https://reviews.llvm.org/D138318). That patch improves the matchers to recognize these cases.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137379/new/
https://reviews.llvm.org/D137379
More information about the cfe-commits
mailing list