llvm.org GIT mirror llvm / 125de50
Add assertions for out of bound index in ComputeLinearIndex git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225951 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 5 years ago
1 changed file(s) with 3 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
5050 return ComputeLinearIndex(*EI, Indices+1, IndicesEnd, CurIndex);
5151 CurIndex = ComputeLinearIndex(*EI, nullptr, nullptr, CurIndex);
5252 }
53 assert(!Indices && "Unexpected out of bound");
5354 return CurIndex;
5455 }
5556 // Given an array type, recursively traverse the elements.
5859 unsigned NumElts = ATy->getNumElements();
5960 // Compute the Linear offset when jumping one element of the array
6061 unsigned EltLinearOffset = ComputeLinearIndex(EltTy, nullptr, nullptr, 0);
61 if (Indices && *Indices < NumElts) {
62 if (Indices) {
63 assert(*Indices < NumElts && "Unexpected out of bound");
6264 // If the indice is inside the array, compute the index to the requested
6365 // elt and recurse inside the element with the end of the indices list
6466 CurIndex += EltLinearOffset* *Indices;
6567 return ComputeLinearIndex(EltTy, Indices+1, IndicesEnd, CurIndex);
6668 }
67 // Out of bound? Assert instead?
6869 CurIndex += EltLinearOffset*NumElts;
6970 return CurIndex;
7071 }