[NFC][DA] Remove duplicate code in checkSrcSubscript and checkDstSubscript
[DA] Move common code in checkSrcSubscript and checkDstSubscript to a
new function checkSubscript. This avoids duplicate code and possible
out of sync in the future.
Reviewers: sebpop, jmolloy, reames
Reviewed By: sebpop
Subscribers: bmahjour, hiraditya, llvm-commits, amehsan
Differential Revision: https://reviews.llvm.org/D71087
Patch by zhongduo.