Bug Summary

File:tools/clang/lib/AST/OpenMPClause.cpp
Warning:line 278, column 3
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name OpenMPClause.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/lib/AST -I /build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST -I /build/llvm-toolchain-snapshot-7~svn326246/tools/clang/include -I /build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-7~svn326246/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn326246/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn326246/build-llvm/tools/clang/lib/AST -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-02-28-041547-14988-1 -x c++ /build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp
1//===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the subclesses of Stmt class declared in OpenMPClause.h
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/OpenMPClause.h"
15#include "clang/AST/ASTContext.h"
16#include "clang/AST/Decl.h"
17#include "clang/Basic/LLVM.h"
18#include "llvm/ADT/SmallPtrSet.h"
19#include "llvm/Support/Casting.h"
20#include "llvm/Support/ErrorHandling.h"
21#include <algorithm>
22#include <cassert>
23
24using namespace clang;
25
26OMPClause::child_range OMPClause::children() {
27 switch (getClauseKind()) {
28 default:
29 break;
30#define OPENMP_CLAUSE(Name, Class) \
31 case OMPC_##Name: \
32 return static_cast<Class *>(this)->children();
33#include "clang/Basic/OpenMPKinds.def"
34 }
35 llvm_unreachable("unknown OMPClause")::llvm::llvm_unreachable_internal("unknown OMPClause", "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 35)
;
36}
37
38OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) {
39 auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
40 return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
41}
42
43const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
44 switch (C->getClauseKind()) {
45 case OMPC_schedule:
46 return static_cast<const OMPScheduleClause *>(C);
47 case OMPC_dist_schedule:
48 return static_cast<const OMPDistScheduleClause *>(C);
49 case OMPC_firstprivate:
50 return static_cast<const OMPFirstprivateClause *>(C);
51 case OMPC_lastprivate:
52 return static_cast<const OMPLastprivateClause *>(C);
53 case OMPC_reduction:
54 return static_cast<const OMPReductionClause *>(C);
55 case OMPC_task_reduction:
56 return static_cast<const OMPTaskReductionClause *>(C);
57 case OMPC_in_reduction:
58 return static_cast<const OMPInReductionClause *>(C);
59 case OMPC_linear:
60 return static_cast<const OMPLinearClause *>(C);
61 case OMPC_if:
62 return static_cast<const OMPIfClause *>(C);
63 case OMPC_num_threads:
64 return static_cast<const OMPNumThreadsClause *>(C);
65 case OMPC_num_teams:
66 return static_cast<const OMPNumTeamsClause *>(C);
67 case OMPC_thread_limit:
68 return static_cast<const OMPThreadLimitClause *>(C);
69 case OMPC_device:
70 return static_cast<const OMPDeviceClause *>(C);
71 case OMPC_default:
72 case OMPC_proc_bind:
73 case OMPC_final:
74 case OMPC_safelen:
75 case OMPC_simdlen:
76 case OMPC_collapse:
77 case OMPC_private:
78 case OMPC_shared:
79 case OMPC_aligned:
80 case OMPC_copyin:
81 case OMPC_copyprivate:
82 case OMPC_ordered:
83 case OMPC_nowait:
84 case OMPC_untied:
85 case OMPC_mergeable:
86 case OMPC_threadprivate:
87 case OMPC_flush:
88 case OMPC_read:
89 case OMPC_write:
90 case OMPC_update:
91 case OMPC_capture:
92 case OMPC_seq_cst:
93 case OMPC_depend:
94 case OMPC_threads:
95 case OMPC_simd:
96 case OMPC_map:
97 case OMPC_priority:
98 case OMPC_grainsize:
99 case OMPC_nogroup:
100 case OMPC_num_tasks:
101 case OMPC_hint:
102 case OMPC_defaultmap:
103 case OMPC_unknown:
104 case OMPC_uniform:
105 case OMPC_to:
106 case OMPC_from:
107 case OMPC_use_device_ptr:
108 case OMPC_is_device_ptr:
109 break;
110 }
111
112 return nullptr;
113}
114
115OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) {
116 auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
117 return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
118}
119
120const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) {
121 switch (C->getClauseKind()) {
122 case OMPC_lastprivate:
123 return static_cast<const OMPLastprivateClause *>(C);
124 case OMPC_reduction:
125 return static_cast<const OMPReductionClause *>(C);
126 case OMPC_task_reduction:
127 return static_cast<const OMPTaskReductionClause *>(C);
128 case OMPC_in_reduction:
129 return static_cast<const OMPInReductionClause *>(C);
130 case OMPC_linear:
131 return static_cast<const OMPLinearClause *>(C);
132 case OMPC_schedule:
133 case OMPC_dist_schedule:
134 case OMPC_firstprivate:
135 case OMPC_default:
136 case OMPC_proc_bind:
137 case OMPC_if:
138 case OMPC_final:
139 case OMPC_num_threads:
140 case OMPC_safelen:
141 case OMPC_simdlen:
142 case OMPC_collapse:
143 case OMPC_private:
144 case OMPC_shared:
145 case OMPC_aligned:
146 case OMPC_copyin:
147 case OMPC_copyprivate:
148 case OMPC_ordered:
149 case OMPC_nowait:
150 case OMPC_untied:
151 case OMPC_mergeable:
152 case OMPC_threadprivate:
153 case OMPC_flush:
154 case OMPC_read:
155 case OMPC_write:
156 case OMPC_update:
157 case OMPC_capture:
158 case OMPC_seq_cst:
159 case OMPC_depend:
160 case OMPC_device:
161 case OMPC_threads:
162 case OMPC_simd:
163 case OMPC_map:
164 case OMPC_num_teams:
165 case OMPC_thread_limit:
166 case OMPC_priority:
167 case OMPC_grainsize:
168 case OMPC_nogroup:
169 case OMPC_num_tasks:
170 case OMPC_hint:
171 case OMPC_defaultmap:
172 case OMPC_unknown:
173 case OMPC_uniform:
174 case OMPC_to:
175 case OMPC_from:
176 case OMPC_use_device_ptr:
177 case OMPC_is_device_ptr:
178 break;
179 }
180
181 return nullptr;
182}
183
184void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
185 assert(VL.size() == varlist_size() &&(static_cast <bool> (VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 186, __extension__ __PRETTY_FUNCTION__))
186 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 186, __extension__ __PRETTY_FUNCTION__))
;
187 std::copy(VL.begin(), VL.end(), varlist_end());
188}
189
190OMPPrivateClause *
191OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
192 SourceLocation LParenLoc, SourceLocation EndLoc,
193 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
194 // Allocate space for private variables and initializer expressions.
195 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
196 OMPPrivateClause *Clause =
197 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
198 Clause->setVarRefs(VL);
199 Clause->setPrivateCopies(PrivateVL);
200 return Clause;
201}
202
203OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
204 unsigned N) {
205 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
206 return new (Mem) OMPPrivateClause(N);
207}
208
209void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
210 assert(VL.size() == varlist_size() &&(static_cast <bool> (VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 211, __extension__ __PRETTY_FUNCTION__))
211 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 211, __extension__ __PRETTY_FUNCTION__))
;
212 std::copy(VL.begin(), VL.end(), varlist_end());
213}
214
215void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
216 assert(VL.size() == varlist_size() &&(static_cast <bool> (VL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 217, __extension__ __PRETTY_FUNCTION__))
217 "Number of inits is not the same as the preallocated buffer")(static_cast <bool> (VL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 217, __extension__ __PRETTY_FUNCTION__))
;
218 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
219}
220
221OMPFirstprivateClause *
222OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc,
223 SourceLocation LParenLoc, SourceLocation EndLoc,
224 ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
225 ArrayRef<Expr *> InitVL, Stmt *PreInit) {
226 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
227 OMPFirstprivateClause *Clause =
228 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
229 Clause->setVarRefs(VL);
230 Clause->setPrivateCopies(PrivateVL);
231 Clause->setInits(InitVL);
232 Clause->setPreInitStmt(PreInit);
233 return Clause;
234}
235
236OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
237 unsigned N) {
238 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
239 return new (Mem) OMPFirstprivateClause(N);
240}
241
242void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
243 assert(PrivateCopies.size() == varlist_size() &&(static_cast <bool> (PrivateCopies.size() == varlist_size
() && "Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("PrivateCopies.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 244, __extension__ __PRETTY_FUNCTION__))
244 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (PrivateCopies.size() == varlist_size
() && "Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("PrivateCopies.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 244, __extension__ __PRETTY_FUNCTION__))
;
245 std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
246}
247
248void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
249 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 251, __extension__ __PRETTY_FUNCTION__))
250 "not the same as the "(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 251, __extension__ __PRETTY_FUNCTION__))
251 "preallocated buffer")(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 251, __extension__ __PRETTY_FUNCTION__))
;
252 std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
253}
254
255void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
256 assert(DstExprs.size() == varlist_size() && "Number of destination "(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 258, __extension__ __PRETTY_FUNCTION__))
257 "expressions is not the same as "(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 258, __extension__ __PRETTY_FUNCTION__))
258 "the preallocated buffer")(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 258, __extension__ __PRETTY_FUNCTION__))
;
259 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
260}
261
262void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
263 assert(AssignmentOps.size() == varlist_size() &&(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 265, __extension__ __PRETTY_FUNCTION__))
264 "Number of assignment expressions is not the same as the preallocated "(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 265, __extension__ __PRETTY_FUNCTION__))
265 "buffer")(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 265, __extension__ __PRETTY_FUNCTION__))
;
266 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
267 getDestinationExprs().end());
268}
269
270OMPLastprivateClause *OMPLastprivateClause::Create(
271 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
272 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
273 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
274 Expr *PostUpdate) {
275 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
276 OMPLastprivateClause *Clause =
1
'Clause' initialized to a null pointer value
277 new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
278 Clause->setVarRefs(VL);
2
Called C++ object pointer is null
279 Clause->setSourceExprs(SrcExprs);
280 Clause->setDestinationExprs(DstExprs);
281 Clause->setAssignmentOps(AssignmentOps);
282 Clause->setPreInitStmt(PreInit);
283 Clause->setPostUpdateExpr(PostUpdate);
284 return Clause;
285}
286
287OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C,
288 unsigned N) {
289 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
290 return new (Mem) OMPLastprivateClause(N);
291}
292
293OMPSharedClause *OMPSharedClause::Create(const ASTContext &C,
294 SourceLocation StartLoc,
295 SourceLocation LParenLoc,
296 SourceLocation EndLoc,
297 ArrayRef<Expr *> VL) {
298 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
299 OMPSharedClause *Clause =
300 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
301 Clause->setVarRefs(VL);
302 return Clause;
303}
304
305OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
306 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
307 return new (Mem) OMPSharedClause(N);
308}
309
310void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
311 assert(PL.size() == varlist_size() &&(static_cast <bool> (PL.size() == varlist_size() &&
"Number of privates is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("PL.size() == varlist_size() && \"Number of privates is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 312, __extension__ __PRETTY_FUNCTION__))
312 "Number of privates is not the same as the preallocated buffer")(static_cast <bool> (PL.size() == varlist_size() &&
"Number of privates is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("PL.size() == varlist_size() && \"Number of privates is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 312, __extension__ __PRETTY_FUNCTION__))
;
313 std::copy(PL.begin(), PL.end(), varlist_end());
314}
315
316void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
317 assert(IL.size() == varlist_size() &&(static_cast <bool> (IL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("IL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 318, __extension__ __PRETTY_FUNCTION__))
318 "Number of inits is not the same as the preallocated buffer")(static_cast <bool> (IL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("IL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 318, __extension__ __PRETTY_FUNCTION__))
;
319 std::copy(IL.begin(), IL.end(), getPrivates().end());
320}
321
322void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
323 assert(UL.size() == varlist_size() &&(static_cast <bool> (UL.size() == varlist_size() &&
"Number of updates is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("UL.size() == varlist_size() && \"Number of updates is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 324, __extension__ __PRETTY_FUNCTION__))
324 "Number of updates is not the same as the preallocated buffer")(static_cast <bool> (UL.size() == varlist_size() &&
"Number of updates is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("UL.size() == varlist_size() && \"Number of updates is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 324, __extension__ __PRETTY_FUNCTION__))
;
325 std::copy(UL.begin(), UL.end(), getInits().end());
326}
327
328void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
329 assert(FL.size() == varlist_size() &&(static_cast <bool> (FL.size() == varlist_size() &&
"Number of final updates is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("FL.size() == varlist_size() && \"Number of final updates is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 330, __extension__ __PRETTY_FUNCTION__))
330 "Number of final updates is not the same as the preallocated buffer")(static_cast <bool> (FL.size() == varlist_size() &&
"Number of final updates is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("FL.size() == varlist_size() && \"Number of final updates is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 330, __extension__ __PRETTY_FUNCTION__))
;
331 std::copy(FL.begin(), FL.end(), getUpdates().end());
332}
333
334OMPLinearClause *OMPLinearClause::Create(
335 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
336 OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc,
337 SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL,
338 ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep,
339 Stmt *PreInit, Expr *PostUpdate) {
340 // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
341 // (Step and CalcStep).
342 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
343 OMPLinearClause *Clause = new (Mem) OMPLinearClause(
344 StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
345 Clause->setVarRefs(VL);
346 Clause->setPrivates(PL);
347 Clause->setInits(IL);
348 // Fill update and final expressions with zeroes, they are provided later,
349 // after the directive construction.
350 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
351 nullptr);
352 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
353 nullptr);
354 Clause->setStep(Step);
355 Clause->setCalcStep(CalcStep);
356 Clause->setPreInitStmt(PreInit);
357 Clause->setPostUpdateExpr(PostUpdate);
358 return Clause;
359}
360
361OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C,
362 unsigned NumVars) {
363 // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
364 // (Step and CalcStep).
365 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
366 return new (Mem) OMPLinearClause(NumVars);
367}
368
369OMPAlignedClause *
370OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc,
371 SourceLocation LParenLoc, SourceLocation ColonLoc,
372 SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
373 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
374 OMPAlignedClause *Clause = new (Mem)
375 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
376 Clause->setVarRefs(VL);
377 Clause->setAlignment(A);
378 return Clause;
379}
380
381OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C,
382 unsigned NumVars) {
383 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
384 return new (Mem) OMPAlignedClause(NumVars);
385}
386
387void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
388 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 390, __extension__ __PRETTY_FUNCTION__))
389 "not the same as the "(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 390, __extension__ __PRETTY_FUNCTION__))
390 "preallocated buffer")(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 390, __extension__ __PRETTY_FUNCTION__))
;
391 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
392}
393
394void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
395 assert(DstExprs.size() == varlist_size() && "Number of destination "(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 397, __extension__ __PRETTY_FUNCTION__))
396 "expressions is not the same as "(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 397, __extension__ __PRETTY_FUNCTION__))
397 "the preallocated buffer")(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 397, __extension__ __PRETTY_FUNCTION__))
;
398 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
399}
400
401void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
402 assert(AssignmentOps.size() == varlist_size() &&(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 404, __extension__ __PRETTY_FUNCTION__))
403 "Number of assignment expressions is not the same as the preallocated "(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 404, __extension__ __PRETTY_FUNCTION__))
404 "buffer")(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 404, __extension__ __PRETTY_FUNCTION__))
;
405 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
406 getDestinationExprs().end());
407}
408
409OMPCopyinClause *OMPCopyinClause::Create(
410 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
411 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
412 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
413 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
414 OMPCopyinClause *Clause =
415 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
416 Clause->setVarRefs(VL);
417 Clause->setSourceExprs(SrcExprs);
418 Clause->setDestinationExprs(DstExprs);
419 Clause->setAssignmentOps(AssignmentOps);
420 return Clause;
421}
422
423OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) {
424 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
425 return new (Mem) OMPCopyinClause(N);
426}
427
428void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
429 assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 431, __extension__ __PRETTY_FUNCTION__))
430 "not the same as the "(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 431, __extension__ __PRETTY_FUNCTION__))
431 "preallocated buffer")(static_cast <bool> (SrcExprs.size() == varlist_size() &&
"Number of source expressions is " "not the same as the " "preallocated buffer"
) ? void (0) : __assert_fail ("SrcExprs.size() == varlist_size() && \"Number of source expressions is \" \"not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 431, __extension__ __PRETTY_FUNCTION__))
;
432 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
433}
434
435void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
436 assert(DstExprs.size() == varlist_size() && "Number of destination "(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 438, __extension__ __PRETTY_FUNCTION__))
437 "expressions is not the same as "(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 438, __extension__ __PRETTY_FUNCTION__))
438 "the preallocated buffer")(static_cast <bool> (DstExprs.size() == varlist_size() &&
"Number of destination " "expressions is not the same as " "the preallocated buffer"
) ? void (0) : __assert_fail ("DstExprs.size() == varlist_size() && \"Number of destination \" \"expressions is not the same as \" \"the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 438, __extension__ __PRETTY_FUNCTION__))
;
439 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
440}
441
442void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
443 assert(AssignmentOps.size() == varlist_size() &&(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 445, __extension__ __PRETTY_FUNCTION__))
444 "Number of assignment expressions is not the same as the preallocated "(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 445, __extension__ __PRETTY_FUNCTION__))
445 "buffer")(static_cast <bool> (AssignmentOps.size() == varlist_size
() && "Number of assignment expressions is not the same as the preallocated "
"buffer") ? void (0) : __assert_fail ("AssignmentOps.size() == varlist_size() && \"Number of assignment expressions is not the same as the preallocated \" \"buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 445, __extension__ __PRETTY_FUNCTION__))
;
446 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
447 getDestinationExprs().end());
448}
449
450OMPCopyprivateClause *OMPCopyprivateClause::Create(
451 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
452 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
453 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
454 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
455 OMPCopyprivateClause *Clause =
456 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
457 Clause->setVarRefs(VL);
458 Clause->setSourceExprs(SrcExprs);
459 Clause->setDestinationExprs(DstExprs);
460 Clause->setAssignmentOps(AssignmentOps);
461 return Clause;
462}
463
464OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
465 unsigned N) {
466 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
467 return new (Mem) OMPCopyprivateClause(N);
468}
469
470void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
471 assert(Privates.size() == varlist_size() &&(static_cast <bool> (Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 472, __extension__ __PRETTY_FUNCTION__))
472 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 472, __extension__ __PRETTY_FUNCTION__))
;
473 std::copy(Privates.begin(), Privates.end(), varlist_end());
474}
475
476void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
477 assert((static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 479, __extension__ __PRETTY_FUNCTION__))
478 LHSExprs.size() == varlist_size() &&(static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 479, __extension__ __PRETTY_FUNCTION__))
479 "Number of LHS expressions is not the same as the preallocated buffer")(static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 479, __extension__ __PRETTY_FUNCTION__))
;
480 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
481}
482
483void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
484 assert((static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 486, __extension__ __PRETTY_FUNCTION__))
485 RHSExprs.size() == varlist_size() &&(static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 486, __extension__ __PRETTY_FUNCTION__))
486 "Number of RHS expressions is not the same as the preallocated buffer")(static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 486, __extension__ __PRETTY_FUNCTION__))
;
487 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
488}
489
490void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
491 assert(ReductionOps.size() == varlist_size() && "Number of reduction "(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 493, __extension__ __PRETTY_FUNCTION__))
492 "expressions is not the same "(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 493, __extension__ __PRETTY_FUNCTION__))
493 "as the preallocated buffer")(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 493, __extension__ __PRETTY_FUNCTION__))
;
494 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
495}
496
497OMPReductionClause *OMPReductionClause::Create(
498 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
499 SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
500 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
501 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
502 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
503 Expr *PostUpdate) {
504 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
505 OMPReductionClause *Clause = new (Mem) OMPReductionClause(
506 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
507 Clause->setVarRefs(VL);
508 Clause->setPrivates(Privates);
509 Clause->setLHSExprs(LHSExprs);
510 Clause->setRHSExprs(RHSExprs);
511 Clause->setReductionOps(ReductionOps);
512 Clause->setPreInitStmt(PreInit);
513 Clause->setPostUpdateExpr(PostUpdate);
514 return Clause;
515}
516
517OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C,
518 unsigned N) {
519 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
520 return new (Mem) OMPReductionClause(N);
521}
522
523void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
524 assert(Privates.size() == varlist_size() &&(static_cast <bool> (Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 525, __extension__ __PRETTY_FUNCTION__))
525 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 525, __extension__ __PRETTY_FUNCTION__))
;
526 std::copy(Privates.begin(), Privates.end(), varlist_end());
527}
528
529void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
530 assert((static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 532, __extension__ __PRETTY_FUNCTION__))
531 LHSExprs.size() == varlist_size() &&(static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 532, __extension__ __PRETTY_FUNCTION__))
532 "Number of LHS expressions is not the same as the preallocated buffer")(static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 532, __extension__ __PRETTY_FUNCTION__))
;
533 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
534}
535
536void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
537 assert((static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 539, __extension__ __PRETTY_FUNCTION__))
538 RHSExprs.size() == varlist_size() &&(static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 539, __extension__ __PRETTY_FUNCTION__))
539 "Number of RHS expressions is not the same as the preallocated buffer")(static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 539, __extension__ __PRETTY_FUNCTION__))
;
540 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
541}
542
543void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
544 assert(ReductionOps.size() == varlist_size() && "Number of task reduction "(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of task reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of task reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 546, __extension__ __PRETTY_FUNCTION__))
545 "expressions is not the same "(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of task reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of task reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 546, __extension__ __PRETTY_FUNCTION__))
546 "as the preallocated buffer")(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of task reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of task reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 546, __extension__ __PRETTY_FUNCTION__))
;
547 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
548}
549
550OMPTaskReductionClause *OMPTaskReductionClause::Create(
551 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
552 SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
553 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
554 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
555 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
556 Expr *PostUpdate) {
557 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
558 OMPTaskReductionClause *Clause = new (Mem) OMPTaskReductionClause(
559 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
560 Clause->setVarRefs(VL);
561 Clause->setPrivates(Privates);
562 Clause->setLHSExprs(LHSExprs);
563 Clause->setRHSExprs(RHSExprs);
564 Clause->setReductionOps(ReductionOps);
565 Clause->setPreInitStmt(PreInit);
566 Clause->setPostUpdateExpr(PostUpdate);
567 return Clause;
568}
569
570OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C,
571 unsigned N) {
572 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
573 return new (Mem) OMPTaskReductionClause(N);
574}
575
576void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
577 assert(Privates.size() == varlist_size() &&(static_cast <bool> (Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 578, __extension__ __PRETTY_FUNCTION__))
578 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("Privates.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 578, __extension__ __PRETTY_FUNCTION__))
;
579 std::copy(Privates.begin(), Privates.end(), varlist_end());
580}
581
582void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
583 assert((static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 585, __extension__ __PRETTY_FUNCTION__))
584 LHSExprs.size() == varlist_size() &&(static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 585, __extension__ __PRETTY_FUNCTION__))
585 "Number of LHS expressions is not the same as the preallocated buffer")(static_cast <bool> (LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("LHSExprs.size() == varlist_size() && \"Number of LHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 585, __extension__ __PRETTY_FUNCTION__))
;
586 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
587}
588
589void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
590 assert((static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 592, __extension__ __PRETTY_FUNCTION__))
591 RHSExprs.size() == varlist_size() &&(static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 592, __extension__ __PRETTY_FUNCTION__))
592 "Number of RHS expressions is not the same as the preallocated buffer")(static_cast <bool> (RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("RHSExprs.size() == varlist_size() && \"Number of RHS expressions is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 592, __extension__ __PRETTY_FUNCTION__))
;
593 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
594}
595
596void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
597 assert(ReductionOps.size() == varlist_size() && "Number of in reduction "(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of in reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of in reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 599, __extension__ __PRETTY_FUNCTION__))
598 "expressions is not the same "(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of in reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of in reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 599, __extension__ __PRETTY_FUNCTION__))
599 "as the preallocated buffer")(static_cast <bool> (ReductionOps.size() == varlist_size
() && "Number of in reduction " "expressions is not the same "
"as the preallocated buffer") ? void (0) : __assert_fail ("ReductionOps.size() == varlist_size() && \"Number of in reduction \" \"expressions is not the same \" \"as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 599, __extension__ __PRETTY_FUNCTION__))
;
600 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
601}
602
603void OMPInReductionClause::setTaskgroupDescriptors(
604 ArrayRef<Expr *> TaskgroupDescriptors) {
605 assert(TaskgroupDescriptors.size() == varlist_size() &&(static_cast <bool> (TaskgroupDescriptors.size() == varlist_size
() && "Number of in reduction descriptors is not the same as the "
"preallocated buffer") ? void (0) : __assert_fail ("TaskgroupDescriptors.size() == varlist_size() && \"Number of in reduction descriptors is not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 607, __extension__ __PRETTY_FUNCTION__))
606 "Number of in reduction descriptors is not the same as the "(static_cast <bool> (TaskgroupDescriptors.size() == varlist_size
() && "Number of in reduction descriptors is not the same as the "
"preallocated buffer") ? void (0) : __assert_fail ("TaskgroupDescriptors.size() == varlist_size() && \"Number of in reduction descriptors is not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 607, __extension__ __PRETTY_FUNCTION__))
607 "preallocated buffer")(static_cast <bool> (TaskgroupDescriptors.size() == varlist_size
() && "Number of in reduction descriptors is not the same as the "
"preallocated buffer") ? void (0) : __assert_fail ("TaskgroupDescriptors.size() == varlist_size() && \"Number of in reduction descriptors is not the same as the \" \"preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 607, __extension__ __PRETTY_FUNCTION__))
;
608 std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
609 getReductionOps().end());
610}
611
612OMPInReductionClause *OMPInReductionClause::Create(
613 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
614 SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
615 NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
616 ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
617 ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
618 ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
619 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
620 OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
621 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
622 Clause->setVarRefs(VL);
623 Clause->setPrivates(Privates);
624 Clause->setLHSExprs(LHSExprs);
625 Clause->setRHSExprs(RHSExprs);
626 Clause->setReductionOps(ReductionOps);
627 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
628 Clause->setPreInitStmt(PreInit);
629 Clause->setPostUpdateExpr(PostUpdate);
630 return Clause;
631}
632
633OMPInReductionClause *OMPInReductionClause::CreateEmpty(const ASTContext &C,
634 unsigned N) {
635 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
636 return new (Mem) OMPInReductionClause(N);
637}
638
639OMPFlushClause *OMPFlushClause::Create(const ASTContext &C,
640 SourceLocation StartLoc,
641 SourceLocation LParenLoc,
642 SourceLocation EndLoc,
643 ArrayRef<Expr *> VL) {
644 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
645 OMPFlushClause *Clause =
646 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
647 Clause->setVarRefs(VL);
648 return Clause;
649}
650
651OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) {
652 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
653 return new (Mem) OMPFlushClause(N);
654}
655
656OMPDependClause *OMPDependClause::Create(
657 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
658 SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
659 SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
660 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
661 OMPDependClause *Clause =
662 new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
663 Clause->setVarRefs(VL);
664 Clause->setDependencyKind(DepKind);
665 Clause->setDependencyLoc(DepLoc);
666 Clause->setColonLoc(ColonLoc);
667 Clause->setCounterValue(nullptr);
668 return Clause;
669}
670
671OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) {
672 void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
673 return new (Mem) OMPDependClause(N);
674}
675
676void OMPDependClause::setCounterValue(Expr *V) {
677 assert(getDependencyKind() == OMPC_DEPEND_sink ||(static_cast <bool> (getDependencyKind() == OMPC_DEPEND_sink
|| getDependencyKind() == OMPC_DEPEND_source || V == nullptr
) ? void (0) : __assert_fail ("getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source || V == nullptr"
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 678, __extension__ __PRETTY_FUNCTION__))
678 getDependencyKind() == OMPC_DEPEND_source || V == nullptr)(static_cast <bool> (getDependencyKind() == OMPC_DEPEND_sink
|| getDependencyKind() == OMPC_DEPEND_source || V == nullptr
) ? void (0) : __assert_fail ("getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source || V == nullptr"
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 678, __extension__ __PRETTY_FUNCTION__))
;
679 *getVarRefs().end() = V;
680}
681
682const Expr *OMPDependClause::getCounterValue() const {
683 auto *V = *getVarRefs().end();
684 assert(getDependencyKind() == OMPC_DEPEND_sink ||(static_cast <bool> (getDependencyKind() == OMPC_DEPEND_sink
|| getDependencyKind() == OMPC_DEPEND_source || V == nullptr
) ? void (0) : __assert_fail ("getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source || V == nullptr"
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 685, __extension__ __PRETTY_FUNCTION__))
685 getDependencyKind() == OMPC_DEPEND_source || V == nullptr)(static_cast <bool> (getDependencyKind() == OMPC_DEPEND_sink
|| getDependencyKind() == OMPC_DEPEND_source || V == nullptr
) ? void (0) : __assert_fail ("getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source || V == nullptr"
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 685, __extension__ __PRETTY_FUNCTION__))
;
686 return V;
687}
688
689Expr *OMPDependClause::getCounterValue() {
690 auto *V = *getVarRefs().end();
691 assert(getDependencyKind() == OMPC_DEPEND_sink ||(static_cast <bool> (getDependencyKind() == OMPC_DEPEND_sink
|| getDependencyKind() == OMPC_DEPEND_source || V == nullptr
) ? void (0) : __assert_fail ("getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source || V == nullptr"
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 692, __extension__ __PRETTY_FUNCTION__))
692 getDependencyKind() == OMPC_DEPEND_source || V == nullptr)(static_cast <bool> (getDependencyKind() == OMPC_DEPEND_sink
|| getDependencyKind() == OMPC_DEPEND_source || V == nullptr
) ? void (0) : __assert_fail ("getDependencyKind() == OMPC_DEPEND_sink || getDependencyKind() == OMPC_DEPEND_source || V == nullptr"
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 692, __extension__ __PRETTY_FUNCTION__))
;
693 return V;
694}
695
696unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber(
697 MappableExprComponentListsRef ComponentLists) {
698 unsigned TotalNum = 0u;
699 for (auto &C : ComponentLists)
700 TotalNum += C.size();
701 return TotalNum;
702}
703
704unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber(
705 ArrayRef<ValueDecl *> Declarations) {
706 unsigned TotalNum = 0u;
707 llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
708 for (auto *D : Declarations) {
709 const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
710 if (Cache.count(VD))
711 continue;
712 ++TotalNum;
713 Cache.insert(VD);
714 }
715 return TotalNum;
716}
717
718OMPMapClause *
719OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc,
720 SourceLocation LParenLoc, SourceLocation EndLoc,
721 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
722 MappableExprComponentListsRef ComponentLists,
723 OpenMPMapClauseKind TypeModifier, OpenMPMapClauseKind Type,
724 bool TypeIsImplicit, SourceLocation TypeLoc) {
725 unsigned NumVars = Vars.size();
726 unsigned NumUniqueDeclarations =
727 getUniqueDeclarationsTotalNumber(Declarations);
728 unsigned NumComponentLists = ComponentLists.size();
729 unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
730
731 // We need to allocate:
732 // NumVars x Expr* - we have an original list expression for each clause list
733 // entry.
734 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
735 // with each component list.
736 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
737 // number of lists for each unique declaration and the size of each component
738 // list.
739 // NumComponents x MappableComponent - the total of all the components in all
740 // the lists.
741 void *Mem = C.Allocate(
742 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
743 OMPClauseMappableExprCommon::MappableComponent>(
744 NumVars, NumUniqueDeclarations,
745 NumUniqueDeclarations + NumComponentLists, NumComponents));
746 OMPMapClause *Clause = new (Mem) OMPMapClause(
747 TypeModifier, Type, TypeIsImplicit, TypeLoc, StartLoc, LParenLoc, EndLoc,
748 NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents);
749
750 Clause->setVarRefs(Vars);
751 Clause->setClauseInfo(Declarations, ComponentLists);
752 Clause->setMapTypeModifier(TypeModifier);
753 Clause->setMapType(Type);
754 Clause->setMapLoc(TypeLoc);
755 return Clause;
756}
757
758OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
759 unsigned NumUniqueDeclarations,
760 unsigned NumComponentLists,
761 unsigned NumComponents) {
762 void *Mem = C.Allocate(
763 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
764 OMPClauseMappableExprCommon::MappableComponent>(
765 NumVars, NumUniqueDeclarations,
766 NumUniqueDeclarations + NumComponentLists, NumComponents));
767 return new (Mem) OMPMapClause(NumVars, NumUniqueDeclarations,
768 NumComponentLists, NumComponents);
769}
770
771OMPToClause *OMPToClause::Create(const ASTContext &C, SourceLocation StartLoc,
772 SourceLocation LParenLoc,
773 SourceLocation EndLoc, ArrayRef<Expr *> Vars,
774 ArrayRef<ValueDecl *> Declarations,
775 MappableExprComponentListsRef ComponentLists) {
776 unsigned NumVars = Vars.size();
777 unsigned NumUniqueDeclarations =
778 getUniqueDeclarationsTotalNumber(Declarations);
779 unsigned NumComponentLists = ComponentLists.size();
780 unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
781
782 // We need to allocate:
783 // NumVars x Expr* - we have an original list expression for each clause list
784 // entry.
785 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
786 // with each component list.
787 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
788 // number of lists for each unique declaration and the size of each component
789 // list.
790 // NumComponents x MappableComponent - the total of all the components in all
791 // the lists.
792 void *Mem = C.Allocate(
793 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
794 OMPClauseMappableExprCommon::MappableComponent>(
795 NumVars, NumUniqueDeclarations,
796 NumUniqueDeclarations + NumComponentLists, NumComponents));
797
798 OMPToClause *Clause = new (Mem)
799 OMPToClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
800 NumComponentLists, NumComponents);
801
802 Clause->setVarRefs(Vars);
803 Clause->setClauseInfo(Declarations, ComponentLists);
804 return Clause;
805}
806
807OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
808 unsigned NumUniqueDeclarations,
809 unsigned NumComponentLists,
810 unsigned NumComponents) {
811 void *Mem = C.Allocate(
812 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
813 OMPClauseMappableExprCommon::MappableComponent>(
814 NumVars, NumUniqueDeclarations,
815 NumUniqueDeclarations + NumComponentLists, NumComponents));
816 return new (Mem) OMPToClause(NumVars, NumUniqueDeclarations,
817 NumComponentLists, NumComponents);
818}
819
820OMPFromClause *
821OMPFromClause::Create(const ASTContext &C, SourceLocation StartLoc,
822 SourceLocation LParenLoc, SourceLocation EndLoc,
823 ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
824 MappableExprComponentListsRef ComponentLists) {
825 unsigned NumVars = Vars.size();
826 unsigned NumUniqueDeclarations =
827 getUniqueDeclarationsTotalNumber(Declarations);
828 unsigned NumComponentLists = ComponentLists.size();
829 unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
830
831 // We need to allocate:
832 // NumVars x Expr* - we have an original list expression for each clause list
833 // entry.
834 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
835 // with each component list.
836 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
837 // number of lists for each unique declaration and the size of each component
838 // list.
839 // NumComponents x MappableComponent - the total of all the components in all
840 // the lists.
841 void *Mem = C.Allocate(
842 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
843 OMPClauseMappableExprCommon::MappableComponent>(
844 NumVars, NumUniqueDeclarations,
845 NumUniqueDeclarations + NumComponentLists, NumComponents));
846
847 OMPFromClause *Clause = new (Mem)
848 OMPFromClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
849 NumComponentLists, NumComponents);
850
851 Clause->setVarRefs(Vars);
852 Clause->setClauseInfo(Declarations, ComponentLists);
853 return Clause;
854}
855
856OMPFromClause *OMPFromClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
857 unsigned NumUniqueDeclarations,
858 unsigned NumComponentLists,
859 unsigned NumComponents) {
860 void *Mem = C.Allocate(
861 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
862 OMPClauseMappableExprCommon::MappableComponent>(
863 NumVars, NumUniqueDeclarations,
864 NumUniqueDeclarations + NumComponentLists, NumComponents));
865 return new (Mem) OMPFromClause(NumVars, NumUniqueDeclarations,
866 NumComponentLists, NumComponents);
867}
868
869void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
870 assert(VL.size() == varlist_size() &&(static_cast <bool> (VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 871, __extension__ __PRETTY_FUNCTION__))
871 "Number of private copies is not the same as the preallocated buffer")(static_cast <bool> (VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of private copies is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 871, __extension__ __PRETTY_FUNCTION__))
;
872 std::copy(VL.begin(), VL.end(), varlist_end());
873}
874
875void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
876 assert(VL.size() == varlist_size() &&(static_cast <bool> (VL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 877, __extension__ __PRETTY_FUNCTION__))
877 "Number of inits is not the same as the preallocated buffer")(static_cast <bool> (VL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"
) ? void (0) : __assert_fail ("VL.size() == varlist_size() && \"Number of inits is not the same as the preallocated buffer\""
, "/build/llvm-toolchain-snapshot-7~svn326246/tools/clang/lib/AST/OpenMPClause.cpp"
, 877, __extension__ __PRETTY_FUNCTION__))
;
878 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
879}
880
881OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
882 const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
883 SourceLocation EndLoc, ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
884 ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
885 MappableExprComponentListsRef ComponentLists) {
886 unsigned NumVars = Vars.size();
887 unsigned NumUniqueDeclarations =
888 getUniqueDeclarationsTotalNumber(Declarations);
889 unsigned NumComponentLists = ComponentLists.size();
890 unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
891
892 // We need to allocate:
893 // 3 x NumVars x Expr* - we have an original list expression for each clause
894 // list entry and an equal number of private copies and inits.
895 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
896 // with each component list.
897 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
898 // number of lists for each unique declaration and the size of each component
899 // list.
900 // NumComponents x MappableComponent - the total of all the components in all
901 // the lists.
902 void *Mem = C.Allocate(
903 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
904 OMPClauseMappableExprCommon::MappableComponent>(
905 3 * NumVars, NumUniqueDeclarations,
906 NumUniqueDeclarations + NumComponentLists, NumComponents));
907
908 OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(
909 StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
910 NumComponentLists, NumComponents);
911
912 Clause->setVarRefs(Vars);
913 Clause->setPrivateCopies(PrivateVars);
914 Clause->setInits(Inits);
915 Clause->setClauseInfo(Declarations, ComponentLists);
916 return Clause;
917}
918
919OMPUseDevicePtrClause *OMPUseDevicePtrClause::CreateEmpty(
920 const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
921 unsigned NumComponentLists, unsigned NumComponents) {
922 void *Mem = C.Allocate(
923 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
924 OMPClauseMappableExprCommon::MappableComponent>(
925 3 * NumVars, NumUniqueDeclarations,
926 NumUniqueDeclarations + NumComponentLists, NumComponents));
927 return new (Mem) OMPUseDevicePtrClause(NumVars, NumUniqueDeclarations,
928 NumComponentLists, NumComponents);
929}
930
931OMPIsDevicePtrClause *
932OMPIsDevicePtrClause::Create(const ASTContext &C, SourceLocation StartLoc,
933 SourceLocation LParenLoc, SourceLocation EndLoc,
934 ArrayRef<Expr *> Vars,
935 ArrayRef<ValueDecl *> Declarations,
936 MappableExprComponentListsRef ComponentLists) {
937 unsigned NumVars = Vars.size();
938 unsigned NumUniqueDeclarations =
939 getUniqueDeclarationsTotalNumber(Declarations);
940 unsigned NumComponentLists = ComponentLists.size();
941 unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
942
943 // We need to allocate:
944 // NumVars x Expr* - we have an original list expression for each clause list
945 // entry.
946 // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
947 // with each component list.
948 // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
949 // number of lists for each unique declaration and the size of each component
950 // list.
951 // NumComponents x MappableComponent - the total of all the components in all
952 // the lists.
953 void *Mem = C.Allocate(
954 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
955 OMPClauseMappableExprCommon::MappableComponent>(
956 NumVars, NumUniqueDeclarations,
957 NumUniqueDeclarations + NumComponentLists, NumComponents));
958
959 OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(
960 StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
961 NumComponentLists, NumComponents);
962
963 Clause->setVarRefs(Vars);
964 Clause->setClauseInfo(Declarations, ComponentLists);
965 return Clause;
966}
967
968OMPIsDevicePtrClause *OMPIsDevicePtrClause::CreateEmpty(
969 const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
970 unsigned NumComponentLists, unsigned NumComponents) {
971 void *Mem = C.Allocate(
972 totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
973 OMPClauseMappableExprCommon::MappableComponent>(
974 NumVars, NumUniqueDeclarations,
975 NumUniqueDeclarations + NumComponentLists, NumComponents));
976 return new (Mem) OMPIsDevicePtrClause(NumVars, NumUniqueDeclarations,
977 NumComponentLists, NumComponents);
978}