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

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 2 07:33:24 PDT 2017


arphaman added inline comments.


================
Comment at: tools/libclang/CIndex.cpp:7287
+
   if (!HadAvailAttr)
     if (const EnumConstantDecl *EnumConst = dyn_cast<EnumConstantDecl>(D))
----------------
I think that you can move this `if` before the new `if`, and convert the new `if` to be an `if (AvailabilityAttrs.empty())` that returns early. Then you can do the merging outside of the `if` at the end of the function.


================
Comment at: tools/libclang/CIndex.cpp:7322
+
+  for (int I = 0, E = AvailabilityAttrs.size(); I < E && I < availability_size;
+       ++I) {
----------------
You can use a ranged for loop here if you use `take_front`, e.g.

```
for (const auto *Avail : AvailabilityAttrs.take_front(availability_size))
```


https://reviews.llvm.org/D33478





More information about the cfe-commits mailing list