[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

Ronald Wampler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 2 09:36:30 PDT 2017


rdwampler added inline comments.


================
Comment at: tools/libclang/CIndex.cpp:7322
+
+  for (int I = 0, E = AvailabilityAttrs.size(); I < E && I < availability_size;
+       ++I) {
----------------
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++;
  }
}
```


https://reviews.llvm.org/D33478





More information about the cfe-commits mailing list