[PATCH] D144964: [clang][ExtractAPI] Handle platform specific unavailability correctly
Ankur Saini via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 28 06:53:48 PST 2023
Arsenic created this revision.
Herald added a reviewer: ributzka.
Herald added a project: All.
Arsenic requested review of this revision.
Herald added a reviewer: dang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This Patch gives ExtractAPI the ability to emit correct availability
information for symbols marked as unavailable on a specific platform
( PR#60954 )
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144964
Files:
clang/include/clang/ExtractAPI/AvailabilityInfo.h
clang/lib/ExtractAPI/AvailabilityInfo.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/availability.c
Index: clang/test/ExtractAPI/availability.c
===================================================================
--- clang/test/ExtractAPI/availability.c
+++ clang/test/ExtractAPI/availability.c
@@ -26,6 +26,9 @@
void f(void) __attribute__((unavailable)) __attribute__((availability(macos, introduced=11.0)));
void d(void) __attribute__((availability(tvos, introduced=15.0)));
+
+void e(void) __attribute__((availability(tvos, unavailable)));
+
///expected-no-diagnostics
//--- reference.output.json.in
@@ -391,6 +394,10 @@
"minor": 0,
"patch": 0
}
+ },
+ {
+ "domain": "tvos",
+ "isUnconditionallyUnavailable": true
}
],
"declarationFragments": [
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===================================================================
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -171,12 +171,16 @@
for (const auto &AvailInfo : Availabilities) {
Object Availability;
Availability["domain"] = AvailInfo.Domain;
- serializeObject(Availability, "introducedVersion",
- serializeSemanticVersion(AvailInfo.Introduced));
- serializeObject(Availability, "deprecatedVersion",
- serializeSemanticVersion(AvailInfo.Deprecated));
- serializeObject(Availability, "obsoletedVersion",
- serializeSemanticVersion(AvailInfo.Obsoleted));
+ if (AvailInfo.Unavailable)
+ Availability["isUnconditionallyUnavailable"] = true;
+ else {
+ serializeObject(Availability, "introducedVersion",
+ serializeSemanticVersion(AvailInfo.Introduced));
+ serializeObject(Availability, "deprecatedVersion",
+ serializeSemanticVersion(AvailInfo.Deprecated));
+ serializeObject(Availability, "obsoletedVersion",
+ serializeSemanticVersion(AvailInfo.Obsoleted));
+ }
AvailabilityArray.emplace_back(std::move(Availability));
}
Index: clang/lib/ExtractAPI/AvailabilityInfo.cpp
===================================================================
--- clang/lib/ExtractAPI/AvailabilityInfo.cpp
+++ clang/lib/ExtractAPI/AvailabilityInfo.cpp
@@ -42,8 +42,8 @@
Availability->Obsoleted = Attr->getObsoleted();
} else {
Availabilities.emplace_back(Domain, Attr->getIntroduced(),
- Attr->getDeprecated(),
- Attr->getObsoleted());
+ Attr->getDeprecated(), Attr->getObsoleted(),
+ Attr->getUnavailable());
}
}
}
Index: clang/include/clang/ExtractAPI/AvailabilityInfo.h
===================================================================
--- clang/include/clang/ExtractAPI/AvailabilityInfo.h
+++ clang/include/clang/ExtractAPI/AvailabilityInfo.h
@@ -33,12 +33,14 @@
VersionTuple Introduced;
VersionTuple Deprecated;
VersionTuple Obsoleted;
+ bool Unavailable;
AvailabilityInfo() = default;
AvailabilityInfo(StringRef Domain, VersionTuple I, VersionTuple D,
- VersionTuple O)
- : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O) {}
+ VersionTuple O, bool U)
+ : Domain(Domain), Introduced(I), Deprecated(D), Obsoleted(O),
+ Unavailable(U) {}
};
class AvailabilitySet {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144964.501123.patch
Type: text/x-patch
Size: 3500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230228/966c5043/attachment-0001.bin>
More information about the cfe-commits
mailing list