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