[PATCH] D71714: [Sema] Fix -Warray-bounds false negative when casting an out-of-bounds array item

Ilya Mirsky via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 23 13:19:16 PST 2019


ilya marked an inline comment as done.
ilya added a comment.

In D71714#1791464 <https://reviews.llvm.org/D71714#1791464>, @riccibruno wrote:

> These are not the only AST nodes representing cast expressions (there is also `CXXFunctionalCastExpr`, ...). What about replacing the `IgnoreParenImpCasts()` above by `IgnoreParenCasts()` ? Incidentally doing this uncovers another test (`Parser/cxx-ambig-decl-expr.cpp )` where this diagnostic is triggered.


Thanks, using `IgnoreParenCasts` is even better.



================
Comment at: clang/lib/Sema/SemaChecking.cpp:13384
       case Stmt::MemberExprClass: {
         expr = cast<MemberExpr>(expr)->getBase();
         break;
----------------
rsmith wrote:
> Hmm, don't we need to do different things for dot and arrow in this case?
There are several test cases for an out of bounds access on an array member using dot and arrow operators in array-bounds.cpp. Do you have a specific test case for which you think the code is broken?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71714/new/

https://reviews.llvm.org/D71714





More information about the cfe-commits mailing list