mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-03 08:26:07 +00:00

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
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
#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::extractapi;
|
|
using namespace llvm;
|
|
|
|
AvailabilityInfo AvailabilityInfo::createFromDecl(const Decl *Decl) {
|
|
ASTContext &Context = Decl->getASTContext();
|
|
StringRef PlatformName = Context.getTargetInfo().getPlatformName();
|
|
AvailabilityInfo Availability;
|
|
|
|
// Collect availability attributes from all redeclarations.
|
|
for (const auto *RD : Decl->redecls()) {
|
|
for (const auto *A : RD->specific_attrs<AvailabilityAttr>()) {
|
|
if (A->getPlatform()->getName() != PlatformName)
|
|
continue;
|
|
Availability =
|
|
AvailabilityInfo(A->getPlatform()->getName(), A->getIntroduced(),
|
|
A->getDeprecated(), A->getObsoleted(), false, false);
|
|
break;
|
|
}
|
|
|
|
if (const auto *A = RD->getAttr<UnavailableAttr>())
|
|
if (!A->isImplicit())
|
|
Availability.UnconditionallyUnavailable = true;
|
|
|
|
if (const auto *A = RD->getAttr<DeprecatedAttr>())
|
|
if (!A->isImplicit())
|
|
Availability.UnconditionallyDeprecated = true;
|
|
}
|
|
return Availability;
|
|
}
|