aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/Analysis.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2021-02-21 19:58:07 -0800
committerKazu Hirata <kazu@google.com>2021-02-21 19:58:07 -0800
commitffba9e596d09a1d41f83102756e145b59d3f8495 (patch)
treeb5cc2badfc7d3f85ea950a1c1335ab4279ca74be /llvm/lib/CodeGen/Analysis.cpp
parent5032b5890bb43895012585bd29ff5c3fbd1a7812 (diff)
downloadllvm-ffba9e596d09a1d41f83102756e145b59d3f8495.zip
llvm-ffba9e596d09a1d41f83102756e145b59d3f8495.tar.gz
llvm-ffba9e596d09a1d41f83102756e145b59d3f8495.tar.bz2
[CodeGen] Use range-based for loops (NFC)
Diffstat (limited to 'llvm/lib/CodeGen/Analysis.cpp')
-rw-r--r--llvm/lib/CodeGen/Analysis.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp
index ebeff1f..5d1b004 100644
--- a/llvm/lib/CodeGen/Analysis.cpp
+++ b/llvm/lib/CodeGen/Analysis.cpp
@@ -43,13 +43,11 @@ unsigned llvm::ComputeLinearIndex(Type *Ty,
// Given a struct type, recursively traverse the elements.
if (StructType *STy = dyn_cast<StructType>(Ty)) {
- for (StructType::element_iterator EB = STy->element_begin(),
- EI = EB,
- EE = STy->element_end();
- EI != EE; ++EI) {
- if (Indices && *Indices == unsigned(EI - EB))
- return ComputeLinearIndex(*EI, Indices+1, IndicesEnd, CurIndex);
- CurIndex = ComputeLinearIndex(*EI, nullptr, nullptr, CurIndex);
+ for (auto I : llvm::enumerate(STy->elements())) {
+ Type *ET = I.value();
+ if (Indices && *Indices == I.index())
+ return ComputeLinearIndex(ET, Indices + 1, IndicesEnd, CurIndex);
+ CurIndex = ComputeLinearIndex(ET, nullptr, nullptr, CurIndex);
}
assert(!Indices && "Unexpected out of bound");
return CurIndex;