diff options
author | Kazu Hirata <kazu@google.com> | 2021-12-08 20:35:39 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2021-12-08 20:35:39 -0800 |
commit | c23ebf17140cc4fd42117f3bfb8cb045279d0c4d (patch) | |
tree | 5eae726c8d0385a682fca71c5aa959093d3402f7 /llvm/lib/IR/Constants.cpp | |
parent | aebd932bc4bfe52605249722d46ec64b06905672 (diff) | |
download | llvm-c23ebf17140cc4fd42117f3bfb8cb045279d0c4d.zip llvm-c23ebf17140cc4fd42117f3bfb8cb045279d0c4d.tar.gz llvm-c23ebf17140cc4fd42117f3bfb8cb045279d0c4d.tar.bz2 |
[llvm] Use range-based for loops (NFC)
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r-- | llvm/lib/IR/Constants.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index c66cfb6..a118f4d 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -1296,9 +1296,10 @@ Constant *ConstantArray::getImpl(ArrayType *Ty, ArrayRef<Constant*> V) { if (V.empty()) return ConstantAggregateZero::get(Ty); - for (unsigned i = 0, e = V.size(); i != e; ++i) { - assert(V[i]->getType() == Ty->getElementType() && + for (Constant *C : V) { + assert(C->getType() == Ty->getElementType() && "Wrong type in array element initializer"); + (void)C; } // If this is an all-zero array, return a ConstantAggregateZero object. If @@ -1364,12 +1365,12 @@ Constant *ConstantStruct::get(StructType *ST, ArrayRef<Constant*> V) { isZero = V[0]->isNullValue(); // PoisonValue inherits UndefValue, so its check is not necessary. if (isUndef || isZero) { - for (unsigned i = 0, e = V.size(); i != e; ++i) { - if (!V[i]->isNullValue()) + for (Constant *C : V) { + if (!C->isNullValue()) isZero = false; - if (!isa<PoisonValue>(V[i])) + if (!isa<PoisonValue>(C)) isPoison = false; - if (isa<PoisonValue>(V[i]) || !isa<UndefValue>(V[i])) + if (isa<PoisonValue>(C) || !isa<UndefValue>(C)) isUndef = false; } } |