/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/DeclOpenMP.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- DeclOpenMP.cpp - Declaration OpenMP AST Node Implementation ------===// |
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 | | /// \file |
9 | | /// This file implements OMPThreadPrivateDecl, OMPCapturedExprDecl |
10 | | /// classes. |
11 | | /// |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #include "clang/AST/ASTContext.h" |
15 | | #include "clang/AST/Decl.h" |
16 | | #include "clang/AST/DeclBase.h" |
17 | | #include "clang/AST/DeclOpenMP.h" |
18 | | #include "clang/AST/Expr.h" |
19 | | |
20 | | using namespace clang; |
21 | | |
22 | | //===----------------------------------------------------------------------===// |
23 | | // OMPThreadPrivateDecl Implementation. |
24 | | //===----------------------------------------------------------------------===// |
25 | | |
26 | 0 | void OMPThreadPrivateDecl::anchor() {} |
27 | | |
28 | | OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C, |
29 | | DeclContext *DC, |
30 | | SourceLocation L, |
31 | 2.93k | ArrayRef<Expr *> VL) { |
32 | 2.93k | auto *D = OMPDeclarativeDirective::createDirective<OMPThreadPrivateDecl>( |
33 | 2.93k | C, DC, llvm::None, VL.size(), L); |
34 | 2.93k | D->setVars(VL); |
35 | 2.93k | return D; |
36 | 2.93k | } |
37 | | |
38 | | OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C, |
39 | | unsigned ID, |
40 | 252 | unsigned N) { |
41 | 252 | return OMPDeclarativeDirective::createEmptyDirective<OMPThreadPrivateDecl>( |
42 | 252 | C, ID, 0, N); |
43 | 252 | } |
44 | | |
45 | 2.93k | void OMPThreadPrivateDecl::setVars(ArrayRef<Expr *> VL) { |
46 | 2.93k | assert(VL.size() == Data->getNumChildren() && |
47 | 2.93k | "Number of variables is not the same as the preallocated buffer"); |
48 | 0 | llvm::copy(VL, getVars().begin()); |
49 | 2.93k | } |
50 | | |
51 | | //===----------------------------------------------------------------------===// |
52 | | // OMPAllocateDecl Implementation. |
53 | | //===----------------------------------------------------------------------===// |
54 | | |
55 | 0 | void OMPAllocateDecl::anchor() { } |
56 | | |
57 | | OMPAllocateDecl *OMPAllocateDecl::Create(ASTContext &C, DeclContext *DC, |
58 | | SourceLocation L, ArrayRef<Expr *> VL, |
59 | 734 | ArrayRef<OMPClause *> CL) { |
60 | 734 | auto *D = OMPDeclarativeDirective::createDirective<OMPAllocateDecl>( |
61 | 734 | C, DC, CL, VL.size(), L); |
62 | 734 | D->setVars(VL); |
63 | 734 | return D; |
64 | 734 | } |
65 | | |
66 | | OMPAllocateDecl *OMPAllocateDecl::CreateDeserialized(ASTContext &C, unsigned ID, |
67 | | unsigned NVars, |
68 | 173 | unsigned NClauses) { |
69 | 173 | return OMPDeclarativeDirective::createEmptyDirective<OMPAllocateDecl>( |
70 | 173 | C, ID, NClauses, NVars, SourceLocation()); |
71 | 173 | } |
72 | | |
73 | 734 | void OMPAllocateDecl::setVars(ArrayRef<Expr *> VL) { |
74 | 734 | assert(VL.size() == Data->getNumChildren() && |
75 | 734 | "Number of variables is not the same as the preallocated buffer"); |
76 | 0 | llvm::copy(VL, getVars().begin()); |
77 | 734 | } |
78 | | |
79 | | //===----------------------------------------------------------------------===// |
80 | | // OMPRequiresDecl Implementation. |
81 | | //===----------------------------------------------------------------------===// |
82 | | |
83 | 0 | void OMPRequiresDecl::anchor() {} |
84 | | |
85 | | OMPRequiresDecl *OMPRequiresDecl::Create(ASTContext &C, DeclContext *DC, |
86 | | SourceLocation L, |
87 | 187 | ArrayRef<OMPClause *> CL) { |
88 | 187 | return OMPDeclarativeDirective::createDirective<OMPRequiresDecl>(C, DC, CL, 0, |
89 | 187 | L); |
90 | 187 | } |
91 | | |
92 | | OMPRequiresDecl *OMPRequiresDecl::CreateDeserialized(ASTContext &C, unsigned ID, |
93 | 32 | unsigned N) { |
94 | 32 | return OMPDeclarativeDirective::createEmptyDirective<OMPRequiresDecl>( |
95 | 32 | C, ID, N, 0, SourceLocation()); |
96 | 32 | } |
97 | | |
98 | | //===----------------------------------------------------------------------===// |
99 | | // OMPDeclareReductionDecl Implementation. |
100 | | //===----------------------------------------------------------------------===// |
101 | | |
102 | | OMPDeclareReductionDecl::OMPDeclareReductionDecl( |
103 | | Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, |
104 | | QualType Ty, OMPDeclareReductionDecl *PrevDeclInScope) |
105 | | : ValueDecl(DK, DC, L, Name, Ty), DeclContext(DK), Combiner(nullptr), |
106 | 918 | PrevDeclInScope(PrevDeclInScope) { |
107 | 918 | setInitializer(nullptr, CallInit); |
108 | 918 | } |
109 | | |
110 | 0 | void OMPDeclareReductionDecl::anchor() {} |
111 | | |
112 | | OMPDeclareReductionDecl *OMPDeclareReductionDecl::Create( |
113 | | ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, |
114 | 778 | QualType T, OMPDeclareReductionDecl *PrevDeclInScope) { |
115 | 778 | return new (C, DC) OMPDeclareReductionDecl(OMPDeclareReduction, DC, L, Name, |
116 | 778 | T, PrevDeclInScope); |
117 | 778 | } |
118 | | |
119 | | OMPDeclareReductionDecl * |
120 | 140 | OMPDeclareReductionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { |
121 | 140 | return new (C, ID) OMPDeclareReductionDecl( |
122 | 140 | OMPDeclareReduction, /*DC=*/nullptr, SourceLocation(), DeclarationName(), |
123 | 140 | QualType(), /*PrevDeclInScope=*/nullptr); |
124 | 140 | } |
125 | | |
126 | 347 | OMPDeclareReductionDecl *OMPDeclareReductionDecl::getPrevDeclInScope() { |
127 | 347 | return cast_or_null<OMPDeclareReductionDecl>( |
128 | 347 | PrevDeclInScope.get(getASTContext().getExternalSource())); |
129 | 347 | } |
130 | | const OMPDeclareReductionDecl * |
131 | 0 | OMPDeclareReductionDecl::getPrevDeclInScope() const { |
132 | 0 | return cast_or_null<OMPDeclareReductionDecl>( |
133 | 0 | PrevDeclInScope.get(getASTContext().getExternalSource())); |
134 | 0 | } |
135 | | |
136 | | //===----------------------------------------------------------------------===// |
137 | | // OMPDeclareMapperDecl Implementation. |
138 | | //===----------------------------------------------------------------------===// |
139 | | |
140 | 0 | void OMPDeclareMapperDecl::anchor() {} |
141 | | |
142 | | OMPDeclareMapperDecl *OMPDeclareMapperDecl::Create( |
143 | | ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, |
144 | | QualType T, DeclarationName VarName, ArrayRef<OMPClause *> Clauses, |
145 | 333 | OMPDeclareMapperDecl *PrevDeclInScope) { |
146 | 333 | return OMPDeclarativeDirective::createDirective<OMPDeclareMapperDecl>( |
147 | 333 | C, DC, Clauses, 1, L, Name, T, VarName, PrevDeclInScope); |
148 | 333 | } |
149 | | |
150 | | OMPDeclareMapperDecl *OMPDeclareMapperDecl::CreateDeserialized(ASTContext &C, |
151 | | unsigned ID, |
152 | 86 | unsigned N) { |
153 | 86 | return OMPDeclarativeDirective::createEmptyDirective<OMPDeclareMapperDecl>( |
154 | 86 | C, ID, N, 1, SourceLocation(), DeclarationName(), QualType(), |
155 | 86 | DeclarationName(), /*PrevDeclInScope=*/nullptr); |
156 | 86 | } |
157 | | |
158 | 138 | OMPDeclareMapperDecl *OMPDeclareMapperDecl::getPrevDeclInScope() { |
159 | 138 | return cast_or_null<OMPDeclareMapperDecl>( |
160 | 138 | PrevDeclInScope.get(getASTContext().getExternalSource())); |
161 | 138 | } |
162 | | |
163 | 0 | const OMPDeclareMapperDecl *OMPDeclareMapperDecl::getPrevDeclInScope() const { |
164 | 0 | return cast_or_null<OMPDeclareMapperDecl>( |
165 | 0 | PrevDeclInScope.get(getASTContext().getExternalSource())); |
166 | 0 | } |
167 | | |
168 | | //===----------------------------------------------------------------------===// |
169 | | // OMPCapturedExprDecl Implementation. |
170 | | //===----------------------------------------------------------------------===// |
171 | | |
172 | 0 | void OMPCapturedExprDecl::anchor() {} |
173 | | |
174 | | OMPCapturedExprDecl *OMPCapturedExprDecl::Create(ASTContext &C, DeclContext *DC, |
175 | | IdentifierInfo *Id, QualType T, |
176 | 72.3k | SourceLocation StartLoc) { |
177 | 72.3k | return new (C, DC) OMPCapturedExprDecl( |
178 | 72.3k | C, DC, Id, T, C.getTrivialTypeSourceInfo(T), StartLoc); |
179 | 72.3k | } |
180 | | |
181 | | OMPCapturedExprDecl *OMPCapturedExprDecl::CreateDeserialized(ASTContext &C, |
182 | 4.32k | unsigned ID) { |
183 | 4.32k | return new (C, ID) OMPCapturedExprDecl(C, nullptr, nullptr, QualType(), |
184 | 4.32k | /*TInfo=*/nullptr, SourceLocation()); |
185 | 4.32k | } |
186 | | |
187 | 104 | SourceRange OMPCapturedExprDecl::getSourceRange() const { |
188 | 104 | assert(hasInit()); |
189 | 0 | return SourceRange(getInit()->getBeginLoc(), getInit()->getEndLoc()); |
190 | 104 | } |