[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)
Daniel Grumberg via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 14 03:01:07 PDT 2024
================
@@ -16,33 +16,101 @@
#include "clang/AST/Decl.h"
#include "clang/Basic/TargetInfo.h"
-namespace clang {
+namespace {
+
+struct AvailabilitySet {
+ llvm::SmallVector<clang::AvailabilityInfo> Availabilities;
+ bool UnconditionallyDeprecated = false;
+ bool UnconditionallyUnavailable = false;
-AvailabilityInfo AvailabilityInfo::createFromDecl(const Decl *Decl) {
- ASTContext &Context = Decl->getASTContext();
- StringRef PlatformName = Context.getTargetInfo().getPlatformName();
- AvailabilityInfo Availability;
+ void insert(clang::AvailabilityInfo &&Availability) {
+ auto *Found = getForPlatform(Availability.Domain);
+ if (Found)
+ Found->mergeWith(std::move(Availability));
+ else
+ Availabilities.emplace_back(std::move(Availability));
+ }
+
+ clang::AvailabilityInfo *getForPlatform(llvm::StringRef Domain) {
----------------
daniel-grumberg wrote:
The semantic is that you get a reference of the thing inside the Availabilities vector if it exist (this method is used by `insert` and not just `AvailabilityInfo::createFromDecl`), to express that with `std::optional<AvailabilityInfo &>` which doesn't exist.
https://github.com/llvm/llvm-project/pull/103040
More information about the cfe-commits
mailing list