blob: ada64cfb92e641684edde28eacf42351290ec134 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include "clang/ExtractAPI/AvailabilityInfo.h"
#include "clang/AST/Attr.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<UnavailableAttr>()) {
if (!A->isImplicit()) {
this->Availabilities.clear();
UnconditionallyUnavailable = true;
}
}
if (const auto *A = RD->getAttr<DeprecatedAttr>()) {
if (!A->isImplicit()) {
this->Availabilities.clear();
UnconditionallyDeprecated = true;
}
}
for (const auto *Attr : RD->specific_attrs<AvailabilityAttr>()) {
StringRef Domain = Attr->getPlatform()->getName();
auto *Availability =
llvm::find_if(Availabilities, [Domain](const AvailabilityInfo &Info) {
return Domain.equals(Info.Domain);
});
if (Availability != Availabilities.end()) {
// Get the highest introduced version for all redeclarations.
if (Availability->Introduced < Attr->getIntroduced())
Availability->Introduced = Attr->getIntroduced();
// Get the lowest deprecated version for all redeclarations.
if (Availability->Deprecated > Attr->getDeprecated())
Availability->Deprecated = Attr->getDeprecated();
// Get the lowest obsoleted version for all redeclarations.
if (Availability->Obsoleted > Attr->getObsoleted())
Availability->Obsoleted = Attr->getObsoleted();
} else {
Availabilities.emplace_back(Domain, Attr->getIntroduced(),
Attr->getDeprecated(),
Attr->getObsoleted());
}
}
}
}
|