clang  3.7.0
Stmt.cpp
Go to the documentation of this file.
1 //===--- Stmt.cpp - Statement AST Node Implementation ---------------------===//
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 Stmt class and statement subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/ExprCXX.h"
17 #include "clang/AST/ExprObjC.h"
18 #include "clang/AST/Stmt.h"
19 #include "clang/AST/StmtCXX.h"
20 #include "clang/AST/StmtObjC.h"
21 #include "clang/AST/StmtOpenMP.h"
22 #include "clang/AST/Type.h"
23 #include "clang/Basic/CharInfo.h"
24 #include "clang/Basic/TargetInfo.h"
25 #include "clang/Lex/Token.h"
26 #include "llvm/ADT/StringExtras.h"
27 #include "llvm/Support/raw_ostream.h"
28 using namespace clang;
29 
30 static struct StmtClassNameTable {
31  const char *Name;
32  unsigned Counter;
33  unsigned Size;
34 } StmtClassInfo[Stmt::lastStmtConstant+1];
35 
36 static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
37  static bool Initialized = false;
38  if (Initialized)
39  return StmtClassInfo[E];
40 
41  // Intialize the table on the first use.
42  Initialized = true;
43 #define ABSTRACT_STMT(STMT)
44 #define STMT(CLASS, PARENT) \
45  StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
46  StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
47 #include "clang/AST/StmtNodes.inc"
48 
49  return StmtClassInfo[E];
50 }
51 
52 void *Stmt::operator new(size_t bytes, const ASTContext& C,
53  unsigned alignment) {
54  return ::operator new(bytes, C, alignment);
55 }
56 
57 const char *Stmt::getStmtClassName() const {
58  return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name;
59 }
60 
61 void Stmt::PrintStats() {
62  // Ensure the table is primed.
63  getStmtInfoTableEntry(Stmt::NullStmtClass);
64 
65  unsigned sum = 0;
66  llvm::errs() << "\n*** Stmt/Expr Stats:\n";
67  for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
68  if (StmtClassInfo[i].Name == nullptr) continue;
69  sum += StmtClassInfo[i].Counter;
70  }
71  llvm::errs() << " " << sum << " stmts/exprs total.\n";
72  sum = 0;
73  for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
74  if (StmtClassInfo[i].Name == nullptr) continue;
75  if (StmtClassInfo[i].Counter == 0) continue;
76  llvm::errs() << " " << StmtClassInfo[i].Counter << " "
77  << StmtClassInfo[i].Name << ", " << StmtClassInfo[i].Size
78  << " each (" << StmtClassInfo[i].Counter*StmtClassInfo[i].Size
79  << " bytes)\n";
81  }
82 
83  llvm::errs() << "Total bytes = " << sum << "\n";
84 }
85 
86 void Stmt::addStmtClass(StmtClass s) {
88 }
89 
90 bool Stmt::StatisticsEnabled = false;
91 void Stmt::EnableStatistics() {
92  StatisticsEnabled = true;
93 }
94 
95 Stmt *Stmt::IgnoreImplicit() {
96  Stmt *s = this;
97 
98  if (auto *ewc = dyn_cast<ExprWithCleanups>(s))
99  s = ewc->getSubExpr();
100 
101  if (auto *mte = dyn_cast<MaterializeTemporaryExpr>(s))
102  s = mte->GetTemporaryExpr();
103 
104  if (auto *bte = dyn_cast<CXXBindTemporaryExpr>(s))
105  s = bte->getSubExpr();
106 
107  while (auto *ice = dyn_cast<ImplicitCastExpr>(s))
108  s = ice->getSubExpr();
109 
110  return s;
111 }
112 
113 /// \brief Skip no-op (attributed, compound) container stmts and skip captured
114 /// stmt at the top, if \a IgnoreCaptured is true.
115 Stmt *Stmt::IgnoreContainers(bool IgnoreCaptured) {
116  Stmt *S = this;
117  if (IgnoreCaptured)
118  if (auto CapS = dyn_cast_or_null<CapturedStmt>(S))
119  S = CapS->getCapturedStmt();
120  while (true) {
121  if (auto AS = dyn_cast_or_null<AttributedStmt>(S))
122  S = AS->getSubStmt();
123  else if (auto CS = dyn_cast_or_null<CompoundStmt>(S)) {
124  if (CS->size() != 1)
125  break;
126  S = CS->body_back();
127  } else
128  break;
129  }
130  return S;
131 }
132 
133 /// \brief Strip off all label-like statements.
134 ///
135 /// This will strip off label statements, case statements, attributed
136 /// statements and default statements recursively.
137 const Stmt *Stmt::stripLabelLikeStatements() const {
138  const Stmt *S = this;
139  while (true) {
140  if (const LabelStmt *LS = dyn_cast<LabelStmt>(S))
141  S = LS->getSubStmt();
142  else if (const SwitchCase *SC = dyn_cast<SwitchCase>(S))
143  S = SC->getSubStmt();
144  else if (const AttributedStmt *AS = dyn_cast<AttributedStmt>(S))
145  S = AS->getSubStmt();
146  else
147  return S;
148  }
149 }
150 
151 namespace {
152  struct good {};
153  struct bad {};
154 
155  // These silly little functions have to be static inline to suppress
156  // unused warnings, and they have to be defined to suppress other
157  // warnings.
158  static inline good is_good(good) { return good(); }
159 
160  typedef Stmt::child_range children_t();
161  template <class T> good implements_children(children_t T::*) {
162  return good();
163  }
164  LLVM_ATTRIBUTE_UNUSED
165  static inline bad implements_children(children_t Stmt::*) {
166  return bad();
167  }
168 
169  typedef SourceLocation getLocStart_t() const;
170  template <class T> good implements_getLocStart(getLocStart_t T::*) {
171  return good();
172  }
173  LLVM_ATTRIBUTE_UNUSED
174  static inline bad implements_getLocStart(getLocStart_t Stmt::*) {
175  return bad();
176  }
177 
178  typedef SourceLocation getLocEnd_t() const;
179  template <class T> good implements_getLocEnd(getLocEnd_t T::*) {
180  return good();
181  }
182  LLVM_ATTRIBUTE_UNUSED
183  static inline bad implements_getLocEnd(getLocEnd_t Stmt::*) {
184  return bad();
185  }
186 
187 #define ASSERT_IMPLEMENTS_children(type) \
188  (void) is_good(implements_children(&type::children))
189 #define ASSERT_IMPLEMENTS_getLocStart(type) \
190  (void) is_good(implements_getLocStart(&type::getLocStart))
191 #define ASSERT_IMPLEMENTS_getLocEnd(type) \
192  (void) is_good(implements_getLocEnd(&type::getLocEnd))
193 }
194 
195 /// Check whether the various Stmt classes implement their member
196 /// functions.
197 LLVM_ATTRIBUTE_UNUSED
198 static inline void check_implementations() {
199 #define ABSTRACT_STMT(type)
200 #define STMT(type, base) \
201  ASSERT_IMPLEMENTS_children(type); \
202  ASSERT_IMPLEMENTS_getLocStart(type); \
203  ASSERT_IMPLEMENTS_getLocEnd(type);
204 #include "clang/AST/StmtNodes.inc"
205 }
206 
207 Stmt::child_range Stmt::children() {
208  switch (getStmtClass()) {
209  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
210 #define ABSTRACT_STMT(type)
211 #define STMT(type, base) \
212  case Stmt::type##Class: \
213  return static_cast<type*>(this)->children();
214 #include "clang/AST/StmtNodes.inc"
215  }
216  llvm_unreachable("unknown statement kind!");
217 }
218 
219 // Amusing macro metaprogramming hack: check whether a class provides
220 // a more specific implementation of getSourceRange.
221 //
222 // See also Expr.cpp:getExprLoc().
223 namespace {
224  /// This implementation is used when a class provides a custom
225  /// implementation of getSourceRange.
226  template <class S, class T>
227  SourceRange getSourceRangeImpl(const Stmt *stmt,
228  SourceRange (T::*v)() const) {
229  return static_cast<const S*>(stmt)->getSourceRange();
230  }
231 
232  /// This implementation is used when a class doesn't provide a custom
233  /// implementation of getSourceRange. Overload resolution should pick it over
234  /// the implementation above because it's more specialized according to
235  /// function template partial ordering.
236  template <class S>
237  SourceRange getSourceRangeImpl(const Stmt *stmt,
238  SourceRange (Stmt::*v)() const) {
239  return SourceRange(static_cast<const S*>(stmt)->getLocStart(),
240  static_cast<const S*>(stmt)->getLocEnd());
241  }
242 }
243 
244 SourceRange Stmt::getSourceRange() const {
245  switch (getStmtClass()) {
246  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
247 #define ABSTRACT_STMT(type)
248 #define STMT(type, base) \
249  case Stmt::type##Class: \
250  return getSourceRangeImpl<type>(this, &type::getSourceRange);
251 #include "clang/AST/StmtNodes.inc"
252  }
253  llvm_unreachable("unknown statement kind!");
254 }
255 
256 SourceLocation Stmt::getLocStart() const {
257 // llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
258  switch (getStmtClass()) {
259  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
260 #define ABSTRACT_STMT(type)
261 #define STMT(type, base) \
262  case Stmt::type##Class: \
263  return static_cast<const type*>(this)->getLocStart();
264 #include "clang/AST/StmtNodes.inc"
265  }
266  llvm_unreachable("unknown statement kind");
267 }
268 
269 SourceLocation Stmt::getLocEnd() const {
270  switch (getStmtClass()) {
271  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
272 #define ABSTRACT_STMT(type)
273 #define STMT(type, base) \
274  case Stmt::type##Class: \
275  return static_cast<const type*>(this)->getLocEnd();
276 #include "clang/AST/StmtNodes.inc"
277  }
278  llvm_unreachable("unknown statement kind");
279 }
280 
283  : Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) {
284  CompoundStmtBits.NumStmts = Stmts.size();
285  assert(CompoundStmtBits.NumStmts == Stmts.size() &&
286  "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
287 
288  if (Stmts.size() == 0) {
289  Body = nullptr;
290  return;
291  }
292 
293  Body = new (C) Stmt*[Stmts.size()];
294  std::copy(Stmts.begin(), Stmts.end(), Body);
295 }
296 
298  unsigned NumStmts) {
299  if (this->Body)
300  C.Deallocate(Body);
301  this->CompoundStmtBits.NumStmts = NumStmts;
302 
303  Body = new (C) Stmt*[NumStmts];
304  memcpy(Body, Stmts, sizeof(Stmt *) * NumStmts);
305 }
306 
307 const char *LabelStmt::getName() const {
308  return getDecl()->getIdentifier()->getNameStart();
309 }
310 
312  ArrayRef<const Attr*> Attrs,
313  Stmt *SubStmt) {
314  assert(!Attrs.empty() && "Attrs should not be empty");
315  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * Attrs.size(),
316  llvm::alignOf<AttributedStmt>());
317  return new (Mem) AttributedStmt(Loc, Attrs, SubStmt);
318 }
319 
321  unsigned NumAttrs) {
322  assert(NumAttrs > 0 && "NumAttrs should be greater than zero");
323  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * NumAttrs,
324  llvm::alignOf<AttributedStmt>());
325  return new (Mem) AttributedStmt(EmptyShell(), NumAttrs);
326 }
327 
328 std::string AsmStmt::generateAsmString(const ASTContext &C) const {
329  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
330  return gccAsmStmt->generateAsmString(C);
331  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
332  return msAsmStmt->generateAsmString(C);
333  llvm_unreachable("unknown asm statement kind!");
334 }
335 
336 StringRef AsmStmt::getOutputConstraint(unsigned i) const {
337  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
338  return gccAsmStmt->getOutputConstraint(i);
339  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
340  return msAsmStmt->getOutputConstraint(i);
341  llvm_unreachable("unknown asm statement kind!");
342 }
343 
344 const Expr *AsmStmt::getOutputExpr(unsigned i) const {
345  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
346  return gccAsmStmt->getOutputExpr(i);
347  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
348  return msAsmStmt->getOutputExpr(i);
349  llvm_unreachable("unknown asm statement kind!");
350 }
351 
352 StringRef AsmStmt::getInputConstraint(unsigned i) const {
353  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
354  return gccAsmStmt->getInputConstraint(i);
355  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
356  return msAsmStmt->getInputConstraint(i);
357  llvm_unreachable("unknown asm statement kind!");
358 }
359 
360 const Expr *AsmStmt::getInputExpr(unsigned i) const {
361  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
362  return gccAsmStmt->getInputExpr(i);
363  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
364  return msAsmStmt->getInputExpr(i);
365  llvm_unreachable("unknown asm statement kind!");
366 }
367 
368 StringRef AsmStmt::getClobber(unsigned i) const {
369  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
370  return gccAsmStmt->getClobber(i);
371  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
372  return msAsmStmt->getClobber(i);
373  llvm_unreachable("unknown asm statement kind!");
374 }
375 
376 /// getNumPlusOperands - Return the number of output operands that have a "+"
377 /// constraint.
378 unsigned AsmStmt::getNumPlusOperands() const {
379  unsigned Res = 0;
380  for (unsigned i = 0, e = getNumOutputs(); i != e; ++i)
381  if (isOutputPlusConstraint(i))
382  ++Res;
383  return Res;
384 }
385 
387  assert(isOperand() && "Only Operands can have modifiers.");
388  return isLetter(Str[0]) ? Str[0] : '\0';
389 }
390 
391 StringRef GCCAsmStmt::getClobber(unsigned i) const {
392  return getClobberStringLiteral(i)->getString();
393 }
394 
396  return cast<Expr>(Exprs[i]);
397 }
398 
399 /// getOutputConstraint - Return the constraint string for the specified
400 /// output operand. All output constraints are known to be non-empty (either
401 /// '=' or '+').
402 StringRef GCCAsmStmt::getOutputConstraint(unsigned i) const {
404 }
405 
407  return cast<Expr>(Exprs[i + NumOutputs]);
408 }
409 void GCCAsmStmt::setInputExpr(unsigned i, Expr *E) {
410  Exprs[i + NumOutputs] = E;
411 }
412 
413 /// getInputConstraint - Return the specified input constraint. Unlike output
414 /// constraints, these can be empty.
415 StringRef GCCAsmStmt::getInputConstraint(unsigned i) const {
417 }
418 
419 void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C,
420  IdentifierInfo **Names,
421  StringLiteral **Constraints,
422  Stmt **Exprs,
423  unsigned NumOutputs,
424  unsigned NumInputs,
425  StringLiteral **Clobbers,
426  unsigned NumClobbers) {
427  this->NumOutputs = NumOutputs;
428  this->NumInputs = NumInputs;
429  this->NumClobbers = NumClobbers;
430 
431  unsigned NumExprs = NumOutputs + NumInputs;
432 
433  C.Deallocate(this->Names);
434  this->Names = new (C) IdentifierInfo*[NumExprs];
435  std::copy(Names, Names + NumExprs, this->Names);
436 
437  C.Deallocate(this->Exprs);
438  this->Exprs = new (C) Stmt*[NumExprs];
439  std::copy(Exprs, Exprs + NumExprs, this->Exprs);
440 
441  C.Deallocate(this->Constraints);
442  this->Constraints = new (C) StringLiteral*[NumExprs];
443  std::copy(Constraints, Constraints + NumExprs, this->Constraints);
444 
445  C.Deallocate(this->Clobbers);
446  this->Clobbers = new (C) StringLiteral*[NumClobbers];
447  std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers);
448 }
449 
450 /// getNamedOperand - Given a symbolic operand reference like %[foo],
451 /// translate this into a numeric value needed to reference the same operand.
452 /// This returns -1 if the operand name is invalid.
453 int GCCAsmStmt::getNamedOperand(StringRef SymbolicName) const {
454  unsigned NumPlusOperands = 0;
455 
456  // Check if this is an output operand.
457  for (unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
458  if (getOutputName(i) == SymbolicName)
459  return i;
460  }
461 
462  for (unsigned i = 0, e = getNumInputs(); i != e; ++i)
463  if (getInputName(i) == SymbolicName)
464  return getNumOutputs() + NumPlusOperands + i;
465 
466  // Not found.
467  return -1;
468 }
469 
470 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
471 /// it into pieces. If the asm string is erroneous, emit errors and return
472 /// true, otherwise return false.
474  const ASTContext &C, unsigned &DiagOffs) const {
475  StringRef Str = getAsmString()->getString();
476  const char *StrStart = Str.begin();
477  const char *StrEnd = Str.end();
478  const char *CurPtr = StrStart;
479 
480  // "Simple" inline asms have no constraints or operands, just convert the asm
481  // string to escape $'s.
482  if (isSimple()) {
483  std::string Result;
484  for (; CurPtr != StrEnd; ++CurPtr) {
485  switch (*CurPtr) {
486  case '$':
487  Result += "$$";
488  break;
489  default:
490  Result += *CurPtr;
491  break;
492  }
493  }
494  Pieces.push_back(AsmStringPiece(Result));
495  return 0;
496  }
497 
498  // CurStringPiece - The current string that we are building up as we scan the
499  // asm string.
500  std::string CurStringPiece;
501 
502  bool HasVariants = !C.getTargetInfo().hasNoAsmVariants();
503 
504  while (1) {
505  // Done with the string?
506  if (CurPtr == StrEnd) {
507  if (!CurStringPiece.empty())
508  Pieces.push_back(AsmStringPiece(CurStringPiece));
509  return 0;
510  }
511 
512  char CurChar = *CurPtr++;
513  switch (CurChar) {
514  case '$': CurStringPiece += "$$"; continue;
515  case '{': CurStringPiece += (HasVariants ? "$(" : "{"); continue;
516  case '|': CurStringPiece += (HasVariants ? "$|" : "|"); continue;
517  case '}': CurStringPiece += (HasVariants ? "$)" : "}"); continue;
518  case '%':
519  break;
520  default:
521  CurStringPiece += CurChar;
522  continue;
523  }
524 
525  // Escaped "%" character in asm string.
526  if (CurPtr == StrEnd) {
527  // % at end of string is invalid (no escape).
528  DiagOffs = CurPtr-StrStart-1;
529  return diag::err_asm_invalid_escape;
530  }
531 
532  char EscapedChar = *CurPtr++;
533  if (EscapedChar == '%') { // %% -> %
534  // Escaped percentage sign.
535  CurStringPiece += '%';
536  continue;
537  }
538 
539  if (EscapedChar == '=') { // %= -> Generate an unique ID.
540  CurStringPiece += "${:uid}";
541  continue;
542  }
543 
544  // Otherwise, we have an operand. If we have accumulated a string so far,
545  // add it to the Pieces list.
546  if (!CurStringPiece.empty()) {
547  Pieces.push_back(AsmStringPiece(CurStringPiece));
548  CurStringPiece.clear();
549  }
550 
551  // Handle operands that have asmSymbolicName (e.g., %x[foo]) and those that
552  // don't (e.g., %x4). 'x' following the '%' is the constraint modifier.
553 
554  const char *Begin = CurPtr - 1; // Points to the character following '%'.
555  const char *Percent = Begin - 1; // Points to '%'.
556 
557  if (isLetter(EscapedChar)) {
558  if (CurPtr == StrEnd) { // Premature end.
559  DiagOffs = CurPtr-StrStart-1;
560  return diag::err_asm_invalid_escape;
561  }
562  EscapedChar = *CurPtr++;
563  }
564 
565  const TargetInfo &TI = C.getTargetInfo();
566  const SourceManager &SM = C.getSourceManager();
567  const LangOptions &LO = C.getLangOpts();
568 
569  // Handle operands that don't have asmSymbolicName (e.g., %x4).
570  if (isDigit(EscapedChar)) {
571  // %n - Assembler operand n
572  unsigned N = 0;
573 
574  --CurPtr;
575  while (CurPtr != StrEnd && isDigit(*CurPtr))
576  N = N*10 + ((*CurPtr++)-'0');
577 
578  unsigned NumOperands =
580  if (N >= NumOperands) {
581  DiagOffs = CurPtr-StrStart-1;
582  return diag::err_asm_invalid_operand_number;
583  }
584 
585  // Str contains "x4" (Operand without the leading %).
586  std::string Str(Begin, CurPtr - Begin);
587 
588  // (BeginLoc, EndLoc) represents the range of the operand we are currently
589  // processing. Unlike Str, the range includes the leading '%'.
590  SourceLocation BeginLoc =
591  getAsmString()->getLocationOfByte(Percent - StrStart, SM, LO, TI);
592  SourceLocation EndLoc =
593  getAsmString()->getLocationOfByte(CurPtr - StrStart, SM, LO, TI);
594 
595  Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
596  continue;
597  }
598 
599  // Handle operands that have asmSymbolicName (e.g., %x[foo]).
600  if (EscapedChar == '[') {
601  DiagOffs = CurPtr-StrStart-1;
602 
603  // Find the ']'.
604  const char *NameEnd = (const char*)memchr(CurPtr, ']', StrEnd-CurPtr);
605  if (NameEnd == nullptr)
606  return diag::err_asm_unterminated_symbolic_operand_name;
607  if (NameEnd == CurPtr)
608  return diag::err_asm_empty_symbolic_operand_name;
609 
610  StringRef SymbolicName(CurPtr, NameEnd - CurPtr);
611 
612  int N = getNamedOperand(SymbolicName);
613  if (N == -1) {
614  // Verify that an operand with that name exists.
615  DiagOffs = CurPtr-StrStart;
616  return diag::err_asm_unknown_symbolic_operand_name;
617  }
618 
619  // Str contains "x[foo]" (Operand without the leading %).
620  std::string Str(Begin, NameEnd + 1 - Begin);
621 
622  // (BeginLoc, EndLoc) represents the range of the operand we are currently
623  // processing. Unlike Str, the range includes the leading '%'.
624  SourceLocation BeginLoc =
625  getAsmString()->getLocationOfByte(Percent - StrStart, SM, LO, TI);
626  SourceLocation EndLoc =
627  getAsmString()->getLocationOfByte(NameEnd + 1 - StrStart, SM, LO, TI);
628 
629  Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
630 
631  CurPtr = NameEnd+1;
632  continue;
633  }
634 
635  DiagOffs = CurPtr-StrStart-1;
636  return diag::err_asm_invalid_escape;
637  }
638 }
639 
640 /// Assemble final IR asm string (GCC-style).
641 std::string GCCAsmStmt::generateAsmString(const ASTContext &C) const {
642  // Analyze the asm string to decompose it into its pieces. We know that Sema
643  // has already done this, so it is guaranteed to be successful.
645  unsigned DiagOffs;
646  AnalyzeAsmString(Pieces, C, DiagOffs);
647 
648  std::string AsmString;
649  for (unsigned i = 0, e = Pieces.size(); i != e; ++i) {
650  if (Pieces[i].isString())
651  AsmString += Pieces[i].getString();
652  else if (Pieces[i].getModifier() == '\0')
653  AsmString += '$' + llvm::utostr(Pieces[i].getOperandNo());
654  else
655  AsmString += "${" + llvm::utostr(Pieces[i].getOperandNo()) + ':' +
656  Pieces[i].getModifier() + '}';
657  }
658  return AsmString;
659 }
660 
661 /// Assemble final IR asm string (MS-style).
662 std::string MSAsmStmt::generateAsmString(const ASTContext &C) const {
663  // FIXME: This needs to be translated into the IR string representation.
664  return AsmStr;
665 }
666 
668  return cast<Expr>(Exprs[i]);
669 }
670 
672  return cast<Expr>(Exprs[i + NumOutputs]);
673 }
674 void MSAsmStmt::setInputExpr(unsigned i, Expr *E) {
675  Exprs[i + NumOutputs] = E;
676 }
677 
679  if (ExceptionDecl)
680  return ExceptionDecl->getType();
681  return QualType();
682 }
683 
684 //===----------------------------------------------------------------------===//
685 // Constructors
686 //===----------------------------------------------------------------------===//
687 
689  bool issimple, bool isvolatile, unsigned numoutputs,
690  unsigned numinputs, IdentifierInfo **names,
691  StringLiteral **constraints, Expr **exprs,
692  StringLiteral *asmstr, unsigned numclobbers,
693  StringLiteral **clobbers, SourceLocation rparenloc)
694  : AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
695  numinputs, numclobbers), RParenLoc(rparenloc), AsmStr(asmstr) {
696 
697  unsigned NumExprs = NumOutputs + NumInputs;
698 
699  Names = new (C) IdentifierInfo*[NumExprs];
700  std::copy(names, names + NumExprs, Names);
701 
702  Exprs = new (C) Stmt*[NumExprs];
703  std::copy(exprs, exprs + NumExprs, Exprs);
704 
705  Constraints = new (C) StringLiteral*[NumExprs];
706  std::copy(constraints, constraints + NumExprs, Constraints);
707 
708  Clobbers = new (C) StringLiteral*[NumClobbers];
709  std::copy(clobbers, clobbers + NumClobbers, Clobbers);
710 }
711 
713  SourceLocation lbraceloc, bool issimple, bool isvolatile,
714  ArrayRef<Token> asmtoks, unsigned numoutputs,
715  unsigned numinputs,
716  ArrayRef<StringRef> constraints, ArrayRef<Expr*> exprs,
717  StringRef asmstr, ArrayRef<StringRef> clobbers,
718  SourceLocation endloc)
719  : AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
720  numinputs, clobbers.size()), LBraceLoc(lbraceloc),
721  EndLoc(endloc), NumAsmToks(asmtoks.size()) {
722 
723  initialize(C, asmstr, asmtoks, constraints, exprs, clobbers);
724 }
725 
726 static StringRef copyIntoContext(const ASTContext &C, StringRef str) {
727  if (str.empty())
728  return StringRef();
729  size_t size = str.size();
730  char *buffer = new (C) char[size];
731  memcpy(buffer, str.data(), size);
732  return StringRef(buffer, size);
733 }
734 
735 void MSAsmStmt::initialize(const ASTContext &C, StringRef asmstr,
736  ArrayRef<Token> asmtoks,
737  ArrayRef<StringRef> constraints,
738  ArrayRef<Expr*> exprs,
739  ArrayRef<StringRef> clobbers) {
740  assert(NumAsmToks == asmtoks.size());
741  assert(NumClobbers == clobbers.size());
742 
743  unsigned NumExprs = exprs.size();
744  assert(NumExprs == NumOutputs + NumInputs);
745  assert(NumExprs == constraints.size());
746 
747  AsmStr = copyIntoContext(C, asmstr);
748 
749  Exprs = new (C) Stmt*[NumExprs];
750  for (unsigned i = 0, e = NumExprs; i != e; ++i)
751  Exprs[i] = exprs[i];
752 
753  AsmToks = new (C) Token[NumAsmToks];
754  for (unsigned i = 0, e = NumAsmToks; i != e; ++i)
755  AsmToks[i] = asmtoks[i];
756 
757  Constraints = new (C) StringRef[NumExprs];
758  for (unsigned i = 0, e = NumExprs; i != e; ++i) {
759  Constraints[i] = copyIntoContext(C, constraints[i]);
760  }
761 
762  Clobbers = new (C) StringRef[NumClobbers];
763  for (unsigned i = 0, e = NumClobbers; i != e; ++i) {
764  // FIXME: Avoid the allocation/copy if at all possible.
765  Clobbers[i] = copyIntoContext(C, clobbers[i]);
766  }
767 }
768 
770  Stmt *Body, SourceLocation FCL,
771  SourceLocation RPL)
772 : Stmt(ObjCForCollectionStmtClass) {
773  SubExprs[ELEM] = Elem;
774  SubExprs[COLLECTION] = Collect;
775  SubExprs[BODY] = Body;
776  ForLoc = FCL;
777  RParenLoc = RPL;
778 }
779 
780 ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
781  Stmt **CatchStmts, unsigned NumCatchStmts,
782  Stmt *atFinallyStmt)
783  : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc),
784  NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != nullptr) {
785  Stmt **Stmts = getStmts();
786  Stmts[0] = atTryStmt;
787  for (unsigned I = 0; I != NumCatchStmts; ++I)
788  Stmts[I + 1] = CatchStmts[I];
789 
790  if (HasFinally)
791  Stmts[NumCatchStmts + 1] = atFinallyStmt;
792 }
793 
795  SourceLocation atTryLoc,
796  Stmt *atTryStmt,
797  Stmt **CatchStmts,
798  unsigned NumCatchStmts,
799  Stmt *atFinallyStmt) {
800  unsigned Size = sizeof(ObjCAtTryStmt) +
801  (1 + NumCatchStmts + (atFinallyStmt != nullptr)) * sizeof(Stmt *);
802  void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>());
803  return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts,
804  atFinallyStmt);
805 }
806 
808  unsigned NumCatchStmts,
809  bool HasFinally) {
810  unsigned Size = sizeof(ObjCAtTryStmt) +
811  (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *);
812  void *Mem = Context.Allocate(Size, llvm::alignOf<ObjCAtTryStmt>());
813  return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
814 }
815 
817  if (HasFinally)
818  return getFinallyStmt()->getLocEnd();
819  if (NumCatchStmts)
820  return getCatchStmt(NumCatchStmts - 1)->getLocEnd();
821  return getTryBody()->getLocEnd();
822 }
823 
825  Stmt *tryBlock, ArrayRef<Stmt*> handlers) {
826  std::size_t Size = sizeof(CXXTryStmt);
827  Size += ((handlers.size() + 1) * sizeof(Stmt));
828 
829  void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>());
830  return new (Mem) CXXTryStmt(tryLoc, tryBlock, handlers);
831 }
832 
833 CXXTryStmt *CXXTryStmt::Create(const ASTContext &C, EmptyShell Empty,
834  unsigned numHandlers) {
835  std::size_t Size = sizeof(CXXTryStmt);
836  Size += ((numHandlers + 1) * sizeof(Stmt));
837 
838  void *Mem = C.Allocate(Size, llvm::alignOf<CXXTryStmt>());
839  return new (Mem) CXXTryStmt(Empty, numHandlers);
840 }
841 
842 CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, Stmt *tryBlock,
843  ArrayRef<Stmt*> handlers)
844  : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {
845  Stmt **Stmts = reinterpret_cast<Stmt **>(this + 1);
846  Stmts[0] = tryBlock;
847  std::copy(handlers.begin(), handlers.end(), Stmts + 1);
848 }
849 
851  Expr *Cond, Expr *Inc, DeclStmt *LoopVar,
852  Stmt *Body, SourceLocation FL,
854  : Stmt(CXXForRangeStmtClass), ForLoc(FL), ColonLoc(CL), RParenLoc(RPL) {
855  SubExprs[RANGE] = Range;
856  SubExprs[BEGINEND] = BeginEndStmt;
857  SubExprs[COND] = Cond;
858  SubExprs[INC] = Inc;
859  SubExprs[LOOPVAR] = LoopVar;
860  SubExprs[BODY] = Body;
861 }
862 
864  DeclStmt *RangeStmt = getRangeStmt();
865  VarDecl *RangeDecl = dyn_cast_or_null<VarDecl>(RangeStmt->getSingleDecl());
866  assert(RangeDecl && "for-range should have a single var decl");
867  return RangeDecl->getInit();
868 }
869 
871  return const_cast<CXXForRangeStmt*>(this)->getRangeInit();
872 }
873 
875  Decl *LV = cast<DeclStmt>(getLoopVarStmt())->getSingleDecl();
876  assert(LV && "No loop variable in CXXForRangeStmt");
877  return cast<VarDecl>(LV);
878 }
879 
881  return const_cast<CXXForRangeStmt*>(this)->getLoopVariable();
882 }
883 
885  Stmt *then, SourceLocation EL, Stmt *elsev)
886  : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL)
887 {
888  setConditionVariable(C, var);
889  SubExprs[COND] = cond;
890  SubExprs[THEN] = then;
891  SubExprs[ELSE] = elsev;
892 }
893 
895  if (!SubExprs[VAR])
896  return nullptr;
897 
898  DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
899  return cast<VarDecl>(DS->getSingleDecl());
900 }
901 
903  if (!V) {
904  SubExprs[VAR] = nullptr;
905  return;
906  }
907 
908  SourceRange VarRange = V->getSourceRange();
909  SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
910  VarRange.getEnd());
911 }
912 
913 ForStmt::ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
914  Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
915  SourceLocation RP)
916  : Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP)
917 {
918  SubExprs[INIT] = Init;
919  setConditionVariable(C, condVar);
920  SubExprs[COND] = Cond;
921  SubExprs[INC] = Inc;
922  SubExprs[BODY] = Body;
923 }
924 
926  if (!SubExprs[CONDVAR])
927  return nullptr;
928 
929  DeclStmt *DS = cast<DeclStmt>(SubExprs[CONDVAR]);
930  return cast<VarDecl>(DS->getSingleDecl());
931 }
932 
934  if (!V) {
935  SubExprs[CONDVAR] = nullptr;
936  return;
937  }
938 
939  SourceRange VarRange = V->getSourceRange();
940  SubExprs[CONDVAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
941  VarRange.getEnd());
942 }
943 
945  : Stmt(SwitchStmtClass), FirstCase(nullptr, false) {
946  setConditionVariable(C, Var);
947  SubExprs[COND] = cond;
948  SubExprs[BODY] = nullptr;
949 }
950 
952  if (!SubExprs[VAR])
953  return nullptr;
954 
955  DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
956  return cast<VarDecl>(DS->getSingleDecl());
957 }
958 
960  if (!V) {
961  SubExprs[VAR] = nullptr;
962  return;
963  }
964 
965  SourceRange VarRange = V->getSourceRange();
966  SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
967  VarRange.getEnd());
968 }
969 
971  if (isa<CaseStmt>(this))
972  return cast<CaseStmt>(this)->getSubStmt();
973  return cast<DefaultStmt>(this)->getSubStmt();
974 }
975 
976 WhileStmt::WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
977  SourceLocation WL)
978  : Stmt(WhileStmtClass) {
979  setConditionVariable(C, Var);
980  SubExprs[COND] = cond;
981  SubExprs[BODY] = body;
982  WhileLoc = WL;
983 }
984 
986  if (!SubExprs[VAR])
987  return nullptr;
988 
989  DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
990  return cast<VarDecl>(DS->getSingleDecl());
991 }
992 
994  if (!V) {
995  SubExprs[VAR] = nullptr;
996  return;
997  }
998 
999  SourceRange VarRange = V->getSourceRange();
1000  SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
1001  VarRange.getEnd());
1002 }
1003 
1004 // IndirectGotoStmt
1006  if (AddrLabelExpr *E =
1007  dyn_cast<AddrLabelExpr>(getTarget()->IgnoreParenImpCasts()))
1008  return E->getLabel();
1009  return nullptr;
1010 }
1011 
1012 // ReturnStmt
1014  return cast_or_null<Expr>(RetExpr);
1015 }
1017  return cast_or_null<Expr>(RetExpr);
1018 }
1019 
1020 SEHTryStmt::SEHTryStmt(bool IsCXXTry,
1021  SourceLocation TryLoc,
1022  Stmt *TryBlock,
1023  Stmt *Handler)
1024  : Stmt(SEHTryStmtClass),
1025  IsCXXTry(IsCXXTry),
1026  TryLoc(TryLoc)
1027 {
1028  Children[TRY] = TryBlock;
1029  Children[HANDLER] = Handler;
1030 }
1031 
1032 SEHTryStmt* SEHTryStmt::Create(const ASTContext &C, bool IsCXXTry,
1033  SourceLocation TryLoc, Stmt *TryBlock,
1034  Stmt *Handler) {
1035  return new(C) SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler);
1036 }
1037 
1039  return dyn_cast<SEHExceptStmt>(getHandler());
1040 }
1041 
1043  return dyn_cast<SEHFinallyStmt>(getHandler());
1044 }
1045 
1046 SEHExceptStmt::SEHExceptStmt(SourceLocation Loc,
1047  Expr *FilterExpr,
1048  Stmt *Block)
1049  : Stmt(SEHExceptStmtClass),
1050  Loc(Loc)
1051 {
1052  Children[FILTER_EXPR] = FilterExpr;
1053  Children[BLOCK] = Block;
1054 }
1055 
1057  Expr *FilterExpr, Stmt *Block) {
1058  return new(C) SEHExceptStmt(Loc,FilterExpr,Block);
1059 }
1060 
1061 SEHFinallyStmt::SEHFinallyStmt(SourceLocation Loc,
1062  Stmt *Block)
1063  : Stmt(SEHFinallyStmtClass),
1064  Loc(Loc),
1065  Block(Block)
1066 {}
1067 
1069  Stmt *Block) {
1070  return new(C)SEHFinallyStmt(Loc,Block);
1071 }
1072 
1073 CapturedStmt::Capture *CapturedStmt::getStoredCaptures() const {
1074  unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1);
1075 
1076  // Offset of the first Capture object.
1077  unsigned FirstCaptureOffset =
1078  llvm::RoundUpToAlignment(Size, llvm::alignOf<Capture>());
1079 
1080  return reinterpret_cast<Capture *>(
1081  reinterpret_cast<char *>(const_cast<CapturedStmt *>(this))
1082  + FirstCaptureOffset);
1083 }
1084 
1085 CapturedStmt::CapturedStmt(Stmt *S, CapturedRegionKind Kind,
1086  ArrayRef<Capture> Captures,
1087  ArrayRef<Expr *> CaptureInits,
1088  CapturedDecl *CD,
1089  RecordDecl *RD)
1090  : Stmt(CapturedStmtClass), NumCaptures(Captures.size()),
1091  CapDeclAndKind(CD, Kind), TheRecordDecl(RD) {
1092  assert( S && "null captured statement");
1093  assert(CD && "null captured declaration for captured statement");
1094  assert(RD && "null record declaration for captured statement");
1095 
1096  // Copy initialization expressions.
1097  Stmt **Stored = getStoredStmts();
1098  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
1099  *Stored++ = CaptureInits[I];
1100 
1101  // Copy the statement being captured.
1102  *Stored = S;
1103 
1104  // Copy all Capture objects.
1105  Capture *Buffer = getStoredCaptures();
1106  std::copy(Captures.begin(), Captures.end(), Buffer);
1107 }
1108 
1109 CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures)
1110  : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
1111  CapDeclAndKind(nullptr, CR_Default), TheRecordDecl(nullptr) {
1112  getStoredStmts()[NumCaptures] = nullptr;
1113 }
1114 
1116  CapturedRegionKind Kind,
1117  ArrayRef<Capture> Captures,
1118  ArrayRef<Expr *> CaptureInits,
1119  CapturedDecl *CD,
1120  RecordDecl *RD) {
1121  // The layout is
1122  //
1123  // -----------------------------------------------------------
1124  // | CapturedStmt, Init, ..., Init, S, Capture, ..., Capture |
1125  // ----------------^-------------------^----------------------
1126  // getStoredStmts() getStoredCaptures()
1127  //
1128  // where S is the statement being captured.
1129  //
1130  assert(CaptureInits.size() == Captures.size() && "wrong number of arguments");
1131 
1132  unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (Captures.size() + 1);
1133  if (!Captures.empty()) {
1134  // Realign for the following Capture array.
1135  Size = llvm::RoundUpToAlignment(Size, llvm::alignOf<Capture>());
1136  Size += sizeof(Capture) * Captures.size();
1137  }
1138 
1139  void *Mem = Context.Allocate(Size);
1140  return new (Mem) CapturedStmt(S, Kind, Captures, CaptureInits, CD, RD);
1141 }
1142 
1144  unsigned NumCaptures) {
1145  unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1);
1146  if (NumCaptures > 0) {
1147  // Realign for the following Capture array.
1148  Size = llvm::RoundUpToAlignment(Size, llvm::alignOf<Capture>());
1149  Size += sizeof(Capture) * NumCaptures;
1150  }
1151 
1152  void *Mem = Context.Allocate(Size);
1153  return new (Mem) CapturedStmt(EmptyShell(), NumCaptures);
1154 }
1155 
1156 Stmt::child_range CapturedStmt::children() {
1157  // Children are captured field initilizers.
1158  return child_range(getStoredStmts(), getStoredStmts() + NumCaptures);
1159 }
1160 
1161 bool CapturedStmt::capturesVariable(const VarDecl *Var) const {
1162  for (const auto &I : captures()) {
1163  if (!I.capturesVariable())
1164  continue;
1165 
1166  // This does not handle variable redeclarations. This should be
1167  // extended to capture variables with redeclarations, for example
1168  // a thread-private variable in OpenMP.
1169  if (I.getCapturedVar() == Var)
1170  return true;
1171  }
1172 
1173  return false;
1174 }
1175 
1177  switch(getClauseKind()) {
1178  default : break;
1179 #define OPENMP_CLAUSE(Name, Class) \
1180  case OMPC_ ## Name : return static_cast<Class *>(this)->children();
1181 #include "clang/Basic/OpenMPKinds.def"
1182  }
1183  llvm_unreachable("unknown OMPClause");
1184 }
1185 
1186 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
1187  assert(VL.size() == varlist_size() &&
1188  "Number of private copies is not the same as the preallocated buffer");
1189  std::copy(VL.begin(), VL.end(), varlist_end());
1190 }
1191 
1194  SourceLocation LParenLoc, SourceLocation EndLoc,
1195  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
1196  // Allocate space for private variables and initializer expressions.
1197  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPPrivateClause),
1198  llvm::alignOf<Expr *>()) +
1199  2 * sizeof(Expr *) * VL.size());
1200  OMPPrivateClause *Clause =
1201  new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
1202  Clause->setVarRefs(VL);
1203  Clause->setPrivateCopies(PrivateVL);
1204  return Clause;
1205 }
1206 
1208  unsigned N) {
1209  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPPrivateClause),
1210  llvm::alignOf<Expr *>()) +
1211  2 * sizeof(Expr *) * N);
1212  return new (Mem) OMPPrivateClause(N);
1213 }
1214 
1215 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
1216  assert(VL.size() == varlist_size() &&
1217  "Number of private copies is not the same as the preallocated buffer");
1218  std::copy(VL.begin(), VL.end(), varlist_end());
1219 }
1220 
1221 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
1222  assert(VL.size() == varlist_size() &&
1223  "Number of inits is not the same as the preallocated buffer");
1224  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1225 }
1226 
1229  SourceLocation LParenLoc, SourceLocation EndLoc,
1230  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
1231  ArrayRef<Expr *> InitVL) {
1232  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFirstprivateClause),
1233  llvm::alignOf<Expr *>()) +
1234  3 * sizeof(Expr *) * VL.size());
1235  OMPFirstprivateClause *Clause =
1236  new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
1237  Clause->setVarRefs(VL);
1238  Clause->setPrivateCopies(PrivateVL);
1239  Clause->setInits(InitVL);
1240  return Clause;
1241 }
1242 
1244  unsigned N) {
1245  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFirstprivateClause),
1246  llvm::alignOf<Expr *>()) +
1247  3 * sizeof(Expr *) * N);
1248  return new (Mem) OMPFirstprivateClause(N);
1249 }
1250 
1252  assert(PrivateCopies.size() == varlist_size() &&
1253  "Number of private copies is not the same as the preallocated buffer");
1254  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
1255 }
1256 
1257 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
1258  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
1259  "not the same as the "
1260  "preallocated buffer");
1261  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
1262 }
1263 
1264 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
1265  assert(DstExprs.size() == varlist_size() && "Number of destination "
1266  "expressions is not the same as "
1267  "the preallocated buffer");
1268  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
1269 }
1270 
1271 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
1272  assert(AssignmentOps.size() == varlist_size() &&
1273  "Number of assignment expressions is not the same as the preallocated "
1274  "buffer");
1275  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
1276  getDestinationExprs().end());
1277 }
1278 
1280  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1281  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1282  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
1283  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLastprivateClause),
1284  llvm::alignOf<Expr *>()) +
1285  5 * sizeof(Expr *) * VL.size());
1286  OMPLastprivateClause *Clause =
1287  new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
1288  Clause->setVarRefs(VL);
1289  Clause->setSourceExprs(SrcExprs);
1290  Clause->setDestinationExprs(DstExprs);
1291  Clause->setAssignmentOps(AssignmentOps);
1292  return Clause;
1293 }
1294 
1296  unsigned N) {
1297  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLastprivateClause),
1298  llvm::alignOf<Expr *>()) +
1299  5 * sizeof(Expr *) * N);
1300  return new (Mem) OMPLastprivateClause(N);
1301 }
1302 
1304  SourceLocation StartLoc,
1305  SourceLocation LParenLoc,
1306  SourceLocation EndLoc,
1307  ArrayRef<Expr *> VL) {
1308  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPSharedClause),
1309  llvm::alignOf<Expr *>()) +
1310  sizeof(Expr *) * VL.size());
1311  OMPSharedClause *Clause = new (Mem) OMPSharedClause(StartLoc, LParenLoc,
1312  EndLoc, VL.size());
1313  Clause->setVarRefs(VL);
1314  return Clause;
1315 }
1316 
1318  unsigned N) {
1319  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPSharedClause),
1320  llvm::alignOf<Expr *>()) +
1321  sizeof(Expr *) * N);
1322  return new (Mem) OMPSharedClause(N);
1323 }
1324 
1326  assert(IL.size() == varlist_size() &&
1327  "Number of inits is not the same as the preallocated buffer");
1328  std::copy(IL.begin(), IL.end(), varlist_end());
1329 }
1330 
1332  assert(UL.size() == varlist_size() &&
1333  "Number of updates is not the same as the preallocated buffer");
1334  std::copy(UL.begin(), UL.end(), getInits().end());
1335 }
1336 
1338  assert(FL.size() == varlist_size() &&
1339  "Number of final updates is not the same as the preallocated buffer");
1340  std::copy(FL.begin(), FL.end(), getUpdates().end());
1341 }
1342 
1346  SourceLocation EndLoc, ArrayRef<Expr *> VL,
1348  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
1349  // (Step and CalcStep).
1350  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLinearClause),
1351  llvm::alignOf<Expr *>()) +
1352  (4 * VL.size() + 2) * sizeof(Expr *));
1353  OMPLinearClause *Clause = new (Mem)
1354  OMPLinearClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
1355  Clause->setVarRefs(VL);
1356  Clause->setInits(IL);
1357  // Fill update and final expressions with zeroes, they are provided later,
1358  // after the directive construction.
1359  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
1360  nullptr);
1361  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
1362  nullptr);
1363  Clause->setStep(Step);
1364  Clause->setCalcStep(CalcStep);
1365  return Clause;
1366 }
1367 
1369  unsigned NumVars) {
1370  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
1371  // (Step and CalcStep).
1372  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLinearClause),
1373  llvm::alignOf<Expr *>()) +
1374  (4 * NumVars + 2) * sizeof(Expr *));
1375  return new (Mem) OMPLinearClause(NumVars);
1376 }
1377 
1380  SourceLocation LParenLoc, SourceLocation ColonLoc,
1381  SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
1382  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPAlignedClause),
1383  llvm::alignOf<Expr *>()) +
1384  sizeof(Expr *) * (VL.size() + 1));
1385  OMPAlignedClause *Clause = new (Mem)
1386  OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
1387  Clause->setVarRefs(VL);
1388  Clause->setAlignment(A);
1389  return Clause;
1390 }
1391 
1393  unsigned NumVars) {
1394  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPAlignedClause),
1395  llvm::alignOf<Expr *>()) +
1396  sizeof(Expr *) * (NumVars + 1));
1397  return new (Mem) OMPAlignedClause(NumVars);
1398 }
1399 
1400 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
1401  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
1402  "not the same as the "
1403  "preallocated buffer");
1404  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
1405 }
1406 
1407 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
1408  assert(DstExprs.size() == varlist_size() && "Number of destination "
1409  "expressions is not the same as "
1410  "the preallocated buffer");
1411  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
1412 }
1413 
1414 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
1415  assert(AssignmentOps.size() == varlist_size() &&
1416  "Number of assignment expressions is not the same as the preallocated "
1417  "buffer");
1418  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
1419  getDestinationExprs().end());
1420 }
1421 
1423  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1424  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1425  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
1426  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyinClause),
1427  llvm::alignOf<Expr *>()) +
1428  4 * sizeof(Expr *) * VL.size());
1429  OMPCopyinClause *Clause = new (Mem) OMPCopyinClause(StartLoc, LParenLoc,
1430  EndLoc, VL.size());
1431  Clause->setVarRefs(VL);
1432  Clause->setSourceExprs(SrcExprs);
1433  Clause->setDestinationExprs(DstExprs);
1434  Clause->setAssignmentOps(AssignmentOps);
1435  return Clause;
1436 }
1437 
1439  unsigned N) {
1440  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyinClause),
1441  llvm::alignOf<Expr *>()) +
1442  4 * sizeof(Expr *) * N);
1443  return new (Mem) OMPCopyinClause(N);
1444 }
1445 
1446 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
1447  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
1448  "not the same as the "
1449  "preallocated buffer");
1450  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
1451 }
1452 
1453 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
1454  assert(DstExprs.size() == varlist_size() && "Number of destination "
1455  "expressions is not the same as "
1456  "the preallocated buffer");
1457  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
1458 }
1459 
1460 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
1461  assert(AssignmentOps.size() == varlist_size() &&
1462  "Number of assignment expressions is not the same as the preallocated "
1463  "buffer");
1464  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
1465  getDestinationExprs().end());
1466 }
1467 
1469  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1470  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
1471  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
1472  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyprivateClause),
1473  llvm::alignOf<Expr *>()) +
1474  4 * sizeof(Expr *) * VL.size());
1475  OMPCopyprivateClause *Clause =
1476  new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
1477  Clause->setVarRefs(VL);
1478  Clause->setSourceExprs(SrcExprs);
1479  Clause->setDestinationExprs(DstExprs);
1480  Clause->setAssignmentOps(AssignmentOps);
1481  return Clause;
1482 }
1483 
1485  unsigned N) {
1486  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyprivateClause),
1487  llvm::alignOf<Expr *>()) +
1488  4 * sizeof(Expr *) * N);
1489  return new (Mem) OMPCopyprivateClause(N);
1490 }
1491 
1493  assert(Clauses.size() == getNumClauses() &&
1494  "Number of clauses is not the same as the preallocated buffer");
1495  std::copy(Clauses.begin(), Clauses.end(), getClauses().begin());
1496 }
1497 
1499  assert(A.size() == getCollapsedNumber() &&
1500  "Number of loop counters is not the same as the collapsed number");
1501  std::copy(A.begin(), A.end(), getCounters().begin());
1502 }
1503 
1505  assert(A.size() == getCollapsedNumber() &&
1506  "Number of counter inits is not the same as the collapsed number");
1507  std::copy(A.begin(), A.end(), getInits().begin());
1508 }
1509 
1511  assert(A.size() == getCollapsedNumber() &&
1512  "Number of counter updates is not the same as the collapsed number");
1513  std::copy(A.begin(), A.end(), getUpdates().begin());
1514 }
1515 
1517  assert(A.size() == getCollapsedNumber() &&
1518  "Number of counter finals is not the same as the collapsed number");
1519  std::copy(A.begin(), A.end(), getFinals().begin());
1520 }
1521 
1522 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
1523  assert(
1524  LHSExprs.size() == varlist_size() &&
1525  "Number of LHS expressions is not the same as the preallocated buffer");
1526  std::copy(LHSExprs.begin(), LHSExprs.end(), varlist_end());
1527 }
1528 
1529 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
1530  assert(
1531  RHSExprs.size() == varlist_size() &&
1532  "Number of RHS expressions is not the same as the preallocated buffer");
1533  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
1534 }
1535 
1536 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
1537  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
1538  "expressions is not the same "
1539  "as the preallocated buffer");
1540  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
1541 }
1542 
1544  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
1545  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
1546  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
1547  ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
1548  ArrayRef<Expr *> ReductionOps) {
1549  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPReductionClause),
1550  llvm::alignOf<Expr *>()) +
1551  4 * sizeof(Expr *) * VL.size());
1552  OMPReductionClause *Clause = new (Mem) OMPReductionClause(
1553  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
1554  Clause->setVarRefs(VL);
1555  Clause->setLHSExprs(LHSExprs);
1556  Clause->setRHSExprs(RHSExprs);
1557  Clause->setReductionOps(ReductionOps);
1558  return Clause;
1559 }
1560 
1562  unsigned N) {
1563  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPReductionClause),
1564  llvm::alignOf<Expr *>()) +
1565  4 * sizeof(Expr *) * N);
1566  return new (Mem) OMPReductionClause(N);
1567 }
1568 
1570  SourceLocation StartLoc,
1571  SourceLocation LParenLoc,
1572  SourceLocation EndLoc,
1573  ArrayRef<Expr *> VL) {
1574  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFlushClause),
1575  llvm::alignOf<Expr *>()) +
1576  sizeof(Expr *) * VL.size());
1577  OMPFlushClause *Clause =
1578  new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1579  Clause->setVarRefs(VL);
1580  return Clause;
1581 }
1582 
1584  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFlushClause),
1585  llvm::alignOf<Expr *>()) +
1586  sizeof(Expr *) * N);
1587  return new (Mem) OMPFlushClause(N);
1588 }
1589 
1592  SourceLocation LParenLoc, SourceLocation EndLoc,
1593  OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
1594  SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
1595  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPDependClause),
1596  llvm::alignOf<Expr *>()) +
1597  sizeof(Expr *) * VL.size());
1598  OMPDependClause *Clause =
1599  new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
1600  Clause->setVarRefs(VL);
1601  Clause->setDependencyKind(DepKind);
1602  Clause->setDependencyLoc(DepLoc);
1603  Clause->setColonLoc(ColonLoc);
1604  return Clause;
1605 }
1606 
1608  void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPDependClause),
1609  llvm::alignOf<Expr *>()) +
1610  sizeof(Expr *) * N);
1611  return new (Mem) OMPDependClause(N);
1612 }
1613 
1614 const OMPClause *
1616  auto &&I = getClausesOfKind(K);
1617 
1618  if (I) {
1619  auto *Clause = *I;
1620  assert(!++I && "There are at least 2 clauses of the specified kind");
1621  return Clause;
1622  }
1623  return nullptr;
1624 }
1625 
1627  const ASTContext &C,
1628  SourceLocation StartLoc,
1629  SourceLocation EndLoc,
1630  ArrayRef<OMPClause *> Clauses,
1631  Stmt *AssociatedStmt) {
1632  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelDirective),
1633  llvm::alignOf<OMPClause *>());
1634  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1635  sizeof(Stmt *));
1636  OMPParallelDirective *Dir = new (Mem) OMPParallelDirective(StartLoc, EndLoc,
1637  Clauses.size());
1638  Dir->setClauses(Clauses);
1639  Dir->setAssociatedStmt(AssociatedStmt);
1640  return Dir;
1641 }
1642 
1644  unsigned NumClauses,
1645  EmptyShell) {
1646  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelDirective),
1647  llvm::alignOf<OMPClause *>());
1648  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1649  sizeof(Stmt *));
1650  return new (Mem) OMPParallelDirective(NumClauses);
1651 }
1652 
1655  SourceLocation EndLoc, unsigned CollapsedNum,
1656  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1657  const HelperExprs &Exprs) {
1658  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSimdDirective),
1659  llvm::alignOf<OMPClause *>());
1660  void *Mem =
1661  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1662  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
1663  OMPSimdDirective *Dir = new (Mem)
1664  OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1665  Dir->setClauses(Clauses);
1666  Dir->setAssociatedStmt(AssociatedStmt);
1668  Dir->setLastIteration(Exprs.LastIteration);
1670  Dir->setPreCond(Exprs.PreCond);
1671  Dir->setCond(Exprs.Cond);
1672  Dir->setInit(Exprs.Init);
1673  Dir->setInc(Exprs.Inc);
1674  Dir->setCounters(Exprs.Counters);
1675  Dir->setInits(Exprs.Inits);
1676  Dir->setUpdates(Exprs.Updates);
1677  Dir->setFinals(Exprs.Finals);
1678  return Dir;
1679 }
1680 
1682  unsigned NumClauses,
1683  unsigned CollapsedNum,
1684  EmptyShell) {
1685  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSimdDirective),
1686  llvm::alignOf<OMPClause *>());
1687  void *Mem =
1688  C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1689  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
1690  return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses);
1691 }
1692 
1695  SourceLocation EndLoc, unsigned CollapsedNum,
1696  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1697  const HelperExprs &Exprs) {
1698  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForDirective),
1699  llvm::alignOf<OMPClause *>());
1700  void *Mem =
1701  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1702  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
1703  OMPForDirective *Dir =
1704  new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1705  Dir->setClauses(Clauses);
1706  Dir->setAssociatedStmt(AssociatedStmt);
1708  Dir->setLastIteration(Exprs.LastIteration);
1710  Dir->setPreCond(Exprs.PreCond);
1711  Dir->setCond(Exprs.Cond);
1712  Dir->setInit(Exprs.Init);
1713  Dir->setInc(Exprs.Inc);
1714  Dir->setIsLastIterVariable(Exprs.IL);
1715  Dir->setLowerBoundVariable(Exprs.LB);
1716  Dir->setUpperBoundVariable(Exprs.UB);
1717  Dir->setStrideVariable(Exprs.ST);
1718  Dir->setEnsureUpperBound(Exprs.EUB);
1719  Dir->setNextLowerBound(Exprs.NLB);
1720  Dir->setNextUpperBound(Exprs.NUB);
1721  Dir->setCounters(Exprs.Counters);
1722  Dir->setInits(Exprs.Inits);
1723  Dir->setUpdates(Exprs.Updates);
1724  Dir->setFinals(Exprs.Finals);
1725  return Dir;
1726 }
1727 
1729  unsigned NumClauses,
1730  unsigned CollapsedNum,
1731  EmptyShell) {
1732  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForDirective),
1733  llvm::alignOf<OMPClause *>());
1734  void *Mem =
1735  C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1736  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
1737  return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
1738 }
1739 
1742  SourceLocation EndLoc, unsigned CollapsedNum,
1743  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1744  const HelperExprs &Exprs) {
1745  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForSimdDirective),
1746  llvm::alignOf<OMPClause *>());
1747  void *Mem =
1748  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1749  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
1750  OMPForSimdDirective *Dir = new (Mem)
1751  OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1752  Dir->setClauses(Clauses);
1753  Dir->setAssociatedStmt(AssociatedStmt);
1755  Dir->setLastIteration(Exprs.LastIteration);
1757  Dir->setPreCond(Exprs.PreCond);
1758  Dir->setCond(Exprs.Cond);
1759  Dir->setInit(Exprs.Init);
1760  Dir->setInc(Exprs.Inc);
1761  Dir->setIsLastIterVariable(Exprs.IL);
1762  Dir->setLowerBoundVariable(Exprs.LB);
1763  Dir->setUpperBoundVariable(Exprs.UB);
1764  Dir->setStrideVariable(Exprs.ST);
1765  Dir->setEnsureUpperBound(Exprs.EUB);
1766  Dir->setNextLowerBound(Exprs.NLB);
1767  Dir->setNextUpperBound(Exprs.NUB);
1768  Dir->setCounters(Exprs.Counters);
1769  Dir->setInits(Exprs.Inits);
1770  Dir->setUpdates(Exprs.Updates);
1771  Dir->setFinals(Exprs.Finals);
1772  return Dir;
1773 }
1774 
1776  unsigned NumClauses,
1777  unsigned CollapsedNum,
1778  EmptyShell) {
1779  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPForSimdDirective),
1780  llvm::alignOf<OMPClause *>());
1781  void *Mem =
1782  C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1783  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
1784  return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
1785 }
1786 
1788  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1789  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1790  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionsDirective),
1791  llvm::alignOf<OMPClause *>());
1792  void *Mem =
1793  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1794  OMPSectionsDirective *Dir =
1795  new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
1796  Dir->setClauses(Clauses);
1797  Dir->setAssociatedStmt(AssociatedStmt);
1798  return Dir;
1799 }
1800 
1802  unsigned NumClauses,
1803  EmptyShell) {
1804  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionsDirective),
1805  llvm::alignOf<OMPClause *>());
1806  void *Mem =
1807  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1808  return new (Mem) OMPSectionsDirective(NumClauses);
1809 }
1810 
1812  SourceLocation StartLoc,
1813  SourceLocation EndLoc,
1814  Stmt *AssociatedStmt) {
1815  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionDirective),
1816  llvm::alignOf<Stmt *>());
1817  void *Mem = C.Allocate(Size + sizeof(Stmt *));
1818  OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
1819  Dir->setAssociatedStmt(AssociatedStmt);
1820  return Dir;
1821 }
1822 
1824  EmptyShell) {
1825  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSectionDirective),
1826  llvm::alignOf<Stmt *>());
1827  void *Mem = C.Allocate(Size + sizeof(Stmt *));
1828  return new (Mem) OMPSectionDirective();
1829 }
1830 
1832  SourceLocation StartLoc,
1833  SourceLocation EndLoc,
1834  ArrayRef<OMPClause *> Clauses,
1835  Stmt *AssociatedStmt) {
1836  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective),
1837  llvm::alignOf<OMPClause *>());
1838  void *Mem =
1839  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1840  OMPSingleDirective *Dir =
1841  new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
1842  Dir->setClauses(Clauses);
1843  Dir->setAssociatedStmt(AssociatedStmt);
1844  return Dir;
1845 }
1846 
1848  unsigned NumClauses,
1849  EmptyShell) {
1850  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPSingleDirective),
1851  llvm::alignOf<OMPClause *>());
1852  void *Mem =
1853  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1854  return new (Mem) OMPSingleDirective(NumClauses);
1855 }
1856 
1858  SourceLocation StartLoc,
1859  SourceLocation EndLoc,
1860  Stmt *AssociatedStmt) {
1861  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPMasterDirective),
1862  llvm::alignOf<Stmt *>());
1863  void *Mem = C.Allocate(Size + sizeof(Stmt *));
1864  OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
1865  Dir->setAssociatedStmt(AssociatedStmt);
1866  return Dir;
1867 }
1868 
1870  EmptyShell) {
1871  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPMasterDirective),
1872  llvm::alignOf<Stmt *>());
1873  void *Mem = C.Allocate(Size + sizeof(Stmt *));
1874  return new (Mem) OMPMasterDirective();
1875 }
1876 
1878  const ASTContext &C, const DeclarationNameInfo &Name,
1879  SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt) {
1880  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCriticalDirective),
1881  llvm::alignOf<Stmt *>());
1882  void *Mem = C.Allocate(Size + sizeof(Stmt *));
1883  OMPCriticalDirective *Dir =
1884  new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc);
1885  Dir->setAssociatedStmt(AssociatedStmt);
1886  return Dir;
1887 }
1888 
1890  EmptyShell) {
1891  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCriticalDirective),
1892  llvm::alignOf<Stmt *>());
1893  void *Mem = C.Allocate(Size + sizeof(Stmt *));
1894  return new (Mem) OMPCriticalDirective();
1895 }
1896 
1898  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1899  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1900  const HelperExprs &Exprs) {
1901  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForDirective),
1902  llvm::alignOf<OMPClause *>());
1903  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1904  sizeof(Stmt *) *
1905  numLoopChildren(CollapsedNum, OMPD_parallel_for));
1906  OMPParallelForDirective *Dir = new (Mem)
1907  OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1908  Dir->setClauses(Clauses);
1909  Dir->setAssociatedStmt(AssociatedStmt);
1911  Dir->setLastIteration(Exprs.LastIteration);
1913  Dir->setPreCond(Exprs.PreCond);
1914  Dir->setCond(Exprs.Cond);
1915  Dir->setInit(Exprs.Init);
1916  Dir->setInc(Exprs.Inc);
1917  Dir->setIsLastIterVariable(Exprs.IL);
1918  Dir->setLowerBoundVariable(Exprs.LB);
1919  Dir->setUpperBoundVariable(Exprs.UB);
1920  Dir->setStrideVariable(Exprs.ST);
1921  Dir->setEnsureUpperBound(Exprs.EUB);
1922  Dir->setNextLowerBound(Exprs.NLB);
1923  Dir->setNextUpperBound(Exprs.NUB);
1924  Dir->setCounters(Exprs.Counters);
1925  Dir->setInits(Exprs.Inits);
1926  Dir->setUpdates(Exprs.Updates);
1927  Dir->setFinals(Exprs.Finals);
1928  return Dir;
1929 }
1930 
1932 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1933  unsigned CollapsedNum, EmptyShell) {
1934  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForDirective),
1935  llvm::alignOf<OMPClause *>());
1936  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1937  sizeof(Stmt *) *
1938  numLoopChildren(CollapsedNum, OMPD_parallel_for));
1939  return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
1940 }
1941 
1943  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1944  unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1945  const HelperExprs &Exprs) {
1946  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForSimdDirective),
1947  llvm::alignOf<OMPClause *>());
1948  void *Mem = C.Allocate(
1949  Size + sizeof(OMPClause *) * Clauses.size() +
1950  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
1952  StartLoc, EndLoc, CollapsedNum, Clauses.size());
1953  Dir->setClauses(Clauses);
1954  Dir->setAssociatedStmt(AssociatedStmt);
1956  Dir->setLastIteration(Exprs.LastIteration);
1958  Dir->setPreCond(Exprs.PreCond);
1959  Dir->setCond(Exprs.Cond);
1960  Dir->setInit(Exprs.Init);
1961  Dir->setInc(Exprs.Inc);
1962  Dir->setIsLastIterVariable(Exprs.IL);
1963  Dir->setLowerBoundVariable(Exprs.LB);
1964  Dir->setUpperBoundVariable(Exprs.UB);
1965  Dir->setStrideVariable(Exprs.ST);
1966  Dir->setEnsureUpperBound(Exprs.EUB);
1967  Dir->setNextLowerBound(Exprs.NLB);
1968  Dir->setNextUpperBound(Exprs.NUB);
1969  Dir->setCounters(Exprs.Counters);
1970  Dir->setInits(Exprs.Inits);
1971  Dir->setUpdates(Exprs.Updates);
1972  Dir->setFinals(Exprs.Finals);
1973  return Dir;
1974 }
1975 
1978  unsigned NumClauses,
1979  unsigned CollapsedNum, EmptyShell) {
1980  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelForSimdDirective),
1981  llvm::alignOf<OMPClause *>());
1982  void *Mem = C.Allocate(
1983  Size + sizeof(OMPClause *) * NumClauses +
1984  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
1985  return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses);
1986 }
1987 
1989  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1990  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1991  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelSectionsDirective),
1992  llvm::alignOf<OMPClause *>());
1993  void *Mem =
1994  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1996  new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
1997  Dir->setClauses(Clauses);
1998  Dir->setAssociatedStmt(AssociatedStmt);
1999  return Dir;
2000 }
2001 
2004  unsigned NumClauses, EmptyShell) {
2005  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPParallelSectionsDirective),
2006  llvm::alignOf<OMPClause *>());
2007  void *Mem =
2008  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
2009  return new (Mem) OMPParallelSectionsDirective(NumClauses);
2010 }
2011 
2013  SourceLocation StartLoc,
2014  SourceLocation EndLoc,
2015  ArrayRef<OMPClause *> Clauses,
2016  Stmt *AssociatedStmt) {
2017  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskDirective),
2018  llvm::alignOf<OMPClause *>());
2019  void *Mem =
2020  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
2021  OMPTaskDirective *Dir =
2022  new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
2023  Dir->setClauses(Clauses);
2024  Dir->setAssociatedStmt(AssociatedStmt);
2025  return Dir;
2026 }
2027 
2029  unsigned NumClauses,
2030  EmptyShell) {
2031  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskDirective),
2032  llvm::alignOf<OMPClause *>());
2033  void *Mem =
2034  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
2035  return new (Mem) OMPTaskDirective(NumClauses);
2036 }
2037 
2039  SourceLocation StartLoc,
2040  SourceLocation EndLoc) {
2041  void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
2042  OMPTaskyieldDirective *Dir =
2043  new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
2044  return Dir;
2045 }
2046 
2048  EmptyShell) {
2049  void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
2050  return new (Mem) OMPTaskyieldDirective();
2051 }
2052 
2054  SourceLocation StartLoc,
2055  SourceLocation EndLoc) {
2056  void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
2057  OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
2058  return Dir;
2059 }
2060 
2062  EmptyShell) {
2063  void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
2064  return new (Mem) OMPBarrierDirective();
2065 }
2066 
2068  SourceLocation StartLoc,
2069  SourceLocation EndLoc) {
2070  void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
2071  OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
2072  return Dir;
2073 }
2074 
2076  EmptyShell) {
2077  void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
2078  return new (Mem) OMPTaskwaitDirective();
2079 }
2080 
2082  SourceLocation StartLoc,
2083  SourceLocation EndLoc,
2084  Stmt *AssociatedStmt) {
2085  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskgroupDirective),
2086  llvm::alignOf<Stmt *>());
2087  void *Mem = C.Allocate(Size + sizeof(Stmt *));
2088  OMPTaskgroupDirective *Dir =
2089  new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc);
2090  Dir->setAssociatedStmt(AssociatedStmt);
2091  return Dir;
2092 }
2093 
2095  EmptyShell) {
2096  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTaskgroupDirective),
2097  llvm::alignOf<Stmt *>());
2098  void *Mem = C.Allocate(Size + sizeof(Stmt *));
2099  return new (Mem) OMPTaskgroupDirective();
2100 }
2101 
2103  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2104  OpenMPDirectiveKind CancelRegion) {
2105  unsigned Size = llvm::RoundUpToAlignment(
2106  sizeof(OMPCancellationPointDirective), llvm::alignOf<Stmt *>());
2107  void *Mem = C.Allocate(Size);
2109  new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
2110  Dir->setCancelRegion(CancelRegion);
2111  return Dir;
2112 }
2113 
2116  unsigned Size = llvm::RoundUpToAlignment(
2117  sizeof(OMPCancellationPointDirective), llvm::alignOf<Stmt *>());
2118  void *Mem = C.Allocate(Size);
2119  return new (Mem) OMPCancellationPointDirective();
2120 }
2121 
2124  SourceLocation EndLoc,
2125  OpenMPDirectiveKind CancelRegion) {
2126  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCancelDirective),
2127  llvm::alignOf<Stmt *>());
2128  void *Mem = C.Allocate(Size);
2129  OMPCancelDirective *Dir = new (Mem) OMPCancelDirective(StartLoc, EndLoc);
2130  Dir->setCancelRegion(CancelRegion);
2131  return Dir;
2132 }
2133 
2135  EmptyShell) {
2136  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPCancelDirective),
2137  llvm::alignOf<Stmt *>());
2138  void *Mem = C.Allocate(Size);
2139  return new (Mem) OMPCancelDirective();
2140 }
2141 
2143  SourceLocation StartLoc,
2144  SourceLocation EndLoc,
2145  ArrayRef<OMPClause *> Clauses) {
2146  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPFlushDirective),
2147  llvm::alignOf<OMPClause *>());
2148  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
2149  OMPFlushDirective *Dir =
2150  new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
2151  Dir->setClauses(Clauses);
2152  return Dir;
2153 }
2154 
2156  unsigned NumClauses,
2157  EmptyShell) {
2158  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPFlushDirective),
2159  llvm::alignOf<OMPClause *>());
2160  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
2161  return new (Mem) OMPFlushDirective(NumClauses);
2162 }
2163 
2165  SourceLocation StartLoc,
2166  SourceLocation EndLoc,
2167  Stmt *AssociatedStmt) {
2168  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPOrderedDirective),
2169  llvm::alignOf<Stmt *>());
2170  void *Mem = C.Allocate(Size + sizeof(Stmt *));
2171  OMPOrderedDirective *Dir = new (Mem) OMPOrderedDirective(StartLoc, EndLoc);
2172  Dir->setAssociatedStmt(AssociatedStmt);
2173  return Dir;
2174 }
2175 
2177  EmptyShell) {
2178  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPOrderedDirective),
2179  llvm::alignOf<Stmt *>());
2180  void *Mem = C.Allocate(Size + sizeof(Stmt *));
2181  return new (Mem) OMPOrderedDirective();
2182 }
2183 
2185  const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2186  ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
2187  Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
2188  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPAtomicDirective),
2189  llvm::alignOf<OMPClause *>());
2190  void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
2191  5 * sizeof(Stmt *));
2192  OMPAtomicDirective *Dir =
2193  new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
2194  Dir->setClauses(Clauses);
2195  Dir->setAssociatedStmt(AssociatedStmt);
2196  Dir->setX(X);
2197  Dir->setV(V);
2198  Dir->setExpr(E);
2199  Dir->setUpdateExpr(UE);
2200  Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
2201  Dir->IsPostfixUpdate = IsPostfixUpdate;
2202  return Dir;
2203 }
2204 
2206  unsigned NumClauses,
2207  EmptyShell) {
2208  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPAtomicDirective),
2209  llvm::alignOf<OMPClause *>());
2210  void *Mem =
2211  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
2212  return new (Mem) OMPAtomicDirective(NumClauses);
2213 }
2214 
2216  SourceLocation StartLoc,
2217  SourceLocation EndLoc,
2218  ArrayRef<OMPClause *> Clauses,
2219  Stmt *AssociatedStmt) {
2220  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTargetDirective),
2221  llvm::alignOf<OMPClause *>());
2222  void *Mem =
2223  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
2224  OMPTargetDirective *Dir =
2225  new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
2226  Dir->setClauses(Clauses);
2227  Dir->setAssociatedStmt(AssociatedStmt);
2228  return Dir;
2229 }
2230 
2232  unsigned NumClauses,
2233  EmptyShell) {
2234  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTargetDirective),
2235  llvm::alignOf<OMPClause *>());
2236  void *Mem =
2237  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
2238  return new (Mem) OMPTargetDirective(NumClauses);
2239 }
2240 
2242  SourceLocation StartLoc,
2243  SourceLocation EndLoc,
2244  ArrayRef<OMPClause *> Clauses,
2245  Stmt *AssociatedStmt) {
2246  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTeamsDirective),
2247  llvm::alignOf<OMPClause *>());
2248  void *Mem =
2249  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
2250  OMPTeamsDirective *Dir =
2251  new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
2252  Dir->setClauses(Clauses);
2253  Dir->setAssociatedStmt(AssociatedStmt);
2254  return Dir;
2255 }
2256 
2258  unsigned NumClauses,
2259  EmptyShell) {
2260  unsigned Size = llvm::RoundUpToAlignment(sizeof(OMPTeamsDirective),
2261  llvm::alignOf<OMPClause *>());
2262  void *Mem =
2263  C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
2264  return new (Mem) OMPTeamsDirective(NumClauses);
2265 }
2266 
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1193
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
Definition: Stmt.cpp:320
Expr * NLB
Update of LowerBound for statically sheduled 'omp for' loops.
Definition: StmtOpenMP.h:460
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.cpp:816
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:933
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: Stmt.cpp:1607
Defines the clang::ASTContext interface.
SmallVector< Expr *, 4 > Finals
Final loop counter values for GodeGen.
Definition: StmtOpenMP.h:470
This represents '#pragma omp master' directive.
Definition: StmtOpenMP.h:989
SourceLocation getEnd() const
SmallVector< Expr *, 4 > Updates
Expressions for loop counters update for CodeGen.
Definition: StmtOpenMP.h:468
This represents '#pragma omp task' directive.
Definition: StmtOpenMP.h:1295
void setEnsureUpperBound(Expr *EUB)
Definition: StmtOpenMP.h:409
static OMPSectionDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt)
Creates directive.
Definition: Stmt.cpp:1811
unsigned getNumOutputs() const
Definition: Stmt.h:1447
static LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
Definition: CharInfo.h:94
static OMPMasterDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:1869
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: Stmt.cpp:1438
This represents clause 'copyin' in the '#pragma omp ...' directives.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:224
const OMPClause * getSingleClause(OpenMPClauseKind K) const
Gets a single clause of the specified kind K associated with the current directive iff there is only ...
Definition: Stmt.cpp:1615
IdentifierInfo * getIdentifier() const
Definition: Decl.h:163
static OMPTaskwaitDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2075
void setLastIteration(Expr *LI)
Definition: StmtOpenMP.h:375
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Definition: ASTMatchers.h:826
const char * Name
Definition: Stmt.cpp:31
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.cpp:344
static OMPCopyprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1468
This represents '#pragma omp for simd' directive.
Definition: StmtOpenMP.h:765
Expr * EUB
EnsureUpperBound – expression LB = min(LB, NumIterations).
Definition: StmtOpenMP.h:458
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1243
static LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
Definition: CharInfo.h:112
static OMPCopyinClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1422
static OMPSectionsDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1787
Represents an attribute applied to a statement.
Definition: Stmt.h:833
void setUpperBoundVariable(Expr *UB)
Definition: StmtOpenMP.h:399
GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, IdentifierInfo **names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, StringLiteral **clobbers, SourceLocation rparenloc)
Definition: Stmt.cpp:688
static CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr * > CaptureInits, CapturedDecl *CD, RecordDecl *RD)
Definition: Stmt.cpp:1115
static OMPAtomicDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V, Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate)
Creates directive with a list of Clauses and 'x', 'v' and 'expr' parts of the atomic construct (see S...
Definition: Stmt.cpp:2184
CXXForRangeStmt(DeclStmt *Range, DeclStmt *BeginEnd, Expr *Cond, Expr *Inc, DeclStmt *LoopVar, Stmt *Body, SourceLocation FL, SourceLocation CL, SourceLocation RPL)
Definition: Stmt.cpp:850
void setNextLowerBound(Expr *NLB)
Definition: StmtOpenMP.h:414
const Expr * getInit() const
Definition: Decl.h:1068
unsigned NumOutputs
Definition: Stmt.h:1410
This represents '#pragma omp parallel for' directive.
Definition: StmtOpenMP.h:1102
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:925
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:993
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition: Stmt.cpp:641
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1561
void setInputExpr(unsigned i, Expr *E)
Definition: Stmt.cpp:674
void setIsLastIterVariable(Expr *IL)
Definition: StmtOpenMP.h:389
void setInputExpr(unsigned i, Expr *E)
Definition: Stmt.cpp:409
static OMPParallelForDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, const HelperExprs &Exprs)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1897
This represents clause 'private' in the '#pragma omp ...' directives.
Definition: OpenMPClause.h:956
static OMPParallelDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for N clauses.
Definition: Stmt.cpp:1643
This represents implicit clause 'flush' for the '#pragma omp flush' directive. This clause does not e...
Defines the Objective-C statement AST node classes.
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:63
void setInit(Expr *Init)
Definition: StmtOpenMP.h:387
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * LastIteration
Loop last iteration number.
Definition: StmtOpenMP.h:436
static struct StmtClassNameTable StmtClassInfo[Stmt::lastStmtConstant+1]
bool isOutputPlusConstraint(unsigned i) const
Definition: Stmt.h:1457
void setFinals(ArrayRef< Expr * > A)
Definition: Stmt.cpp:1516
CalcStep
Definition: OpenMPClause.h:304
static OMPTargetDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:2231
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1303
This represents '#pragma omp parallel' directive.
Definition: StmtOpenMP.h:219
unsigned getNumInputs() const
Definition: Stmt.h:1469
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1228
SourceLocation getLocEnd() const LLVM_READONLY
Definition: StmtObjC.h:137
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:89
A C++ nested-name-specifier augmented with source location information.
WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, SourceLocation WL)
Definition: Stmt.cpp:976
static OMPCancelDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2134
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
void Deallocate(void *Ptr) const
Definition: ASTContext.h:504
static OMPFlushDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:2155
This represents '#pragma omp barrier' directive.
Definition: StmtOpenMP.h:1395
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
This represents '#pragma omp critical' directive.
Definition: StmtOpenMP.h:1036
void setCond(Expr *Cond)
Definition: StmtOpenMP.h:384
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
StmtRange children()
SwitchStmt(const ASTContext &C, VarDecl *Var, Expr *cond)
Definition: Stmt.cpp:944
StringRef getOutputConstraint(unsigned i) const
Definition: Stmt.cpp:336
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:518
const LangOptions & getLangOpts() const
Definition: ASTContext.h:533
void setCounters(ArrayRef< Expr * > A)
Definition: Stmt.cpp:1498
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
StringRef getClobber(unsigned i) const
Definition: Stmt.cpp:391
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:395
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef< Stmt * > handlers)
Definition: Stmt.cpp:824
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
This represents '#pragma omp cancellation point' directive.
Definition: StmtOpenMP.h:1885
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1543
This represents '#pragma omp teams' directive.
Definition: StmtOpenMP.h:1828
Expr * CalcLastIteration
Calculation of last iteration.
Definition: StmtOpenMP.h:440
This represents clause 'reduction' in the '#pragma omp ...' directives.
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:206
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1714
static OMPTaskyieldDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2047
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3616
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: Stmt.cpp:1032
Expr * NUB
Update of UpperBound for statically sheduled 'omp for' loops.
Definition: StmtOpenMP.h:462
unsigned NumClobbers
Definition: Stmt.h:1412
Expr * Cond
Loop condition.
Definition: StmtOpenMP.h:444
Expr * PreCond
Loop pre-condition.
Definition: StmtOpenMP.h:442
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:56
static OMPSimdDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, const HelperExprs &Exprs)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1654
The expressions built for the OpenMP loop CodeGen for the whole collapsed loop nest.
Definition: StmtOpenMP.h:432
static OMPTaskgroupDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2094
Describes the capture of either a variable, or 'this', or variable-length array type.
Definition: Stmt.h:2001
This represents '#pragma omp taskgroup' directive.
Definition: StmtOpenMP.h:1483
static OMPSingleDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1847
This represents clause 'aligned' in the '#pragma omp ...' directives.
Stmt * getHandler() const
Definition: Stmt.h:1940
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Definition: Stmt.cpp:1392
StringRef getInputConstraint(unsigned i) const
Definition: Stmt.cpp:415
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
ASTContext * Context
Expr * IterationVarRef
Loop iteration variable.
Definition: StmtOpenMP.h:434
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition: Stmt.cpp:328
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition: Stmt.cpp:662
static OMPTeamsDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:2257
SourceManager & SM
static OMPTargetDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:2215
Exposes information about the current target.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1569
LabelDecl * getDecl() const
Definition: Stmt.h:809
static OMPSimdDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1681
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.cpp:360
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
Definition: Stmt.cpp:1161
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
static unsigned numLoopChildren(unsigned CollapsedNum, OpenMPDirectiveKind Kind)
Children number.
Definition: StmtOpenMP.h:366
ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, Stmt *Body, SourceLocation FCL, SourceLocation RPL)
Definition: Stmt.cpp:769
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:985
static OMPMasterDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt)
Creates directive.
Definition: Stmt.cpp:1857
LabelDecl * getConstantTarget()
Definition: Stmt.cpp:1005
void setInits(ArrayRef< Expr * > IL)
Sets the list of the initial values for linear variables.
OpenMPClauseKind
OpenMP clauses.
Definition: OpenMPKinds.h:33
child_range children()
Definition: Stmt.cpp:1156
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: Stmt.cpp:1583
StringRef getInputName(unsigned i) const
Definition: Stmt.h:1672
static StringRef copyIntoContext(const ASTContext &C, StringRef str)
Definition: Stmt.cpp:726
This represents '#pragma omp for' directive.
Definition: StmtOpenMP.h:701
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
void setAssociatedStmt(Stmt *S)
Set the associated statement for the directive.
Definition: StmtOpenMP.h:86
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
Definition: Stmt.cpp:1251
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:671
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:667
static OMPParallelForSimdDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1977
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1207
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: Stmt.cpp:311
This represents '#pragma omp cancel' directive.
Definition: StmtOpenMP.h:1943
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
StringRef getInputConstraint(unsigned i) const
Definition: Stmt.cpp:352
The result type of a method or function.
unsigned getNumClauses() const
Get number of clauses.
Definition: StmtOpenMP.h:172
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1591
static OMPTaskDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:2012
do v
Definition: arm_acle.h:77
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target) const
Definition: Expr.cpp:1006
This represents '#pragma omp flush' directive.
Definition: StmtOpenMP.h:1534
This represents '#pragma omp parallel for simd' directive.
Definition: StmtOpenMP.h:1169
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition: Stmt.cpp:1068
Expr * ST
Stride - local variable passed to runtime.
Definition: StmtOpenMP.h:456
static OMPParallelForDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1932
void setLowerBoundVariable(Expr *LB)
Definition: StmtOpenMP.h:394
static OMPSectionDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:1823
const StringLiteral * getAsmString() const
Definition: Stmt.h:1577
#define false
Definition: stdbool.h:33
Kind
This captures a statement into a function. For example, the following pragma annotated compound state...
Definition: Stmt.h:1989
SmallVector< Expr *, 4 > Counters
Counters Loop counters.
Definition: StmtOpenMP.h:464
static OMPCriticalDirective * Create(const ASTContext &C, const DeclarationNameInfo &Name, SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt)
Creates directive.
Definition: Stmt.cpp:1877
This represents '#pragma omp single' directive.
Definition: StmtOpenMP.h:934
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
void setIterationVariable(Expr *IV)
Definition: StmtOpenMP.h:372
static OMPOrderedDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2176
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:66
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
clang::OMPLinearClause OMPVarListClause getInits()
static OMPCancelDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, OpenMPDirectiveKind CancelRegion)
Creates directive.
Definition: Stmt.cpp:2123
static OMPTaskDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:2028
static OMPTeamsDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:2241
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:88
static ObjCAtTryStmt * CreateEmpty(const ASTContext &Context, unsigned NumCatchStmts, bool HasFinally)
Definition: Stmt.cpp:807
unsigned getCollapsedNumber() const
Get number of collapsed loops.
Definition: StmtOpenMP.h:511
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
This represents clause 'shared' in the '#pragma omp ...' directives.
MSAsmStmt(const ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc, bool issimple, bool isvolatile, ArrayRef< Token > asmtoks, unsigned numoutputs, unsigned numinputs, ArrayRef< StringRef > constraints, ArrayRef< Expr * > exprs, StringRef asmstr, ArrayRef< StringRef > clobbers, SourceLocation endloc)
Definition: Stmt.cpp:712
static OMPAtomicDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:2205
This represents '#pragma omp taskwait' directive.
Definition: StmtOpenMP.h:1439
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:959
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:32
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "switch" statement, if any.
Definition: Stmt.cpp:951
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Definition: Stmt.cpp:1038
This represents '#pragma omp target' directive.
Definition: StmtOpenMP.h:1771
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:406
SourceLocation getBegin() const
Expr * getRangeInit()
Definition: Stmt.cpp:863
void setClauses(ArrayRef< OMPClause * > Clauses)
Sets the list of variables for this clause.
Definition: Stmt.cpp:1492
static OMPAlignedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Expr *A)
Creates clause with a list of variables VL and alignment A.
Definition: Stmt.cpp:1379
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:1644
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:1825
This represents '#pragma omp ordered' directive.
Definition: StmtOpenMP.h:1589
Expr * LB
LowerBound - local variable passed to runtime.
Definition: StmtOpenMP.h:452
static OMPCriticalDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:1889
Expr * Init
Loop iteration variable init.
Definition: StmtOpenMP.h:446
__SIZE_TYPE__ size_t
Definition: stddef.h:62
const Decl * getSingleDecl() const
Definition: Stmt.h:467
static OMPParallelForSimdDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, const HelperExprs &Exprs)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1942
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3357
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:894
static OMPForDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1728
CompoundStmt(const ASTContext &C, ArrayRef< Stmt * > Stmts, SourceLocation LB, SourceLocation RB)
Definition: Stmt.cpp:281
unsigned AnalyzeAsmString(SmallVectorImpl< AsmStringPiece > &Pieces, const ASTContext &C, unsigned &DiagOffs) const
Definition: Stmt.cpp:473
SmallVector< Expr *, 4 > Inits
Expressions for loop counters inits for CodeGen.
Definition: StmtOpenMP.h:466
static OMPParallelSectionsDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1988
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
Definition: Stmt.cpp:1143
This represents '#pragma omp section' directive.
Definition: StmtOpenMP.h:885
* Step
Definition: OpenMPClause.h:304
This represents '#pragma omp simd' directive.
Definition: StmtOpenMP.h:636
unsigned Counter
Definition: Stmt.cpp:32
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1653
QualType getCaughtType() const
Definition: Stmt.cpp:678
StringRef getString() const
Definition: Expr.h:1521
This represents clause 'linear' in the '#pragma omp ...' directives.
static LLVM_ATTRIBUTE_UNUSED void check_implementations()
Definition: Stmt.cpp:198
const Expr * getRetValue() const
Definition: Stmt.cpp:1013
This represents '#pragma omp atomic' directive.
Definition: StmtOpenMP.h:1637
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: Stmt.cpp:1317
static OMPOrderedDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt)
Creates directive.
Definition: Stmt.cpp:2164
static OMPForSimdDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1775
static OMPForDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, const HelperExprs &Exprs)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1694
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:902
static OMPBarrierDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2061
This file defines OpenMP AST classes for executable directives and clauses.
filtered_clause_iterator< ClauseKindFilter > getClausesOfKind(OpenMPClauseKind Kind) const
Definition: StmtOpenMP.h:144
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: Stmt.cpp:1484
int getNamedOperand(StringRef SymbolicName) const
Definition: Stmt.cpp:453
Expr * Inc
Loop increment.
Definition: StmtOpenMP.h:448
static OMPForSimdDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, unsigned CollapsedNum, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, const HelperExprs &Exprs)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1741
unsigned getNumPlusOperands() const
Definition: Stmt.cpp:378
ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP)
Definition: Stmt.cpp:913
StringRef getClobber(unsigned i) const
Definition: Stmt.cpp:368
StmtRange children()
Definition: Stmt.cpp:1176
static OMPSingleDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1831
Stmt * getSubStmt()
Definition: Stmt.cpp:970
SourceManager & getSourceManager()
Definition: ASTContext.h:494
DeclStmt * getRangeStmt()
Definition: StmtCXX.h:150
Stmt ** Exprs
Definition: Stmt.h:1414
Expr * getTarget()
Definition: Stmt.h:1266
SourceLocation getLocEnd() const LLVM_READONLY
Definition: StmtObjC.h:108
X
Definition: SemaDecl.cpp:11429
IfStmt(const ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond, Stmt *then, SourceLocation EL=SourceLocation(), Stmt *elsev=nullptr)
Definition: Stmt.cpp:884
static OMPTaskyieldDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates directive.
Definition: Stmt.cpp:2038
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1681
Expr * UB
UpperBound - local variable passed to runtime.
Definition: StmtOpenMP.h:454
void setStrideVariable(Expr *ST)
Definition: StmtOpenMP.h:404
unsigned Size
Definition: Stmt.cpp:33
static OMPParallelSectionsDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:2003
VarDecl * getLoopVariable()
Definition: Stmt.cpp:874
static OMPBarrierDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates directive.
Definition: Stmt.cpp:2053
void setUpdates(ArrayRef< Expr * > A)
Definition: Stmt.cpp:1510
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:501
Represents Objective-C's @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
bool isSimple() const
Definition: Stmt.h:1431
static OMPSectionsDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
Definition: Stmt.cpp:1801
Defines the clang::TargetInfo interface.
static OMPTaskgroupDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, Stmt *AssociatedStmt)
Creates directive.
Definition: Stmt.cpp:2081
void setPreCond(Expr *PC)
Definition: StmtOpenMP.h:381
StringRef getOutputConstraint(unsigned i) const
Definition: Stmt.cpp:402
static OMPParallelDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:1626
static OMPTaskwaitDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates directive.
Definition: Stmt.cpp:2067
This represents '#pragma omp sections' directive.
Definition: StmtOpenMP.h:830
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:197
void setNextUpperBound(Expr *NUB)
Definition: StmtOpenMP.h:419
capture_range captures()
Definition: Stmt.h:2143
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
void setInc(Expr *Inc)
Definition: StmtOpenMP.h:388
DeclStmt * getLoopVarStmt()
Definition: StmtCXX.h:156
static StmtClassNameTable & getStmtInfoTableEntry(Stmt::StmtClass E)
Definition: Stmt.cpp:36
Expr * IL
IsLastIteration - local flag variable passed to runtime.
Definition: StmtOpenMP.h:450
A trivial tuple used to represent a source range.
This represents '#pragma omp taskyield' directive.
Definition: StmtOpenMP.h:1351
unsigned NumInputs
Definition: Stmt.h:1411
static OMPCancellationPointDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, OpenMPDirectiveKind CancelRegion)
Creates directive.
Definition: Stmt.cpp:2102
static OMPFlushDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses)
Creates directive with a list of Clauses.
Definition: Stmt.cpp:2142
This represents '#pragma omp parallel sections' directive.
Definition: StmtOpenMP.h:1237
void setCalcLastIteration(Expr *CLI)
Definition: StmtOpenMP.h:378
const char * getName() const
Definition: Stmt.cpp:307
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: Stmt.cpp:1295
SourceLocation ColonLoc
Location of ':'.
Definition: OpenMPClause.h:260
void setStmts(const ASTContext &C, Stmt **Stmts, unsigned NumStmts)
Definition: Stmt.cpp:297
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
Definition: Stmt.cpp:1056
This class handles loading and caching of source files into memory.
void setInits(ArrayRef< Expr * > A)
Definition: Stmt.cpp:1504
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
Definition: Stmt.cpp:794
Attr - This represents one attribute.
Definition: Attr.h:44
static OMPCancellationPointDirective * CreateEmpty(const ASTContext &C, EmptyShell)
Creates an empty directive.
Definition: Stmt.cpp:2115
SEHFinallyStmt * getFinallyHandler() const
Definition: Stmt.cpp:1042
#define BLOCK(DERIVED, BASE)
Definition: Template.h:423
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
Definition: Stmt.cpp:1279