[PATCH] D45865: [Sema] Emit -Warray-bounds for multiple levels of subscript expressions.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 23 11:32:33 PDT 2018


aaron.ballman added a reviewer: rsmith.
aaron.ballman added inline comments.


================
Comment at: lib/Sema/SemaChecking.cpp:11284
+      case Stmt::MemberExprClass: {
+        const MemberExpr *ME = cast<MemberExpr>(expr);
+        expr = ME->getBase();
----------------
Can use `const auto *` here instead of spelling the type out twice. Alternatively, you could skip the local variable entirely if you want.


================
Comment at: test/SemaCXX/array-bounds.cpp:275
+int test_multiarray() {
+  return multi[2][0][0]; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+}
----------------
Can you also add tests for `multi[0][2][0]` and `multi[0][0][2]` to more clearly demonstrate that all levels of array indexing are checked?


Repository:
  rC Clang

https://reviews.llvm.org/D45865





More information about the cfe-commits mailing list