[clang] [clang][ExtractAPI] Compute inherited availability information (PR #103040)

Cyndy Ishida via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 16:20:48 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) {
----------------
cyndyishida wrote:

nit: why not `std::optional`?

https://github.com/llvm/llvm-project/pull/103040


More information about the cfe-commits mailing list