/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Sema/UsedDeclVisitor.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- UsedDeclVisitor.h - ODR-used declarations visitor --------*- C++ -*-===// |
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 | | // This file defines UsedDeclVisitor, a CRTP class which visits all the |
9 | | // declarations that are ODR-used by an expression or statement. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_CLANG_LIB_SEMA_USEDDECLVISITOR_H |
14 | | #define LLVM_CLANG_LIB_SEMA_USEDDECLVISITOR_H |
15 | | |
16 | | #include "clang/AST/EvaluatedExprVisitor.h" |
17 | | #include "clang/Sema/SemaInternal.h" |
18 | | |
19 | | namespace clang { |
20 | | template <class Derived> |
21 | | class UsedDeclVisitor : public EvaluatedExprVisitor<Derived> { |
22 | | protected: |
23 | | Sema &S; |
24 | | |
25 | | public: |
26 | | typedef EvaluatedExprVisitor<Derived> Inherited; |
27 | | |
28 | 126k | UsedDeclVisitor(Sema &S) : Inherited(S.Context), S(S) {} Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::UsedDeclVisitor(clang::Sema&) Line | Count | Source | 28 | 8.86k | UsedDeclVisitor(Sema &S) : Inherited(S.Context), S(S) {} |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::UsedDeclVisitor(clang::Sema&) Line | Count | Source | 28 | 118k | UsedDeclVisitor(Sema &S) : Inherited(S.Context), S(S) {} |
|
29 | | |
30 | 1.35M | Derived &asImpl() { return *static_cast<Derived *>(this); } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::asImpl() Line | Count | Source | 30 | 1.34M | Derived &asImpl() { return *static_cast<Derived *>(this); } |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::asImpl() Line | Count | Source | 30 | 10.5k | Derived &asImpl() { return *static_cast<Derived *>(this); } |
|
31 | | |
32 | 748k | void VisitDeclRefExpr(DeclRefExpr *E) { |
33 | 748k | auto *D = E->getDecl(); |
34 | 748k | if (isa<FunctionDecl>(D) || isa<VarDecl>(D)669k ) { |
35 | 748k | asImpl().visitUsedDecl(E->getLocation(), D); |
36 | 748k | } |
37 | 748k | } |
38 | | |
39 | 15.3k | void VisitMemberExpr(MemberExpr *E) { |
40 | 15.3k | auto *D = E->getMemberDecl(); |
41 | 15.3k | if (isa<FunctionDecl>(D) || isa<VarDecl>(D)10.0k ) { |
42 | 5.32k | asImpl().visitUsedDecl(E->getMemberLoc(), D); |
43 | 5.32k | } |
44 | 15.3k | asImpl().Visit(E->getBase()); |
45 | 15.3k | } |
46 | | |
47 | 273k | void VisitCapturedStmt(CapturedStmt *Node) { |
48 | 273k | asImpl().visitUsedDecl(Node->getBeginLoc(), Node->getCapturedDecl()); |
49 | 273k | Inherited::VisitCapturedStmt(Node); |
50 | 273k | } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::VisitCapturedStmt(clang::CapturedStmt*) Line | Count | Source | 47 | 273k | void VisitCapturedStmt(CapturedStmt *Node) { | 48 | 273k | asImpl().visitUsedDecl(Node->getBeginLoc(), Node->getCapturedDecl()); | 49 | 273k | Inherited::VisitCapturedStmt(Node); | 50 | 273k | } |
Unexecuted instantiation: SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::VisitCapturedStmt(clang::CapturedStmt*) |
51 | | |
52 | 7.47k | void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
53 | 7.47k | asImpl().visitUsedDecl( |
54 | 7.47k | E->getBeginLoc(), |
55 | 7.47k | const_cast<CXXDestructorDecl *>(E->getTemporary()->getDestructor())); |
56 | 7.47k | asImpl().Visit(E->getSubExpr()); |
57 | 7.47k | } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::VisitCXXBindTemporaryExpr(clang::CXXBindTemporaryExpr*) Line | Count | Source | 52 | 4.41k | void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { | 53 | 4.41k | asImpl().visitUsedDecl( | 54 | 4.41k | E->getBeginLoc(), | 55 | 4.41k | const_cast<CXXDestructorDecl *>(E->getTemporary()->getDestructor())); | 56 | 4.41k | asImpl().Visit(E->getSubExpr()); | 57 | 4.41k | } |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::VisitCXXBindTemporaryExpr(clang::CXXBindTemporaryExpr*) Line | Count | Source | 52 | 3.05k | void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { | 53 | 3.05k | asImpl().visitUsedDecl( | 54 | 3.05k | E->getBeginLoc(), | 55 | 3.05k | const_cast<CXXDestructorDecl *>(E->getTemporary()->getDestructor())); | 56 | 3.05k | asImpl().Visit(E->getSubExpr()); | 57 | 3.05k | } |
|
58 | | |
59 | 45 | void VisitCXXNewExpr(CXXNewExpr *E) { |
60 | 45 | if (E->getOperatorNew()) |
61 | 45 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorNew()); |
62 | 45 | if (E->getOperatorDelete()) |
63 | 1 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete()); |
64 | 45 | Inherited::VisitCXXNewExpr(E); |
65 | 45 | } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::VisitCXXNewExpr(clang::CXXNewExpr*) Line | Count | Source | 59 | 40 | void VisitCXXNewExpr(CXXNewExpr *E) { | 60 | 40 | if (E->getOperatorNew()) | 61 | 40 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorNew()); | 62 | 40 | if (E->getOperatorDelete()) | 63 | 0 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete()); | 64 | 40 | Inherited::VisitCXXNewExpr(E); | 65 | 40 | } |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::VisitCXXNewExpr(clang::CXXNewExpr*) Line | Count | Source | 59 | 5 | void VisitCXXNewExpr(CXXNewExpr *E) { | 60 | 5 | if (E->getOperatorNew()) | 61 | 5 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorNew()); | 62 | 5 | if (E->getOperatorDelete()) | 63 | 1 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete()); | 64 | 5 | Inherited::VisitCXXNewExpr(E); | 65 | 5 | } |
|
66 | | |
67 | 23 | void VisitCXXDeleteExpr(CXXDeleteExpr *E) { |
68 | 23 | if (E->getOperatorDelete()) |
69 | 23 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete()); |
70 | 23 | QualType DestroyedOrNull = E->getDestroyedType(); |
71 | 23 | if (!DestroyedOrNull.isNull()) { |
72 | 23 | QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull); |
73 | 23 | if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) { |
74 | 23 | CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl()); |
75 | 23 | asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record)); |
76 | 23 | } |
77 | 23 | } |
78 | | |
79 | 23 | Inherited::VisitCXXDeleteExpr(E); |
80 | 23 | } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::VisitCXXDeleteExpr(clang::CXXDeleteExpr*) Line | Count | Source | 67 | 20 | void VisitCXXDeleteExpr(CXXDeleteExpr *E) { | 68 | 20 | if (E->getOperatorDelete()) | 69 | 20 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete()); | 70 | 20 | QualType DestroyedOrNull = E->getDestroyedType(); | 71 | 20 | if (!DestroyedOrNull.isNull()) { | 72 | 20 | QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull); | 73 | 20 | if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) { | 74 | 20 | CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl()); | 75 | 20 | asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record)); | 76 | 20 | } | 77 | 20 | } | 78 | | | 79 | 20 | Inherited::VisitCXXDeleteExpr(E); | 80 | 20 | } |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::VisitCXXDeleteExpr(clang::CXXDeleteExpr*) Line | Count | Source | 67 | 3 | void VisitCXXDeleteExpr(CXXDeleteExpr *E) { | 68 | 3 | if (E->getOperatorDelete()) | 69 | 3 | asImpl().visitUsedDecl(E->getBeginLoc(), E->getOperatorDelete()); | 70 | 3 | QualType DestroyedOrNull = E->getDestroyedType(); | 71 | 3 | if (!DestroyedOrNull.isNull()) { | 72 | 3 | QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull); | 73 | 3 | if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) { | 74 | 3 | CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl()); | 75 | 3 | asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record)); | 76 | 3 | } | 77 | 3 | } | 78 | | | 79 | 3 | Inherited::VisitCXXDeleteExpr(E); | 80 | 3 | } |
|
81 | | |
82 | 25.4k | void VisitCXXConstructExpr(CXXConstructExpr *E) { |
83 | 25.4k | asImpl().visitUsedDecl(E->getBeginLoc(), E->getConstructor()); |
84 | 25.4k | Inherited::VisitCXXConstructExpr(E); |
85 | 25.4k | } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::VisitCXXConstructExpr(clang::CXXConstructExpr*) Line | Count | Source | 82 | 21.1k | void VisitCXXConstructExpr(CXXConstructExpr *E) { | 83 | 21.1k | asImpl().visitUsedDecl(E->getBeginLoc(), E->getConstructor()); | 84 | 21.1k | Inherited::VisitCXXConstructExpr(E); | 85 | 21.1k | } |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::VisitCXXConstructExpr(clang::CXXConstructExpr*) Line | Count | Source | 82 | 4.27k | void VisitCXXConstructExpr(CXXConstructExpr *E) { | 83 | 4.27k | asImpl().visitUsedDecl(E->getBeginLoc(), E->getConstructor()); | 84 | 4.27k | Inherited::VisitCXXConstructExpr(E); | 85 | 4.27k | } |
|
86 | | |
87 | 1.97k | void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
88 | 1.97k | asImpl().Visit(E->getExpr()); |
89 | 1.97k | } Sema.cpp:clang::UsedDeclVisitor<(anonymous namespace)::DeferredDiagnosticsEmitter>::VisitCXXDefaultArgExpr(clang::CXXDefaultArgExpr*) Line | Count | Source | 87 | 1.79k | void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { | 88 | 1.79k | asImpl().Visit(E->getExpr()); | 89 | 1.79k | } |
SemaExpr.cpp:clang::UsedDeclVisitor<(anonymous namespace)::EvaluatedExprMarker>::VisitCXXDefaultArgExpr(clang::CXXDefaultArgExpr*) Line | Count | Source | 87 | 179 | void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { | 88 | 179 | asImpl().Visit(E->getExpr()); | 89 | 179 | } |
|
90 | | |
91 | 273k | void visitUsedDecl(SourceLocation Loc, Decl *D) { |
92 | 273k | if (auto *CD = dyn_cast<CapturedDecl>(D)) { |
93 | 273k | if (auto *S = CD->getBody()) { |
94 | 273k | asImpl().Visit(S); |
95 | 273k | } |
96 | 0 | } else if (auto *CD = dyn_cast<BlockDecl>(D)) { |
97 | 0 | if (auto *S = CD->getBody()) { |
98 | 0 | asImpl().Visit(S); |
99 | 0 | } |
100 | 0 | } |
101 | 273k | } |
102 | | }; |
103 | | } // end namespace clang |
104 | | |
105 | | #endif // LLVM_CLANG_LIB_SEMA_USEDDECLVISITOR_H |