This is an archive of the discontinued LLVM Phabricator instance.

[clang][ExtractAPI] Handle platform specific unavailability correctly
ClosedPublic

Authored by Arsenic on Feb 27 2023, 8:56 PM.

Details

Summary

This Patch gives ExtractAPI the ability to emit correct availability information for symbols marked as unavailable on a specific platform ( PR#60954 )

Diff Detail

Event Timeline

Arsenic created this revision.Feb 27 2023, 8:56 PM
Herald added a project: Restricted Project. · View Herald Transcript
Arsenic edited the summary of this revision. (Show Details)Feb 27 2023, 9:08 PM
Arsenic added reviewers: dang, zixuw.
Arsenic added a subscriber: Arsenic.
Arsenic published this revision for review.Feb 27 2023, 9:11 PM
Arsenic added inline comments.
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
550

These changes seems to have added by clang-format.
Is there a way to not let clang format edit the code that I haven't touched ?

Herald added a project: Restricted Project. · View Herald TranscriptFeb 27 2023, 9:11 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dang requested changes to this revision.Feb 28 2023, 3:57 AM

Nice! glad to see this getting fixed. You should add a lit test to ensure we don't regress this behavior in the future.

clang/include/clang/ExtractAPI/AvailabilityInfo.h
48

I don't think this change here is necessary.

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
550

Yes you can use git-clang-format, instructions here for setup: https://offlinemark.com/2021/04/02/surgical-formatting-with-git-clang-format/

This revision now requires changes to proceed.Feb 28 2023, 3:57 AM

Nice! glad to see this getting fixed. You should add a lit test to ensure we don't regress this behavior in the future.

I see a test checking for availability attribute already exists ( clang/test/ExtractAPI/availability.c ) would it be better if I update it with another function having a platform specific unavailability attribute or should I create a new test file ?

dang added a comment.Feb 28 2023, 4:48 AM

Nice! glad to see this getting fixed. You should add a lit test to ensure we don't regress this behavior in the future.

I see a test checking for availability attribute already exists ( clang/test/ExtractAPI/availability.c ) would it be better if I update it with another function having a platform specific unavailability attribute or should I create a new test file ?

Yes I think updating that test with another API that has a platform specific unavailability attribute is the best way to do this.

Arsenic updated this revision to Diff 501148.Feb 28 2023, 8:04 AM

Add test to check platform specific unavailability

The update also remove the useless changes that were introduced by
using clang format on the entire file instead of current commit.

dang accepted this revision.Feb 28 2023, 8:34 AM

LGTM, It's worth noting that if the user specifies that an API is unavailable in a later redeclaration, this will be ignored. For example if I add a line to the test void e(void) __attribute__((availability(macos, unavailable))); it will be ignored. Up to you whether you want to fix it now or at a later date.

This revision is now accepted and ready to land.Feb 28 2023, 8:34 AM
This revision was landed with ongoing or failed builds.Mar 2 2023, 7:50 AM
This revision was automatically updated to reflect the committed changes.