clang  3.8.0
Stmt.h
Go to the documentation of this file.
1 //===--- Stmt.h - Classes for representing statements -----------*- C++ -*-===//
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 defines the Stmt interface and subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_STMT_H
15 #define LLVM_CLANG_AST_STMT_H
16 
17 #include "clang/AST/DeclGroup.h"
18 #include "clang/AST/StmtIterator.h"
21 #include "clang/Basic/LLVM.h"
23 #include "llvm/ADT/ArrayRef.h"
24 #include "llvm/ADT/PointerIntPair.h"
25 #include "llvm/ADT/iterator.h"
26 #include "llvm/Support/Compiler.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include <string>
29 
30 namespace llvm {
31  class FoldingSetNodeID;
32 }
33 
34 namespace clang {
35  class ASTContext;
36  class Attr;
37  class CapturedDecl;
38  class Decl;
39  class Expr;
40  class IdentifierInfo;
41  class LabelDecl;
42  class ParmVarDecl;
43  class PrinterHelper;
44  struct PrintingPolicy;
45  class QualType;
46  class RecordDecl;
47  class SourceManager;
48  class StringLiteral;
49  class SwitchStmt;
50  class Token;
51  class VarDecl;
52 
53 //===----------------------------------------------------------------------===//
54 // AST classes for statements.
55 //===----------------------------------------------------------------------===//
56 
57 /// Stmt - This represents one statement.
58 ///
59 class LLVM_ALIGNAS(LLVM_PTR_SIZE) Stmt {
60 public:
61  enum StmtClass {
62  NoStmtClass = 0,
63 #define STMT(CLASS, PARENT) CLASS##Class,
64 #define STMT_RANGE(BASE, FIRST, LAST) \
65  first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class,
66 #define LAST_STMT_RANGE(BASE, FIRST, LAST) \
67  first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class
68 #define ABSTRACT_STMT(STMT)
69 #include "clang/AST/StmtNodes.inc"
70  };
71 
72  // Make vanilla 'new' and 'delete' illegal for Stmts.
73 protected:
74  void *operator new(size_t bytes) LLVM_NOEXCEPT {
75  llvm_unreachable("Stmts cannot be allocated with regular 'new'.");
76  }
77  void operator delete(void *data) LLVM_NOEXCEPT {
78  llvm_unreachable("Stmts cannot be released with regular 'delete'.");
79  }
80 
81  class StmtBitfields {
82  friend class Stmt;
83 
84  /// \brief The statement class.
85  unsigned sClass : 8;
86  };
87  enum { NumStmtBits = 8 };
88 
89  class CompoundStmtBitfields {
90  friend class CompoundStmt;
91  unsigned : NumStmtBits;
92 
93  unsigned NumStmts : 32 - NumStmtBits;
94  };
95 
96  class ExprBitfields {
97  friend class Expr;
98  friend class DeclRefExpr; // computeDependence
99  friend class InitListExpr; // ctor
100  friend class DesignatedInitExpr; // ctor
101  friend class BlockDeclRefExpr; // ctor
102  friend class ASTStmtReader; // deserialization
103  friend class CXXNewExpr; // ctor
104  friend class DependentScopeDeclRefExpr; // ctor
105  friend class CXXConstructExpr; // ctor
106  friend class CallExpr; // ctor
107  friend class OffsetOfExpr; // ctor
108  friend class ObjCMessageExpr; // ctor
109  friend class ObjCArrayLiteral; // ctor
110  friend class ObjCDictionaryLiteral; // ctor
111  friend class ShuffleVectorExpr; // ctor
112  friend class ParenListExpr; // ctor
113  friend class CXXUnresolvedConstructExpr; // ctor
114  friend class CXXDependentScopeMemberExpr; // ctor
115  friend class OverloadExpr; // ctor
116  friend class PseudoObjectExpr; // ctor
117  friend class AtomicExpr; // ctor
118  unsigned : NumStmtBits;
119 
120  unsigned ValueKind : 2;
121  unsigned ObjectKind : 2;
122  unsigned TypeDependent : 1;
123  unsigned ValueDependent : 1;
124  unsigned InstantiationDependent : 1;
125  unsigned ContainsUnexpandedParameterPack : 1;
126  };
127  enum { NumExprBits = 16 };
128 
129  class CharacterLiteralBitfields {
130  friend class CharacterLiteral;
131  unsigned : NumExprBits;
132 
133  unsigned Kind : 3;
134  };
135 
136  enum APFloatSemantics {
137  IEEEhalf,
138  IEEEsingle,
139  IEEEdouble,
140  x87DoubleExtended,
141  IEEEquad,
142  PPCDoubleDouble
143  };
144 
145  class FloatingLiteralBitfields {
146  friend class FloatingLiteral;
147  unsigned : NumExprBits;
148 
149  unsigned Semantics : 3; // Provides semantics for APFloat construction
150  unsigned IsExact : 1;
151  };
152 
153  class UnaryExprOrTypeTraitExprBitfields {
154  friend class UnaryExprOrTypeTraitExpr;
155  unsigned : NumExprBits;
156 
157  unsigned Kind : 2;
158  unsigned IsType : 1; // true if operand is a type, false if an expression.
159  };
160 
161  class DeclRefExprBitfields {
162  friend class DeclRefExpr;
163  friend class ASTStmtReader; // deserialization
164  unsigned : NumExprBits;
165 
166  unsigned HasQualifier : 1;
167  unsigned HasTemplateKWAndArgsInfo : 1;
168  unsigned HasFoundDecl : 1;
169  unsigned HadMultipleCandidates : 1;
170  unsigned RefersToEnclosingVariableOrCapture : 1;
171  };
172 
173  class CastExprBitfields {
174  friend class CastExpr;
175  unsigned : NumExprBits;
176 
177  unsigned Kind : 6;
178  unsigned BasePathSize : 32 - 6 - NumExprBits;
179  };
180 
181  class CallExprBitfields {
182  friend class CallExpr;
183  unsigned : NumExprBits;
184 
185  unsigned NumPreArgs : 1;
186  };
187 
188  class ExprWithCleanupsBitfields {
189  friend class ExprWithCleanups;
190  friend class ASTStmtReader; // deserialization
191 
192  unsigned : NumExprBits;
193 
194  unsigned NumObjects : 32 - NumExprBits;
195  };
196 
197  class PseudoObjectExprBitfields {
198  friend class PseudoObjectExpr;
199  friend class ASTStmtReader; // deserialization
200 
201  unsigned : NumExprBits;
202 
203  // These don't need to be particularly wide, because they're
204  // strictly limited by the forms of expressions we permit.
205  unsigned NumSubExprs : 8;
206  unsigned ResultIndex : 32 - 8 - NumExprBits;
207  };
208 
209  class ObjCIndirectCopyRestoreExprBitfields {
210  friend class ObjCIndirectCopyRestoreExpr;
211  unsigned : NumExprBits;
212 
213  unsigned ShouldCopy : 1;
214  };
215 
216  class InitListExprBitfields {
217  friend class InitListExpr;
218 
219  unsigned : NumExprBits;
220 
221  /// Whether this initializer list originally had a GNU array-range
222  /// designator in it. This is a temporary marker used by CodeGen.
223  unsigned HadArrayRangeDesignator : 1;
224  };
225 
226  class TypeTraitExprBitfields {
227  friend class TypeTraitExpr;
228  friend class ASTStmtReader;
229  friend class ASTStmtWriter;
230 
231  unsigned : NumExprBits;
232 
233  /// \brief The kind of type trait, which is a value of a TypeTrait enumerator.
234  unsigned Kind : 8;
235 
236  /// \brief If this expression is not value-dependent, this indicates whether
237  /// the trait evaluated true or false.
238  unsigned Value : 1;
239 
240  /// \brief The number of arguments to this type trait.
241  unsigned NumArgs : 32 - 8 - 1 - NumExprBits;
242  };
243 
244  union {
245  StmtBitfields StmtBits;
246  CompoundStmtBitfields CompoundStmtBits;
247  ExprBitfields ExprBits;
248  CharacterLiteralBitfields CharacterLiteralBits;
249  FloatingLiteralBitfields FloatingLiteralBits;
250  UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits;
251  DeclRefExprBitfields DeclRefExprBits;
252  CastExprBitfields CastExprBits;
253  CallExprBitfields CallExprBits;
254  ExprWithCleanupsBitfields ExprWithCleanupsBits;
255  PseudoObjectExprBitfields PseudoObjectExprBits;
256  ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits;
257  InitListExprBitfields InitListExprBits;
258  TypeTraitExprBitfields TypeTraitExprBits;
259  };
260 
261  friend class ASTStmtReader;
262  friend class ASTStmtWriter;
263 
264 public:
265  // Only allow allocation of Stmts using the allocator in ASTContext
266  // or by doing a placement new.
267  void* operator new(size_t bytes, const ASTContext& C,
268  unsigned alignment = 8);
269 
270  void* operator new(size_t bytes, const ASTContext* C,
271  unsigned alignment = 8) {
272  return operator new(bytes, *C, alignment);
273  }
274 
275  void *operator new(size_t bytes, void *mem) LLVM_NOEXCEPT { return mem; }
276 
277  void operator delete(void *, const ASTContext &, unsigned) LLVM_NOEXCEPT {}
278  void operator delete(void *, const ASTContext *, unsigned) LLVM_NOEXCEPT {}
279  void operator delete(void *, size_t) LLVM_NOEXCEPT {}
280  void operator delete(void *, void *) LLVM_NOEXCEPT {}
281 
282 public:
283  /// \brief A placeholder type used to construct an empty shell of a
284  /// type, that will be filled in later (e.g., by some
285  /// de-serialization).
286  struct EmptyShell { };
287 
288 protected:
289  /// Iterator for iterating over Stmt * arrays that contain only Expr *
290  ///
291  /// This is needed because AST nodes use Stmt* arrays to store
292  /// references to children (to be compatible with StmtIterator).
293  struct ExprIterator
294  : llvm::iterator_adaptor_base<ExprIterator, Stmt **,
295  std::random_access_iterator_tag, Expr *> {
296  ExprIterator() : iterator_adaptor_base(nullptr) {}
297  ExprIterator(Stmt **I) : iterator_adaptor_base(I) {}
298 
299  reference operator*() const {
300  assert((*I)->getStmtClass() >= firstExprConstant &&
301  (*I)->getStmtClass() <= lastExprConstant);
302  return *reinterpret_cast<Expr **>(I);
303  }
304  };
305 
306  /// Const iterator for iterating over Stmt * arrays that contain only Expr *
307  struct ConstExprIterator
308  : llvm::iterator_adaptor_base<ConstExprIterator, const Stmt *const *,
309  std::random_access_iterator_tag,
310  const Expr *const> {
311  ConstExprIterator() : iterator_adaptor_base(nullptr) {}
312  ConstExprIterator(const Stmt *const *I) : iterator_adaptor_base(I) {}
313 
314  reference operator*() const {
315  assert((*I)->getStmtClass() >= firstExprConstant &&
316  (*I)->getStmtClass() <= lastExprConstant);
317  return *reinterpret_cast<const Expr *const *>(I);
318  }
319  };
320 
321 private:
322  /// \brief Whether statistic collection is enabled.
323  static bool StatisticsEnabled;
324 
325 protected:
326  /// \brief Construct an empty statement.
327  explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
328 
329 public:
330  Stmt(StmtClass SC) {
331  static_assert(sizeof(*this) % llvm::AlignOf<void *>::Alignment == 0,
332  "Insufficient alignment!");
333  StmtBits.sClass = SC;
334  if (StatisticsEnabled) Stmt::addStmtClass(SC);
335  }
336 
337  StmtClass getStmtClass() const {
338  return static_cast<StmtClass>(StmtBits.sClass);
339  }
340  const char *getStmtClassName() const;
341 
342  /// SourceLocation tokens are not useful in isolation - they are low level
343  /// value objects created/interpreted by SourceManager. We assume AST
344  /// clients will have a pointer to the respective SourceManager.
345  SourceRange getSourceRange() const LLVM_READONLY;
346  SourceLocation getLocStart() const LLVM_READONLY;
347  SourceLocation getLocEnd() const LLVM_READONLY;
348 
349  // global temp stats (until we have a per-module visitor)
350  static void addStmtClass(const StmtClass s);
351  static void EnableStatistics();
352  static void PrintStats();
353 
354  /// \brief Dumps the specified AST fragment and all subtrees to
355  /// \c llvm::errs().
356  void dump() const;
357  void dump(SourceManager &SM) const;
358  void dump(raw_ostream &OS, SourceManager &SM) const;
359  void dump(raw_ostream &OS) const;
360 
361  /// dumpColor - same as dump(), but forces color highlighting.
362  void dumpColor() const;
363 
364  /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
365  /// back to its original source language syntax.
366  void dumpPretty(const ASTContext &Context) const;
367  void printPretty(raw_ostream &OS, PrinterHelper *Helper,
368  const PrintingPolicy &Policy,
369  unsigned Indentation = 0) const;
370 
371  /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
372  /// works on systems with GraphViz (Mac OS X) or dot+gv installed.
373  void viewAST() const;
374 
375  /// Skip past any implicit AST nodes which might surround this
376  /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
377  Stmt *IgnoreImplicit();
378 
379  /// \brief Skip no-op (attributed, compound) container stmts and skip captured
380  /// stmt at the top, if \a IgnoreCaptured is true.
381  Stmt *IgnoreContainers(bool IgnoreCaptured = false);
382 
383  const Stmt *stripLabelLikeStatements() const;
384  Stmt *stripLabelLikeStatements() {
385  return const_cast<Stmt*>(
386  const_cast<const Stmt*>(this)->stripLabelLikeStatements());
387  }
388 
389  /// Child Iterators: All subclasses must implement 'children'
390  /// to permit easy iteration over the substatements/subexpessions of an
391  /// AST node. This permits easy iteration over all nodes in the AST.
392  typedef StmtIterator child_iterator;
393  typedef ConstStmtIterator const_child_iterator;
394 
395  typedef llvm::iterator_range<child_iterator> child_range;
396  typedef llvm::iterator_range<const_child_iterator> const_child_range;
397 
398  child_range children();
399  const_child_range children() const {
400  auto Children = const_cast<Stmt *>(this)->children();
401  return const_child_range(Children.begin(), Children.end());
402  }
403 
404  child_iterator child_begin() { return children().begin(); }
405  child_iterator child_end() { return children().end(); }
406 
407  const_child_iterator child_begin() const { return children().begin(); }
408  const_child_iterator child_end() const { return children().end(); }
409 
410  /// \brief Produce a unique representation of the given statement.
411  ///
412  /// \param ID once the profiling operation is complete, will contain
413  /// the unique representation of the given statement.
414  ///
415  /// \param Context the AST context in which the statement resides
416  ///
417  /// \param Canonical whether the profile should be based on the canonical
418  /// representation of this statement (e.g., where non-type template
419  /// parameters are identified by index/level rather than their
420  /// declaration pointers) or the exact representation of the statement as
421  /// written in the source.
422  void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
423  bool Canonical) const;
424 };
425 
426 /// DeclStmt - Adaptor class for mixing declarations with statements and
427 /// expressions. For example, CompoundStmt mixes statements, expressions
428 /// and declarations (variables, types). Another example is ForStmt, where
429 /// the first statement can be an expression or a declaration.
430 ///
431 class DeclStmt : public Stmt {
432  DeclGroupRef DG;
433  SourceLocation StartLoc, EndLoc;
434 
435 public:
437  SourceLocation endLoc) : Stmt(DeclStmtClass), DG(dg),
438  StartLoc(startLoc), EndLoc(endLoc) {}
439 
440  /// \brief Build an empty declaration statement.
441  explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) { }
442 
443  /// isSingleDecl - This method returns true if this DeclStmt refers
444  /// to a single Decl.
445  bool isSingleDecl() const {
446  return DG.isSingleDecl();
447  }
448 
449  const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
450  Decl *getSingleDecl() { return DG.getSingleDecl(); }
451 
452  const DeclGroupRef getDeclGroup() const { return DG; }
453  DeclGroupRef getDeclGroup() { return DG; }
454  void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
455 
456  SourceLocation getStartLoc() const { return StartLoc; }
457  void setStartLoc(SourceLocation L) { StartLoc = L; }
458  SourceLocation getEndLoc() const { return EndLoc; }
459  void setEndLoc(SourceLocation L) { EndLoc = L; }
460 
461  SourceLocation getLocStart() const LLVM_READONLY { return StartLoc; }
462  SourceLocation getLocEnd() const LLVM_READONLY { return EndLoc; }
463 
464  static bool classof(const Stmt *T) {
465  return T->getStmtClass() == DeclStmtClass;
466  }
467 
468  // Iterators over subexpressions.
469  child_range children() {
470  return child_range(child_iterator(DG.begin(), DG.end()),
471  child_iterator(DG.end(), DG.end()));
472  }
473 
476  typedef llvm::iterator_range<decl_iterator> decl_range;
477  typedef llvm::iterator_range<const_decl_iterator> decl_const_range;
478 
479  decl_range decls() { return decl_range(decl_begin(), decl_end()); }
481  return decl_const_range(decl_begin(), decl_end());
482  }
483  decl_iterator decl_begin() { return DG.begin(); }
484  decl_iterator decl_end() { return DG.end(); }
485  const_decl_iterator decl_begin() const { return DG.begin(); }
486  const_decl_iterator decl_end() const { return DG.end(); }
487 
488  typedef std::reverse_iterator<decl_iterator> reverse_decl_iterator;
490  return reverse_decl_iterator(decl_end());
491  }
493  return reverse_decl_iterator(decl_begin());
494  }
495 };
496 
497 /// NullStmt - This is the null statement ";": C99 6.8.3p3.
498 ///
499 class NullStmt : public Stmt {
500  SourceLocation SemiLoc;
501 
502  /// \brief True if the null statement was preceded by an empty macro, e.g:
503  /// @code
504  /// #define CALL(x)
505  /// CALL(0);
506  /// @endcode
507  bool HasLeadingEmptyMacro;
508 public:
509  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
510  : Stmt(NullStmtClass), SemiLoc(L),
511  HasLeadingEmptyMacro(hasLeadingEmptyMacro) {}
512 
513  /// \brief Build an empty null statement.
514  explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty),
515  HasLeadingEmptyMacro(false) { }
516 
517  SourceLocation getSemiLoc() const { return SemiLoc; }
518  void setSemiLoc(SourceLocation L) { SemiLoc = L; }
519 
520  bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; }
521 
522  SourceLocation getLocStart() const LLVM_READONLY { return SemiLoc; }
523  SourceLocation getLocEnd() const LLVM_READONLY { return SemiLoc; }
524 
525  static bool classof(const Stmt *T) {
526  return T->getStmtClass() == NullStmtClass;
527  }
528 
529  child_range children() {
530  return child_range(child_iterator(), child_iterator());
531  }
532 
533  friend class ASTStmtReader;
534  friend class ASTStmtWriter;
535 };
536 
537 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
538 ///
539 class CompoundStmt : public Stmt {
540  Stmt** Body;
541  SourceLocation LBraceLoc, RBraceLoc;
542 
543  friend class ASTStmtReader;
544 
545 public:
548 
549  // \brief Build an empty compound statement with a location.
551  : Stmt(CompoundStmtClass), Body(nullptr), LBraceLoc(Loc), RBraceLoc(Loc) {
552  CompoundStmtBits.NumStmts = 0;
553  }
554 
555  // \brief Build an empty compound statement.
556  explicit CompoundStmt(EmptyShell Empty)
557  : Stmt(CompoundStmtClass, Empty), Body(nullptr) {
558  CompoundStmtBits.NumStmts = 0;
559  }
560 
561  void setStmts(const ASTContext &C, ArrayRef<Stmt *> Stmts);
562 
563  bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
564  unsigned size() const { return CompoundStmtBits.NumStmts; }
565 
566  typedef Stmt** body_iterator;
567  typedef llvm::iterator_range<body_iterator> body_range;
568 
569  body_range body() { return body_range(body_begin(), body_end()); }
570  body_iterator body_begin() { return Body; }
571  body_iterator body_end() { return Body + size(); }
572  Stmt *body_front() { return !body_empty() ? Body[0] : nullptr; }
573  Stmt *body_back() { return !body_empty() ? Body[size()-1] : nullptr; }
574 
575  void setLastStmt(Stmt *S) {
576  assert(!body_empty() && "setLastStmt");
577  Body[size()-1] = S;
578  }
579 
580  typedef Stmt* const * const_body_iterator;
581  typedef llvm::iterator_range<const_body_iterator> body_const_range;
582 
584  return body_const_range(body_begin(), body_end());
585  }
586  const_body_iterator body_begin() const { return Body; }
587  const_body_iterator body_end() const { return Body + size(); }
588  const Stmt *body_front() const {
589  return !body_empty() ? Body[0] : nullptr;
590  }
591  const Stmt *body_back() const {
592  return !body_empty() ? Body[size() - 1] : nullptr;
593  }
594 
595  typedef std::reverse_iterator<body_iterator> reverse_body_iterator;
597  return reverse_body_iterator(body_end());
598  }
600  return reverse_body_iterator(body_begin());
601  }
602 
603  typedef std::reverse_iterator<const_body_iterator>
605 
607  return const_reverse_body_iterator(body_end());
608  }
609 
611  return const_reverse_body_iterator(body_begin());
612  }
613 
614  SourceLocation getLocStart() const LLVM_READONLY { return LBraceLoc; }
615  SourceLocation getLocEnd() const LLVM_READONLY { return RBraceLoc; }
616 
617  SourceLocation getLBracLoc() const { return LBraceLoc; }
618  SourceLocation getRBracLoc() const { return RBraceLoc; }
619 
620  static bool classof(const Stmt *T) {
621  return T->getStmtClass() == CompoundStmtClass;
622  }
623 
624  // Iterators
625  child_range children() {
626  return child_range(Body, Body + CompoundStmtBits.NumStmts);
627  }
628 
629  const_child_range children() const {
630  return const_child_range(child_iterator(Body),
631  child_iterator(Body + CompoundStmtBits.NumStmts));
632  }
633 };
634 
635 // SwitchCase is the base class for CaseStmt and DefaultStmt,
636 class SwitchCase : public Stmt {
637 protected:
638  // A pointer to the following CaseStmt or DefaultStmt class,
639  // used by SwitchStmt.
643 
645  : Stmt(SC), NextSwitchCase(nullptr), KeywordLoc(KWLoc), ColonLoc(ColonLoc) {
646  }
647 
648  SwitchCase(StmtClass SC, EmptyShell)
649  : Stmt(SC), NextSwitchCase(nullptr) {}
650 
651 public:
652  const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
653 
654  SwitchCase *getNextSwitchCase() { return NextSwitchCase; }
655 
656  void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
657 
658  SourceLocation getKeywordLoc() const { return KeywordLoc; }
659  void setKeywordLoc(SourceLocation L) { KeywordLoc = L; }
660  SourceLocation getColonLoc() const { return ColonLoc; }
662 
663  Stmt *getSubStmt();
664  const Stmt *getSubStmt() const {
665  return const_cast<SwitchCase*>(this)->getSubStmt();
666  }
667 
668  SourceLocation getLocStart() const LLVM_READONLY { return KeywordLoc; }
669  SourceLocation getLocEnd() const LLVM_READONLY;
670 
671  static bool classof(const Stmt *T) {
672  return T->getStmtClass() == CaseStmtClass ||
673  T->getStmtClass() == DefaultStmtClass;
674  }
675 };
676 
677 class CaseStmt : public SwitchCase {
678  SourceLocation EllipsisLoc;
679  enum { LHS, RHS, SUBSTMT, END_EXPR };
680  Stmt* SubExprs[END_EXPR]; // The expression for the RHS is Non-null for
681  // GNU "case 1 ... 4" extension
682 public:
683  CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
684  SourceLocation ellipsisLoc, SourceLocation colonLoc)
685  : SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
686  SubExprs[SUBSTMT] = nullptr;
687  SubExprs[LHS] = reinterpret_cast<Stmt*>(lhs);
688  SubExprs[RHS] = reinterpret_cast<Stmt*>(rhs);
689  EllipsisLoc = ellipsisLoc;
690  }
691 
692  /// \brief Build an empty switch case statement.
693  explicit CaseStmt(EmptyShell Empty) : SwitchCase(CaseStmtClass, Empty) { }
694 
695  SourceLocation getCaseLoc() const { return KeywordLoc; }
696  void setCaseLoc(SourceLocation L) { KeywordLoc = L; }
697  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
698  void setEllipsisLoc(SourceLocation L) { EllipsisLoc = L; }
699  SourceLocation getColonLoc() const { return ColonLoc; }
701 
702  Expr *getLHS() { return reinterpret_cast<Expr*>(SubExprs[LHS]); }
703  Expr *getRHS() { return reinterpret_cast<Expr*>(SubExprs[RHS]); }
704  Stmt *getSubStmt() { return SubExprs[SUBSTMT]; }
705 
706  const Expr *getLHS() const {
707  return reinterpret_cast<const Expr*>(SubExprs[LHS]);
708  }
709  const Expr *getRHS() const {
710  return reinterpret_cast<const Expr*>(SubExprs[RHS]);
711  }
712  const Stmt *getSubStmt() const { return SubExprs[SUBSTMT]; }
713 
714  void setSubStmt(Stmt *S) { SubExprs[SUBSTMT] = S; }
715  void setLHS(Expr *Val) { SubExprs[LHS] = reinterpret_cast<Stmt*>(Val); }
716  void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
717 
718  SourceLocation getLocStart() const LLVM_READONLY { return KeywordLoc; }
719  SourceLocation getLocEnd() const LLVM_READONLY {
720  // Handle deeply nested case statements with iteration instead of recursion.
721  const CaseStmt *CS = this;
722  while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
723  CS = CS2;
724 
725  return CS->getSubStmt()->getLocEnd();
726  }
727 
728  static bool classof(const Stmt *T) {
729  return T->getStmtClass() == CaseStmtClass;
730  }
731 
732  // Iterators
733  child_range children() {
734  return child_range(&SubExprs[0], &SubExprs[END_EXPR]);
735  }
736 };
737 
738 class DefaultStmt : public SwitchCase {
739  Stmt* SubStmt;
740 public:
742  SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
743 
744  /// \brief Build an empty default statement.
745  explicit DefaultStmt(EmptyShell Empty)
746  : SwitchCase(DefaultStmtClass, Empty) { }
747 
748  Stmt *getSubStmt() { return SubStmt; }
749  const Stmt *getSubStmt() const { return SubStmt; }
750  void setSubStmt(Stmt *S) { SubStmt = S; }
751 
752  SourceLocation getDefaultLoc() const { return KeywordLoc; }
753  void setDefaultLoc(SourceLocation L) { KeywordLoc = L; }
754  SourceLocation getColonLoc() const { return ColonLoc; }
756 
757  SourceLocation getLocStart() const LLVM_READONLY { return KeywordLoc; }
758  SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
759 
760  static bool classof(const Stmt *T) {
761  return T->getStmtClass() == DefaultStmtClass;
762  }
763 
764  // Iterators
765  child_range children() { return child_range(&SubStmt, &SubStmt+1); }
766 };
767 
769  if (const CaseStmt *CS = dyn_cast<CaseStmt>(this))
770  return CS->getLocEnd();
771  return cast<DefaultStmt>(this)->getLocEnd();
772 }
773 
774 /// LabelStmt - Represents a label, which has a substatement. For example:
775 /// foo: return;
776 ///
777 class LabelStmt : public Stmt {
778  SourceLocation IdentLoc;
779  LabelDecl *TheDecl;
780  Stmt *SubStmt;
781 
782 public:
784  : Stmt(LabelStmtClass), IdentLoc(IL), TheDecl(D), SubStmt(substmt) {
785  static_assert(sizeof(LabelStmt) ==
786  2 * sizeof(SourceLocation) + 2 * sizeof(void *),
787  "LabelStmt too big");
788  }
789 
790  // \brief Build an empty label statement.
791  explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) { }
792 
793  SourceLocation getIdentLoc() const { return IdentLoc; }
794  LabelDecl *getDecl() const { return TheDecl; }
795  void setDecl(LabelDecl *D) { TheDecl = D; }
796  const char *getName() const;
797  Stmt *getSubStmt() { return SubStmt; }
798  const Stmt *getSubStmt() const { return SubStmt; }
799  void setIdentLoc(SourceLocation L) { IdentLoc = L; }
800  void setSubStmt(Stmt *SS) { SubStmt = SS; }
801 
802  SourceLocation getLocStart() const LLVM_READONLY { return IdentLoc; }
803  SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
804 
805  child_range children() { return child_range(&SubStmt, &SubStmt+1); }
806 
807  static bool classof(const Stmt *T) {
808  return T->getStmtClass() == LabelStmtClass;
809  }
810 };
811 
812 
813 /// \brief Represents an attribute applied to a statement.
814 ///
815 /// Represents an attribute applied to a statement. For example:
816 /// [[omp::for(...)]] for (...) { ... }
817 ///
818 class AttributedStmt : public Stmt {
819  Stmt *SubStmt;
820  SourceLocation AttrLoc;
821  unsigned NumAttrs;
822 
823  friend class ASTStmtReader;
824 
826  : Stmt(AttributedStmtClass), SubStmt(SubStmt), AttrLoc(Loc),
827  NumAttrs(Attrs.size()) {
828  std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
829  }
830 
831  explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)
832  : Stmt(AttributedStmtClass, Empty), NumAttrs(NumAttrs) {
833  std::fill_n(getAttrArrayPtr(), NumAttrs, nullptr);
834  }
835 
836  const Attr *const *getAttrArrayPtr() const {
837  return reinterpret_cast<const Attr *const *>(this + 1);
838  }
839  const Attr **getAttrArrayPtr() {
840  return reinterpret_cast<const Attr **>(this + 1);
841  }
842 
843 public:
844  static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,
845  ArrayRef<const Attr*> Attrs, Stmt *SubStmt);
846  // \brief Build an empty attributed statement.
847  static AttributedStmt *CreateEmpty(const ASTContext &C, unsigned NumAttrs);
848 
849  SourceLocation getAttrLoc() const { return AttrLoc; }
851  return llvm::makeArrayRef(getAttrArrayPtr(), NumAttrs);
852  }
853  Stmt *getSubStmt() { return SubStmt; }
854  const Stmt *getSubStmt() const { return SubStmt; }
855 
856  SourceLocation getLocStart() const LLVM_READONLY { return AttrLoc; }
857  SourceLocation getLocEnd() const LLVM_READONLY { return SubStmt->getLocEnd();}
858 
859  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
860 
861  static bool classof(const Stmt *T) {
862  return T->getStmtClass() == AttributedStmtClass;
863  }
864 };
865 
866 
867 /// IfStmt - This represents an if/then/else.
868 ///
869 class IfStmt : public Stmt {
870  enum { VAR, COND, THEN, ELSE, END_EXPR };
871  Stmt* SubExprs[END_EXPR];
872 
873  SourceLocation IfLoc;
874  SourceLocation ElseLoc;
875 
876 public:
877  IfStmt(const ASTContext &C, SourceLocation IL, VarDecl *var, Expr *cond,
878  Stmt *then, SourceLocation EL = SourceLocation(),
879  Stmt *elsev = nullptr);
880 
881  /// \brief Build an empty if/then/else statement
882  explicit IfStmt(EmptyShell Empty) : Stmt(IfStmtClass, Empty) { }
883 
884  /// \brief Retrieve the variable declared in this "if" statement, if any.
885  ///
886  /// In the following example, "x" is the condition variable.
887  /// \code
888  /// if (int x = foo()) {
889  /// printf("x is %d", x);
890  /// }
891  /// \endcode
892  VarDecl *getConditionVariable() const;
893  void setConditionVariable(const ASTContext &C, VarDecl *V);
894 
895  /// If this IfStmt has a condition variable, return the faux DeclStmt
896  /// associated with the creation of that condition variable.
898  return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
899  }
900 
901  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
902  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
903  const Stmt *getThen() const { return SubExprs[THEN]; }
904  void setThen(Stmt *S) { SubExprs[THEN] = S; }
905  const Stmt *getElse() const { return SubExprs[ELSE]; }
906  void setElse(Stmt *S) { SubExprs[ELSE] = S; }
907 
908  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
909  Stmt *getThen() { return SubExprs[THEN]; }
910  Stmt *getElse() { return SubExprs[ELSE]; }
911 
912  SourceLocation getIfLoc() const { return IfLoc; }
913  void setIfLoc(SourceLocation L) { IfLoc = L; }
914  SourceLocation getElseLoc() const { return ElseLoc; }
915  void setElseLoc(SourceLocation L) { ElseLoc = L; }
916 
917  SourceLocation getLocStart() const LLVM_READONLY { return IfLoc; }
918  SourceLocation getLocEnd() const LLVM_READONLY {
919  if (SubExprs[ELSE])
920  return SubExprs[ELSE]->getLocEnd();
921  else
922  return SubExprs[THEN]->getLocEnd();
923  }
924 
925  // Iterators over subexpressions. The iterators will include iterating
926  // over the initialization expression referenced by the condition variable.
927  child_range children() {
928  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
929  }
930 
931  static bool classof(const Stmt *T) {
932  return T->getStmtClass() == IfStmtClass;
933  }
934 };
935 
936 /// SwitchStmt - This represents a 'switch' stmt.
937 ///
938 class SwitchStmt : public Stmt {
939  SourceLocation SwitchLoc;
940  enum { VAR, COND, BODY, END_EXPR };
941  Stmt* SubExprs[END_EXPR];
942  // This points to a linked list of case and default statements and, if the
943  // SwitchStmt is a switch on an enum value, records whether all the enum
944  // values were covered by CaseStmts. The coverage information value is meant
945  // to be a hint for possible clients.
946  llvm::PointerIntPair<SwitchCase *, 1, bool> FirstCase;
947 
948 public:
949  SwitchStmt(const ASTContext &C, VarDecl *Var, Expr *cond);
950 
951  /// \brief Build a empty switch statement.
952  explicit SwitchStmt(EmptyShell Empty) : Stmt(SwitchStmtClass, Empty) { }
953 
954  /// \brief Retrieve the variable declared in this "switch" statement, if any.
955  ///
956  /// In the following example, "x" is the condition variable.
957  /// \code
958  /// switch (int x = foo()) {
959  /// case 0: break;
960  /// // ...
961  /// }
962  /// \endcode
963  VarDecl *getConditionVariable() const;
964  void setConditionVariable(const ASTContext &C, VarDecl *V);
965 
966  /// If this SwitchStmt has a condition variable, return the faux DeclStmt
967  /// associated with the creation of that condition variable.
969  return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
970  }
971 
972  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
973  const Stmt *getBody() const { return SubExprs[BODY]; }
974  const SwitchCase *getSwitchCaseList() const { return FirstCase.getPointer(); }
975 
976  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]);}
977  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt *>(E); }
978  Stmt *getBody() { return SubExprs[BODY]; }
979  void setBody(Stmt *S) { SubExprs[BODY] = S; }
980  SwitchCase *getSwitchCaseList() { return FirstCase.getPointer(); }
981 
982  /// \brief Set the case list for this switch statement.
983  void setSwitchCaseList(SwitchCase *SC) { FirstCase.setPointer(SC); }
984 
985  SourceLocation getSwitchLoc() const { return SwitchLoc; }
986  void setSwitchLoc(SourceLocation L) { SwitchLoc = L; }
987 
989  SubExprs[BODY] = S;
990  SwitchLoc = SL;
991  }
993  assert(!SC->getNextSwitchCase()
994  && "case/default already added to a switch");
995  SC->setNextSwitchCase(FirstCase.getPointer());
996  FirstCase.setPointer(SC);
997  }
998 
999  /// Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a
1000  /// switch over an enum value then all cases have been explicitly covered.
1001  void setAllEnumCasesCovered() { FirstCase.setInt(true); }
1002 
1003  /// Returns true if the SwitchStmt is a switch of an enum value and all cases
1004  /// have been explicitly covered.
1005  bool isAllEnumCasesCovered() const { return FirstCase.getInt(); }
1006 
1007  SourceLocation getLocStart() const LLVM_READONLY { return SwitchLoc; }
1008  SourceLocation getLocEnd() const LLVM_READONLY {
1009  return SubExprs[BODY] ? SubExprs[BODY]->getLocEnd() : SubExprs[COND]->getLocEnd();
1010  }
1011 
1012  // Iterators
1013  child_range children() {
1014  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1015  }
1016 
1017  static bool classof(const Stmt *T) {
1018  return T->getStmtClass() == SwitchStmtClass;
1019  }
1020 };
1021 
1022 
1023 /// WhileStmt - This represents a 'while' stmt.
1024 ///
1025 class WhileStmt : public Stmt {
1026  SourceLocation WhileLoc;
1027  enum { VAR, COND, BODY, END_EXPR };
1028  Stmt* SubExprs[END_EXPR];
1029 public:
1030  WhileStmt(const ASTContext &C, VarDecl *Var, Expr *cond, Stmt *body,
1031  SourceLocation WL);
1032 
1033  /// \brief Build an empty while statement.
1034  explicit WhileStmt(EmptyShell Empty) : Stmt(WhileStmtClass, Empty) { }
1035 
1036  /// \brief Retrieve the variable declared in this "while" statement, if any.
1037  ///
1038  /// In the following example, "x" is the condition variable.
1039  /// \code
1040  /// while (int x = random()) {
1041  /// // ...
1042  /// }
1043  /// \endcode
1044  VarDecl *getConditionVariable() const;
1045  void setConditionVariable(const ASTContext &C, VarDecl *V);
1046 
1047  /// If this WhileStmt has a condition variable, return the faux DeclStmt
1048  /// associated with the creation of that condition variable.
1050  return reinterpret_cast<DeclStmt*>(SubExprs[VAR]);
1051  }
1052 
1053  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
1054  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
1055  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1056  Stmt *getBody() { return SubExprs[BODY]; }
1057  const Stmt *getBody() const { return SubExprs[BODY]; }
1058  void setBody(Stmt *S) { SubExprs[BODY] = S; }
1059 
1060  SourceLocation getWhileLoc() const { return WhileLoc; }
1061  void setWhileLoc(SourceLocation L) { WhileLoc = L; }
1062 
1063  SourceLocation getLocStart() const LLVM_READONLY { return WhileLoc; }
1064  SourceLocation getLocEnd() const LLVM_READONLY {
1065  return SubExprs[BODY]->getLocEnd();
1066  }
1067 
1068  static bool classof(const Stmt *T) {
1069  return T->getStmtClass() == WhileStmtClass;
1070  }
1071 
1072  // Iterators
1073  child_range children() {
1074  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1075  }
1076 };
1077 
1078 /// DoStmt - This represents a 'do/while' stmt.
1079 ///
1080 class DoStmt : public Stmt {
1081  SourceLocation DoLoc;
1082  enum { BODY, COND, END_EXPR };
1083  Stmt* SubExprs[END_EXPR];
1084  SourceLocation WhileLoc;
1085  SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
1086 
1087 public:
1089  SourceLocation RP)
1090  : Stmt(DoStmtClass), DoLoc(DL), WhileLoc(WL), RParenLoc(RP) {
1091  SubExprs[COND] = reinterpret_cast<Stmt*>(cond);
1092  SubExprs[BODY] = body;
1093  }
1094 
1095  /// \brief Build an empty do-while statement.
1096  explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) { }
1097 
1098  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
1099  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
1100  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1101  Stmt *getBody() { return SubExprs[BODY]; }
1102  const Stmt *getBody() const { return SubExprs[BODY]; }
1103  void setBody(Stmt *S) { SubExprs[BODY] = S; }
1104 
1105  SourceLocation getDoLoc() const { return DoLoc; }
1106  void setDoLoc(SourceLocation L) { DoLoc = L; }
1107  SourceLocation getWhileLoc() const { return WhileLoc; }
1108  void setWhileLoc(SourceLocation L) { WhileLoc = L; }
1109 
1110  SourceLocation getRParenLoc() const { return RParenLoc; }
1111  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1112 
1113  SourceLocation getLocStart() const LLVM_READONLY { return DoLoc; }
1114  SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
1115 
1116  static bool classof(const Stmt *T) {
1117  return T->getStmtClass() == DoStmtClass;
1118  }
1119 
1120  // Iterators
1121  child_range children() {
1122  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1123  }
1124 };
1125 
1126 
1127 /// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of
1128 /// the init/cond/inc parts of the ForStmt will be null if they were not
1129 /// specified in the source.
1130 ///
1131 class ForStmt : public Stmt {
1132  SourceLocation ForLoc;
1133  enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
1134  Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
1135  SourceLocation LParenLoc, RParenLoc;
1136 
1137 public:
1138  ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
1139  Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
1140  SourceLocation RP);
1141 
1142  /// \brief Build an empty for statement.
1143  explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) { }
1144 
1145  Stmt *getInit() { return SubExprs[INIT]; }
1146 
1147  /// \brief Retrieve the variable declared in this "for" statement, if any.
1148  ///
1149  /// In the following example, "y" is the condition variable.
1150  /// \code
1151  /// for (int x = random(); int y = mangle(x); ++x) {
1152  /// // ...
1153  /// }
1154  /// \endcode
1155  VarDecl *getConditionVariable() const;
1156  void setConditionVariable(const ASTContext &C, VarDecl *V);
1157 
1158  /// If this ForStmt has a condition variable, return the faux DeclStmt
1159  /// associated with the creation of that condition variable.
1161  return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
1162  }
1163 
1164  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
1165  Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
1166  Stmt *getBody() { return SubExprs[BODY]; }
1167 
1168  const Stmt *getInit() const { return SubExprs[INIT]; }
1169  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
1170  const Expr *getInc() const { return reinterpret_cast<Expr*>(SubExprs[INC]); }
1171  const Stmt *getBody() const { return SubExprs[BODY]; }
1172 
1173  void setInit(Stmt *S) { SubExprs[INIT] = S; }
1174  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
1175  void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
1176  void setBody(Stmt *S) { SubExprs[BODY] = S; }
1177 
1178  SourceLocation getForLoc() const { return ForLoc; }
1179  void setForLoc(SourceLocation L) { ForLoc = L; }
1180  SourceLocation getLParenLoc() const { return LParenLoc; }
1181  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
1182  SourceLocation getRParenLoc() const { return RParenLoc; }
1183  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1184 
1185  SourceLocation getLocStart() const LLVM_READONLY { return ForLoc; }
1186  SourceLocation getLocEnd() const LLVM_READONLY {
1187  return SubExprs[BODY]->getLocEnd();
1188  }
1189 
1190  static bool classof(const Stmt *T) {
1191  return T->getStmtClass() == ForStmtClass;
1192  }
1193 
1194  // Iterators
1195  child_range children() {
1196  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
1197  }
1198 };
1199 
1200 /// GotoStmt - This represents a direct goto.
1201 ///
1202 class GotoStmt : public Stmt {
1203  LabelDecl *Label;
1204  SourceLocation GotoLoc;
1205  SourceLocation LabelLoc;
1206 public:
1208  : Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {}
1209 
1210  /// \brief Build an empty goto statement.
1211  explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) { }
1212 
1213  LabelDecl *getLabel() const { return Label; }
1214  void setLabel(LabelDecl *D) { Label = D; }
1215 
1216  SourceLocation getGotoLoc() const { return GotoLoc; }
1217  void setGotoLoc(SourceLocation L) { GotoLoc = L; }
1218  SourceLocation getLabelLoc() const { return LabelLoc; }
1219  void setLabelLoc(SourceLocation L) { LabelLoc = L; }
1220 
1221  SourceLocation getLocStart() const LLVM_READONLY { return GotoLoc; }
1222  SourceLocation getLocEnd() const LLVM_READONLY { return LabelLoc; }
1223 
1224  static bool classof(const Stmt *T) {
1225  return T->getStmtClass() == GotoStmtClass;
1226  }
1227 
1228  // Iterators
1229  child_range children() {
1230  return child_range(child_iterator(), child_iterator());
1231  }
1232 };
1233 
1234 /// IndirectGotoStmt - This represents an indirect goto.
1235 ///
1236 class IndirectGotoStmt : public Stmt {
1237  SourceLocation GotoLoc;
1238  SourceLocation StarLoc;
1239  Stmt *Target;
1240 public:
1242  Expr *target)
1243  : Stmt(IndirectGotoStmtClass), GotoLoc(gotoLoc), StarLoc(starLoc),
1244  Target((Stmt*)target) {}
1245 
1246  /// \brief Build an empty indirect goto statement.
1247  explicit IndirectGotoStmt(EmptyShell Empty)
1248  : Stmt(IndirectGotoStmtClass, Empty) { }
1249 
1250  void setGotoLoc(SourceLocation L) { GotoLoc = L; }
1251  SourceLocation getGotoLoc() const { return GotoLoc; }
1252  void setStarLoc(SourceLocation L) { StarLoc = L; }
1253  SourceLocation getStarLoc() const { return StarLoc; }
1254 
1255  Expr *getTarget() { return reinterpret_cast<Expr*>(Target); }
1256  const Expr *getTarget() const {return reinterpret_cast<const Expr*>(Target);}
1257  void setTarget(Expr *E) { Target = reinterpret_cast<Stmt*>(E); }
1258 
1259  /// getConstantTarget - Returns the fixed target of this indirect
1260  /// goto, if one exists.
1261  LabelDecl *getConstantTarget();
1262  const LabelDecl *getConstantTarget() const {
1263  return const_cast<IndirectGotoStmt*>(this)->getConstantTarget();
1264  }
1265 
1266  SourceLocation getLocStart() const LLVM_READONLY { return GotoLoc; }
1267  SourceLocation getLocEnd() const LLVM_READONLY { return Target->getLocEnd(); }
1268 
1269  static bool classof(const Stmt *T) {
1270  return T->getStmtClass() == IndirectGotoStmtClass;
1271  }
1272 
1273  // Iterators
1274  child_range children() { return child_range(&Target, &Target+1); }
1275 };
1276 
1277 
1278 /// ContinueStmt - This represents a continue.
1279 ///
1280 class ContinueStmt : public Stmt {
1281  SourceLocation ContinueLoc;
1282 public:
1283  ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass), ContinueLoc(CL) {}
1284 
1285  /// \brief Build an empty continue statement.
1286  explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) { }
1287 
1288  SourceLocation getContinueLoc() const { return ContinueLoc; }
1289  void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
1290 
1291  SourceLocation getLocStart() const LLVM_READONLY { return ContinueLoc; }
1292  SourceLocation getLocEnd() const LLVM_READONLY { return ContinueLoc; }
1293 
1294  static bool classof(const Stmt *T) {
1295  return T->getStmtClass() == ContinueStmtClass;
1296  }
1297 
1298  // Iterators
1299  child_range children() {
1300  return child_range(child_iterator(), child_iterator());
1301  }
1302 };
1303 
1304 /// BreakStmt - This represents a break.
1305 ///
1306 class BreakStmt : public Stmt {
1307  SourceLocation BreakLoc;
1308 
1309 public:
1310  BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass), BreakLoc(BL) {
1311  static_assert(sizeof(BreakStmt) == 2 * sizeof(SourceLocation),
1312  "BreakStmt too large");
1313  }
1314 
1315  /// \brief Build an empty break statement.
1316  explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) { }
1317 
1318  SourceLocation getBreakLoc() const { return BreakLoc; }
1319  void setBreakLoc(SourceLocation L) { BreakLoc = L; }
1320 
1321  SourceLocation getLocStart() const LLVM_READONLY { return BreakLoc; }
1322  SourceLocation getLocEnd() const LLVM_READONLY { return BreakLoc; }
1323 
1324  static bool classof(const Stmt *T) {
1325  return T->getStmtClass() == BreakStmtClass;
1326  }
1327 
1328  // Iterators
1329  child_range children() {
1330  return child_range(child_iterator(), child_iterator());
1331  }
1332 };
1333 
1334 
1335 /// ReturnStmt - This represents a return, optionally of an expression:
1336 /// return;
1337 /// return 4;
1338 ///
1339 /// Note that GCC allows return with no argument in a function declared to
1340 /// return a value, and it allows returning a value in functions declared to
1341 /// return void. We explicitly model this in the AST, which means you can't
1342 /// depend on the return type of the function and the presence of an argument.
1343 ///
1344 class ReturnStmt : public Stmt {
1345  SourceLocation RetLoc;
1346  Stmt *RetExpr;
1347  const VarDecl *NRVOCandidate;
1348 
1349 public:
1350  explicit ReturnStmt(SourceLocation RL) : ReturnStmt(RL, nullptr, nullptr) {}
1351 
1352  ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
1353  : Stmt(ReturnStmtClass), RetLoc(RL), RetExpr((Stmt *)E),
1354  NRVOCandidate(NRVOCandidate) {}
1355 
1356  /// \brief Build an empty return expression.
1357  explicit ReturnStmt(EmptyShell Empty) : Stmt(ReturnStmtClass, Empty) { }
1358 
1359  const Expr *getRetValue() const;
1360  Expr *getRetValue();
1361  void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt*>(E); }
1362 
1363  SourceLocation getReturnLoc() const { return RetLoc; }
1364  void setReturnLoc(SourceLocation L) { RetLoc = L; }
1365 
1366  /// \brief Retrieve the variable that might be used for the named return
1367  /// value optimization.
1368  ///
1369  /// The optimization itself can only be performed if the variable is
1370  /// also marked as an NRVO object.
1371  const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
1372  void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
1373 
1374  SourceLocation getLocStart() const LLVM_READONLY { return RetLoc; }
1375  SourceLocation getLocEnd() const LLVM_READONLY {
1376  return RetExpr ? RetExpr->getLocEnd() : RetLoc;
1377  }
1378 
1379  static bool classof(const Stmt *T) {
1380  return T->getStmtClass() == ReturnStmtClass;
1381  }
1382 
1383  // Iterators
1384  child_range children() {
1385  if (RetExpr) return child_range(&RetExpr, &RetExpr+1);
1386  return child_range(child_iterator(), child_iterator());
1387  }
1388 };
1389 
1390 /// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
1391 ///
1392 class AsmStmt : public Stmt {
1393 protected:
1395  /// \brief True if the assembly statement does not have any input or output
1396  /// operands.
1397  bool IsSimple;
1398 
1399  /// \brief If true, treat this inline assembly as having side effects.
1400  /// This assembly statement should not be optimized, deleted or moved.
1402 
1403  unsigned NumOutputs;
1404  unsigned NumInputs;
1405  unsigned NumClobbers;
1406 
1408 
1409  AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile,
1410  unsigned numoutputs, unsigned numinputs, unsigned numclobbers) :
1411  Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
1412  NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) { }
1413 
1414  friend class ASTStmtReader;
1415 
1416 public:
1417  /// \brief Build an empty inline-assembly statement.
1418  explicit AsmStmt(StmtClass SC, EmptyShell Empty) :
1419  Stmt(SC, Empty), Exprs(nullptr) { }
1420 
1421  SourceLocation getAsmLoc() const { return AsmLoc; }
1422  void setAsmLoc(SourceLocation L) { AsmLoc = L; }
1423 
1424  bool isSimple() const { return IsSimple; }
1425  void setSimple(bool V) { IsSimple = V; }
1426 
1427  bool isVolatile() const { return IsVolatile; }
1428  void setVolatile(bool V) { IsVolatile = V; }
1429 
1430  SourceLocation getLocStart() const LLVM_READONLY { return SourceLocation(); }
1431  SourceLocation getLocEnd() const LLVM_READONLY { return SourceLocation(); }
1432 
1433  //===--- Asm String Analysis ---===//
1434 
1435  /// Assemble final IR asm string.
1436  std::string generateAsmString(const ASTContext &C) const;
1437 
1438  //===--- Output operands ---===//
1439 
1440  unsigned getNumOutputs() const { return NumOutputs; }
1441 
1442  /// getOutputConstraint - Return the constraint string for the specified
1443  /// output operand. All output constraints are known to be non-empty (either
1444  /// '=' or '+').
1445  StringRef getOutputConstraint(unsigned i) const;
1446 
1447  /// isOutputPlusConstraint - Return true if the specified output constraint
1448  /// is a "+" constraint (which is both an input and an output) or false if it
1449  /// is an "=" constraint (just an output).
1450  bool isOutputPlusConstraint(unsigned i) const {
1451  return getOutputConstraint(i)[0] == '+';
1452  }
1453 
1454  const Expr *getOutputExpr(unsigned i) const;
1455 
1456  /// getNumPlusOperands - Return the number of output operands that have a "+"
1457  /// constraint.
1458  unsigned getNumPlusOperands() const;
1459 
1460  //===--- Input operands ---===//
1461 
1462  unsigned getNumInputs() const { return NumInputs; }
1463 
1464  /// getInputConstraint - Return the specified input constraint. Unlike output
1465  /// constraints, these can be empty.
1466  StringRef getInputConstraint(unsigned i) const;
1467 
1468  const Expr *getInputExpr(unsigned i) const;
1469 
1470  //===--- Other ---===//
1471 
1472  unsigned getNumClobbers() const { return NumClobbers; }
1473  StringRef getClobber(unsigned i) const;
1474 
1475  static bool classof(const Stmt *T) {
1476  return T->getStmtClass() == GCCAsmStmtClass ||
1477  T->getStmtClass() == MSAsmStmtClass;
1478  }
1479 
1480  // Input expr iterators.
1481 
1482  typedef ExprIterator inputs_iterator;
1483  typedef ConstExprIterator const_inputs_iterator;
1484  typedef llvm::iterator_range<inputs_iterator> inputs_range;
1485  typedef llvm::iterator_range<const_inputs_iterator> inputs_const_range;
1486 
1488  return &Exprs[0] + NumOutputs;
1489  }
1490 
1492  return &Exprs[0] + NumOutputs + NumInputs;
1493  }
1494 
1495  inputs_range inputs() { return inputs_range(begin_inputs(), end_inputs()); }
1496 
1498  return &Exprs[0] + NumOutputs;
1499  }
1500 
1502  return &Exprs[0] + NumOutputs + NumInputs;
1503  }
1504 
1506  return inputs_const_range(begin_inputs(), end_inputs());
1507  }
1508 
1509  // Output expr iterators.
1510 
1511  typedef ExprIterator outputs_iterator;
1512  typedef ConstExprIterator const_outputs_iterator;
1513  typedef llvm::iterator_range<outputs_iterator> outputs_range;
1514  typedef llvm::iterator_range<const_outputs_iterator> outputs_const_range;
1515 
1517  return &Exprs[0];
1518  }
1520  return &Exprs[0] + NumOutputs;
1521  }
1523  return outputs_range(begin_outputs(), end_outputs());
1524  }
1525 
1527  return &Exprs[0];
1528  }
1530  return &Exprs[0] + NumOutputs;
1531  }
1533  return outputs_const_range(begin_outputs(), end_outputs());
1534  }
1535 
1536  child_range children() {
1537  return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
1538  }
1539 };
1540 
1541 /// This represents a GCC inline-assembly statement extension.
1542 ///
1543 class GCCAsmStmt : public AsmStmt {
1544  SourceLocation RParenLoc;
1545  StringLiteral *AsmStr;
1546 
1547  // FIXME: If we wanted to, we could allocate all of these in one big array.
1548  StringLiteral **Constraints;
1549  StringLiteral **Clobbers;
1550  IdentifierInfo **Names;
1551 
1552  friend class ASTStmtReader;
1553 
1554 public:
1555  GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple,
1556  bool isvolatile, unsigned numoutputs, unsigned numinputs,
1557  IdentifierInfo **names, StringLiteral **constraints, Expr **exprs,
1558  StringLiteral *asmstr, unsigned numclobbers,
1559  StringLiteral **clobbers, SourceLocation rparenloc);
1560 
1561  /// \brief Build an empty inline-assembly statement.
1562  explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty),
1563  Constraints(nullptr), Clobbers(nullptr), Names(nullptr) { }
1564 
1565  SourceLocation getRParenLoc() const { return RParenLoc; }
1566  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
1567 
1568  //===--- Asm String Analysis ---===//
1569 
1570  const StringLiteral *getAsmString() const { return AsmStr; }
1571  StringLiteral *getAsmString() { return AsmStr; }
1572  void setAsmString(StringLiteral *E) { AsmStr = E; }
1573 
1574  /// AsmStringPiece - this is part of a decomposed asm string specification
1575  /// (for use with the AnalyzeAsmString function below). An asm string is
1576  /// considered to be a concatenation of these parts.
1578  public:
1579  enum Kind {
1580  String, // String in .ll asm string form, "$" -> "$$" and "%%" -> "%".
1581  Operand // Operand reference, with optional modifier %c4.
1582  };
1583  private:
1584  Kind MyKind;
1585  std::string Str;
1586  unsigned OperandNo;
1587 
1588  // Source range for operand references.
1589  CharSourceRange Range;
1590  public:
1591  AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {}
1592  AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin,
1594  : MyKind(Operand), Str(S), OperandNo(OpNo),
1595  Range(CharSourceRange::getCharRange(Begin, End)) {
1596  }
1597 
1598  bool isString() const { return MyKind == String; }
1599  bool isOperand() const { return MyKind == Operand; }
1600 
1601  const std::string &getString() const {
1602  return Str;
1603  }
1604 
1605  unsigned getOperandNo() const {
1606  assert(isOperand());
1607  return OperandNo;
1608  }
1609 
1611  assert(isOperand() && "Range is currently used only for Operands.");
1612  return Range;
1613  }
1614 
1615  /// getModifier - Get the modifier for this operand, if present. This
1616  /// returns '\0' if there was no modifier.
1617  char getModifier() const;
1618  };
1619 
1620  /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
1621  /// it into pieces. If the asm string is erroneous, emit errors and return
1622  /// true, otherwise return false. This handles canonicalization and
1623  /// translation of strings from GCC syntax to LLVM IR syntax, and handles
1624  //// flattening of named references like %[foo] to Operand AsmStringPiece's.
1625  unsigned AnalyzeAsmString(SmallVectorImpl<AsmStringPiece> &Pieces,
1626  const ASTContext &C, unsigned &DiagOffs) const;
1627 
1628  /// Assemble final IR asm string.
1629  std::string generateAsmString(const ASTContext &C) const;
1630 
1631  //===--- Output operands ---===//
1632 
1634  return Names[i];
1635  }
1636 
1637  StringRef getOutputName(unsigned i) const {
1638  if (IdentifierInfo *II = getOutputIdentifier(i))
1639  return II->getName();
1640 
1641  return StringRef();
1642  }
1643 
1644  StringRef getOutputConstraint(unsigned i) const;
1645 
1646  const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
1647  return Constraints[i];
1648  }
1650  return Constraints[i];
1651  }
1652 
1653  Expr *getOutputExpr(unsigned i);
1654 
1655  const Expr *getOutputExpr(unsigned i) const {
1656  return const_cast<GCCAsmStmt*>(this)->getOutputExpr(i);
1657  }
1658 
1659  //===--- Input operands ---===//
1660 
1661  IdentifierInfo *getInputIdentifier(unsigned i) const {
1662  return Names[i + NumOutputs];
1663  }
1664 
1665  StringRef getInputName(unsigned i) const {
1666  if (IdentifierInfo *II = getInputIdentifier(i))
1667  return II->getName();
1668 
1669  return StringRef();
1670  }
1671 
1672  StringRef getInputConstraint(unsigned i) const;
1673 
1674  const StringLiteral *getInputConstraintLiteral(unsigned i) const {
1675  return Constraints[i + NumOutputs];
1676  }
1678  return Constraints[i + NumOutputs];
1679  }
1680 
1681  Expr *getInputExpr(unsigned i);
1682  void setInputExpr(unsigned i, Expr *E);
1683 
1684  const Expr *getInputExpr(unsigned i) const {
1685  return const_cast<GCCAsmStmt*>(this)->getInputExpr(i);
1686  }
1687 
1688 private:
1689  void setOutputsAndInputsAndClobbers(const ASTContext &C,
1690  IdentifierInfo **Names,
1691  StringLiteral **Constraints,
1692  Stmt **Exprs,
1693  unsigned NumOutputs,
1694  unsigned NumInputs,
1695  StringLiteral **Clobbers,
1696  unsigned NumClobbers);
1697 public:
1698 
1699  //===--- Other ---===//
1700 
1701  /// getNamedOperand - Given a symbolic operand reference like %[foo],
1702  /// translate this into a numeric value needed to reference the same operand.
1703  /// This returns -1 if the operand name is invalid.
1704  int getNamedOperand(StringRef SymbolicName) const;
1705 
1706  StringRef getClobber(unsigned i) const;
1707  StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; }
1708  const StringLiteral *getClobberStringLiteral(unsigned i) const {
1709  return Clobbers[i];
1710  }
1711 
1712  SourceLocation getLocStart() const LLVM_READONLY { return AsmLoc; }
1713  SourceLocation getLocEnd() const LLVM_READONLY { return RParenLoc; }
1714 
1715  static bool classof(const Stmt *T) {
1716  return T->getStmtClass() == GCCAsmStmtClass;
1717  }
1718 };
1719 
1720 /// This represents a Microsoft inline-assembly statement extension.
1721 ///
1722 class MSAsmStmt : public AsmStmt {
1723  SourceLocation LBraceLoc, EndLoc;
1724  StringRef AsmStr;
1725 
1726  unsigned NumAsmToks;
1727 
1728  Token *AsmToks;
1729  StringRef *Constraints;
1730  StringRef *Clobbers;
1731 
1732  friend class ASTStmtReader;
1733 
1734 public:
1735  MSAsmStmt(const ASTContext &C, SourceLocation asmloc,
1736  SourceLocation lbraceloc, bool issimple, bool isvolatile,
1737  ArrayRef<Token> asmtoks, unsigned numoutputs, unsigned numinputs,
1738  ArrayRef<StringRef> constraints,
1739  ArrayRef<Expr*> exprs, StringRef asmstr,
1740  ArrayRef<StringRef> clobbers, SourceLocation endloc);
1741 
1742  /// \brief Build an empty MS-style inline-assembly statement.
1743  explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty),
1744  NumAsmToks(0), AsmToks(nullptr), Constraints(nullptr), Clobbers(nullptr) { }
1745 
1746  SourceLocation getLBraceLoc() const { return LBraceLoc; }
1747  void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
1748  SourceLocation getEndLoc() const { return EndLoc; }
1749  void setEndLoc(SourceLocation L) { EndLoc = L; }
1750 
1751  bool hasBraces() const { return LBraceLoc.isValid(); }
1752 
1753  unsigned getNumAsmToks() { return NumAsmToks; }
1754  Token *getAsmToks() { return AsmToks; }
1755 
1756  //===--- Asm String Analysis ---===//
1757  StringRef getAsmString() const { return AsmStr; }
1758 
1759  /// Assemble final IR asm string.
1760  std::string generateAsmString(const ASTContext &C) const;
1761 
1762  //===--- Output operands ---===//
1763 
1764  StringRef getOutputConstraint(unsigned i) const {
1765  assert(i < NumOutputs);
1766  return Constraints[i];
1767  }
1768 
1769  Expr *getOutputExpr(unsigned i);
1770 
1771  const Expr *getOutputExpr(unsigned i) const {
1772  return const_cast<MSAsmStmt*>(this)->getOutputExpr(i);
1773  }
1774 
1775  //===--- Input operands ---===//
1776 
1777  StringRef getInputConstraint(unsigned i) const {
1778  assert(i < NumInputs);
1779  return Constraints[i + NumOutputs];
1780  }
1781 
1782  Expr *getInputExpr(unsigned i);
1783  void setInputExpr(unsigned i, Expr *E);
1784 
1785  const Expr *getInputExpr(unsigned i) const {
1786  return const_cast<MSAsmStmt*>(this)->getInputExpr(i);
1787  }
1788 
1789  //===--- Other ---===//
1790 
1792  return llvm::makeArrayRef(Constraints, NumInputs + NumOutputs);
1793  }
1795  return llvm::makeArrayRef(Clobbers, NumClobbers);
1796  }
1798  return llvm::makeArrayRef(reinterpret_cast<Expr**>(Exprs),
1799  NumInputs + NumOutputs);
1800  }
1801 
1802  StringRef getClobber(unsigned i) const { return getClobbers()[i]; }
1803 
1804 private:
1805  void initialize(const ASTContext &C, StringRef AsmString,
1806  ArrayRef<Token> AsmToks, ArrayRef<StringRef> Constraints,
1807  ArrayRef<Expr*> Exprs, ArrayRef<StringRef> Clobbers);
1808 public:
1809 
1810  SourceLocation getLocStart() const LLVM_READONLY { return AsmLoc; }
1811  SourceLocation getLocEnd() const LLVM_READONLY { return EndLoc; }
1812 
1813  static bool classof(const Stmt *T) {
1814  return T->getStmtClass() == MSAsmStmtClass;
1815  }
1816 
1817  child_range children() {
1818  return child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]);
1819  }
1820 };
1821 
1822 class SEHExceptStmt : public Stmt {
1823  SourceLocation Loc;
1824  Stmt *Children[2];
1825 
1826  enum { FILTER_EXPR, BLOCK };
1827 
1829  Expr *FilterExpr,
1830  Stmt *Block);
1831 
1832  friend class ASTReader;
1833  friend class ASTStmtReader;
1834  explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) { }
1835 
1836 public:
1837  static SEHExceptStmt* Create(const ASTContext &C,
1838  SourceLocation ExceptLoc,
1839  Expr *FilterExpr,
1840  Stmt *Block);
1841 
1842  SourceLocation getLocStart() const LLVM_READONLY { return getExceptLoc(); }
1843  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1844 
1845  SourceLocation getExceptLoc() const { return Loc; }
1846  SourceLocation getEndLoc() const { return getBlock()->getLocEnd(); }
1847 
1848  Expr *getFilterExpr() const {
1849  return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
1850  }
1851 
1853  return cast<CompoundStmt>(Children[BLOCK]);
1854  }
1855 
1856  child_range children() {
1857  return child_range(Children,Children+2);
1858  }
1859 
1860  static bool classof(const Stmt *T) {
1861  return T->getStmtClass() == SEHExceptStmtClass;
1862  }
1863 
1864 };
1865 
1866 class SEHFinallyStmt : public Stmt {
1867  SourceLocation Loc;
1868  Stmt *Block;
1869 
1871  Stmt *Block);
1872 
1873  friend class ASTReader;
1874  friend class ASTStmtReader;
1875  explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) { }
1876 
1877 public:
1878  static SEHFinallyStmt* Create(const ASTContext &C,
1879  SourceLocation FinallyLoc,
1880  Stmt *Block);
1881 
1882  SourceLocation getLocStart() const LLVM_READONLY { return getFinallyLoc(); }
1883  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1884 
1885  SourceLocation getFinallyLoc() const { return Loc; }
1886  SourceLocation getEndLoc() const { return Block->getLocEnd(); }
1887 
1888  CompoundStmt *getBlock() const { return cast<CompoundStmt>(Block); }
1889 
1890  child_range children() {
1891  return child_range(&Block,&Block+1);
1892  }
1893 
1894  static bool classof(const Stmt *T) {
1895  return T->getStmtClass() == SEHFinallyStmtClass;
1896  }
1897 
1898 };
1899 
1900 class SEHTryStmt : public Stmt {
1901  bool IsCXXTry;
1902  SourceLocation TryLoc;
1903  Stmt *Children[2];
1904 
1905  enum { TRY = 0, HANDLER = 1 };
1906 
1907  SEHTryStmt(bool isCXXTry, // true if 'try' otherwise '__try'
1908  SourceLocation TryLoc,
1909  Stmt *TryBlock,
1910  Stmt *Handler);
1911 
1912  friend class ASTReader;
1913  friend class ASTStmtReader;
1914  explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) { }
1915 
1916 public:
1917  static SEHTryStmt* Create(const ASTContext &C, bool isCXXTry,
1918  SourceLocation TryLoc, Stmt *TryBlock,
1919  Stmt *Handler);
1920 
1921  SourceLocation getLocStart() const LLVM_READONLY { return getTryLoc(); }
1922  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1923 
1924  SourceLocation getTryLoc() const { return TryLoc; }
1925  SourceLocation getEndLoc() const { return Children[HANDLER]->getLocEnd(); }
1926 
1927  bool getIsCXXTry() const { return IsCXXTry; }
1928 
1930  return cast<CompoundStmt>(Children[TRY]);
1931  }
1932 
1933  Stmt *getHandler() const { return Children[HANDLER]; }
1934 
1935  /// Returns 0 if not defined
1936  SEHExceptStmt *getExceptHandler() const;
1937  SEHFinallyStmt *getFinallyHandler() const;
1938 
1939  child_range children() {
1940  return child_range(Children,Children+2);
1941  }
1942 
1943  static bool classof(const Stmt *T) {
1944  return T->getStmtClass() == SEHTryStmtClass;
1945  }
1946 };
1947 
1948 /// Represents a __leave statement.
1949 ///
1950 class SEHLeaveStmt : public Stmt {
1951  SourceLocation LeaveLoc;
1952 public:
1954  : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
1955 
1956  /// \brief Build an empty __leave statement.
1957  explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) { }
1958 
1959  SourceLocation getLeaveLoc() const { return LeaveLoc; }
1960  void setLeaveLoc(SourceLocation L) { LeaveLoc = L; }
1961 
1962  SourceLocation getLocStart() const LLVM_READONLY { return LeaveLoc; }
1963  SourceLocation getLocEnd() const LLVM_READONLY { return LeaveLoc; }
1964 
1965  static bool classof(const Stmt *T) {
1966  return T->getStmtClass() == SEHLeaveStmtClass;
1967  }
1968 
1969  // Iterators
1970  child_range children() {
1971  return child_range(child_iterator(), child_iterator());
1972  }
1973 };
1974 
1975 /// \brief This captures a statement into a function. For example, the following
1976 /// pragma annotated compound statement can be represented as a CapturedStmt,
1977 /// and this compound statement is the body of an anonymous outlined function.
1978 /// @code
1979 /// #pragma omp parallel
1980 /// {
1981 /// compute();
1982 /// }
1983 /// @endcode
1984 class CapturedStmt : public Stmt {
1985 public:
1986  /// \brief The different capture forms: by 'this', by reference, capture for
1987  /// variable-length array type etc.
1993  };
1994 
1995  /// \brief Describes the capture of either a variable, or 'this', or
1996  /// variable-length array type.
1997  class Capture {
1998  llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
1999  SourceLocation Loc;
2000 
2001  public:
2002  /// \brief Create a new capture.
2003  ///
2004  /// \param Loc The source location associated with this capture.
2005  ///
2006  /// \param Kind The kind of capture (this, ByRef, ...).
2007  ///
2008  /// \param Var The variable being captured, or null if capturing this.
2009  ///
2011  VarDecl *Var = nullptr);
2012 
2013  /// \brief Determine the kind of capture.
2014  VariableCaptureKind getCaptureKind() const;
2015 
2016  /// \brief Retrieve the source location at which the variable or 'this' was
2017  /// first used.
2018  SourceLocation getLocation() const { return Loc; }
2019 
2020  /// \brief Determine whether this capture handles the C++ 'this' pointer.
2021  bool capturesThis() const { return getCaptureKind() == VCK_This; }
2022 
2023  /// \brief Determine whether this capture handles a variable (by reference).
2024  bool capturesVariable() const { return getCaptureKind() == VCK_ByRef; }
2025 
2026  /// \brief Determine whether this capture handles a variable by copy.
2027  bool capturesVariableByCopy() const {
2028  return getCaptureKind() == VCK_ByCopy;
2029  }
2030 
2031  /// \brief Determine whether this capture handles a variable-length array
2032  /// type.
2034  return getCaptureKind() == VCK_VLAType;
2035  }
2036 
2037  /// \brief Retrieve the declaration of the variable being captured.
2038  ///
2039  /// This operation is only valid if this capture captures a variable.
2040  VarDecl *getCapturedVar() const;
2041 
2042  friend class ASTStmtReader;
2043  };
2044 
2045 private:
2046  /// \brief The number of variable captured, including 'this'.
2047  unsigned NumCaptures;
2048 
2049  /// \brief The pointer part is the implicit the outlined function and the
2050  /// int part is the captured region kind, 'CR_Default' etc.
2051  llvm::PointerIntPair<CapturedDecl *, 1, CapturedRegionKind> CapDeclAndKind;
2052 
2053  /// \brief The record for captured variables, a RecordDecl or CXXRecordDecl.
2054  RecordDecl *TheRecordDecl;
2055 
2056  /// \brief Construct a captured statement.
2058  ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD);
2059 
2060  /// \brief Construct an empty captured statement.
2061  CapturedStmt(EmptyShell Empty, unsigned NumCaptures);
2062 
2063  Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); }
2064 
2065  Stmt *const *getStoredStmts() const {
2066  return reinterpret_cast<Stmt *const *>(this + 1);
2067  }
2068 
2069  Capture *getStoredCaptures() const;
2070 
2071  void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; }
2072 
2073 public:
2074  static CapturedStmt *Create(const ASTContext &Context, Stmt *S,
2076  ArrayRef<Capture> Captures,
2077  ArrayRef<Expr *> CaptureInits,
2078  CapturedDecl *CD, RecordDecl *RD);
2079 
2080  static CapturedStmt *CreateDeserialized(const ASTContext &Context,
2081  unsigned NumCaptures);
2082 
2083  /// \brief Retrieve the statement being captured.
2084  Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; }
2085  const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; }
2086 
2087  /// \brief Retrieve the outlined function declaration.
2088  CapturedDecl *getCapturedDecl();
2089  const CapturedDecl *getCapturedDecl() const;
2090 
2091  /// \brief Set the outlined function declaration.
2092  void setCapturedDecl(CapturedDecl *D);
2093 
2094  /// \brief Retrieve the captured region kind.
2095  CapturedRegionKind getCapturedRegionKind() const;
2096 
2097  /// \brief Set the captured region kind.
2098  void setCapturedRegionKind(CapturedRegionKind Kind);
2099 
2100  /// \brief Retrieve the record declaration for captured variables.
2101  const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; }
2102 
2103  /// \brief Set the record declaration for captured variables.
2105  assert(D && "null RecordDecl");
2106  TheRecordDecl = D;
2107  }
2108 
2109  /// \brief True if this variable has been captured.
2110  bool capturesVariable(const VarDecl *Var) const;
2111 
2112  /// \brief An iterator that walks over the captures.
2115  typedef llvm::iterator_range<capture_iterator> capture_range;
2116  typedef llvm::iterator_range<const_capture_iterator> capture_const_range;
2117 
2119  return capture_range(capture_begin(), capture_end());
2120  }
2122  return capture_const_range(capture_begin(), capture_end());
2123  }
2124 
2125  /// \brief Retrieve an iterator pointing to the first capture.
2126  capture_iterator capture_begin() { return getStoredCaptures(); }
2127  const_capture_iterator capture_begin() const { return getStoredCaptures(); }
2128 
2129  /// \brief Retrieve an iterator pointing past the end of the sequence of
2130  /// captures.
2132  return getStoredCaptures() + NumCaptures;
2133  }
2134 
2135  /// \brief Retrieve the number of captures, including 'this'.
2136  unsigned capture_size() const { return NumCaptures; }
2137 
2138  /// \brief Iterator that walks over the capture initialization arguments.
2140  typedef llvm::iterator_range<capture_init_iterator> capture_init_range;
2141 
2142  /// \brief Const iterator that walks over the capture initialization
2143  /// arguments.
2145  typedef llvm::iterator_range<const_capture_init_iterator>
2147 
2149  return capture_init_range(capture_init_begin(), capture_init_end());
2150  }
2151 
2153  return const_capture_init_range(capture_init_begin(), capture_init_end());
2154  }
2155 
2156  /// \brief Retrieve the first initialization argument.
2158  return reinterpret_cast<Expr **>(getStoredStmts());
2159  }
2160 
2162  return reinterpret_cast<Expr *const *>(getStoredStmts());
2163  }
2164 
2165  /// \brief Retrieve the iterator pointing one past the last initialization
2166  /// argument.
2168  return capture_init_begin() + NumCaptures;
2169  }
2170 
2172  return capture_init_begin() + NumCaptures;
2173  }
2174 
2175  SourceLocation getLocStart() const LLVM_READONLY {
2176  return getCapturedStmt()->getLocStart();
2177  }
2178  SourceLocation getLocEnd() const LLVM_READONLY {
2179  return getCapturedStmt()->getLocEnd();
2180  }
2181  SourceRange getSourceRange() const LLVM_READONLY {
2182  return getCapturedStmt()->getSourceRange();
2183  }
2184 
2185  static bool classof(const Stmt *T) {
2186  return T->getStmtClass() == CapturedStmtClass;
2187  }
2188 
2189  child_range children();
2190 
2191  friend class ASTStmtReader;
2192 };
2193 
2194 } // end namespace clang
2195 
2196 #endif
Expr * getInc()
Definition: Stmt.h:1165
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1464
void setThen(Stmt *S)
Definition: Stmt.h:904
GotoStmt(EmptyShell Empty)
Build an empty goto statement.
Definition: Stmt.h:1211
DoStmt(Stmt *body, Expr *cond, SourceLocation DL, SourceLocation WL, SourceLocation RP)
Definition: Stmt.h:1088
static bool classof(const Stmt *T)
Definition: Stmt.h:931
const SwitchCase * getNextSwitchCase() const
Definition: Stmt.h:652
child_range children()
Definition: Stmt.h:1013
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1543
Stmt * body_back()
Definition: Stmt.h:573
decl_const_range decls() const
Definition: Stmt.h:480
unsigned getNumOutputs() const
Definition: Stmt.h:1440
body_iterator body_end()
Definition: Stmt.h:571
const DeclGroupRef getDeclGroup() const
Definition: Stmt.h:452
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument.
Definition: Stmt.h:2157
const Stmt * getSubStmt() const
Definition: Stmt.h:749
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1843
DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt)
Definition: Stmt.h:741
void setNRVOCandidate(const VarDecl *Var)
Definition: Stmt.h:1372
bool hasLeadingEmptyMacro() const
Definition: Stmt.h:520
SourceLocation getLParenLoc() const
Definition: Stmt.h:1180
static bool classof(const Stmt *T)
Definition: Stmt.h:1813
SourceLocation getEndLoc() const
Definition: Stmt.h:1925
Expr * getCond()
Definition: Stmt.h:1053
inputs_range inputs()
Definition: Stmt.h:1495
llvm::iterator_range< capture_iterator > capture_range
Definition: Stmt.h:2115
const Stmt * getSubStmt() const
Definition: Stmt.h:854
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2191
void setCond(Expr *E)
Definition: Stmt.h:1055
unsigned getNumAsmToks()
Definition: Stmt.h:1753
std::reverse_iterator< body_iterator > reverse_body_iterator
Definition: Stmt.h:595
outputs_iterator end_outputs()
Definition: Stmt.h:1519
IndirectGotoStmt(EmptyShell Empty)
Build an empty indirect goto statement.
Definition: Stmt.h:1247
llvm::iterator_range< outputs_iterator > outputs_range
Definition: Stmt.h:1513
IfStmt - This represents an if/then/else.
Definition: Stmt.h:869
AsmStmt(StmtClass SC, EmptyShell Empty)
Build an empty inline-assembly statement.
Definition: Stmt.h:1418
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:668
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1431
capture_const_range captures() const
Definition: Stmt.h:2121
ContinueStmt(EmptyShell Empty)
Build an empty continue statement.
Definition: Stmt.h:1286
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:1566
void setContinueLoc(SourceLocation L)
Definition: Stmt.h:1289
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
void setDeclGroup(DeclGroupRef DGR)
Definition: Stmt.h:454
DeclGroupRef::iterator decl_iterator
Definition: Stmt.h:474
NullStmt(EmptyShell Empty)
Build an empty null statement.
Definition: Stmt.h:514
Represents an attribute applied to a statement.
Definition: Stmt.h:818
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1321
void setCond(Expr *E)
Definition: Stmt.h:1100
SourceLocation getIfLoc() const
Definition: Stmt.h:912
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1149
unsigned NumOutputs
Definition: Stmt.h:1403
const_capture_init_range capture_inits() const
Definition: Stmt.h:2152
child_range children()
Definition: Stmt.h:1970
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void setSwitchCaseList(SwitchCase *SC)
Set the case list for this switch statement.
Definition: Stmt.h:983
const Stmt * getElse() const
Definition: Stmt.h:905
NullStmt(SourceLocation L, bool hasLeadingEmptyMacro=false)
Definition: Stmt.h:509
void setStartLoc(SourceLocation L)
Definition: Stmt.h:457
void setForLoc(SourceLocation L)
Definition: Stmt.h:1179
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1374
const Stmt * getBody() const
Definition: Stmt.h:1171
SourceLocation getEndLoc() const
Definition: Stmt.h:1748
WhileStmt(EmptyShell Empty)
Build an empty while statement.
Definition: Stmt.h:1034
CompoundStmt * getBlock() const
Definition: Stmt.h:1888
Stmt * getSubStmt()
Definition: Stmt.h:748
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:719
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:699
SourceLocation getReturnLoc() const
Definition: Stmt.h:1363
static bool classof(const Stmt *T)
Definition: Stmt.h:620
StringRef getInputConstraint(unsigned i) const
Definition: Stmt.h:1777
void setAsmLoc(SourceLocation L)
Definition: Stmt.h:1422
unsigned size() const
Definition: Stmt.h:564
llvm::iterator_range< capture_init_iterator > capture_init_range
Definition: Stmt.h:2140
SourceLocation getDoLoc() const
Definition: Stmt.h:1105
SourceLocation getRParenLoc() const
Definition: Stmt.h:1565
Stmt * getThen()
Definition: Stmt.h:909
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:35
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:522
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
Definition: Stmt.h:2126
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:68
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:2847
const Stmt * getSubStmt() const
Definition: Stmt.h:798
bool body_empty() const
Definition: Stmt.h:563
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.h:1655
SourceLocation getDefaultLoc() const
Definition: Stmt.h:752
SourceLocation getEllipsisLoc() const
Definition: Stmt.h:697
void setBody(Stmt *S, SourceLocation SL)
Definition: Stmt.h:988
bool getIsCXXTry() const
Definition: Stmt.h:1927
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1291
void setTarget(Expr *E)
Definition: Stmt.h:1257
static bool classof(const Stmt *T)
Definition: Stmt.h:1943
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:777
bool isOutputPlusConstraint(unsigned i) const
isOutputPlusConstraint - Return true if the specified output constraint is a "+" constraint (which is...
Definition: Stmt.h:1450
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3166
Represents a C99 designated initializer expression.
Definition: Expr.h:3931
inputs_iterator begin_inputs()
Definition: Stmt.h:1487
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:1101
const_decl_iterator decl_begin() const
Definition: Stmt.h:485
unsigned getNumInputs() const
Definition: Stmt.h:1462
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3400
SourceLocation ColonLoc
Definition: Stmt.h:642
outputs_const_range outputs() const
Definition: Stmt.h:1532
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
child_range children()
Definition: Stmt.h:1890
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1842
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1882
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:718
LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
Definition: Stmt.h:783
const Expr * getRHS() const
Definition: Stmt.h:709
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1962
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1921
SourceLocation getCaseLoc() const
Definition: Stmt.h:695
Token - This structure provides full information about a lexed token.
Definition: Token.h:37
Stmt * body_front()
Definition: Stmt.h:572
void setReturnLoc(SourceLocation L)
Definition: Stmt.h:1364
MSAsmStmt(EmptyShell Empty)
Build an empty MS-style inline-assembly statement.
Definition: Stmt.h:1743
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1811
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition: CharUnits.h:201
SourceLocation getLBracLoc() const
Definition: Stmt.h:617
SourceLocation getLBraceLoc() const
Definition: Stmt.h:1746
static bool classof(const Stmt *T)
Definition: Stmt.h:1475
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:144
child_range children()
Definition: Stmt.h:1817
void setSubStmt(Stmt *S)
Definition: Stmt.h:714
child_range children()
Definition: Stmt.h:1121
SwitchCase(StmtClass SC, SourceLocation KWLoc, SourceLocation ColonLoc)
Definition: Stmt.h:644
Expr * getFilterExpr() const
Definition: Stmt.h:1848
void addSwitchCase(SwitchCase *SC)
Definition: Stmt.h:992
child_range children()
Definition: Stmt.h:529
child_range children()
Definition: Stmt.h:1939
SourceLocation getWhileLoc() const
Definition: Stmt.h:1060
void setBody(Stmt *S)
Definition: Stmt.h:979
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
Definition: Stmt.h:1371
static bool classof(const Stmt *T)
Definition: Stmt.h:1068
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1236
Describes an C or C++ initializer list.
Definition: Expr.h:3724
body_const_range body() const
Definition: Stmt.h:583
OpenMPLinearClauseKind getModifier() const
Return modifier.
SwitchCase(StmtClass SC, EmptyShell)
Definition: Stmt.h:648
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:1633
GCCAsmStmt(EmptyShell Empty)
Build an empty inline-assembly statement.
Definition: Stmt.h:1562
child_range children()
Definition: Stmt.h:859
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:1131
outputs_iterator begin_outputs()
Definition: Stmt.h:1516
void setCond(Expr *E)
Definition: Stmt.h:977
const_capture_iterator capture_begin() const
Definition: Stmt.h:2127
const_child_range children() const
Definition: Stmt.h:629
const Expr * getCond() const
Definition: Stmt.h:1099
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:2178
SourceLocation getRParenLoc() const
Definition: Stmt.h:1110
void setEndLoc(SourceLocation L)
Definition: Stmt.h:459
DeclStmt(EmptyShell Empty)
Build an empty declaration statement.
Definition: Stmt.h:441
Stmt * getBody()
Definition: Stmt.h:1166
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:1794
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:1791
const_reverse_body_iterator body_rbegin() const
Definition: Stmt.h:606
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1266
Stmt * getInit()
Definition: Stmt.h:1145
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1322
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1221
child_range children()
Definition: Stmt.h:805
void setAsmString(StringLiteral *E)
Definition: Stmt.h:1572
static bool classof(const Stmt *T)
Definition: Stmt.h:1379
AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
Definition: Stmt.h:1409
const DeclStmt * getConditionVariableDeclStmt() const
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Definition: Stmt.h:968
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1810
const_outputs_iterator end_outputs() const
Definition: Stmt.h:1529
Expr * getCond()
Definition: Stmt.h:1164
void setLHS(Expr *Val)
Definition: Stmt.h:715
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2610
void setBody(Stmt *S)
Definition: Stmt.h:1058
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1222
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1707
const_capture_init_iterator capture_init_begin() const
Definition: Stmt.h:2161
void setCond(Expr *E)
Definition: Stmt.h:1174
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:615
decl_iterator decl_end()
Definition: Stmt.h:484
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Definition: Stmt.h:2101
void setEndLoc(SourceLocation L)
Definition: Stmt.h:1749
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3034
child_range children()
Definition: Stmt.h:625
This represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:3560
detail::InMemoryDirectory::const_iterator I
Stmt * getBody()
Definition: Stmt.h:978
SourceLocation getSwitchLoc() const
Definition: Stmt.h:985
unsigned NumClobbers
Definition: Stmt.h:1405
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1185
llvm::iterator_range< inputs_iterator > inputs_range
Definition: Stmt.h:1484
StringLiteral * getAsmString()
Definition: Stmt.h:1571
void setColonLoc(SourceLocation L)
Definition: Stmt.h:755
child_range children()
Definition: Stmt.h:733
void setBreakLoc(SourceLocation L)
Definition: Stmt.h:1319
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:539
SourceLocation getAsmLoc() const
Definition: Stmt.h:1421
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1922
Describes the capture of either a variable, or 'this', or variable-length array type.
Definition: Stmt.h:1997
const Stmt * getBody() const
Definition: Stmt.h:1102
StringRef getAsmString() const
Definition: Stmt.h:1757
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:917
Decl * getSingleDecl()
Definition: Stmt.h:450
static bool classof(const Stmt *T)
Definition: Stmt.h:1269
void setSemiLoc(SourceLocation L)
Definition: Stmt.h:518
SourceLocation getEndLoc() const
Definition: Stmt.h:1886
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1430
Stmt * getHandler() const
Definition: Stmt.h:1933
const Stmt * getBody() const
Definition: Stmt.h:1057
child_range children()
Definition: Stmt.h:1536
bool IsVolatile
If true, treat this inline assembly as having side effects.
Definition: Stmt.h:1401
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:1960
static bool classof(const Stmt *T)
Definition: Stmt.h:1860
static bool classof(const Stmt *T)
Definition: Stmt.h:1190
ASTContext * Context
const SmallVectorImpl< AnnotatedLine * >::const_iterator End
llvm::iterator_range< const_capture_iterator > capture_const_range
Definition: Stmt.h:2116
ID
Defines the set of possible language-specific address spaces.
Definition: AddressSpaces.h:27
SourceLocation getColonLoc() const
Definition: Stmt.h:699
SourceManager & SM
void setLeaveLoc(SourceLocation L)
Definition: Stmt.h:1960
const Expr * getTarget() const
Definition: Stmt.h:1256
LabelDecl * getDecl() const
Definition: Stmt.h:794
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:1111
friend class ASTContext
Definition: Type.h:4012
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:1661
GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL)
Definition: Stmt.h:1207
Expr - This represents one expression.
Definition: Expr.h:104
SourceRange getSourceRange() const LLVM_READONLY
Definition: Stmt.h:2181
const Stmt * getSubStmt() const
Definition: Stmt.h:712
void setWhileLoc(SourceLocation L)
Definition: Stmt.h:1061
Represents a character-granular source range.
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:856
bool hasBraces() const
Definition: Stmt.h:1751
static bool classof(const Stmt *T)
Definition: Stmt.h:1965
void setLParenLoc(SourceLocation L)
Definition: Stmt.h:1181
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1883
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
Definition: Stmt.h:1577
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.h:1684
SourceLocation getGotoLoc() const
Definition: Stmt.h:1216
void setInc(Expr *E)
Definition: Stmt.h:1175
Stmt * getBody()
Definition: Stmt.h:1056
SourceLocation KeywordLoc
Definition: Stmt.h:641
void setRetValue(Expr *E)
Definition: Stmt.h:1361
void setBody(Stmt *S)
Definition: Stmt.h:1176
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:257
Expr * getRHS()
Definition: Stmt.h:703
void setColonLoc(SourceLocation L)
Definition: Stmt.h:700
ExprIterator outputs_iterator
Definition: Stmt.h:1511
Expr ** capture_init_iterator
Iterator that walks over the capture initialization arguments.
Definition: Stmt.h:2139
FormatToken * Token
child_range children()
Definition: Stmt.h:927
SwitchCase * NextSwitchCase
Definition: Stmt.h:640
static bool classof(const Stmt *T)
Definition: Stmt.h:525
SourceLocation getEndLoc() const
Definition: Stmt.h:458
bool capturesVariableArrayType() const
Determine whether this capture handles a variable-length array type.
Definition: Stmt.h:2033
const SwitchCase * getSwitchCaseList() const
Definition: Stmt.h:974
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
StringRef getInputName(unsigned i) const
Definition: Stmt.h:1665
capture_init_range capture_inits()
Definition: Stmt.h:2148
SourceLocation getLabelLoc() const
Definition: Stmt.h:1218
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1963
llvm::iterator_range< decl_iterator > decl_range
Definition: Stmt.h:476
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
AsmStringPiece(const std::string &S)
Definition: Stmt.h:1591
ForStmt(EmptyShell Empty)
Build an empty for statement.
Definition: Stmt.h:1143
StringLiteral * getOutputConstraintLiteral(unsigned i)
Definition: Stmt.h:1649
child_range children()
Definition: Stmt.h:1274
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1344
SourceLocation getLocation() const
Retrieve the source location at which the variable or 'this' was first used.
Definition: Stmt.h:2018
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:860
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:1722
void setColonLoc(SourceLocation L)
Definition: Stmt.h:661
SwitchCase * getSwitchCaseList()
Definition: Stmt.h:980
const DeclStmt * getConditionVariableDeclStmt() const
If this ForStmt has a condition variable, return the faux DeclStmt associated with the creation of th...
Definition: Stmt.h:1160
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
const DeclStmt * getConditionVariableDeclStmt() const
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition: Stmt.h:897
child_range children()
Definition: Stmt.h:765
child_range children()
Definition: Stmt.h:1299
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1007
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:3988
const Expr * getLHS() const
Definition: Stmt.h:706
Expr * getCond()
Definition: Stmt.h:908
std::reverse_iterator< const_body_iterator > const_reverse_body_iterator
Definition: Stmt.h:604
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:462
static bool classof(const Stmt *T)
Definition: Stmt.h:1224
const LabelDecl * getConstantTarget() const
Definition: Stmt.h:1262
SourceLocation getSemiLoc() const
Definition: Stmt.h:517
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1114
llvm::iterator_range< const_body_iterator > body_const_range
Definition: Stmt.h:581
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:1080
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:1392
child_range children()
Definition: Stmt.h:1329
LabelDecl * getLabel() const
Definition: Stmt.h:1213
const_outputs_iterator begin_outputs() const
Definition: Stmt.h:1526
ExprIterator inputs_iterator
Definition: Stmt.h:1482
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:1797
SourceLocation getGotoLoc() const
Definition: Stmt.h:1251
void setDecl(LabelDecl *D)
Definition: Stmt.h:795
const StringLiteral * getAsmString() const
Definition: Stmt.h:1570
#define false
Definition: stdbool.h:33
static bool classof(const Stmt *T)
Definition: Stmt.h:2185
Kind
void setElse(Stmt *S)
Definition: Stmt.h:906
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2402
This captures a statement into a function.
Definition: Stmt.h:1984
Token * getAsmToks()
Definition: Stmt.h:1754
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:4692
void setSubStmt(Stmt *S)
Definition: Stmt.h:750
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:768
void setGotoLoc(SourceLocation L)
Definition: Stmt.h:1250
CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Definition: Stmt.h:683
Encodes a location in the source.
SourceLocation getLeaveLoc() const
Definition: Stmt.h:1959
body_range body()
Definition: Stmt.h:569
SEHLeaveStmt(EmptyShell Empty)
Build an empty __leave statement.
Definition: Stmt.h:1957
void setDoLoc(SourceLocation L)
Definition: Stmt.h:1106
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.h:1771
child_range children()
Definition: Stmt.h:1856
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1723
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl. ...
Definition: Stmt.h:445
Expr * getLHS()
Definition: Stmt.h:702
void setLastStmt(Stmt *S)
Definition: Stmt.h:575
llvm::iterator_range< const_capture_init_iterator > const_capture_init_range
Definition: Stmt.h:2146
SourceLocation getKeywordLoc() const
Definition: Stmt.h:658
const Stmt * getInit() const
Definition: Stmt.h:1168
void setIdentLoc(SourceLocation L)
Definition: Stmt.h:799
Stmt * getElse()
Definition: Stmt.h:910
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
Definition: Stmt.h:2027
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:431
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:355
CompoundStmt * getBlock() const
Definition: Stmt.h:1852
const Expr * getCond() const
Definition: Stmt.h:972
llvm::iterator_range< body_iterator > body_range
Definition: Stmt.h:567
reverse_body_iterator body_rend()
Definition: Stmt.h:599
const_decl_iterator decl_end() const
Definition: Stmt.h:486
SourceLocation getIdentLoc() const
Definition: Stmt.h:793
CaseStmt(EmptyShell Empty)
Build an empty switch case statement.
Definition: Stmt.h:693
SourceLocation getTryLoc() const
Definition: Stmt.h:1924
Expr * getCond()
Definition: Stmt.h:976
void setAllEnumCasesCovered()
Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a switch over an enum value then ...
Definition: Stmt.h:1001
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:614
CompoundStmt(SourceLocation Loc)
Definition: Stmt.h:550
const Expr * getCond() const
Definition: Stmt.h:1054
void setCond(Expr *E)
Definition: Stmt.h:902
bool capturesVariable() const
Determine whether this capture handles a variable (by reference).
Definition: Stmt.h:2024
static bool classof(const Stmt *T)
Definition: Stmt.h:1324
ConstExprIterator const_outputs_iterator
Definition: Stmt.h:1512
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx)
Definition: Type.h:4095
SourceLocation getEndLoc() const
Definition: Stmt.h:1846
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>.
Definition: Expr.h:4817
decl_iterator decl_begin()
Definition: Stmt.h:483
SourceLocation getContinueLoc() const
Definition: Stmt.h:1288
reverse_decl_iterator decl_rbegin()
Definition: Stmt.h:489
SEHLeaveStmt(SourceLocation LL)
Definition: Stmt.h:1953
CharSourceRange getRange() const
Definition: Stmt.h:1610
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition: Stmt.h:2131
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:2084
const_reverse_body_iterator body_rend() const
Definition: Stmt.h:610
void setCaseLoc(SourceLocation L)
Definition: Stmt.h:696
bool isAllEnumCasesCovered() const
Returns true if the SwitchStmt is a switch of an enum value and all cases have been explicitly covere...
Definition: Stmt.h:1005
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:1637
const_body_iterator body_begin() const
Definition: Stmt.h:586
StringRef getOutputConstraint(unsigned i) const
Definition: Stmt.h:1764
LabelStmt(EmptyShell Empty)
Definition: Stmt.h:791
StringRef getClobber(unsigned i) const
Definition: Stmt.h:1802
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1375
__SIZE_TYPE__ size_t
Definition: stddef.h:62
void setCapturedRecordDecl(RecordDecl *D)
Set the record declaration for captured variables.
Definition: Stmt.h:2104
const Decl * getSingleDecl() const
Definition: Stmt.h:449
void setSimple(bool V)
Definition: Stmt.h:1425
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2706
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1712
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.h:1785
const_body_iterator body_end() const
Definition: Stmt.h:587
IfStmt(EmptyShell Empty)
Build an empty if/then/else statement.
Definition: Stmt.h:882
void setGotoLoc(SourceLocation L)
Definition: Stmt.h:1217
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:499
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:461
Stmt ** body_iterator
Definition: Stmt.h:566
llvm::iterator_range< const_outputs_iterator > outputs_const_range
Definition: Stmt.h:1514
child_range children()
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:918
unsigned capture_size() const
Retrieve the number of captures, including 'this'.
Definition: Stmt.h:2136
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1713
const Stmt * getSubStmt() const
Definition: Stmt.h:664
SourceLocation getStarLoc() const
Definition: Stmt.h:1253
const Stmt * body_front() const
Definition: Stmt.h:588
const Expr * getInc() const
Definition: Stmt.h:1170
const Stmt * getBody() const
Definition: Stmt.h:973
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:311
bool capturesThis() const
Determine whether this capture handles the C++ 'this' pointer.
Definition: Stmt.h:2021
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1063
DoStmt(EmptyShell Empty)
Build an empty do-while statement.
Definition: Stmt.h:1096
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1008
const StringLiteral * getClobberStringLiteral(unsigned i) const
Definition: Stmt.h:1708
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:758
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1292
SwitchCase * getNextSwitchCase()
Definition: Stmt.h:654
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1646
static bool classof(const Stmt *T)
Definition: Stmt.h:1894
SourceLocation getWhileLoc() const
Definition: Stmt.h:1107
void setEllipsisLoc(SourceLocation L)
Definition: Stmt.h:698
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1267
detail::InMemoryDirectory::const_iterator E
ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Definition: Stmt.h:1352
static bool classof(const Stmt *T)
Definition: Stmt.h:1715
BreakStmt(EmptyShell Empty)
Build an empty break statement.
Definition: Stmt.h:1316
child_range children()
Definition: Stmt.h:1229
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:523
body_iterator body_begin()
Definition: Stmt.h:570
Stmt *const * const_body_iterator
Definition: Stmt.h:580
static bool classof(const Stmt *T)
Definition: Stmt.h:464
void setBody(Stmt *S)
Definition: Stmt.h:1103
IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target)
Definition: Stmt.h:1241
Represents a __leave statement.
Definition: Stmt.h:1950
const Stmt * getThen() const
Definition: Stmt.h:903
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:938
const_capture_init_iterator capture_init_end() const
Definition: Stmt.h:2171
static bool classof(const OMPClause *T)
llvm::iterator_range< const_decl_iterator > decl_const_range
Definition: Stmt.h:477
void setRHS(Expr *Val)
Definition: Stmt.h:716
void setVolatile(bool V)
Definition: Stmt.h:1428
static bool classof(const Stmt *T)
Definition: Stmt.h:807
DefaultStmt(EmptyShell Empty)
Build an empty default statement.
Definition: Stmt.h:745
reverse_decl_iterator decl_rend()
Definition: Stmt.h:492
StringLiteral * getInputConstraintLiteral(unsigned i)
Definition: Stmt.h:1677
DeclGroupRef getDeclGroup()
Definition: Stmt.h:453
unsigned getOperandNo() const
Definition: Stmt.h:1605
void setSwitchLoc(SourceLocation L)
Definition: Stmt.h:986
DeclGroupRef::const_iterator const_decl_iterator
Definition: Stmt.h:475
static bool classof(const Stmt *T)
Definition: Stmt.h:760
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:857
decl_range decls()
Definition: Stmt.h:479
AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin, SourceLocation End)
Definition: Stmt.h:1592
bool IsSimple
True if the assembly statement does not have any input or output operands.
Definition: Stmt.h:1397
bool isVolatile() const
Definition: Stmt.h:1427
static bool classof(const Stmt *T)
Definition: Stmt.h:861
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:2175
const DeclStmt * getConditionVariableDeclStmt() const
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition: Stmt.h:1049
ReturnStmt(SourceLocation RL)
Definition: Stmt.h:1350
SourceLocation getForLoc() const
Definition: Stmt.h:1178
child_range children()
Definition: Stmt.h:1073
const Expr * getCond() const
Definition: Stmt.h:1169
void setStarLoc(SourceLocation L)
Definition: Stmt.h:1252
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:2927
outputs_range outputs()
Definition: Stmt.h:1522
Stmt ** Exprs
Definition: Stmt.h:1407
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1202
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:850
Expr * getTarget()
Definition: Stmt.h:1255
SourceLocation getColonLoc() const
Definition: Stmt.h:660
SourceLocation getAttrLoc() const
Definition: Stmt.h:849
SwitchStmt(EmptyShell Empty)
Build a empty switch statement.
Definition: Stmt.h:952
Expr * getCond()
Definition: Stmt.h:1098
const std::string & getString() const
Definition: Stmt.h:1601
static bool classof(const Stmt *T)
Definition: Stmt.h:1116
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1674
Decl *const * const_iterator
Definition: DeclGroup.h:80
SourceLocation getFinallyLoc() const
Definition: Stmt.h:1885
Defines the clang::SourceLocation class and associated facilities.
const_inputs_iterator end_inputs() const
Definition: Stmt.h:1501
ContinueStmt - This represents a continue.
Definition: Stmt.h:1280
SourceLocation getRParenLoc() const
Definition: Stmt.h:1182
reverse_body_iterator body_rbegin()
Definition: Stmt.h:596
void setLBraceLoc(SourceLocation L)
Definition: Stmt.h:1747
child_range children()
Definition: Stmt.h:469
llvm::iterator_range< const_inputs_iterator > inputs_const_range
Definition: Stmt.h:1485
void setElseLoc(SourceLocation L)
Definition: Stmt.h:915
SourceLocation getBreakLoc() const
Definition: Stmt.h:1318
ContinueStmt(SourceLocation CL)
Definition: Stmt.h:1283
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:1113
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:1025
void setIfLoc(SourceLocation L)
Definition: Stmt.h:913
SourceLocation getColonLoc() const
Definition: Stmt.h:754
const Expr * getCond() const
Definition: Stmt.h:901
SourceLocation AsmLoc
Definition: Stmt.h:1394
SourceLocation getElseLoc() const
Definition: Stmt.h:914
static bool classof(const Stmt *T)
Definition: Stmt.h:1294
CompoundStmt(EmptyShell Empty)
Definition: Stmt.h:556
void setDefaultLoc(SourceLocation L)
Definition: Stmt.h:753
const Stmt * body_back() const
Definition: Stmt.h:591
VariableCaptureKind
The different capture forms: by 'this', by reference, capture for variable-length array type etc...
Definition: Stmt.h:1988
bool isSimple() const
Definition: Stmt.h:1424
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1452
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2134
static bool classof(const Stmt *T)
Definition: Stmt.h:1017
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:1183
SourceLocation getRBracLoc() const
Definition: Stmt.h:618
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1064
void setNextSwitchCase(SwitchCase *SC)
Definition: Stmt.h:656
child_range children()
Definition: Stmt.h:1195
capture_range captures()
Definition: Stmt.h:2118
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:922
Capture * capture_iterator
An iterator that walks over the captures.
Definition: Stmt.h:2113
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:803
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:802
std::reverse_iterator< decl_iterator > reverse_decl_iterator
Definition: Stmt.h:488
void setLabel(LabelDecl *D)
Definition: Stmt.h:1214
static bool classof(const Stmt *T)
Definition: Stmt.h:728
BreakStmt - This represents a break.
Definition: Stmt.h:1306
const_inputs_iterator begin_inputs() const
Definition: Stmt.h:1497
const Capture * const_capture_iterator
Definition: Stmt.h:2114
void setSubStmt(Stmt *SS)
Definition: Stmt.h:800
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
Stmt * getSubStmt()
Definition: Stmt.h:797
DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc)
Definition: Stmt.h:436
unsigned getNumClobbers() const
Definition: Stmt.h:1472
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:757
A trivial tuple used to represent a source range.
void setInit(Stmt *S)
Definition: Stmt.h:1173
const Stmt * getCapturedStmt() const
Definition: Stmt.h:2085
unsigned NumInputs
Definition: Stmt.h:1404
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:1860
CompoundStmt * getTryBlock() const
Definition: Stmt.h:1929
SourceLocation getStartLoc() const
Definition: Stmt.h:456
inputs_const_range inputs() const
Definition: Stmt.h:1505
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: Stmt.h:2144
SourceLocation getExceptLoc() const
Definition: Stmt.h:1845
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
Definition: Stmt.h:2167
SourceLocation ColonLoc
Location of ':'.
Definition: OpenMPClause.h:266
void setWhileLoc(SourceLocation L)
Definition: Stmt.h:1108
child_range children()
Definition: Stmt.h:1384
This class handles loading and caching of source files into memory.
BreakStmt(SourceLocation BL)
Definition: Stmt.h:1310
Stmt * getSubStmt()
Definition: Stmt.h:853
void setKeywordLoc(SourceLocation L)
Definition: Stmt.h:659
ReturnStmt(EmptyShell Empty)
Build an empty return expression.
Definition: Stmt.h:1357
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:1186
void setLabelLoc(SourceLocation L)
Definition: Stmt.h:1219
ConstExprIterator const_inputs_iterator
Definition: Stmt.h:1483
#define BLOCK(DERIVED, BASE)
Definition: Template.h:423
Stmt * getSubStmt()
Definition: Stmt.h:704
inputs_iterator end_inputs()
Definition: Stmt.h:1491