https://github.com/sofiaromorales created 
https://github.com/llvm/llvm-project/pull/76823

Currently, ExtractAPI provides availability information for all platforms 
within a given domain. With this change, we narrow down the output to include 
availability details only for the specified target platform, so users can 
generate the symbol graph with only the availability information they need, 
omitting information of the other platforms.

This change reverts the functionality introduced in 
[`57c9780`](https://github.com/llvm/llvm-project/commit/57c9780).

rdar://120419037


From d459421cc3a59f56c27eaeafd81ec2c2366b9fa7 Mon Sep 17 00:00:00 2001
From: Sofia Rodriguez <sofia_rodrig...@apple.com>
Date: Wed, 3 Jan 2024 15:29:45 +0100
Subject: [PATCH] [clang][ExtractAPI] Record availability information only for
 the target platform.

Currently, ExtractAPI provides availability information for all platforms 
within a given domain.
With this change, we narrow down the output to include availability details 
only for the specified target platform,
so users can generate the symbol graph with only the availability information 
they need, omitting information of the other platforms.

This change reverts the functionality introduced in `57c9780`.
---
 clang/lib/ExtractAPI/AvailabilityInfo.cpp |  8 ++++++++
 clang/test/ExtractAPI/availability.c      | 20 --------------------
 2 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/clang/lib/ExtractAPI/AvailabilityInfo.cpp 
b/clang/lib/ExtractAPI/AvailabilityInfo.cpp
index 1df852fdbf9304..0c578de227ade1 100644
--- a/clang/lib/ExtractAPI/AvailabilityInfo.cpp
+++ b/clang/lib/ExtractAPI/AvailabilityInfo.cpp
@@ -1,11 +1,17 @@
 #include "clang/ExtractAPI/AvailabilityInfo.h"
 #include "clang/AST/Attr.h"
 #include "llvm/ADT/STLExtras.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang;
 using namespace extractapi;
 
 AvailabilitySet::AvailabilitySet(const Decl *Decl) {
+    
+  ASTContext &Context = Decl->getASTContext();
+  StringRef PlatformName = Context.getTargetInfo().getPlatformName();
+    
   // Collect availability attributes from all redeclrations.
   for (const auto *RD : Decl->redecls()) {
     if (const auto *A = RD->getAttr<UnavailableAttr>()) {
@@ -24,6 +30,8 @@ AvailabilitySet::AvailabilitySet(const Decl *Decl) {
 
     for (const auto *Attr : RD->specific_attrs<AvailabilityAttr>()) {
       StringRef Domain = Attr->getPlatform()->getName();
+      if (Domain != PlatformName)
+        continue;
       auto *Availability =
           llvm::find_if(Availabilities, [Domain](const AvailabilityInfo &Info) 
{
             return Domain.equals(Info.Domain);
diff --git a/clang/test/ExtractAPI/availability.c 
b/clang/test/ExtractAPI/availability.c
index 4bda94ba7c2bf9..3c1ef5c45b634d 100644
--- a/clang/test/ExtractAPI/availability.c
+++ b/clang/test/ExtractAPI/availability.c
@@ -300,22 +300,6 @@ void e(void) __attribute__((availability(tvos, 
unavailable)));
             "minor": 0,
             "patch": 0
           }
-        },
-        {
-          "domain": "ios",
-          "introduced": {
-            "major": 13,
-            "minor": 0,
-            "patch": 0
-          }
-        },
-        {
-          "domain": "tvos",
-          "introduced": {
-            "major": 15,
-            "minor": 0,
-            "patch": 0
-          }
         }
       ],
       "declarationFragments": [
@@ -394,10 +378,6 @@ void e(void) __attribute__((availability(tvos, 
unavailable)));
             "minor": 0,
             "patch": 0
           }
-        },
-        {
-          "domain": "tvos",
-          "isUnconditionallyUnavailable": true
         }
       ],
       "declarationFragments": [

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to