/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/ExtractAPI/AvailabilityInfo.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | #include "clang/ExtractAPI/AvailabilityInfo.h" |
2 | | #include "clang/AST/Attr.h" |
3 | | #include "llvm/ADT/STLExtras.h" |
4 | | |
5 | | using namespace clang; |
6 | | using namespace extractapi; |
7 | | |
8 | 302 | AvailabilitySet::AvailabilitySet(const Decl *Decl) { |
9 | | // Collect availability attributes from all redeclrations. |
10 | 316 | for (const auto *RD : Decl->redecls()) { |
11 | 316 | if (const auto *A = RD->getAttr<UnavailableAttr>()) { |
12 | 3 | if (!A->isImplicit()) { |
13 | 3 | this->Availabilities.clear(); |
14 | 3 | UnconditionallyUnavailable = true; |
15 | 3 | } |
16 | 3 | } |
17 | | |
18 | 316 | if (const auto *A = RD->getAttr<DeprecatedAttr>()) { |
19 | 4 | if (!A->isImplicit()) { |
20 | 4 | this->Availabilities.clear(); |
21 | 4 | UnconditionallyDeprecated = true; |
22 | 4 | } |
23 | 4 | } |
24 | | |
25 | 316 | for (const auto *Attr : RD->specific_attrs<AvailabilityAttr>()) { |
26 | 19 | StringRef Domain = Attr->getPlatform()->getName(); |
27 | 19 | auto *Availability = |
28 | 19 | llvm::find_if(Availabilities, [Domain](const AvailabilityInfo &Info) { |
29 | 14 | return Domain.equals(Info.Domain); |
30 | 14 | }); |
31 | 19 | if (Availability != Availabilities.end()) { |
32 | | // Get the highest introduced version for all redeclarations. |
33 | 4 | if (Availability->Introduced < Attr->getIntroduced()) |
34 | 0 | Availability->Introduced = Attr->getIntroduced(); |
35 | | |
36 | | // Get the lowest deprecated version for all redeclarations. |
37 | 4 | if (Availability->Deprecated > Attr->getDeprecated()) |
38 | 0 | Availability->Deprecated = Attr->getDeprecated(); |
39 | | |
40 | | // Get the lowest obsoleted version for all redeclarations. |
41 | 4 | if (Availability->Obsoleted > Attr->getObsoleted()) |
42 | 0 | Availability->Obsoleted = Attr->getObsoleted(); |
43 | 15 | } else { |
44 | 15 | Availabilities.emplace_back(Domain, Attr->getIntroduced(), |
45 | 15 | Attr->getDeprecated(), Attr->getObsoleted(), |
46 | 15 | Attr->getUnavailable()); |
47 | 15 | } |
48 | 19 | } |
49 | 316 | } |
50 | 302 | } |