clang  6.0.0svn
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/ExprOpenMP.h"
19 #include "clang/AST/Stmt.h"
20 #include "clang/AST/StmtCXX.h"
21 #include "clang/AST/StmtObjC.h"
22 #include "clang/AST/StmtOpenMP.h"
23 #include "clang/AST/Type.h"
24 #include "clang/Basic/CharInfo.h"
25 #include "clang/Basic/TargetInfo.h"
26 #include "clang/Lex/Token.h"
27 #include "llvm/ADT/StringExtras.h"
28 #include "llvm/Support/raw_ostream.h"
29 using namespace clang;
30 
31 static struct StmtClassNameTable {
32  const char *Name;
33  unsigned Counter;
34  unsigned Size;
35 } StmtClassInfo[Stmt::lastStmtConstant+1];
36 
38  static bool Initialized = false;
39  if (Initialized)
40  return StmtClassInfo[E];
41 
42  // Intialize the table on the first use.
43  Initialized = true;
44 #define ABSTRACT_STMT(STMT)
45 #define STMT(CLASS, PARENT) \
46  StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
47  StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
48 #include "clang/AST/StmtNodes.inc"
49 
50  return StmtClassInfo[E];
51 }
52 
53 void *Stmt::operator new(size_t bytes, const ASTContext& C,
54  unsigned alignment) {
55  return ::operator new(bytes, C, alignment);
56 }
57 
58 const char *Stmt::getStmtClassName() const {
59  return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name;
60 }
61 
63  // Ensure the table is primed.
64  getStmtInfoTableEntry(Stmt::NullStmtClass);
65 
66  unsigned sum = 0;
67  llvm::errs() << "\n*** Stmt/Expr Stats:\n";
68  for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
69  if (StmtClassInfo[i].Name == nullptr) continue;
70  sum += StmtClassInfo[i].Counter;
71  }
72  llvm::errs() << " " << sum << " stmts/exprs total.\n";
73  sum = 0;
74  for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
75  if (StmtClassInfo[i].Name == nullptr) continue;
76  if (StmtClassInfo[i].Counter == 0) continue;
77  llvm::errs() << " " << StmtClassInfo[i].Counter << " "
78  << StmtClassInfo[i].Name << ", " << StmtClassInfo[i].Size
79  << " each (" << StmtClassInfo[i].Counter*StmtClassInfo[i].Size
80  << " bytes)\n";
82  }
83 
84  llvm::errs() << "Total bytes = " << sum << "\n";
85 }
86 
89 }
90 
91 bool Stmt::StatisticsEnabled = false;
93  StatisticsEnabled = true;
94 }
95 
97  Stmt *s = this;
98 
99  if (auto *ewc = dyn_cast<ExprWithCleanups>(s))
100  s = ewc->getSubExpr();
101 
102  if (auto *mte = dyn_cast<MaterializeTemporaryExpr>(s))
103  s = mte->GetTemporaryExpr();
104 
105  if (auto *bte = dyn_cast<CXXBindTemporaryExpr>(s))
106  s = bte->getSubExpr();
107 
108  while (auto *ice = dyn_cast<ImplicitCastExpr>(s))
109  s = ice->getSubExpr();
110 
111  return s;
112 }
113 
114 /// \brief Skip no-op (attributed, compound) container stmts and skip captured
115 /// stmt at the top, if \a IgnoreCaptured is true.
116 Stmt *Stmt::IgnoreContainers(bool IgnoreCaptured) {
117  Stmt *S = this;
118  if (IgnoreCaptured)
119  if (auto CapS = dyn_cast_or_null<CapturedStmt>(S))
120  S = CapS->getCapturedStmt();
121  while (true) {
122  if (auto AS = dyn_cast_or_null<AttributedStmt>(S))
123  S = AS->getSubStmt();
124  else if (auto CS = dyn_cast_or_null<CompoundStmt>(S)) {
125  if (CS->size() != 1)
126  break;
127  S = CS->body_back();
128  } else
129  break;
130  }
131  return S;
132 }
133 
134 /// \brief Strip off all label-like statements.
135 ///
136 /// This will strip off label statements, case statements, attributed
137 /// statements and default statements recursively.
139  const Stmt *S = this;
140  while (true) {
141  if (const LabelStmt *LS = dyn_cast<LabelStmt>(S))
142  S = LS->getSubStmt();
143  else if (const SwitchCase *SC = dyn_cast<SwitchCase>(S))
144  S = SC->getSubStmt();
145  else if (const AttributedStmt *AS = dyn_cast<AttributedStmt>(S))
146  S = AS->getSubStmt();
147  else
148  return S;
149  }
150 }
151 
152 namespace {
153  struct good {};
154  struct bad {};
155 
156  // These silly little functions have to be static inline to suppress
157  // unused warnings, and they have to be defined to suppress other
158  // warnings.
159  static inline good is_good(good) { return good(); }
160 
161  typedef Stmt::child_range children_t();
162  template <class T> good implements_children(children_t T::*) {
163  return good();
164  }
165  LLVM_ATTRIBUTE_UNUSED
166  static inline bad implements_children(children_t Stmt::*) {
167  return bad();
168  }
169 
170  typedef SourceLocation getLocStart_t() const;
171  template <class T> good implements_getLocStart(getLocStart_t T::*) {
172  return good();
173  }
174  LLVM_ATTRIBUTE_UNUSED
175  static inline bad implements_getLocStart(getLocStart_t Stmt::*) {
176  return bad();
177  }
178 
179  typedef SourceLocation getLocEnd_t() const;
180  template <class T> good implements_getLocEnd(getLocEnd_t T::*) {
181  return good();
182  }
183  LLVM_ATTRIBUTE_UNUSED
184  static inline bad implements_getLocEnd(getLocEnd_t Stmt::*) {
185  return bad();
186  }
187 
188 #define ASSERT_IMPLEMENTS_children(type) \
189  (void) is_good(implements_children(&type::children))
190 #define ASSERT_IMPLEMENTS_getLocStart(type) \
191  (void) is_good(implements_getLocStart(&type::getLocStart))
192 #define ASSERT_IMPLEMENTS_getLocEnd(type) \
193  (void) is_good(implements_getLocEnd(&type::getLocEnd))
194 }
195 
196 /// Check whether the various Stmt classes implement their member
197 /// functions.
198 LLVM_ATTRIBUTE_UNUSED
199 static inline void check_implementations() {
200 #define ABSTRACT_STMT(type)
201 #define STMT(type, base) \
202  ASSERT_IMPLEMENTS_children(type); \
203  ASSERT_IMPLEMENTS_getLocStart(type); \
204  ASSERT_IMPLEMENTS_getLocEnd(type);
205 #include "clang/AST/StmtNodes.inc"
206 }
207 
209  switch (getStmtClass()) {
210  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
211 #define ABSTRACT_STMT(type)
212 #define STMT(type, base) \
213  case Stmt::type##Class: \
214  return static_cast<type*>(this)->children();
215 #include "clang/AST/StmtNodes.inc"
216  }
217  llvm_unreachable("unknown statement kind!");
218 }
219 
220 // Amusing macro metaprogramming hack: check whether a class provides
221 // a more specific implementation of getSourceRange.
222 //
223 // See also Expr.cpp:getExprLoc().
224 namespace {
225  /// This implementation is used when a class provides a custom
226  /// implementation of getSourceRange.
227  template <class S, class T>
228  SourceRange getSourceRangeImpl(const Stmt *stmt,
229  SourceRange (T::*v)() const) {
230  return static_cast<const S*>(stmt)->getSourceRange();
231  }
232 
233  /// This implementation is used when a class doesn't provide a custom
234  /// implementation of getSourceRange. Overload resolution should pick it over
235  /// the implementation above because it's more specialized according to
236  /// function template partial ordering.
237  template <class S>
238  SourceRange getSourceRangeImpl(const Stmt *stmt,
239  SourceRange (Stmt::*v)() const) {
240  return SourceRange(static_cast<const S*>(stmt)->getLocStart(),
241  static_cast<const S*>(stmt)->getLocEnd());
242  }
243 }
244 
246  switch (getStmtClass()) {
247  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
248 #define ABSTRACT_STMT(type)
249 #define STMT(type, base) \
250  case Stmt::type##Class: \
251  return getSourceRangeImpl<type>(this, &type::getSourceRange);
252 #include "clang/AST/StmtNodes.inc"
253  }
254  llvm_unreachable("unknown statement kind!");
255 }
256 
258 // llvm::errs() << "getLocStart() for " << getStmtClassName() << "\n";
259  switch (getStmtClass()) {
260  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
261 #define ABSTRACT_STMT(type)
262 #define STMT(type, base) \
263  case Stmt::type##Class: \
264  return static_cast<const type*>(this)->getLocStart();
265 #include "clang/AST/StmtNodes.inc"
266  }
267  llvm_unreachable("unknown statement kind");
268 }
269 
271  switch (getStmtClass()) {
272  case Stmt::NoStmtClass: llvm_unreachable("statement without class");
273 #define ABSTRACT_STMT(type)
274 #define STMT(type, base) \
275  case Stmt::type##Class: \
276  return static_cast<const type*>(this)->getLocEnd();
277 #include "clang/AST/StmtNodes.inc"
278  }
279  llvm_unreachable("unknown statement kind");
280 }
281 
284  : Stmt(CompoundStmtClass), LBraceLoc(LB), RBraceLoc(RB) {
285  CompoundStmtBits.NumStmts = Stmts.size();
286  assert(CompoundStmtBits.NumStmts == Stmts.size() &&
287  "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
288 
289  if (Stmts.size() == 0) {
290  Body = nullptr;
291  return;
292  }
293 
294  Body = new (C) Stmt*[Stmts.size()];
295  std::copy(Stmts.begin(), Stmts.end(), Body);
296 }
297 
299  if (Body)
300  C.Deallocate(Body);
301  CompoundStmtBits.NumStmts = Stmts.size();
302  assert(CompoundStmtBits.NumStmts == Stmts.size() &&
303  "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
304 
305  Body = new (C) Stmt*[Stmts.size()];
306  std::copy(Stmts.begin(), Stmts.end(), Body);
307 }
308 
309 const char *LabelStmt::getName() const {
310  return getDecl()->getIdentifier()->getNameStart();
311 }
312 
314  ArrayRef<const Attr*> Attrs,
315  Stmt *SubStmt) {
316  assert(!Attrs.empty() && "Attrs should not be empty");
317  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * Attrs.size(),
318  alignof(AttributedStmt));
319  return new (Mem) AttributedStmt(Loc, Attrs, SubStmt);
320 }
321 
323  unsigned NumAttrs) {
324  assert(NumAttrs > 0 && "NumAttrs should be greater than zero");
325  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * NumAttrs,
326  alignof(AttributedStmt));
327  return new (Mem) AttributedStmt(EmptyShell(), NumAttrs);
328 }
329 
330 std::string AsmStmt::generateAsmString(const ASTContext &C) const {
331  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
332  return gccAsmStmt->generateAsmString(C);
333  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
334  return msAsmStmt->generateAsmString(C);
335  llvm_unreachable("unknown asm statement kind!");
336 }
337 
338 StringRef AsmStmt::getOutputConstraint(unsigned i) const {
339  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
340  return gccAsmStmt->getOutputConstraint(i);
341  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
342  return msAsmStmt->getOutputConstraint(i);
343  llvm_unreachable("unknown asm statement kind!");
344 }
345 
346 const Expr *AsmStmt::getOutputExpr(unsigned i) const {
347  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
348  return gccAsmStmt->getOutputExpr(i);
349  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
350  return msAsmStmt->getOutputExpr(i);
351  llvm_unreachable("unknown asm statement kind!");
352 }
353 
354 StringRef AsmStmt::getInputConstraint(unsigned i) const {
355  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
356  return gccAsmStmt->getInputConstraint(i);
357  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
358  return msAsmStmt->getInputConstraint(i);
359  llvm_unreachable("unknown asm statement kind!");
360 }
361 
362 const Expr *AsmStmt::getInputExpr(unsigned i) const {
363  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
364  return gccAsmStmt->getInputExpr(i);
365  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
366  return msAsmStmt->getInputExpr(i);
367  llvm_unreachable("unknown asm statement kind!");
368 }
369 
370 StringRef AsmStmt::getClobber(unsigned i) const {
371  if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(this))
372  return gccAsmStmt->getClobber(i);
373  if (const MSAsmStmt *msAsmStmt = dyn_cast<MSAsmStmt>(this))
374  return msAsmStmt->getClobber(i);
375  llvm_unreachable("unknown asm statement kind!");
376 }
377 
378 /// getNumPlusOperands - Return the number of output operands that have a "+"
379 /// constraint.
380 unsigned AsmStmt::getNumPlusOperands() const {
381  unsigned Res = 0;
382  for (unsigned i = 0, e = getNumOutputs(); i != e; ++i)
383  if (isOutputPlusConstraint(i))
384  ++Res;
385  return Res;
386 }
387 
389  assert(isOperand() && "Only Operands can have modifiers.");
390  return isLetter(Str[0]) ? Str[0] : '\0';
391 }
392 
393 StringRef GCCAsmStmt::getClobber(unsigned i) const {
394  return getClobberStringLiteral(i)->getString();
395 }
396 
398  return cast<Expr>(Exprs[i]);
399 }
400 
401 /// getOutputConstraint - Return the constraint string for the specified
402 /// output operand. All output constraints are known to be non-empty (either
403 /// '=' or '+').
404 StringRef GCCAsmStmt::getOutputConstraint(unsigned i) const {
405  return getOutputConstraintLiteral(i)->getString();
406 }
407 
409  return cast<Expr>(Exprs[i + NumOutputs]);
410 }
411 void GCCAsmStmt::setInputExpr(unsigned i, Expr *E) {
412  Exprs[i + NumOutputs] = E;
413 }
414 
415 /// getInputConstraint - Return the specified input constraint. Unlike output
416 /// constraints, these can be empty.
417 StringRef GCCAsmStmt::getInputConstraint(unsigned i) const {
418  return getInputConstraintLiteral(i)->getString();
419 }
420 
421 void GCCAsmStmt::setOutputsAndInputsAndClobbers(const ASTContext &C,
422  IdentifierInfo **Names,
423  StringLiteral **Constraints,
424  Stmt **Exprs,
425  unsigned NumOutputs,
426  unsigned NumInputs,
427  StringLiteral **Clobbers,
428  unsigned NumClobbers) {
429  this->NumOutputs = NumOutputs;
430  this->NumInputs = NumInputs;
431  this->NumClobbers = NumClobbers;
432 
433  unsigned NumExprs = NumOutputs + NumInputs;
434 
435  C.Deallocate(this->Names);
436  this->Names = new (C) IdentifierInfo*[NumExprs];
437  std::copy(Names, Names + NumExprs, this->Names);
438 
439  C.Deallocate(this->Exprs);
440  this->Exprs = new (C) Stmt*[NumExprs];
441  std::copy(Exprs, Exprs + NumExprs, this->Exprs);
442 
443  C.Deallocate(this->Constraints);
444  this->Constraints = new (C) StringLiteral*[NumExprs];
445  std::copy(Constraints, Constraints + NumExprs, this->Constraints);
446 
447  C.Deallocate(this->Clobbers);
448  this->Clobbers = new (C) StringLiteral*[NumClobbers];
449  std::copy(Clobbers, Clobbers + NumClobbers, this->Clobbers);
450 }
451 
452 /// getNamedOperand - Given a symbolic operand reference like %[foo],
453 /// translate this into a numeric value needed to reference the same operand.
454 /// This returns -1 if the operand name is invalid.
455 int GCCAsmStmt::getNamedOperand(StringRef SymbolicName) const {
456  unsigned NumPlusOperands = 0;
457 
458  // Check if this is an output operand.
459  for (unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
460  if (getOutputName(i) == SymbolicName)
461  return i;
462  }
463 
464  for (unsigned i = 0, e = getNumInputs(); i != e; ++i)
465  if (getInputName(i) == SymbolicName)
466  return getNumOutputs() + NumPlusOperands + i;
467 
468  // Not found.
469  return -1;
470 }
471 
472 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
473 /// it into pieces. If the asm string is erroneous, emit errors and return
474 /// true, otherwise return false.
476  const ASTContext &C, unsigned &DiagOffs) const {
477  StringRef Str = getAsmString()->getString();
478  const char *StrStart = Str.begin();
479  const char *StrEnd = Str.end();
480  const char *CurPtr = StrStart;
481 
482  // "Simple" inline asms have no constraints or operands, just convert the asm
483  // string to escape $'s.
484  if (isSimple()) {
485  std::string Result;
486  for (; CurPtr != StrEnd; ++CurPtr) {
487  switch (*CurPtr) {
488  case '$':
489  Result += "$$";
490  break;
491  default:
492  Result += *CurPtr;
493  break;
494  }
495  }
496  Pieces.push_back(AsmStringPiece(Result));
497  return 0;
498  }
499 
500  // CurStringPiece - The current string that we are building up as we scan the
501  // asm string.
502  std::string CurStringPiece;
503 
504  bool HasVariants = !C.getTargetInfo().hasNoAsmVariants();
505 
506  unsigned LastAsmStringToken = 0;
507  unsigned LastAsmStringOffset = 0;
508 
509  while (1) {
510  // Done with the string?
511  if (CurPtr == StrEnd) {
512  if (!CurStringPiece.empty())
513  Pieces.push_back(AsmStringPiece(CurStringPiece));
514  return 0;
515  }
516 
517  char CurChar = *CurPtr++;
518  switch (CurChar) {
519  case '$': CurStringPiece += "$$"; continue;
520  case '{': CurStringPiece += (HasVariants ? "$(" : "{"); continue;
521  case '|': CurStringPiece += (HasVariants ? "$|" : "|"); continue;
522  case '}': CurStringPiece += (HasVariants ? "$)" : "}"); continue;
523  case '%':
524  break;
525  default:
526  CurStringPiece += CurChar;
527  continue;
528  }
529 
530  // Escaped "%" character in asm string.
531  if (CurPtr == StrEnd) {
532  // % at end of string is invalid (no escape).
533  DiagOffs = CurPtr-StrStart-1;
534  return diag::err_asm_invalid_escape;
535  }
536  // Handle escaped char and continue looping over the asm string.
537  char EscapedChar = *CurPtr++;
538  switch (EscapedChar) {
539  default:
540  break;
541  case '%': // %% -> %
542  case '{': // %{ -> {
543  case '}': // %} -> }
544  CurStringPiece += EscapedChar;
545  continue;
546  case '=': // %= -> Generate a unique ID.
547  CurStringPiece += "${:uid}";
548  continue;
549  }
550 
551  // Otherwise, we have an operand. If we have accumulated a string so far,
552  // add it to the Pieces list.
553  if (!CurStringPiece.empty()) {
554  Pieces.push_back(AsmStringPiece(CurStringPiece));
555  CurStringPiece.clear();
556  }
557 
558  // Handle operands that have asmSymbolicName (e.g., %x[foo]) and those that
559  // don't (e.g., %x4). 'x' following the '%' is the constraint modifier.
560 
561  const char *Begin = CurPtr - 1; // Points to the character following '%'.
562  const char *Percent = Begin - 1; // Points to '%'.
563 
564  if (isLetter(EscapedChar)) {
565  if (CurPtr == StrEnd) { // Premature end.
566  DiagOffs = CurPtr-StrStart-1;
567  return diag::err_asm_invalid_escape;
568  }
569  EscapedChar = *CurPtr++;
570  }
571 
572  const TargetInfo &TI = C.getTargetInfo();
573  const SourceManager &SM = C.getSourceManager();
574  const LangOptions &LO = C.getLangOpts();
575 
576  // Handle operands that don't have asmSymbolicName (e.g., %x4).
577  if (isDigit(EscapedChar)) {
578  // %n - Assembler operand n
579  unsigned N = 0;
580 
581  --CurPtr;
582  while (CurPtr != StrEnd && isDigit(*CurPtr))
583  N = N*10 + ((*CurPtr++)-'0');
584 
585  unsigned NumOperands =
586  getNumOutputs() + getNumPlusOperands() + getNumInputs();
587  if (N >= NumOperands) {
588  DiagOffs = CurPtr-StrStart-1;
589  return diag::err_asm_invalid_operand_number;
590  }
591 
592  // Str contains "x4" (Operand without the leading %).
593  std::string Str(Begin, CurPtr - Begin);
594 
595  // (BeginLoc, EndLoc) represents the range of the operand we are currently
596  // processing. Unlike Str, the range includes the leading '%'.
597  SourceLocation BeginLoc = getAsmString()->getLocationOfByte(
598  Percent - StrStart, SM, LO, TI, &LastAsmStringToken,
599  &LastAsmStringOffset);
600  SourceLocation EndLoc = getAsmString()->getLocationOfByte(
601  CurPtr - StrStart, SM, LO, TI, &LastAsmStringToken,
602  &LastAsmStringOffset);
603 
604  Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
605  continue;
606  }
607 
608  // Handle operands that have asmSymbolicName (e.g., %x[foo]).
609  if (EscapedChar == '[') {
610  DiagOffs = CurPtr-StrStart-1;
611 
612  // Find the ']'.
613  const char *NameEnd = (const char*)memchr(CurPtr, ']', StrEnd-CurPtr);
614  if (NameEnd == nullptr)
615  return diag::err_asm_unterminated_symbolic_operand_name;
616  if (NameEnd == CurPtr)
617  return diag::err_asm_empty_symbolic_operand_name;
618 
619  StringRef SymbolicName(CurPtr, NameEnd - CurPtr);
620 
621  int N = getNamedOperand(SymbolicName);
622  if (N == -1) {
623  // Verify that an operand with that name exists.
624  DiagOffs = CurPtr-StrStart;
625  return diag::err_asm_unknown_symbolic_operand_name;
626  }
627 
628  // Str contains "x[foo]" (Operand without the leading %).
629  std::string Str(Begin, NameEnd + 1 - Begin);
630 
631  // (BeginLoc, EndLoc) represents the range of the operand we are currently
632  // processing. Unlike Str, the range includes the leading '%'.
633  SourceLocation BeginLoc = getAsmString()->getLocationOfByte(
634  Percent - StrStart, SM, LO, TI, &LastAsmStringToken,
635  &LastAsmStringOffset);
636  SourceLocation EndLoc = getAsmString()->getLocationOfByte(
637  NameEnd + 1 - StrStart, SM, LO, TI, &LastAsmStringToken,
638  &LastAsmStringOffset);
639 
640  Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
641 
642  CurPtr = NameEnd+1;
643  continue;
644  }
645 
646  DiagOffs = CurPtr-StrStart-1;
647  return diag::err_asm_invalid_escape;
648  }
649 }
650 
651 /// Assemble final IR asm string (GCC-style).
652 std::string GCCAsmStmt::generateAsmString(const ASTContext &C) const {
653  // Analyze the asm string to decompose it into its pieces. We know that Sema
654  // has already done this, so it is guaranteed to be successful.
656  unsigned DiagOffs;
657  AnalyzeAsmString(Pieces, C, DiagOffs);
658 
659  std::string AsmString;
660  for (unsigned i = 0, e = Pieces.size(); i != e; ++i) {
661  if (Pieces[i].isString())
662  AsmString += Pieces[i].getString();
663  else if (Pieces[i].getModifier() == '\0')
664  AsmString += '$' + llvm::utostr(Pieces[i].getOperandNo());
665  else
666  AsmString += "${" + llvm::utostr(Pieces[i].getOperandNo()) + ':' +
667  Pieces[i].getModifier() + '}';
668  }
669  return AsmString;
670 }
671 
672 /// Assemble final IR asm string (MS-style).
673 std::string MSAsmStmt::generateAsmString(const ASTContext &C) const {
674  // FIXME: This needs to be translated into the IR string representation.
675  return AsmStr;
676 }
677 
679  return cast<Expr>(Exprs[i]);
680 }
681 
683  return cast<Expr>(Exprs[i + NumOutputs]);
684 }
685 void MSAsmStmt::setInputExpr(unsigned i, Expr *E) {
686  Exprs[i + NumOutputs] = E;
687 }
688 
689 //===----------------------------------------------------------------------===//
690 // Constructors
691 //===----------------------------------------------------------------------===//
692 
694  bool issimple, bool isvolatile, unsigned numoutputs,
695  unsigned numinputs, IdentifierInfo **names,
696  StringLiteral **constraints, Expr **exprs,
697  StringLiteral *asmstr, unsigned numclobbers,
698  StringLiteral **clobbers, SourceLocation rparenloc)
699  : AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
700  numinputs, numclobbers), RParenLoc(rparenloc), AsmStr(asmstr) {
701 
702  unsigned NumExprs = NumOutputs + NumInputs;
703 
704  Names = new (C) IdentifierInfo*[NumExprs];
705  std::copy(names, names + NumExprs, Names);
706 
707  Exprs = new (C) Stmt*[NumExprs];
708  std::copy(exprs, exprs + NumExprs, Exprs);
709 
710  Constraints = new (C) StringLiteral*[NumExprs];
711  std::copy(constraints, constraints + NumExprs, Constraints);
712 
713  Clobbers = new (C) StringLiteral*[NumClobbers];
714  std::copy(clobbers, clobbers + NumClobbers, Clobbers);
715 }
716 
718  SourceLocation lbraceloc, bool issimple, bool isvolatile,
719  ArrayRef<Token> asmtoks, unsigned numoutputs,
720  unsigned numinputs,
721  ArrayRef<StringRef> constraints, ArrayRef<Expr*> exprs,
722  StringRef asmstr, ArrayRef<StringRef> clobbers,
723  SourceLocation endloc)
724  : AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
725  numinputs, clobbers.size()), LBraceLoc(lbraceloc),
726  EndLoc(endloc), NumAsmToks(asmtoks.size()) {
727 
728  initialize(C, asmstr, asmtoks, constraints, exprs, clobbers);
729 }
730 
731 static StringRef copyIntoContext(const ASTContext &C, StringRef str) {
732  return str.copy(C);
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  assert(exprs.size() == NumOutputs + NumInputs);
744  assert(exprs.size() == constraints.size());
745 
746  AsmStr = copyIntoContext(C, asmstr);
747 
748  Exprs = new (C) Stmt*[exprs.size()];
749  std::copy(exprs.begin(), exprs.end(), Exprs);
750 
751  AsmToks = new (C) Token[asmtoks.size()];
752  std::copy(asmtoks.begin(), asmtoks.end(), AsmToks);
753 
754  Constraints = new (C) StringRef[exprs.size()];
755  std::transform(constraints.begin(), constraints.end(), Constraints,
756  [&](StringRef Constraint) {
757  return copyIntoContext(C, Constraint);
758  });
759 
760  Clobbers = new (C) StringRef[NumClobbers];
761  // FIXME: Avoid the allocation/copy if at all possible.
762  std::transform(clobbers.begin(), clobbers.end(), Clobbers,
763  [&](StringRef Clobber) {
764  return copyIntoContext(C, Clobber);
765  });
766 }
767 
768 IfStmt::IfStmt(const ASTContext &C, SourceLocation IL, bool IsConstexpr,
769  Stmt *init, VarDecl *var, Expr *cond, Stmt *then,
770  SourceLocation EL, Stmt *elsev)
771  : Stmt(IfStmtClass), IfLoc(IL), ElseLoc(EL) {
772  setConstexpr(IsConstexpr);
773  setConditionVariable(C, var);
774  SubExprs[INIT] = init;
775  SubExprs[COND] = cond;
776  SubExprs[THEN] = then;
777  SubExprs[ELSE] = elsev;
778 }
779 
781  if (!SubExprs[VAR])
782  return nullptr;
783 
784  DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
785  return cast<VarDecl>(DS->getSingleDecl());
786 }
787 
789  if (!V) {
790  SubExprs[VAR] = nullptr;
791  return;
792  }
793 
794  SourceRange VarRange = V->getSourceRange();
795  SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
796  VarRange.getEnd());
797 }
798 
800  return isa<ObjCAvailabilityCheckExpr>(SubExprs[COND]);
801 }
802 
803 ForStmt::ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
804  Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
805  SourceLocation RP)
806  : Stmt(ForStmtClass), ForLoc(FL), LParenLoc(LP), RParenLoc(RP)
807 {
808  SubExprs[INIT] = Init;
809  setConditionVariable(C, condVar);
810  SubExprs[COND] = Cond;
811  SubExprs[INC] = Inc;
812  SubExprs[BODY] = Body;
813 }
814 
816  if (!SubExprs[CONDVAR])
817  return nullptr;
818 
819  DeclStmt *DS = cast<DeclStmt>(SubExprs[CONDVAR]);
820  return cast<VarDecl>(DS->getSingleDecl());
821 }
822 
824  if (!V) {
825  SubExprs[CONDVAR] = nullptr;
826  return;
827  }
828 
829  SourceRange VarRange = V->getSourceRange();
830  SubExprs[CONDVAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
831  VarRange.getEnd());
832 }
833 
835  Expr *cond)
836  : Stmt(SwitchStmtClass), FirstCase(nullptr, false) {
837  setConditionVariable(C, Var);
838  SubExprs[INIT] = init;
839  SubExprs[COND] = cond;
840  SubExprs[BODY] = nullptr;
841 }
842 
844  if (!SubExprs[VAR])
845  return nullptr;
846 
847  DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
848  return cast<VarDecl>(DS->getSingleDecl());
849 }
850 
852  if (!V) {
853  SubExprs[VAR] = nullptr;
854  return;
855  }
856 
857  SourceRange VarRange = V->getSourceRange();
858  SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
859  VarRange.getEnd());
860 }
861 
863  if (isa<CaseStmt>(this))
864  return cast<CaseStmt>(this)->getSubStmt();
865  return cast<DefaultStmt>(this)->getSubStmt();
866 }
867 
868 WhileStmt::WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
869  SourceLocation WL)
870  : Stmt(WhileStmtClass) {
871  setConditionVariable(C, Var);
872  SubExprs[COND] = cond;
873  SubExprs[BODY] = body;
874  WhileLoc = WL;
875 }
876 
878  if (!SubExprs[VAR])
879  return nullptr;
880 
881  DeclStmt *DS = cast<DeclStmt>(SubExprs[VAR]);
882  return cast<VarDecl>(DS->getSingleDecl());
883 }
884 
886  if (!V) {
887  SubExprs[VAR] = nullptr;
888  return;
889  }
890 
891  SourceRange VarRange = V->getSourceRange();
892  SubExprs[VAR] = new (C) DeclStmt(DeclGroupRef(V), VarRange.getBegin(),
893  VarRange.getEnd());
894 }
895 
896 // IndirectGotoStmt
898  if (AddrLabelExpr *E =
899  dyn_cast<AddrLabelExpr>(getTarget()->IgnoreParenImpCasts()))
900  return E->getLabel();
901  return nullptr;
902 }
903 
904 // ReturnStmt
906  return cast_or_null<Expr>(RetExpr);
907 }
909  return cast_or_null<Expr>(RetExpr);
910 }
911 
912 SEHTryStmt::SEHTryStmt(bool IsCXXTry,
913  SourceLocation TryLoc,
914  Stmt *TryBlock,
915  Stmt *Handler)
916  : Stmt(SEHTryStmtClass),
917  IsCXXTry(IsCXXTry),
918  TryLoc(TryLoc)
919 {
920  Children[TRY] = TryBlock;
921  Children[HANDLER] = Handler;
922 }
923 
924 SEHTryStmt* SEHTryStmt::Create(const ASTContext &C, bool IsCXXTry,
925  SourceLocation TryLoc, Stmt *TryBlock,
926  Stmt *Handler) {
927  return new(C) SEHTryStmt(IsCXXTry,TryLoc,TryBlock,Handler);
928 }
929 
931  return dyn_cast<SEHExceptStmt>(getHandler());
932 }
933 
935  return dyn_cast<SEHFinallyStmt>(getHandler());
936 }
937 
938 SEHExceptStmt::SEHExceptStmt(SourceLocation Loc,
939  Expr *FilterExpr,
940  Stmt *Block)
941  : Stmt(SEHExceptStmtClass),
942  Loc(Loc)
943 {
944  Children[FILTER_EXPR] = FilterExpr;
945  Children[BLOCK] = Block;
946 }
947 
949  Expr *FilterExpr, Stmt *Block) {
950  return new(C) SEHExceptStmt(Loc,FilterExpr,Block);
951 }
952 
953 SEHFinallyStmt::SEHFinallyStmt(SourceLocation Loc,
954  Stmt *Block)
955  : Stmt(SEHFinallyStmtClass),
956  Loc(Loc),
957  Block(Block)
958 {}
959 
961  Stmt *Block) {
962  return new(C)SEHFinallyStmt(Loc,Block);
963 }
964 
966  VarDecl *Var)
967  : VarAndKind(Var, Kind), Loc(Loc) {
968  switch (Kind) {
969  case VCK_This:
970  assert(!Var && "'this' capture cannot have a variable!");
971  break;
972  case VCK_ByRef:
973  assert(Var && "capturing by reference must have a variable!");
974  break;
975  case VCK_ByCopy:
976  assert(Var && "capturing by copy must have a variable!");
977  assert(
978  (Var->getType()->isScalarType() || (Var->getType()->isReferenceType() &&
979  Var->getType()
980  ->castAs<ReferenceType>()
981  ->getPointeeType()
982  ->isScalarType())) &&
983  "captures by copy are expected to have a scalar type!");
984  break;
985  case VCK_VLAType:
986  assert(!Var &&
987  "Variable-length array type capture cannot have a variable!");
988  break;
989  }
990 }
991 
994  return VarAndKind.getInt();
995 }
996 
998  assert((capturesVariable() || capturesVariableByCopy()) &&
999  "No variable available for 'this' or VAT capture");
1000  return VarAndKind.getPointer();
1001 }
1002 
1003 CapturedStmt::Capture *CapturedStmt::getStoredCaptures() const {
1004  unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1);
1005 
1006  // Offset of the first Capture object.
1007  unsigned FirstCaptureOffset = llvm::alignTo(Size, alignof(Capture));
1008 
1009  return reinterpret_cast<Capture *>(
1010  reinterpret_cast<char *>(const_cast<CapturedStmt *>(this))
1011  + FirstCaptureOffset);
1012 }
1013 
1014 CapturedStmt::CapturedStmt(Stmt *S, CapturedRegionKind Kind,
1015  ArrayRef<Capture> Captures,
1016  ArrayRef<Expr *> CaptureInits,
1017  CapturedDecl *CD,
1018  RecordDecl *RD)
1019  : Stmt(CapturedStmtClass), NumCaptures(Captures.size()),
1020  CapDeclAndKind(CD, Kind), TheRecordDecl(RD) {
1021  assert( S && "null captured statement");
1022  assert(CD && "null captured declaration for captured statement");
1023  assert(RD && "null record declaration for captured statement");
1024 
1025  // Copy initialization expressions.
1026  Stmt **Stored = getStoredStmts();
1027  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
1028  *Stored++ = CaptureInits[I];
1029 
1030  // Copy the statement being captured.
1031  *Stored = S;
1032 
1033  // Copy all Capture objects.
1034  Capture *Buffer = getStoredCaptures();
1035  std::copy(Captures.begin(), Captures.end(), Buffer);
1036 }
1037 
1038 CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures)
1039  : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
1040  CapDeclAndKind(nullptr, CR_Default), TheRecordDecl(nullptr) {
1041  getStoredStmts()[NumCaptures] = nullptr;
1042 }
1043 
1046  ArrayRef<Capture> Captures,
1047  ArrayRef<Expr *> CaptureInits,
1048  CapturedDecl *CD,
1049  RecordDecl *RD) {
1050  // The layout is
1051  //
1052  // -----------------------------------------------------------
1053  // | CapturedStmt, Init, ..., Init, S, Capture, ..., Capture |
1054  // ----------------^-------------------^----------------------
1055  // getStoredStmts() getStoredCaptures()
1056  //
1057  // where S is the statement being captured.
1058  //
1059  assert(CaptureInits.size() == Captures.size() && "wrong number of arguments");
1060 
1061  unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (Captures.size() + 1);
1062  if (!Captures.empty()) {
1063  // Realign for the following Capture array.
1064  Size = llvm::alignTo(Size, alignof(Capture));
1065  Size += sizeof(Capture) * Captures.size();
1066  }
1067 
1068  void *Mem = Context.Allocate(Size);
1069  return new (Mem) CapturedStmt(S, Kind, Captures, CaptureInits, CD, RD);
1070 }
1071 
1073  unsigned NumCaptures) {
1074  unsigned Size = sizeof(CapturedStmt) + sizeof(Stmt *) * (NumCaptures + 1);
1075  if (NumCaptures > 0) {
1076  // Realign for the following Capture array.
1077  Size = llvm::alignTo(Size, alignof(Capture));
1078  Size += sizeof(Capture) * NumCaptures;
1079  }
1080 
1081  void *Mem = Context.Allocate(Size);
1082  return new (Mem) CapturedStmt(EmptyShell(), NumCaptures);
1083 }
1084 
1086  // Children are captured field initializers.
1087  return child_range(getStoredStmts(), getStoredStmts() + NumCaptures);
1088 }
1089 
1091  return CapDeclAndKind.getPointer();
1092 }
1094  return CapDeclAndKind.getPointer();
1095 }
1096 
1097 /// \brief Set the outlined function declaration.
1099  assert(D && "null CapturedDecl");
1100  CapDeclAndKind.setPointer(D);
1101 }
1102 
1103 /// \brief Retrieve the captured region kind.
1105  return CapDeclAndKind.getInt();
1106 }
1107 
1108 /// \brief Set the captured region kind.
1110  CapDeclAndKind.setInt(Kind);
1111 }
1112 
1113 bool CapturedStmt::capturesVariable(const VarDecl *Var) const {
1114  for (const auto &I : captures()) {
1115  if (!I.capturesVariable() && !I.capturesVariableByCopy())
1116  continue;
1117  if (I.getCapturedVar()->getCanonicalDecl() == Var->getCanonicalDecl())
1118  return true;
1119  }
1120 
1121  return false;
1122 }
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
Definition: Stmt.cpp:322
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:823
Defines the clang::ASTContext interface.
Capture(SourceLocation Loc, VariableCaptureKind Kind, VarDecl *Var=nullptr)
Create a new capture.
Definition: Stmt.cpp:965
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1591
static LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
Definition: CharInfo.h:94
Stmt - This represents one statement.
Definition: Stmt.h:60
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Definition: ASTMatchers.h:1068
const char * Name
Definition: Stmt.cpp:32
VarDecl * getCapturedVar() const
Retrieve the declaration of the variable being captured.
Definition: Stmt.cpp:997
C Language Family Type Representation.
static LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
Definition: CharInfo.h:112
Represents an attribute applied to a statement.
Definition: Stmt.h:854
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:693
unsigned NumOutputs
Definition: Stmt.h:1451
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:645
Stmt * IgnoreImplicit()
Skip past any implicit AST nodes which might surround this statement, such as ExprWithCleanups or Imp...
Definition: Stmt.cpp:96
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
Definition: Stmt.cpp:313
static void addStmtClass(const StmtClass s)
Definition: Stmt.cpp:87
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:885
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:877
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
Definition: Stmt.cpp:1113
void setInputExpr(unsigned i, Expr *E)
Definition: Stmt.cpp:685
void setInputExpr(unsigned i, Expr *E)
Definition: Stmt.cpp:411
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:771
unsigned AnalyzeAsmString(SmallVectorImpl< AsmStringPiece > &Pieces, const ASTContext &C, unsigned &DiagOffs) const
AnalyzeAsmString - Analyze the asm string of the current asm, decomposing it into pieces...
Definition: Stmt.cpp:475
void setStmts(const ASTContext &C, ArrayRef< Stmt *> Stmts)
Definition: Stmt.cpp:298
const char * getName() const
Definition: Stmt.cpp:309
Defines the Objective-C statement AST node classes.
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:100
int getNamedOperand(StringRef SymbolicName) const
getNamedOperand - Given a symbolic operand reference like %[foo], translate this into a numeric value...
Definition: Stmt.cpp:455
Defines the clang::Expr interface and subclasses for C++ expressions.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "switch" statement, if any.
Definition: Stmt.cpp:843
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition: Stmt.h:349
static struct StmtClassNameTable StmtClassInfo[Stmt::lastStmtConstant+1]
const char * getStmtClassName() const
Definition: Stmt.cpp:58
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:813
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3384
One of these records is kept for each identifier that is lexed.
IfStmt(const ASTContext &C, SourceLocation IL, bool IsConstexpr, Stmt *init, VarDecl *var, Expr *cond, Stmt *then, SourceLocation EL=SourceLocation(), Stmt *elsev=nullptr)
Definition: Stmt.cpp:768
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body, SourceLocation WL)
Definition: Stmt.cpp:868
const Expr * getRetValue() const
Definition: Stmt.cpp:905
bool isReferenceType() const
Definition: Type.h:5775
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
void setCapturedDecl(CapturedDecl *D)
Set the outlined function declaration.
Definition: Stmt.cpp:1098
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
Definition: TargetInfo.h:955
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
static CapturedStmt * Create(const ASTContext &Context, Stmt *S, CapturedRegionKind Kind, ArrayRef< Capture > Captures, ArrayRef< Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD)
Definition: Stmt.cpp:1044
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.cpp:346
child_range children()
Definition: Stmt.cpp:208
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:397
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition: Stmt.cpp:673
unsigned getNumPlusOperands() const
getNumPlusOperands - Return the number of output operands that have a "+" constraint.
Definition: Stmt.cpp:380
bool isScalarType() const
Definition: Type.h:5998
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3756
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:815
StmtClass
Definition: Stmt.h:62
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:717
static SEHTryStmt * Create(const ASTContext &C, bool isCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: Stmt.cpp:924
StringRef getClobber(unsigned i) const
Definition: Stmt.cpp:393
unsigned NumClobbers
Definition: Stmt.h:1453
Describes the capture of either a variable, or &#39;this&#39;, or variable-length array type.
Definition: Stmt.h:2045
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.cpp:270
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition: Stmt.cpp:330
Exposes information about the current target.
Definition: TargetInfo.h:55
CompoundStmt(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
Definition: Stmt.cpp:282
Expr - This represents one expression.
Definition: Expr.h:106
const FunctionProtoType * T
Stmt * IgnoreContainers(bool IgnoreCaptured=false)
Skip no-op (attributed, compound) container stmts and skip captured stmt at the top, if IgnoreCaptured is true.
Definition: Stmt.cpp:116
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:6162
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
Definition: Stmt.h:1625
VariableCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition: Stmt.cpp:993
LabelDecl * getConstantTarget()
getConstantTarget - Returns the fixed target of this indirect goto, if one exists.
Definition: Stmt.cpp:897
SourceLocation Begin
child_range children()
Definition: Stmt.cpp:1085
CompoundStmtBitfields CompoundStmtBits
Definition: Stmt.h:266
static StringRef copyIntoContext(const ASTContext &C, StringRef str)
Definition: Stmt.cpp:731
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:1770
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
Definition: Stmt.cpp:417
SourceLocation getEnd() const
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:682
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:678
StringRef getClobber(unsigned i) const
Definition: Stmt.cpp:370
The result type of a method or function.
do v
Definition: arm_acle.h:78
const SourceManager & SM
Definition: Format.cpp:1308
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition: Decl.cpp:1951
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition: Stmt.cpp:960
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:1440
#define false
Definition: stdbool.h:33
Kind
StringRef getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
Definition: Stmt.cpp:354
This captures a statement into a function.
Definition: Stmt.h:2032
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
Definition: Stmt.cpp:338
Encodes a location in the source.
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:422
static void PrintStats()
Definition: Stmt.cpp:62
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition: Stmt.cpp:652
void setConstexpr(bool C)
Definition: Stmt.h:958
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:467
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:427
bool capturesVariable() const
Determine whether this capture handles a variable (by reference).
Definition: Stmt.h:2072
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:851
StringRef getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
Definition: Stmt.cpp:404
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:408
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:1883
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:308
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:625
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3445
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:780
Dataflow Directional Tag Classes.
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
Definition: Stmt.cpp:1072
const Stmt * stripLabelLikeStatements() const
Strip off all label-like statements.
Definition: Stmt.cpp:138
SourceRange getSourceRange(const SourceRange &Range)
Returns the SourceRange of a SourceRange.
Definition: FixIt.h:34
unsigned Counter
Definition: Stmt.cpp:33
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Definition: Stmt.cpp:930
const Decl * getSingleDecl() const
Definition: Stmt.h:485
static LLVM_ATTRIBUTE_UNUSED void check_implementations()
Check whether the various Stmt classes implement their member functions.
Definition: Stmt.cpp:199
char getModifier() const
getModifier - Get the modifier for this operand, if present.
Definition: Stmt.cpp:388
bool isObjCAvailabilityCheck() const
Definition: Stmt.cpp:799
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
Definition: Stmt.h:2075
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition: Stmt.cpp:788
This file defines OpenMP AST classes for executable directives and clauses.
SwitchStmt(const ASTContext &C, Stmt *Init, VarDecl *Var, Expr *cond)
Definition: Stmt.cpp:834
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:2358
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.cpp:362
ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP)
Definition: Stmt.cpp:803
Stmt * getSubStmt()
Definition: Stmt.cpp:862
SourceManager & getSourceManager()
Definition: ASTContext.h:618
SEHFinallyStmt * getFinallyHandler() const
Definition: Stmt.cpp:934
Stmt ** Exprs
Definition: Stmt.h:1455
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition: Stmt.cpp:1090
void Deallocate(void *Ptr) const
Definition: ASTContext.h:631
unsigned Size
Definition: Stmt.cpp:34
OpenMPLinearClauseKind getModifier() const
Return modifier.
VariableCaptureKind
The different capture forms: by &#39;this&#39;, by reference, capture for variable-length array type etc...
Definition: Stmt.h:2036
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:245
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1509
Defines the clang::TargetInfo interface.
capture_range captures()
Definition: Stmt.h:2166
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
QualType getType() const
Definition: Decl.h:602
static StmtClassNameTable & getStmtInfoTableEntry(Stmt::StmtClass E)
Definition: Stmt.cpp:37
A trivial tuple used to represent a source range.
unsigned NumInputs
Definition: Stmt.h:1452
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.cpp:257
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
Definition: ASTContext.h:661
static SEHExceptStmt * Create(const ASTContext &C, SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block)
Definition: Stmt.cpp:948
This class handles loading and caching of source files into memory.
void setCapturedRegionKind(CapturedRegionKind Kind)
Set the captured region kind.
Definition: Stmt.cpp:1109
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition: Stmt.cpp:1104
Attr - This represents one attribute.
Definition: Attr.h:43
static void EnableStatistics()
Definition: Stmt.cpp:92
#define BLOCK(DERIVED, BASE)
Definition: Template.h:448