[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
https://github.com/daniel-grumberg closed https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
https://github.com/daniel-grumberg approved this pull request. https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
@@ -16,67 +16,61 @@ #define LLVM_CLANG_EXTRACTAPI_AVAILABILITY_INFO_H #include "clang/AST/Decl.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/Support/Error.h" #include "llvm/Support/VersionTuple.h" #include "llvm/Support/raw_ostream.h" - -using llvm::VersionTuple; +#include daniel-grumberg wrote: I don't think this is needed? https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
@@ -1,50 +1,33 @@ #include "clang/ExtractAPI/AvailabilityInfo.h" +#include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" +#include "clang/Basic/TargetInfo.h" #include "llvm/ADT/STLExtras.h" using namespace clang; using namespace extractapi; -AvailabilitySet::AvailabilitySet(const Decl *Decl) { - // Collect availability attributes from all redeclrations. - for (const auto *RD : Decl->redecls()) { -if (const auto *A = RD->getAttr()) { - if (!A->isImplicit()) { -this->Availabilities.clear(); -UnconditionallyUnavailable = true; - } -} +AvailabilityInfo::AvailabilityInfo(const Decl *Decl) { daniel-grumberg wrote: I would prefer if this wasn't a constructor but rather a static type method of with signature: ```c++ AvailabilityInfo createFromDecl(const Decl *D); ``` that way you don't have to do line 19-21 in that way. https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
@@ -256,14 +256,14 @@ struct APIRecord { APIRecord() = delete; APIRecord(RecordKind Kind, StringRef USR, StringRef Name, -PresumedLoc Location, AvailabilitySet Availabilities, +PresumedLoc Location, const AvailabilityInfo &Availability, daniel-grumberg wrote: Can you keep this as a value and bring back the `std::move` below, this allows to prevent unnecessary copies. https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
@@ -61,17 +61,17 @@ APISet::addNamespace(APIRecord *Parent, StringRef Name, StringRef USR, GlobalVariableRecord * APISet::addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc, - AvailabilitySet Availabilities, LinkageInfo Linkage, + const AvailabilityInfo &Availability, LinkageInfo Linkage, const DocComment &Comment, DeclarationFragments Fragments, DeclarationFragments SubHeading, bool IsFromSystemHeader) { return addTopLevelRecord(USRBasedLookupTable, GlobalVariables, USR, Name, Loc, - std::move(Availabilities), Linkage, Comment, - Fragments, SubHeading, IsFromSystemHeader); + Availability, Linkage, Comment, Fragments, daniel-grumberg wrote: Can you make sure that all of Availabilities are `std::move` https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
@@ -45,7 +45,7 @@ RecordTy *addTopLevelRecord(DenseMap &USRLookupTable, NamespaceRecord * APISet::addNamespace(APIRecord *Parent, StringRef Name, StringRef USR, - PresumedLoc Loc, AvailabilitySet Availability, + PresumedLoc Loc, const AvailabilityInfo &Availability, daniel-grumberg wrote: Can we keep these as plain values (i.e. just `AvailabilityInfo Availability`), this prevents the move operation below and leads to a copy. Additionally, this prevents copy ellision with how we pass the parameters in. https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
sofiaromorales wrote: @QuietMisdreavus https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
sofiaromorales wrote: @daniel-grumberg https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
https://github.com/sofiaromorales updated https://github.com/llvm/llvm-project/pull/76823 From d459421cc3a59f56c27eaeafd81ec2c2366b9fa7 Mon Sep 17 00:00:00 2001 From: Sofia Rodriguez Date: Wed, 3 Jan 2024 15:29:45 +0100 Subject: [PATCH 1/2] [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()) { @@ -24,6 +30,8 @@ AvailabilitySet::AvailabilitySet(const Decl *Decl) { for (const auto *Attr : RD->specific_attrs()) { 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": [ From 24237a4b9fff2ccf17c23e6f4e6b00ad605acb1a Mon Sep 17 00:00:00 2001 From: Sofia Rodriguez Date: Wed, 3 Jan 2024 16:13:30 +0100 Subject: [PATCH 2/2] Fix format. --- clang/lib/ExtractAPI/AvailabilityInfo.cpp | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/clang/lib/ExtractAPI/AvailabilityInfo.cpp b/clang/lib/ExtractAPI/AvailabilityInfo.cpp index 0c578de227ade1..7af33453a4c770 100644 --- a/clang/lib/ExtractAPI/AvailabilityInfo.cpp +++ b/clang/lib/ExtractAPI/AvailabilityInfo.cpp @@ -1,17 +1,15 @@ #include "clang/ExtractAPI/AvailabilityInfo.h" -#include "clang/AST/Attr.h" -#include "llvm/ADT/STLExtras.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/Attr.h" #include "clang/Basic/TargetInfo.h" +#include "llvm/ADT/STLExtras.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()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 0d19a8983c05de321d8ab592995e7a36bca448ee d459421cc3a59f56c27eaeafd81ec2c2366b9fa7 -- clang/lib/ExtractAPI/AvailabilityInfo.cpp clang/test/ExtractAPI/availability.c `` View the diff from clang-format here. ``diff diff --git a/clang/lib/ExtractAPI/AvailabilityInfo.cpp b/clang/lib/ExtractAPI/AvailabilityInfo.cpp index 0c578de227..a11666bb7d 100644 --- a/clang/lib/ExtractAPI/AvailabilityInfo.cpp +++ b/clang/lib/ExtractAPI/AvailabilityInfo.cpp @@ -1,17 +1,17 @@ #include "clang/ExtractAPI/AvailabilityInfo.h" -#include "clang/AST/Attr.h" -#include "llvm/ADT/STLExtras.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/Attr.h" #include "clang/Basic/TargetInfo.h" +#include "llvm/ADT/STLExtras.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()) { `` https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Sofía Rodríguez (sofiaromorales) Changes 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 --- Full diff: https://github.com/llvm/llvm-project/pull/76823.diff 2 Files Affected: - (modified) clang/lib/ExtractAPI/AvailabilityInfo.cpp (+8) - (modified) clang/test/ExtractAPI/availability.c (-20) ``diff 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()) { @@ -24,6 +30,8 @@ AvailabilitySet::AvailabilitySet(const Decl *Decl) { for (const auto *Attr : RD->specific_attrs()) { 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": [ `` https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/76823 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)
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 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()) { @@ -24,6 +30,8 @@ AvailabilitySet::AvailabilitySet(const Decl *Decl) { for (const auto *Attr : RD->specific_attrs()) { 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