Path: blob/main/contrib/llvm-project/clang/lib/AST/Availability.cpp
35260 views
//===- Availability.cpp --------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file implements the Availability information for Decls.9//10//===----------------------------------------------------------------------===//1112#include "clang/AST/Availability.h"13#include "clang/AST/ASTContext.h"14#include "clang/AST/Attr.h"15#include "clang/AST/Decl.h"16#include "clang/Basic/TargetInfo.h"1718namespace clang {1920AvailabilityInfo AvailabilityInfo::createFromDecl(const Decl *Decl) {21ASTContext &Context = Decl->getASTContext();22StringRef PlatformName = Context.getTargetInfo().getPlatformName();23AvailabilityInfo Availability;2425// Collect availability attributes from all redeclarations.26for (const auto *RD : Decl->redecls()) {27for (const auto *A : RD->specific_attrs<AvailabilityAttr>()) {28if (A->getPlatform()->getName() != PlatformName)29continue;30Availability = AvailabilityInfo(31A->getPlatform()->getName(), A->getIntroduced(), A->getDeprecated(),32A->getObsoleted(), A->getUnavailable(), false, false);33break;34}3536if (const auto *A = RD->getAttr<UnavailableAttr>())37if (!A->isImplicit())38Availability.UnconditionallyUnavailable = true;3940if (const auto *A = RD->getAttr<DeprecatedAttr>())41if (!A->isImplicit())42Availability.UnconditionallyDeprecated = true;43}44return Availability;45}4647} // namespace clang484950