Details
- Reviewers
arphaman akyrtzi rsmith - Commits
- rG1345ea2a05f4: Recommit r305117: [libclang] Merge multiple availability clauses when getting…
rG2e34be23a283: [libclang] Merge multiple availability clauses when getting the platform's…
rC305221: Recommit r305117: [libclang] Merge multiple availability clauses when
rC305117: [libclang] Merge multiple availability clauses when getting the platform's
rL305221: Recommit r305117: [libclang] Merge multiple availability clauses when
rL305117: [libclang] Merge multiple availability clauses when getting the platform's
Diff Detail
- Repository
- rL LLVM
Event Timeline
tools/libclang/CIndex.cpp | ||
---|---|---|
7287 ↗ | (On Diff #99979) | 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. |
7322 ↗ | (On Diff #99979) | You can use a ranged for loop here if you use take_front, e.g. for (const auto *Avail : AvailabilityAttrs.take_front(availability_size)) |
tools/libclang/CIndex.cpp | ||
---|---|---|
7322 ↗ | (On Diff #99979) | 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++; } } |
tools/libclang/CIndex.cpp | ||
---|---|---|
7322 ↗ | (On Diff #99979) | Right, sorry I forgot about the N. |
Rearrange if statements in getCursorPlatformAvailabilityForDecl to return early if we do not need to merge availability attributes.
Use ranged for loop.
It seems that there's a slight bug in the patch:
If I print the output of the following code using c-index-test -test-load-source all:
void bar2(void) __attribute__((availability(macosx, introduced=10.4))) __attribute__((availability(macosx, deprecated=10.5, message="use x")));
I see availability that includes a deprecation message: FunctionDecl=bar2:15:6 (deprecated) (macos, introduced=10.4, deprecated=10.5, message="use x").
However, if I look at the output of the following code:
void bar2(void) __attribute__((availability(macosx, deprecated=10.5, message="use x"))) __attribute__((availability(macosx, introduced=10.4)));
I get something that doesn't include the message: FunctionDecl=bar2:15:6 (deprecated) (macos, introduced=10.4, deprecated=10.5).
test/Index/availability.c | ||
---|---|---|
13 ↗ | (On Diff #101569) | Please add a test for merge of the obsoleted clause as well. |
tools/libclang/CIndex.cpp | ||
7239 ↗ | (On Diff #101569) | You should be able to keep the return here, since you will sort and unique the attributes in this call to getCursorPlatformAvailabilityForDecl. |
7255 ↗ | (On Diff #101569) | Please invert this if and return false early instead of leaving it at the end of the lambda. |
This should resolve the bug (a conditional was inverted) in the last revision along with the other changes requested.
This looks better, it's almost ready. A couple of small requests:
tools/libclang/CIndex.cpp | ||
---|---|---|
7262 ↗ | (On Diff #101787) | We should also have a test that verifies that we merge identical availabilities. |
7268 ↗ | (On Diff #101787) | I think that we don't really need the (!LHS->getMessage().empty() && !RHS->getMessage().empty()) check here since message has to be either in a deprecated or obsoleted clause, so we should already handle that with previous checks. |
test/Index/availability.c | ||
---|---|---|
20 ↗ | (On Diff #101787) | Sure, if the test passes we can use one FileCheck invocation. We can also use CHECK-DAG: to check for strings without obeying a specific order. |
Remove an unnecessary check when determining a mismatch of availabilities
Simplify invocation of FileCheck in availability.c
Ronald, I had to revert the commit as the availability.c test was failing on Linux (e.g. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/12532). Can you please look into that? I think you might have to got back to the CHECK-1 and CHECK-2 thing
I was able to build and test this on a linux box. The issue was the whitespace surrounding the regex.
On Linux, (unavailable) is not present. I.e,
FunctionDecl=foo:3:6 (ios, introduced=3.2, deprecated=4.1) (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
vs on macOS
FunctionDecl=foo:3:6 (unavailable) (ios, introduced=3.2, deprecated=4.1) (unavailable) (macos, introduced=10.4, deprecated=10.5, obsoleted=10.7)
I changed it to just match any characters between the function declaration and the availabilities.
Sorry for the noise.