[llvm-dev] Question about LLVM Rel10 llvm/IR/AsmWriter.cpp
James Courtier-Dutton via llvm-dev
llvm-dev at lists.llvm.org
Wed Nov 11 15:57:57 PST 2020
Hi,
See fuller extract below.
I am curious about the for loop.
for (unsigned i = 1, e = CA->getNumElements(); i != e; ++i) {
What happens when CA->getNumElements() is zero ? Infinite loop????
Wouldn't the following be better. i.e. safer:
for (unsigned i = 1; i < CA->getNumElements(); i++) {
Kind Regards
James
At about line 1429:
Type *ETy = CA->getType()->getElementType();
Out << '[';
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getElementAsConstant(0),
&TypePrinter, Machine,
Context);
for (unsigned i = 1, e = CA->getNumElements(); i != e; ++i) {
Out << ", ";
TypePrinter.print(ETy, Out);
Out << ' ';
WriteAsOperandInternal(Out, CA->getElementAsConstant(i), &TypePrinter,
Machine, Context);
}
Out << ']';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201111/a75e4b34/attachment.html>
More information about the llvm-dev
mailing list