clang
19.0.0git
lib
AST
Availability.cpp
Go to the documentation of this file.
1
//===- Availability.cpp --------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements the Availability information for Decls.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "
clang/AST/Availability.h
"
14
#include "
clang/AST/ASTContext.h
"
15
#include "
clang/AST/Attr.h
"
16
#include "
clang/AST/Decl.h
"
17
#include "
clang/Basic/TargetInfo.h
"
18
19
namespace
clang
{
20
21
AvailabilityInfo
AvailabilityInfo::createFromDecl
(
const
Decl
*
Decl
) {
22
ASTContext
&Context =
Decl
->
getASTContext
();
23
StringRef PlatformName = Context.getTargetInfo().getPlatformName();
24
AvailabilityInfo
Availability;
25
26
// Collect availability attributes from all redeclarations.
27
for
(
const
auto
*RD :
Decl
->
redecls
()) {
28
for
(
const
auto
*A : RD->specific_attrs<AvailabilityAttr>()) {
29
if
(A->getPlatform()->getName() != PlatformName)
30
continue
;
31
Availability =
AvailabilityInfo
(
32
A->getPlatform()->getName(), A->getIntroduced(), A->getDeprecated(),
33
A->getObsoleted(), A->getUnavailable(),
false
,
false
);
34
break
;
35
}
36
37
if
(
const
auto
*A = RD->getAttr<UnavailableAttr>())
38
if
(!A->isImplicit())
39
Availability.
UnconditionallyUnavailable
=
true
;
40
41
if
(
const
auto
*A = RD->getAttr<DeprecatedAttr>())
42
if
(!A->isImplicit())
43
Availability.
UnconditionallyDeprecated
=
true
;
44
}
45
return
Availability;
46
}
47
48
}
// namespace clang
ASTContext.h
Defines the clang::ASTContext interface.
Attr.h
Availability.h
Decl.h
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition:
ASTContext.h:182
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition:
DeclBase.h:86
clang::Decl::getASTContext
ASTContext & getASTContext() const LLVM_READONLY
Definition:
DeclBase.cpp:501
clang::Decl::redecls
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition:
DeclBase.h:1039
TargetInfo.h
Defines the clang::TargetInfo interface.
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition:
CalledOnceCheck.h:17
clang::AvailabilityInfo
Storage of availability attributes for a declaration.
Definition:
Availability.h:64
clang::AvailabilityInfo::AvailabilityInfo
AvailabilityInfo()=default
clang::AvailabilityInfo::UnconditionallyDeprecated
bool UnconditionallyDeprecated
Definition:
Availability.h:71
clang::AvailabilityInfo::createFromDecl
static AvailabilityInfo createFromDecl(const Decl *Decl)
Definition:
Availability.cpp:21
clang::AvailabilityInfo::UnconditionallyUnavailable
bool UnconditionallyUnavailable
Definition:
Availability.h:72
Generated on Tue Apr 30 2024 15:34:50 for clang by
1.9.6