This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Emit -Warray-bounds for multiple levels of subscript expressions.
ClosedPublic

Authored by ebevhan on Apr 20 2018, 1:21 AM.

Details

Summary

This patch has CheckArrayBounds recurse into
ArraySubscriptExprs and MemberExprs, giving
warnings for invalid indices for every level of
subscript instead of just the topmost one.

Diff Detail

Event Timeline

ebevhan created this revision.Apr 20 2018, 1:21 AM
aaron.ballman added inline comments.
lib/Sema/SemaChecking.cpp
11284

Can use const auto * here instead of spelling the type out twice. Alternatively, you could skip the local variable entirely if you want.

test/SemaCXX/array-bounds.cpp
275

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?

ebevhan updated this revision to Diff 143684.Apr 24 2018, 1:19 AM

Removed local variable and added some more to the test.

This revision is now accepted and ready to land.Apr 24 2018, 4:11 AM

Thank you! I do not have commit rights, so if someone could commit this that would be great.

Committed in r330759, thank you for the patch!