arphaman added inline comments.
================ Comment at: tools/libclang/CIndex.cpp:7322 + + for (int I = 0, E = AvailabilityAttrs.size(); I < E && I < availability_size; + ++I) { ---------------- rdwampler wrote: > arphaman wrote: > > You can use a ranged for loop here if you use `take_front`, e.g. > > > > ``` > > for (const auto *Avail : AvailabilityAttrs.take_front(availability_size)) > > ``` > I would need to covert this to an `ArrayRef`, I believe. Also, I would need > to check `availability_size` is in bounds. Would something like the following > be preferred: > ``` > int N = 0; > for (const auto *Avail : AvailabilityAttrs) { > if (N < availability_size) { > // populate availability > N++; > } > } > ``` Right, sorry I forgot about the `N`. I think that you can use `llvm::enumerate(llvm::makeArrayRef(AvailabilityAttrs).take_front(availability_size))` to get rid of `N` as well, as you can the index and the attribute pointer from the loop variable. Btw, The `take_front(N)` will ensure that you will only iterate either over the first N attributes or all of the attributes if `N > AvailabilityAttrs.size()`, so you won't need to check `N` in the loop. https://reviews.llvm.org/D33478 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits