clang  8.0.0svn
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  //===--- Statement bitfields classes ---===//
93 
94  class StmtBitfields {
95  friend class Stmt;
96 
97  /// The statement class.
98  unsigned sClass : 8;
99  };
100  enum { NumStmtBits = 8 };
101 
103  friend class ASTStmtReader;
104  friend class ASTStmtWriter;
105  friend class NullStmt;
106 
107  unsigned : NumStmtBits;
108 
109  /// True if the null statement was preceded by an empty macro, e.g:
110  /// @code
111  /// #define CALL(x)
112  /// CALL(0);
113  /// @endcode
114  unsigned HasLeadingEmptyMacro : 1;
115 
116  /// The location of the semi-colon.
117  SourceLocation SemiLoc;
118  };
119 
121  friend class ASTStmtReader;
122  friend class CompoundStmt;
123 
124  unsigned : NumStmtBits;
125 
126  unsigned NumStmts : 32 - NumStmtBits;
127 
128  /// The location of the opening "{".
129  SourceLocation LBraceLoc;
130  };
131 
133  friend class LabelStmt;
134 
135  unsigned : NumStmtBits;
136 
137  SourceLocation IdentLoc;
138  };
139 
141  friend class ASTStmtReader;
142  friend class AttributedStmt;
143 
144  unsigned : NumStmtBits;
145 
146  /// Number of attributes.
147  unsigned NumAttrs : 32 - NumStmtBits;
148 
149  /// The location of the attribute.
150  SourceLocation AttrLoc;
151  };
152 
154  friend class ASTStmtReader;
155  friend class IfStmt;
156 
157  unsigned : NumStmtBits;
158 
159  /// True if this if statement is a constexpr if.
160  unsigned IsConstexpr : 1;
161 
162  /// True if this if statement has storage for an else statement.
163  unsigned HasElse : 1;
164 
165  /// True if this if statement has storage for a variable declaration.
166  unsigned HasVar : 1;
167 
168  /// True if this if statement has storage for an init statement.
169  unsigned HasInit : 1;
170 
171  /// The location of the "if".
172  SourceLocation IfLoc;
173  };
174 
176  friend class SwitchStmt;
177 
178  unsigned : NumStmtBits;
179 
180  /// True if the SwitchStmt has storage for an init statement.
181  unsigned HasInit : 1;
182 
183  /// True if the SwitchStmt has storage for a condition variable.
184  unsigned HasVar : 1;
185 
186  /// If the SwitchStmt is a switch on an enum value, records whether all
187  /// the enum values were covered by CaseStmts. The coverage information
188  /// value is meant to be a hint for possible clients.
189  unsigned AllEnumCasesCovered : 1;
190 
191  /// The location of the "switch".
192  SourceLocation SwitchLoc;
193  };
194 
196  friend class ASTStmtReader;
197  friend class WhileStmt;
198 
199  unsigned : NumStmtBits;
200 
201  /// True if the WhileStmt has storage for a condition variable.
202  unsigned HasVar : 1;
203 
204  /// The location of the "while".
205  SourceLocation WhileLoc;
206  };
207 
209  friend class DoStmt;
210 
211  unsigned : NumStmtBits;
212 
213  /// The location of the "do".
214  SourceLocation DoLoc;
215  };
216 
218  friend class ForStmt;
219 
220  unsigned : NumStmtBits;
221 
222  /// The location of the "for".
223  SourceLocation ForLoc;
224  };
225 
227  friend class GotoStmt;
228  friend class IndirectGotoStmt;
229 
230  unsigned : NumStmtBits;
231 
232  /// The location of the "goto".
233  SourceLocation GotoLoc;
234  };
235 
237  friend class ContinueStmt;
238 
239  unsigned : NumStmtBits;
240 
241  /// The location of the "continue".
242  SourceLocation ContinueLoc;
243  };
244 
246  friend class BreakStmt;
247 
248  unsigned : NumStmtBits;
249 
250  /// The location of the "break".
251  SourceLocation BreakLoc;
252  };
253 
255  friend class ReturnStmt;
256 
257  unsigned : NumStmtBits;
258 
259  /// True if this ReturnStmt has storage for an NRVO candidate.
260  unsigned HasNRVOCandidate : 1;
261 
262  /// The location of the "return".
263  SourceLocation RetLoc;
264  };
265 
267  friend class SwitchCase;
268  friend class CaseStmt;
269 
270  unsigned : NumStmtBits;
271 
272  /// Used by CaseStmt to store whether it is a case statement
273  /// of the form case LHS ... RHS (a GNU extension).
274  unsigned CaseStmtIsGNURange : 1;
275 
276  /// The location of the "case" or "default" keyword.
277  SourceLocation KeywordLoc;
278  };
279 
280  //===--- Expression bitfields classes ---===//
281 
283  friend class ASTStmtReader; // deserialization
284  friend class AtomicExpr; // ctor
285  friend class BlockDeclRefExpr; // ctor
286  friend class CallExpr; // ctor
287  friend class CXXConstructExpr; // ctor
288  friend class CXXDependentScopeMemberExpr; // ctor
289  friend class CXXNewExpr; // ctor
290  friend class CXXUnresolvedConstructExpr; // ctor
291  friend class DeclRefExpr; // computeDependence
292  friend class DependentScopeDeclRefExpr; // ctor
293  friend class DesignatedInitExpr; // ctor
294  friend class Expr;
295  friend class InitListExpr; // ctor
296  friend class ObjCArrayLiteral; // ctor
297  friend class ObjCDictionaryLiteral; // ctor
298  friend class ObjCMessageExpr; // ctor
299  friend class OffsetOfExpr; // ctor
300  friend class OpaqueValueExpr; // ctor
301  friend class OverloadExpr; // ctor
302  friend class ParenListExpr; // ctor
303  friend class PseudoObjectExpr; // ctor
304  friend class ShuffleVectorExpr; // ctor
305 
306  unsigned : NumStmtBits;
307 
308  unsigned ValueKind : 2;
309  unsigned ObjectKind : 3;
310  unsigned TypeDependent : 1;
311  unsigned ValueDependent : 1;
312  unsigned InstantiationDependent : 1;
313  unsigned ContainsUnexpandedParameterPack : 1;
314  };
315  enum { NumExprBits = NumStmtBits + 9 };
316 
318  friend class ASTStmtReader;
319  friend class PredefinedExpr;
320 
321  unsigned : NumExprBits;
322 
323  /// The kind of this PredefinedExpr. One of the enumeration values
324  /// in PredefinedExpr::IdentKind.
325  unsigned Kind : 4;
326 
327  /// True if this PredefinedExpr has a trailing "StringLiteral *"
328  /// for the predefined identifier.
329  unsigned HasFunctionName : 1;
330 
331  /// The location of this PredefinedExpr.
332  SourceLocation Loc;
333  };
334 
336  friend class ASTStmtReader; // deserialization
337  friend class DeclRefExpr;
338 
339  unsigned : NumExprBits;
340 
341  unsigned HasQualifier : 1;
342  unsigned HasTemplateKWAndArgsInfo : 1;
343  unsigned HasFoundDecl : 1;
344  unsigned HadMultipleCandidates : 1;
345  unsigned RefersToEnclosingVariableOrCapture : 1;
346 
347  /// The location of the declaration name itself.
348  SourceLocation Loc;
349  };
350 
357  PPCDoubleDouble
358  };
359 
361  friend class FloatingLiteral;
362 
363  unsigned : NumExprBits;
364 
365  unsigned Semantics : 3; // Provides semantics for APFloat construction
366  unsigned IsExact : 1;
367  };
368 
370  friend class ASTStmtReader;
371  friend class StringLiteral;
372 
373  unsigned : NumExprBits;
374 
375  /// The kind of this string literal.
376  /// One of the enumeration values of StringLiteral::StringKind.
377  unsigned Kind : 3;
378 
379  /// The width of a single character in bytes. Only values of 1, 2,
380  /// and 4 bytes are supported. StringLiteral::mapCharByteWidth maps
381  /// the target + string kind to the appropriate CharByteWidth.
382  unsigned CharByteWidth : 3;
383 
384  unsigned IsPascal : 1;
385 
386  /// The number of concatenated token this string is made of.
387  /// This is the number of trailing SourceLocation.
388  unsigned NumConcatenated;
389  };
390 
392  friend class CharacterLiteral;
393 
394  unsigned : NumExprBits;
395 
396  unsigned Kind : 3;
397  };
398 
400  friend class UnaryOperator;
401 
402  unsigned : NumExprBits;
403 
404  unsigned Opc : 5;
405  unsigned CanOverflow : 1;
406 
407  SourceLocation Loc;
408  };
409 
412 
413  unsigned : NumExprBits;
414 
415  unsigned Kind : 3;
416  unsigned IsType : 1; // true if operand is a type, false if an expression.
417  };
418 
420  friend class ArraySubscriptExpr;
421 
422  unsigned : NumExprBits;
423 
424  SourceLocation RBracketLoc;
425  };
426 
428  friend class CallExpr;
429 
430  unsigned : NumExprBits;
431 
432  unsigned NumPreArgs : 1;
433  };
434 
436  friend class MemberExpr;
437 
438  unsigned : NumExprBits;
439 
440  /// IsArrow - True if this is "X->F", false if this is "X.F".
441  unsigned IsArrow : 1;
442 
443  /// True if this member expression used a nested-name-specifier to
444  /// refer to the member, e.g., "x->Base::f", or found its member via
445  /// a using declaration. When true, a MemberExprNameQualifier
446  /// structure is allocated immediately after the MemberExpr.
447  unsigned HasQualifierOrFoundDecl : 1;
448 
449  /// True if this member expression specified a template keyword
450  /// and/or a template argument list explicitly, e.g., x->f<int>,
451  /// x->template f, x->template f<int>.
452  /// When true, an ASTTemplateKWAndArgsInfo structure and its
453  /// TemplateArguments (if any) are present.
454  unsigned HasTemplateKWAndArgsInfo : 1;
455 
456  /// True if this member expression refers to a method that
457  /// was resolved from an overloaded set having size greater than 1.
458  unsigned HadMultipleCandidates : 1;
459 
460  /// This is the location of the -> or . in the expression.
461  SourceLocation OperatorLoc;
462  };
463 
465  friend class CastExpr;
466  friend class ImplicitCastExpr;
467 
468  unsigned : NumExprBits;
469 
470  unsigned Kind : 6;
471  unsigned PartOfExplicitCast : 1; // Only set for ImplicitCastExpr.
472  unsigned BasePathIsEmpty : 1;
473  };
474 
476  friend class BinaryOperator;
477 
478  unsigned : NumExprBits;
479 
480  unsigned Opc : 6;
481 
482  /// This is only meaningful for operations on floating point
483  /// types and 0 otherwise.
484  unsigned FPFeatures : 3;
485 
486  SourceLocation OpLoc;
487  };
488 
490  friend class InitListExpr;
491 
492  unsigned : NumExprBits;
493 
494  /// Whether this initializer list originally had a GNU array-range
495  /// designator in it. This is a temporary marker used by CodeGen.
496  unsigned HadArrayRangeDesignator : 1;
497  };
498 
500  friend class ASTStmtReader;
501  friend class ParenListExpr;
502 
503  unsigned : NumExprBits;
504 
505  /// The number of expressions in the paren list.
506  unsigned NumExprs;
507  };
508 
510  friend class ASTStmtReader; // deserialization
511  friend class PseudoObjectExpr;
512 
513  unsigned : NumExprBits;
514 
515  // These don't need to be particularly wide, because they're
516  // strictly limited by the forms of expressions we permit.
517  unsigned NumSubExprs : 8;
518  unsigned ResultIndex : 32 - 8 - NumExprBits;
519  };
520 
521  //===--- C++ Expression bitfields classes ---===//
522 
524  friend class CXXBoolLiteralExpr;
525 
526  unsigned : NumExprBits;
527 
528  /// The value of the boolean literal.
529  unsigned Value : 1;
530 
531  /// The location of the boolean literal.
532  SourceLocation Loc;
533  };
534 
536  friend class CXXNullPtrLiteralExpr;
537 
538  unsigned : NumExprBits;
539 
540  /// The location of the null pointer literal.
541  SourceLocation Loc;
542  };
543 
545  friend class CXXThisExpr;
546 
547  unsigned : NumExprBits;
548 
549  /// Whether this is an implicit "this".
550  unsigned IsImplicit : 1;
551 
552  /// The location of the "this".
553  SourceLocation Loc;
554  };
555 
557  friend class ASTStmtReader;
558  friend class CXXThrowExpr;
559 
560  unsigned : NumExprBits;
561 
562  /// Whether the thrown variable (if any) is in scope.
563  unsigned IsThrownVariableInScope : 1;
564 
565  /// The location of the "throw".
566  SourceLocation ThrowLoc;
567  };
568 
570  friend class ASTStmtReader;
571  friend class CXXDefaultArgExpr;
572 
573  unsigned : NumExprBits;
574 
575  /// The location where the default argument expression was used.
576  SourceLocation Loc;
577  };
578 
580  friend class ASTStmtReader;
581  friend class CXXDefaultInitExpr;
582 
583  unsigned : NumExprBits;
584 
585  /// The location where the default initializer expression was used.
586  SourceLocation Loc;
587  };
588 
590  friend class ASTStmtReader;
591  friend class CXXDeleteExpr;
592 
593  unsigned : NumExprBits;
594 
595  /// Is this a forced global delete, i.e. "::delete"?
596  unsigned GlobalDelete : 1;
597 
598  /// Is this the array form of delete, i.e. "delete[]"?
599  unsigned ArrayForm : 1;
600 
601  /// ArrayFormAsWritten can be different from ArrayForm if 'delete' is
602  /// applied to pointer-to-array type (ArrayFormAsWritten will be false
603  /// while ArrayForm will be true).
604  unsigned ArrayFormAsWritten : 1;
605 
606  /// Does the usual deallocation function for the element type require
607  /// a size_t argument?
608  unsigned UsualArrayDeleteWantsSize : 1;
609 
610  /// Location of the expression.
611  SourceLocation Loc;
612  };
613 
615  friend class ASTStmtReader;
616  friend class ASTStmtWriter;
617  friend class TypeTraitExpr;
618 
619  unsigned : NumExprBits;
620 
621  /// The kind of type trait, which is a value of a TypeTrait enumerator.
622  unsigned Kind : 8;
623 
624  /// If this expression is not value-dependent, this indicates whether
625  /// the trait evaluated true or false.
626  unsigned Value : 1;
627 
628  /// The number of arguments to this type trait.
629  unsigned NumArgs : 32 - 8 - 1 - NumExprBits;
630  };
631 
633  friend class ASTStmtReader; // deserialization
634  friend class ExprWithCleanups;
635 
636  unsigned : NumExprBits;
637 
638  // When false, it must not have side effects.
639  unsigned CleanupsHaveSideEffects : 1;
640 
641  unsigned NumObjects : 32 - 1 - NumExprBits;
642  };
643 
644  //===--- C++ Coroutines TS bitfields classes ---===//
645 
647  friend class CoawaitExpr;
648 
649  unsigned : NumExprBits;
650 
651  unsigned IsImplicit : 1;
652  };
653 
654  //===--- Obj-C Expression bitfields classes ---===//
655 
658 
659  unsigned : NumExprBits;
660 
661  unsigned ShouldCopy : 1;
662  };
663 
664  //===--- Clang Extensions bitfields classes ---===//
665 
667  friend class OpaqueValueExpr;
668 
669  unsigned : NumExprBits;
670 
671  /// The OVE is a unique semantic reference to its source expressio if this
672  /// bit is set to true.
673  unsigned IsUnique : 1;
674  };
675 
676  union {
677  // Same order as in StmtNodes.td.
678  // Statements
694 
695  // Expressions
712 
713  // C++ Expressions
723 
724  // C++ Coroutines TS expressions
726 
727  // Obj-C Expressions
729 
730  // Clang Extensions
732  };
733 
734 public:
735  // Only allow allocation of Stmts using the allocator in ASTContext
736  // or by doing a placement new.
737  void* operator new(size_t bytes, const ASTContext& C,
738  unsigned alignment = 8);
739 
740  void* operator new(size_t bytes, const ASTContext* C,
741  unsigned alignment = 8) {
742  return operator new(bytes, *C, alignment);
743  }
744 
745  void *operator new(size_t bytes, void *mem) noexcept { return mem; }
746 
747  void operator delete(void *, const ASTContext &, unsigned) noexcept {}
748  void operator delete(void *, const ASTContext *, unsigned) noexcept {}
749  void operator delete(void *, size_t) noexcept {}
750  void operator delete(void *, void *) noexcept {}
751 
752 public:
753  /// A placeholder type used to construct an empty shell of a
754  /// type, that will be filled in later (e.g., by some
755  /// de-serialization).
756  struct EmptyShell {};
757 
758 protected:
759  /// Iterator for iterating over Stmt * arrays that contain only Expr *
760  ///
761  /// This is needed because AST nodes use Stmt* arrays to store
762  /// references to children (to be compatible with StmtIterator).
764  : llvm::iterator_adaptor_base<ExprIterator, Stmt **,
765  std::random_access_iterator_tag, Expr *> {
766  ExprIterator() : iterator_adaptor_base(nullptr) {}
767  ExprIterator(Stmt **I) : iterator_adaptor_base(I) {}
768 
769  reference operator*() const {
770  assert((*I)->getStmtClass() >= firstExprConstant &&
771  (*I)->getStmtClass() <= lastExprConstant);
772  return *reinterpret_cast<Expr **>(I);
773  }
774  };
775 
776  /// Const iterator for iterating over Stmt * arrays that contain only Expr *
778  : llvm::iterator_adaptor_base<ConstExprIterator, const Stmt *const *,
779  std::random_access_iterator_tag,
780  const Expr *const> {
781  ConstExprIterator() : iterator_adaptor_base(nullptr) {}
782  ConstExprIterator(const Stmt *const *I) : iterator_adaptor_base(I) {}
783 
784  reference operator*() const {
785  assert((*I)->getStmtClass() >= firstExprConstant &&
786  (*I)->getStmtClass() <= lastExprConstant);
787  return *reinterpret_cast<const Expr *const *>(I);
788  }
789  };
790 
791 private:
792  /// Whether statistic collection is enabled.
793  static bool StatisticsEnabled;
794 
795 protected:
796  /// Construct an empty statement.
797  explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
798 
799 public:
801  static_assert(sizeof(*this) <= 8,
802  "changing bitfields changed sizeof(Stmt)");
803  static_assert(sizeof(*this) % alignof(void *) == 0,
804  "Insufficient alignment!");
805  StmtBits.sClass = SC;
806  if (StatisticsEnabled) Stmt::addStmtClass(SC);
807  }
808 
810  return static_cast<StmtClass>(StmtBits.sClass);
811  }
812 
813  const char *getStmtClassName() const;
814 
815  /// SourceLocation tokens are not useful in isolation - they are low level
816  /// value objects created/interpreted by SourceManager. We assume AST
817  /// clients will have a pointer to the respective SourceManager.
818  SourceRange getSourceRange() const LLVM_READONLY;
819  SourceLocation getBeginLoc() const LLVM_READONLY;
820  SourceLocation getEndLoc() const LLVM_READONLY;
821 
822  // global temp stats (until we have a per-module visitor)
823  static void addStmtClass(const StmtClass s);
824  static void EnableStatistics();
825  static void PrintStats();
826 
827  /// Dumps the specified AST fragment and all subtrees to
828  /// \c llvm::errs().
829  void dump() const;
830  void dump(SourceManager &SM) const;
831  void dump(raw_ostream &OS, SourceManager &SM) const;
832  void dump(raw_ostream &OS) const;
833 
834  /// \return Unique reproducible object identifier
835  int64_t getID(const ASTContext &Context) const;
836 
837  /// dumpColor - same as dump(), but forces color highlighting.
838  void dumpColor() const;
839 
840  /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
841  /// back to its original source language syntax.
842  void dumpPretty(const ASTContext &Context) const;
843  void printPretty(raw_ostream &OS, PrinterHelper *Helper,
844  const PrintingPolicy &Policy, unsigned Indentation = 0,
845  StringRef NewlineSymbol = "\n",
846  const ASTContext *Context = nullptr) const;
847 
848  /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
849  /// works on systems with GraphViz (Mac OS X) or dot+gv installed.
850  void viewAST() const;
851 
852  /// Skip past any implicit AST nodes which might surround this
853  /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
854  Stmt *IgnoreImplicit();
855  const Stmt *IgnoreImplicit() const {
856  return const_cast<Stmt *>(this)->IgnoreImplicit();
857  }
858 
859  /// Skip no-op (attributed, compound) container stmts and skip captured
860  /// stmt at the top, if \a IgnoreCaptured is true.
861  Stmt *IgnoreContainers(bool IgnoreCaptured = false);
862  const Stmt *IgnoreContainers(bool IgnoreCaptured = false) const {
863  return const_cast<Stmt *>(this)->IgnoreContainers(IgnoreCaptured);
864  }
865 
866  const Stmt *stripLabelLikeStatements() const;
868  return const_cast<Stmt*>(
869  const_cast<const Stmt*>(this)->stripLabelLikeStatements());
870  }
871 
872  /// Child Iterators: All subclasses must implement 'children'
873  /// to permit easy iteration over the substatements/subexpessions of an
874  /// AST node. This permits easy iteration over all nodes in the AST.
877 
878  using child_range = llvm::iterator_range<child_iterator>;
879  using const_child_range = llvm::iterator_range<const_child_iterator>;
880 
882 
884  auto Children = const_cast<Stmt *>(this)->children();
885  return const_child_range(Children.begin(), Children.end());
886  }
887 
888  child_iterator child_begin() { return children().begin(); }
889  child_iterator child_end() { return children().end(); }
890 
891  const_child_iterator child_begin() const { return children().begin(); }
892  const_child_iterator child_end() const { return children().end(); }
893 
894  /// Produce a unique representation of the given statement.
895  ///
896  /// \param ID once the profiling operation is complete, will contain
897  /// the unique representation of the given statement.
898  ///
899  /// \param Context the AST context in which the statement resides
900  ///
901  /// \param Canonical whether the profile should be based on the canonical
902  /// representation of this statement (e.g., where non-type template
903  /// parameters are identified by index/level rather than their
904  /// declaration pointers) or the exact representation of the statement as
905  /// written in the source.
906  void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
907  bool Canonical) const;
908 
909  /// Calculate a unique representation for a statement that is
910  /// stable across compiler invocations.
911  ///
912  /// \param ID profile information will be stored in ID.
913  ///
914  /// \param Hash an ODRHash object which will be called where pointers would
915  /// have been used in the Profile function.
916  void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash& Hash) const;
917 };
918 
919 /// DeclStmt - Adaptor class for mixing declarations with statements and
920 /// expressions. For example, CompoundStmt mixes statements, expressions
921 /// and declarations (variables, types). Another example is ForStmt, where
922 /// the first statement can be an expression or a declaration.
923 class DeclStmt : public Stmt {
924  DeclGroupRef DG;
925  SourceLocation StartLoc, EndLoc;
926 
927 public:
929  : Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
930 
931  /// Build an empty declaration statement.
932  explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) {}
933 
934  /// isSingleDecl - This method returns true if this DeclStmt refers
935  /// to a single Decl.
936  bool isSingleDecl() const { return DG.isSingleDecl(); }
937 
938  const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
939  Decl *getSingleDecl() { return DG.getSingleDecl(); }
940 
941  const DeclGroupRef getDeclGroup() const { return DG; }
942  DeclGroupRef getDeclGroup() { return DG; }
943  void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
944 
945  void setStartLoc(SourceLocation L) { StartLoc = L; }
946  SourceLocation getEndLoc() const { return EndLoc; }
947  void setEndLoc(SourceLocation L) { EndLoc = L; }
948 
949  SourceLocation getBeginLoc() const LLVM_READONLY { return StartLoc; }
950 
951  static bool classof(const Stmt *T) {
952  return T->getStmtClass() == DeclStmtClass;
953  }
954 
955  // Iterators over subexpressions.
957  return child_range(child_iterator(DG.begin(), DG.end()),
958  child_iterator(DG.end(), DG.end()));
959  }
960 
963  using decl_range = llvm::iterator_range<decl_iterator>;
964  using decl_const_range = llvm::iterator_range<const_decl_iterator>;
965 
966  decl_range decls() { return decl_range(decl_begin(), decl_end()); }
967 
969  return decl_const_range(decl_begin(), decl_end());
970  }
971 
972  decl_iterator decl_begin() { return DG.begin(); }
973  decl_iterator decl_end() { return DG.end(); }
974  const_decl_iterator decl_begin() const { return DG.begin(); }
975  const_decl_iterator decl_end() const { return DG.end(); }
976 
977  using reverse_decl_iterator = std::reverse_iterator<decl_iterator>;
978 
980  return reverse_decl_iterator(decl_end());
981  }
982 
984  return reverse_decl_iterator(decl_begin());
985  }
986 };
987 
988 /// NullStmt - This is the null statement ";": C99 6.8.3p3.
989 ///
990 class NullStmt : public Stmt {
991 public:
992  NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false)
993  : Stmt(NullStmtClass) {
994  NullStmtBits.HasLeadingEmptyMacro = hasLeadingEmptyMacro;
995  setSemiLoc(L);
996  }
997 
998  /// Build an empty null statement.
999  explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {}
1000 
1001  SourceLocation getSemiLoc() const { return NullStmtBits.SemiLoc; }
1002  void setSemiLoc(SourceLocation L) { NullStmtBits.SemiLoc = L; }
1003 
1004  bool hasLeadingEmptyMacro() const {
1005  return NullStmtBits.HasLeadingEmptyMacro;
1006  }
1007 
1008  SourceLocation getBeginLoc() const { return getSemiLoc(); }
1009  SourceLocation getEndLoc() const { return getSemiLoc(); }
1010 
1011  static bool classof(const Stmt *T) {
1012  return T->getStmtClass() == NullStmtClass;
1013  }
1014 
1017  }
1018 };
1019 
1020 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
1021 class CompoundStmt final : public Stmt,
1022  private llvm::TrailingObjects<CompoundStmt, Stmt *> {
1023  friend class ASTStmtReader;
1024  friend TrailingObjects;
1025 
1026  /// The location of the closing "}". LBraceLoc is stored in CompoundStmtBits.
1027  SourceLocation RBraceLoc;
1028 
1030  explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {}
1031 
1032  void setStmts(ArrayRef<Stmt *> Stmts);
1033 
1034 public:
1035  static CompoundStmt *Create(const ASTContext &C, ArrayRef<Stmt *> Stmts,
1037 
1038  // Build an empty compound statement with a location.
1040  : Stmt(CompoundStmtClass), RBraceLoc(Loc) {
1041  CompoundStmtBits.NumStmts = 0;
1042  CompoundStmtBits.LBraceLoc = Loc;
1043  }
1044 
1045  // Build an empty compound statement.
1046  static CompoundStmt *CreateEmpty(const ASTContext &C, unsigned NumStmts);
1047 
1048  bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
1049  unsigned size() const { return CompoundStmtBits.NumStmts; }
1050 
1051  using body_iterator = Stmt **;
1052  using body_range = llvm::iterator_range<body_iterator>;
1053 
1054  body_range body() { return body_range(body_begin(), body_end()); }
1055  body_iterator body_begin() { return getTrailingObjects<Stmt *>(); }
1056  body_iterator body_end() { return body_begin() + size(); }
1057  Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; }
1058 
1060  return !body_empty() ? body_begin()[size() - 1] : nullptr;
1061  }
1062 
1063  void setLastStmt(Stmt *S) {
1064  assert(!body_empty() && "setLastStmt");
1065  body_begin()[size() - 1] = S;
1066  }
1067 
1068  using const_body_iterator = Stmt *const *;
1069  using body_const_range = llvm::iterator_range<const_body_iterator>;
1070 
1072  return body_const_range(body_begin(), body_end());
1073  }
1074 
1076  return getTrailingObjects<Stmt *>();
1077  }
1078 
1079  const_body_iterator body_end() const { return body_begin() + size(); }
1080 
1081  const Stmt *body_front() const {
1082  return !body_empty() ? body_begin()[0] : nullptr;
1083  }
1084 
1085  const Stmt *body_back() const {
1086  return !body_empty() ? body_begin()[size() - 1] : nullptr;
1087  }
1088 
1089  using reverse_body_iterator = std::reverse_iterator<body_iterator>;
1090 
1092  return reverse_body_iterator(body_end());
1093  }
1094 
1096  return reverse_body_iterator(body_begin());
1097  }
1098 
1100  std::reverse_iterator<const_body_iterator>;
1101 
1103  return const_reverse_body_iterator(body_end());
1104  }
1105 
1107  return const_reverse_body_iterator(body_begin());
1108  }
1109 
1110  SourceLocation getBeginLoc() const { return CompoundStmtBits.LBraceLoc; }
1111  SourceLocation getEndLoc() const { return RBraceLoc; }
1112 
1113  SourceLocation getLBracLoc() const { return CompoundStmtBits.LBraceLoc; }
1114  SourceLocation getRBracLoc() const { return RBraceLoc; }
1115 
1116  static bool classof(const Stmt *T) {
1117  return T->getStmtClass() == CompoundStmtClass;
1118  }
1119 
1120  // Iterators
1121  child_range children() { return child_range(body_begin(), body_end()); }
1122 
1124  return const_child_range(body_begin(), body_end());
1125  }
1126 };
1127 
1128 // SwitchCase is the base class for CaseStmt and DefaultStmt,
1129 class SwitchCase : public Stmt {
1130 protected:
1131  /// The location of the ":".
1133 
1134  // The location of the "case" or "default" keyword. Stored in SwitchCaseBits.
1135  // SourceLocation KeywordLoc;
1136 
1137  /// A pointer to the following CaseStmt or DefaultStmt class,
1138  /// used by SwitchStmt.
1139  SwitchCase *NextSwitchCase = nullptr;
1140 
1142  : Stmt(SC), ColonLoc(ColonLoc) {
1143  setKeywordLoc(KWLoc);
1144  }
1145 
1147 
1148 public:
1149  const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
1150  SwitchCase *getNextSwitchCase() { return NextSwitchCase; }
1151  void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
1152 
1153  SourceLocation getKeywordLoc() const { return SwitchCaseBits.KeywordLoc; }
1154  void setKeywordLoc(SourceLocation L) { SwitchCaseBits.KeywordLoc = L; }
1156  void setColonLoc(SourceLocation L) { ColonLoc = L; }
1157 
1158  inline Stmt *getSubStmt();
1159  const Stmt *getSubStmt() const {
1160  return const_cast<SwitchCase *>(this)->getSubStmt();
1161  }
1162 
1163  SourceLocation getBeginLoc() const { return getKeywordLoc(); }
1164  inline SourceLocation getEndLoc() const LLVM_READONLY;
1165 
1166  static bool classof(const Stmt *T) {
1167  return T->getStmtClass() == CaseStmtClass ||
1168  T->getStmtClass() == DefaultStmtClass;
1169  }
1170 };
1171 
1172 /// CaseStmt - Represent a case statement. It can optionally be a GNU case
1173 /// statement of the form LHS ... RHS representing a range of cases.
1174 class CaseStmt final
1175  : public SwitchCase,
1176  private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1177  friend TrailingObjects;
1178 
1179  // CaseStmt is followed by several trailing objects, some of which optional.
1180  // Note that it would be more convenient to put the optional trailing objects
1181  // at the end but this would impact children().
1182  // The trailing objects are in order:
1183  //
1184  // * A "Stmt *" for the LHS of the case statement. Always present.
1185  //
1186  // * A "Stmt *" for the RHS of the case statement. This is a GNU extension
1187  // which allow ranges in cases statement of the form LHS ... RHS.
1188  // Present if and only if caseStmtIsGNURange() is true.
1189  //
1190  // * A "Stmt *" for the substatement of the case statement. Always present.
1191  //
1192  // * A SourceLocation for the location of the ... if this is a case statement
1193  // with a range. Present if and only if caseStmtIsGNURange() is true.
1194  enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1195  enum { NumMandatoryStmtPtr = 2 };
1196 
1197  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1198  return NumMandatoryStmtPtr + caseStmtIsGNURange();
1199  }
1200 
1201  unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
1202  return caseStmtIsGNURange();
1203  }
1204 
1205  unsigned lhsOffset() const { return LhsOffset; }
1206  unsigned rhsOffset() const { return LhsOffset + caseStmtIsGNURange(); }
1207  unsigned subStmtOffset() const { return rhsOffset() + SubStmtOffsetFromRhs; }
1208 
1209  /// Build a case statement assuming that the storage for the
1210  /// trailing objects has been properly allocated.
1211  CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
1212  SourceLocation ellipsisLoc, SourceLocation colonLoc)
1213  : SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1214  // Handle GNU case statements of the form LHS ... RHS.
1215  bool IsGNURange = rhs != nullptr;
1216  SwitchCaseBits.CaseStmtIsGNURange = IsGNURange;
1217  setLHS(lhs);
1218  setSubStmt(nullptr);
1219  if (IsGNURange) {
1220  setRHS(rhs);
1221  setEllipsisLoc(ellipsisLoc);
1222  }
1223  }
1224 
1225  /// Build an empty switch case statement.
1226  explicit CaseStmt(EmptyShell Empty, bool CaseStmtIsGNURange)
1227  : SwitchCase(CaseStmtClass, Empty) {
1228  SwitchCaseBits.CaseStmtIsGNURange = CaseStmtIsGNURange;
1229  }
1230 
1231 public:
1232  /// Build a case statement.
1233  static CaseStmt *Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs,
1234  SourceLocation caseLoc, SourceLocation ellipsisLoc,
1235  SourceLocation colonLoc);
1236 
1237  /// Build an empty case statement.
1238  static CaseStmt *CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange);
1239 
1240  /// True if this case statement is of the form case LHS ... RHS, which
1241  /// is a GNU extension. In this case the RHS can be obtained with getRHS()
1242  /// and the location of the ellipsis can be obtained with getEllipsisLoc().
1243  bool caseStmtIsGNURange() const { return SwitchCaseBits.CaseStmtIsGNURange; }
1244 
1245  SourceLocation getCaseLoc() const { return getKeywordLoc(); }
1246  void setCaseLoc(SourceLocation L) { setKeywordLoc(L); }
1247 
1248  /// Get the location of the ... in a case statement of the form LHS ... RHS.
1250  return caseStmtIsGNURange() ? *getTrailingObjects<SourceLocation>()
1251  : SourceLocation();
1252  }
1253 
1254  /// Set the location of the ... in a case statement of the form LHS ... RHS.
1255  /// Assert that this case statement is of this form.
1257  assert(
1258  caseStmtIsGNURange() &&
1259  "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1260  *getTrailingObjects<SourceLocation>() = L;
1261  }
1262 
1264  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1265  }
1266 
1267  const Expr *getLHS() const {
1268  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1269  }
1270 
1271  void setLHS(Expr *Val) {
1272  getTrailingObjects<Stmt *>()[lhsOffset()] = reinterpret_cast<Stmt *>(Val);
1273  }
1274 
1276  return caseStmtIsGNURange() ? reinterpret_cast<Expr *>(
1277  getTrailingObjects<Stmt *>()[rhsOffset()])
1278  : nullptr;
1279  }
1280 
1281  const Expr *getRHS() const {
1282  return caseStmtIsGNURange() ? reinterpret_cast<Expr *>(
1283  getTrailingObjects<Stmt *>()[rhsOffset()])
1284  : nullptr;
1285  }
1286 
1287  void setRHS(Expr *Val) {
1288  assert(caseStmtIsGNURange() &&
1289  "setRHS but this is not a case stmt of the form LHS ... RHS!");
1290  getTrailingObjects<Stmt *>()[rhsOffset()] = reinterpret_cast<Stmt *>(Val);
1291  }
1292 
1293  Stmt *getSubStmt() { return getTrailingObjects<Stmt *>()[subStmtOffset()]; }
1294  const Stmt *getSubStmt() const {
1295  return getTrailingObjects<Stmt *>()[subStmtOffset()];
1296  }
1297 
1298  void setSubStmt(Stmt *S) {
1299  getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1300  }
1301 
1302  SourceLocation getBeginLoc() const { return getKeywordLoc(); }
1303  SourceLocation getEndLoc() const LLVM_READONLY {
1304  // Handle deeply nested case statements with iteration instead of recursion.
1305  const CaseStmt *CS = this;
1306  while (const auto *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
1307  CS = CS2;
1308 
1309  return CS->getSubStmt()->getEndLoc();
1310  }
1311 
1312  static bool classof(const Stmt *T) {
1313  return T->getStmtClass() == CaseStmtClass;
1314  }
1315 
1316  // Iterators
1318  return child_range(getTrailingObjects<Stmt *>(),
1319  getTrailingObjects<Stmt *>() +
1320  numTrailingObjects(OverloadToken<Stmt *>()));
1321  }
1322 };
1323 
1324 class DefaultStmt : public SwitchCase {
1325  Stmt *SubStmt;
1326 
1327 public:
1329  : SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
1330 
1331  /// Build an empty default statement.
1332  explicit DefaultStmt(EmptyShell Empty)
1333  : SwitchCase(DefaultStmtClass, Empty) {}
1334 
1335  Stmt *getSubStmt() { return SubStmt; }
1336  const Stmt *getSubStmt() const { return SubStmt; }
1337  void setSubStmt(Stmt *S) { SubStmt = S; }
1338 
1339  SourceLocation getDefaultLoc() const { return getKeywordLoc(); }
1340  void setDefaultLoc(SourceLocation L) { setKeywordLoc(L); }
1341 
1342  SourceLocation getBeginLoc() const { return getKeywordLoc(); }
1343  SourceLocation getEndLoc() const LLVM_READONLY {
1344  return SubStmt->getEndLoc();
1345  }
1346 
1347  static bool classof(const Stmt *T) {
1348  return T->getStmtClass() == DefaultStmtClass;
1349  }
1350 
1351  // Iterators
1352  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
1353 };
1354 
1355 SourceLocation SwitchCase::getEndLoc() const {
1356  if (const auto *CS = dyn_cast<CaseStmt>(this))
1357  return CS->getEndLoc();
1358  else if (const auto *DS = dyn_cast<DefaultStmt>(this))
1359  return DS->getEndLoc();
1360  llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1361 }
1362 
1363 Stmt *SwitchCase::getSubStmt() {
1364  if (auto *CS = dyn_cast<CaseStmt>(this))
1365  return CS->getSubStmt();
1366  else if (auto *DS = dyn_cast<DefaultStmt>(this))
1367  return DS->getSubStmt();
1368  llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1369 }
1370 
1371 /// LabelStmt - Represents a label, which has a substatement. For example:
1372 /// foo: return;
1373 class LabelStmt : public Stmt {
1374  LabelDecl *TheDecl;
1375  Stmt *SubStmt;
1376 
1377 public:
1378  /// Build a label statement.
1380  : Stmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) {
1381  setIdentLoc(IL);
1382  }
1383 
1384  /// Build an empty label statement.
1385  explicit LabelStmt(EmptyShell Empty) : Stmt(LabelStmtClass, Empty) {}
1386 
1387  SourceLocation getIdentLoc() const { return LabelStmtBits.IdentLoc; }
1388  void setIdentLoc(SourceLocation L) { LabelStmtBits.IdentLoc = L; }
1389 
1390  LabelDecl *getDecl() const { return TheDecl; }
1391  void setDecl(LabelDecl *D) { TheDecl = D; }
1392 
1393  const char *getName() const;
1394  Stmt *getSubStmt() { return SubStmt; }
1395 
1396  const Stmt *getSubStmt() const { return SubStmt; }
1397  void setSubStmt(Stmt *SS) { SubStmt = SS; }
1398 
1399  SourceLocation getBeginLoc() const { return getIdentLoc(); }
1400  SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
1401 
1402  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
1403 
1404  static bool classof(const Stmt *T) {
1405  return T->getStmtClass() == LabelStmtClass;
1406  }
1407 };
1408 
1409 /// Represents an attribute applied to a statement.
1410 ///
1411 /// Represents an attribute applied to a statement. For example:
1412 /// [[omp::for(...)]] for (...) { ... }
1413 class AttributedStmt final
1414  : public Stmt,
1415  private llvm::TrailingObjects<AttributedStmt, const Attr *> {
1416  friend class ASTStmtReader;
1417  friend TrailingObjects;
1418 
1419  Stmt *SubStmt;
1420 
1422  Stmt *SubStmt)
1423  : Stmt(AttributedStmtClass), SubStmt(SubStmt) {
1424  AttributedStmtBits.NumAttrs = Attrs.size();
1425  AttributedStmtBits.AttrLoc = Loc;
1426  std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
1427  }
1428 
1429  explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)
1430  : Stmt(AttributedStmtClass, Empty) {
1431  AttributedStmtBits.NumAttrs = NumAttrs;
1432  AttributedStmtBits.AttrLoc = SourceLocation{};
1433  std::fill_n(getAttrArrayPtr(), NumAttrs, nullptr);
1434  }
1435 
1436  const Attr *const *getAttrArrayPtr() const {
1437  return getTrailingObjects<const Attr *>();
1438  }
1439  const Attr **getAttrArrayPtr() { return getTrailingObjects<const Attr *>(); }
1440 
1441 public:
1442  static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,
1443  ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
1444 
1445  // Build an empty attributed statement.
1446  static AttributedStmt *CreateEmpty(const ASTContext &C, unsigned NumAttrs);
1447 
1448  SourceLocation getAttrLoc() const { return AttributedStmtBits.AttrLoc; }
1450  return llvm::makeArrayRef(getAttrArrayPtr(), AttributedStmtBits.NumAttrs);
1451  }
1452 
1453  Stmt *getSubStmt() { return SubStmt; }
1454  const Stmt *getSubStmt() const { return SubStmt; }
1455 
1456  SourceLocation getBeginLoc() const { return getAttrLoc(); }
1457  SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
1458 
1459  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
1460 
1461  static bool classof(const Stmt *T) {
1462  return T->getStmtClass() == AttributedStmtClass;
1463  }
1464 };
1465 
1466 /// IfStmt - This represents an if/then/else.
1467 class IfStmt final
1468  : public Stmt,
1469  private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
1470  friend TrailingObjects;
1471 
1472  // IfStmt is followed by several trailing objects, some of which optional.
1473  // Note that it would be more convenient to put the optional trailing
1474  // objects at then end but this would change the order of the children.
1475  // The trailing objects are in order:
1476  //
1477  // * A "Stmt *" for the init statement.
1478  // Present if and only if hasInitStorage().
1479  //
1480  // * A "Stmt *" for the condition variable.
1481  // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
1482  //
1483  // * A "Stmt *" for the condition.
1484  // Always present. This is in fact a "Expr *".
1485  //
1486  // * A "Stmt *" for the then statement.
1487  // Always present.
1488  //
1489  // * A "Stmt *" for the else statement.
1490  // Present if and only if hasElseStorage().
1491  //
1492  // * A "SourceLocation" for the location of the "else".
1493  // Present if and only if hasElseStorage().
1494  enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
1495  enum { NumMandatoryStmtPtr = 2 };
1496 
1497  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1498  return NumMandatoryStmtPtr + hasElseStorage() + hasVarStorage() +
1499  hasInitStorage();
1500  }
1501 
1502  unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
1503  return hasElseStorage();
1504  }
1505 
1506  unsigned initOffset() const { return InitOffset; }
1507  unsigned varOffset() const { return InitOffset + hasInitStorage(); }
1508  unsigned condOffset() const {
1509  return InitOffset + hasInitStorage() + hasVarStorage();
1510  }
1511  unsigned thenOffset() const { return condOffset() + ThenOffsetFromCond; }
1512  unsigned elseOffset() const { return condOffset() + ElseOffsetFromCond; }
1513 
1514  /// Build an if/then/else statement.
1515  IfStmt(const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init,
1516  VarDecl *Var, Expr *Cond, Stmt *Then, SourceLocation EL, Stmt *Else);
1517 
1518  /// Build an empty if/then/else statement.
1519  explicit IfStmt(EmptyShell Empty, bool HasElse, bool HasVar, bool HasInit);
1520 
1521 public:
1522  /// Create an IfStmt.
1523  static IfStmt *Create(const ASTContext &Ctx, SourceLocation IL,
1524  bool IsConstexpr, Stmt *Init, VarDecl *Var, Expr *Cond,
1525  Stmt *Then, SourceLocation EL = SourceLocation(),
1526  Stmt *Else = nullptr);
1527 
1528  /// Create an empty IfStmt optionally with storage for an else statement,
1529  /// condition variable and init expression.
1530  static IfStmt *CreateEmpty(const ASTContext &Ctx, bool HasElse, bool HasVar,
1531  bool HasInit);
1532 
1533  /// True if this IfStmt has the storage for an init statement.
1534  bool hasInitStorage() const { return IfStmtBits.HasInit; }
1535 
1536  /// True if this IfStmt has storage for a variable declaration.
1537  bool hasVarStorage() const { return IfStmtBits.HasVar; }
1538 
1539  /// True if this IfStmt has storage for an else statement.
1540  bool hasElseStorage() const { return IfStmtBits.HasElse; }
1541 
1543  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1544  }
1545 
1546  const Expr *getCond() const {
1547  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1548  }
1549 
1550  void setCond(Expr *Cond) {
1551  getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
1552  }
1553 
1554  Stmt *getThen() { return getTrailingObjects<Stmt *>()[thenOffset()]; }
1555  const Stmt *getThen() const {
1556  return getTrailingObjects<Stmt *>()[thenOffset()];
1557  }
1558 
1559  void setThen(Stmt *Then) {
1560  getTrailingObjects<Stmt *>()[thenOffset()] = Then;
1561  }
1562 
1564  return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
1565  : nullptr;
1566  }
1567 
1568  const Stmt *getElse() const {
1569  return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
1570  : nullptr;
1571  }
1572 
1573  void setElse(Stmt *Else) {
1574  assert(hasElseStorage() &&
1575  "This if statement has no storage for an else statement!");
1576  getTrailingObjects<Stmt *>()[elseOffset()] = Else;
1577  }
1578 
1579  /// Retrieve the variable declared in this "if" statement, if any.
1580  ///
1581  /// In the following example, "x" is the condition variable.
1582  /// \code
1583  /// if (int x = foo()) {
1584  /// printf("x is %d", x);
1585  /// }
1586  /// \endcode
1587  VarDecl *getConditionVariable();
1589  return const_cast<IfStmt *>(this)->getConditionVariable();
1590  }
1591 
1592  /// Set the condition variable for this if statement.
1593  /// The if statement must have storage for the condition variable.
1594  void setConditionVariable(const ASTContext &Ctx, VarDecl *V);
1595 
1596  /// If this IfStmt has a condition variable, return the faux DeclStmt
1597  /// associated with the creation of that condition variable.
1599  return hasVarStorage() ? static_cast<DeclStmt *>(
1600  getTrailingObjects<Stmt *>()[varOffset()])
1601  : nullptr;
1602  }
1603 
1605  return hasVarStorage() ? static_cast<DeclStmt *>(
1606  getTrailingObjects<Stmt *>()[varOffset()])
1607  : nullptr;
1608  }
1609 
1611  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
1612  : nullptr;
1613  }
1614 
1615  const Stmt *getInit() const {
1616  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
1617  : nullptr;
1618  }
1619 
1620  void setInit(Stmt *Init) {
1621  assert(hasInitStorage() &&
1622  "This if statement has no storage for an init statement!");
1623  getTrailingObjects<Stmt *>()[initOffset()] = Init;
1624  }
1625 
1626  SourceLocation getIfLoc() const { return IfStmtBits.IfLoc; }
1627  void setIfLoc(SourceLocation IfLoc) { IfStmtBits.IfLoc = IfLoc; }
1628 
1630  return hasElseStorage() ? *getTrailingObjects<SourceLocation>()
1631  : SourceLocation();
1632  }
1633 
1634  void setElseLoc(SourceLocation ElseLoc) {
1635  assert(hasElseStorage() &&
1636  "This if statement has no storage for an else statement!");
1637  *getTrailingObjects<SourceLocation>() = ElseLoc;
1638  }
1639 
1640  bool isConstexpr() const { return IfStmtBits.IsConstexpr; }
1641  void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; }
1642 
1643  bool isObjCAvailabilityCheck() const;
1644 
1645  SourceLocation getBeginLoc() const { return getIfLoc(); }
1646  SourceLocation getEndLoc() const LLVM_READONLY {
1647  if (getElse())
1648  return getElse()->getEndLoc();
1649  return getThen()->getEndLoc();
1650  }
1651 
1652  // Iterators over subexpressions. The iterators will include iterating
1653  // over the initialization expression referenced by the condition variable.
1655  return child_range(getTrailingObjects<Stmt *>(),
1656  getTrailingObjects<Stmt *>() +
1657  numTrailingObjects(OverloadToken<Stmt *>()));
1658  }
1659 
1660  static bool classof(const Stmt *T) {
1661  return T->getStmtClass() == IfStmtClass;
1662  }
1663 };
1664 
1665 /// SwitchStmt - This represents a 'switch' stmt.
1666 class SwitchStmt final : public Stmt,
1667  private llvm::TrailingObjects<SwitchStmt, Stmt *> {
1668  friend TrailingObjects;
1669 
1670  /// Points to a linked list of case and default statements.
1671  SwitchCase *FirstCase;
1672 
1673  // SwitchStmt is followed by several trailing objects,
1674  // some of which optional. Note that it would be more convenient to
1675  // put the optional trailing objects at the end but this would change
1676  // the order in children().
1677  // The trailing objects are in order:
1678  //
1679  // * A "Stmt *" for the init statement.
1680  // Present if and only if hasInitStorage().
1681  //
1682  // * A "Stmt *" for the condition variable.
1683  // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
1684  //
1685  // * A "Stmt *" for the condition.
1686  // Always present. This is in fact an "Expr *".
1687  //
1688  // * A "Stmt *" for the body.
1689  // Always present.
1690  enum { InitOffset = 0, BodyOffsetFromCond = 1 };
1691  enum { NumMandatoryStmtPtr = 2 };
1692 
1693  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1694  return NumMandatoryStmtPtr + hasInitStorage() + hasVarStorage();
1695  }
1696 
1697  unsigned initOffset() const { return InitOffset; }
1698  unsigned varOffset() const { return InitOffset + hasInitStorage(); }
1699  unsigned condOffset() const {
1700  return InitOffset + hasInitStorage() + hasVarStorage();
1701  }
1702  unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
1703 
1704  /// Build a switch statement.
1705  SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond);
1706 
1707  /// Build a empty switch statement.
1708  explicit SwitchStmt(EmptyShell Empty, bool HasInit, bool HasVar);
1709 
1710 public:
1711  /// Create a switch statement.
1712  static SwitchStmt *Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var,
1713  Expr *Cond);
1714 
1715  /// Create an empty switch statement optionally with storage for
1716  /// an init expression and a condition variable.
1717  static SwitchStmt *CreateEmpty(const ASTContext &Ctx, bool HasInit,
1718  bool HasVar);
1719 
1720  /// True if this SwitchStmt has storage for an init statement.
1721  bool hasInitStorage() const { return SwitchStmtBits.HasInit; }
1722 
1723  /// True if this SwitchStmt has storage for a condition variable.
1724  bool hasVarStorage() const { return SwitchStmtBits.HasVar; }
1725 
1727  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1728  }
1729 
1730  const Expr *getCond() const {
1731  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1732  }
1733 
1734  void setCond(Expr *Cond) {
1735  getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
1736  }
1737 
1738  Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; }
1739  const Stmt *getBody() const {
1740  return getTrailingObjects<Stmt *>()[bodyOffset()];
1741  }
1742 
1743  void setBody(Stmt *Body) {
1744  getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
1745  }
1746 
1748  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
1749  : nullptr;
1750  }
1751 
1752  const Stmt *getInit() const {
1753  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
1754  : nullptr;
1755  }
1756 
1757  void setInit(Stmt *Init) {
1758  assert(hasInitStorage() &&
1759  "This switch statement has no storage for an init statement!");
1760  getTrailingObjects<Stmt *>()[initOffset()] = Init;
1761  }
1762 
1763  /// Retrieve the variable declared in this "switch" statement, if any.
1764  ///
1765  /// In the following example, "x" is the condition variable.
1766  /// \code
1767  /// switch (int x = foo()) {
1768  /// case 0: break;
1769  /// // ...
1770  /// }
1771  /// \endcode
1772  VarDecl *getConditionVariable();
1774  return const_cast<SwitchStmt *>(this)->getConditionVariable();
1775  }
1776 
1777  /// Set the condition variable in this switch statement.
1778  /// The switch statement must have storage for it.
1779  void setConditionVariable(const ASTContext &Ctx, VarDecl *VD);
1780 
1781  /// If this SwitchStmt has a condition variable, return the faux DeclStmt
1782  /// associated with the creation of that condition variable.
1784  return hasVarStorage() ? static_cast<DeclStmt *>(
1785  getTrailingObjects<Stmt *>()[varOffset()])
1786  : nullptr;
1787  }
1788 
1790  return hasVarStorage() ? static_cast<DeclStmt *>(
1791  getTrailingObjects<Stmt *>()[varOffset()])
1792  : nullptr;
1793  }
1794 
1795  SwitchCase *getSwitchCaseList() { return FirstCase; }
1796  const SwitchCase *getSwitchCaseList() const { return FirstCase; }
1797  void setSwitchCaseList(SwitchCase *SC) { FirstCase = SC; }
1798 
1799  SourceLocation getSwitchLoc() const { return SwitchStmtBits.SwitchLoc; }
1800  void setSwitchLoc(SourceLocation L) { SwitchStmtBits.SwitchLoc = L; }
1801 
1802  void setBody(Stmt *S, SourceLocation SL) {
1803  setBody(S);
1804  setSwitchLoc(SL);
1805  }
1806 
1808  assert(!SC->getNextSwitchCase() &&
1809  "case/default already added to a switch");
1810  SC->setNextSwitchCase(FirstCase);
1811  FirstCase = SC;
1812  }
1813 
1814  /// Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a
1815  /// switch over an enum value then all cases have been explicitly covered.
1816  void setAllEnumCasesCovered() { SwitchStmtBits.AllEnumCasesCovered = true; }
1817 
1818  /// Returns true if the SwitchStmt is a switch of an enum value and all cases
1819  /// have been explicitly covered.
1820  bool isAllEnumCasesCovered() const {
1821  return SwitchStmtBits.AllEnumCasesCovered;
1822  }
1823 
1824  SourceLocation getBeginLoc() const { return getSwitchLoc(); }
1825  SourceLocation getEndLoc() const LLVM_READONLY {
1826  return getBody() ? getBody()->getEndLoc()
1827  : reinterpret_cast<const Stmt *>(getCond())->getEndLoc();
1828  }
1829 
1830  // Iterators
1832  return child_range(getTrailingObjects<Stmt *>(),
1833  getTrailingObjects<Stmt *>() +
1834  numTrailingObjects(OverloadToken<Stmt *>()));
1835  }
1836 
1837  static bool classof(const Stmt *T) {
1838  return T->getStmtClass() == SwitchStmtClass;
1839  }
1840 };
1841 
1842 /// WhileStmt - This represents a 'while' stmt.
1843 class WhileStmt final : public Stmt,
1844  private llvm::TrailingObjects<WhileStmt, Stmt *> {
1845  friend TrailingObjects;
1846 
1847  // WhileStmt is followed by several trailing objects,
1848  // some of which optional. Note that it would be more
1849  // convenient to put the optional trailing object at the end
1850  // but this would affect children().
1851  // The trailing objects are in order:
1852  //
1853  // * A "Stmt *" for the condition variable.
1854  // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
1855  //
1856  // * A "Stmt *" for the condition.
1857  // Always present. This is in fact an "Expr *".
1858  //
1859  // * A "Stmt *" for the body.
1860  // Always present.
1861  //
1862  enum { VarOffset = 0, BodyOffsetFromCond = 1 };
1863  enum { NumMandatoryStmtPtr = 2 };
1864 
1865  unsigned varOffset() const { return VarOffset; }
1866  unsigned condOffset() const { return VarOffset + hasVarStorage(); }
1867  unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
1868 
1869  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1870  return NumMandatoryStmtPtr + hasVarStorage();
1871  }
1872 
1873  /// Build a while statement.
1874  WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body,
1875  SourceLocation WL);
1876 
1877  /// Build an empty while statement.
1878  explicit WhileStmt(EmptyShell Empty, bool HasVar);
1879 
1880 public:
1881  /// Create a while statement.
1882  static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
1883  Stmt *Body, SourceLocation WL);
1884 
1885  /// Create an empty while statement optionally with storage for
1886  /// a condition variable.
1887  static WhileStmt *CreateEmpty(const ASTContext &Ctx, bool HasVar);
1888 
1889  /// True if this WhileStmt has storage for a condition variable.
1890  bool hasVarStorage() const { return WhileStmtBits.HasVar; }
1891 
1893  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1894  }
1895 
1896  const Expr *getCond() const {
1897  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1898  }
1899 
1900  void setCond(Expr *Cond) {
1901  getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
1902  }
1903 
1904  Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; }
1905  const Stmt *getBody() const {
1906  return getTrailingObjects<Stmt *>()[bodyOffset()];
1907  }
1908 
1909  void setBody(Stmt *Body) {
1910  getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
1911  }
1912 
1913  /// Retrieve the variable declared in this "while" statement, if any.
1914  ///
1915  /// In the following example, "x" is the condition variable.
1916  /// \code
1917  /// while (int x = random()) {
1918  /// // ...
1919  /// }
1920  /// \endcode
1921  VarDecl *getConditionVariable();
1923  return const_cast<WhileStmt *>(this)->getConditionVariable();
1924  }
1925 
1926  /// Set the condition variable of this while statement.
1927  /// The while statement must have storage for it.
1928  void setConditionVariable(const ASTContext &Ctx, VarDecl *V);
1929 
1930  /// If this WhileStmt has a condition variable, return the faux DeclStmt
1931  /// associated with the creation of that condition variable.
1933  return hasVarStorage() ? static_cast<DeclStmt *>(
1934  getTrailingObjects<Stmt *>()[varOffset()])
1935  : nullptr;
1936  }
1937 
1939  return hasVarStorage() ? static_cast<DeclStmt *>(
1940  getTrailingObjects<Stmt *>()[varOffset()])
1941  : nullptr;
1942  }
1943 
1944  SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; }
1945  void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; }
1946 
1947  SourceLocation getBeginLoc() const { return getWhileLoc(); }
1948  SourceLocation getEndLoc() const LLVM_READONLY {
1949  return getBody()->getEndLoc();
1950  }
1951 
1952  static bool classof(const Stmt *T) {
1953  return T->getStmtClass() == WhileStmtClass;
1954  }
1955 
1956  // Iterators
1958  return child_range(getTrailingObjects<Stmt *>(),
1959  getTrailingObjects<Stmt *>() +
1960  numTrailingObjects(OverloadToken<Stmt *>()));
1961  }
1962 };
1963 
1964 /// DoStmt - This represents a 'do/while' stmt.
1965 class DoStmt : public Stmt {
1966  enum { BODY, COND, END_EXPR };
1967  Stmt *SubExprs[END_EXPR];
1968  SourceLocation WhileLoc;
1969  SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
1970 
1971 public:
1973  SourceLocation RP)
1974  : Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
1975  setCond(Cond);
1976  setBody(Body);
1977  setDoLoc(DL);
1978  }
1979 
1980  /// Build an empty do-while statement.
1981  explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) {}
1982 
1983  Expr *getCond() { return reinterpret_cast<Expr *>(SubExprs[COND]); }
1984  const Expr *getCond() const {
1985  return reinterpret_cast<Expr *>(SubExprs[COND]);
1986  }
1987 
1988  void setCond(Expr *Cond) { SubExprs[COND] = reinterpret_cast<Stmt *>(Cond); }
1989 
1990  Stmt *getBody() { return SubExprs[BODY]; }
1991  const Stmt *getBody() const { return SubExprs[BODY]; }
1992  void setBody(Stmt *Body) { SubExprs[BODY] = Body; }
1993 
1994  SourceLocation getDoLoc() const { return DoStmtBits.DoLoc; }
1995  void setDoLoc(SourceLocation L) { DoStmtBits.DoLoc = L; }
1996  SourceLocation getWhileLoc() const { return WhileLoc; }
1997  void setWhileLoc(SourceLocation L) { WhileLoc = L; }
1998  SourceLocation getRParenLoc() const { return RParenLoc; }
1999  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2000 
2001  SourceLocation getBeginLoc() const { return getDoLoc(); }
2002  SourceLocation getEndLoc() const { return getRParenLoc(); }
2003 
2004  static bool classof(const Stmt *T) {
2005  return T->getStmtClass() == DoStmtClass;
2006  }
2007 
2008  // Iterators
2010  return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2011  }
2012 };
2013 
2014 /// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of
2015 /// the init/cond/inc parts of the ForStmt will be null if they were not
2016 /// specified in the source.
2017 class ForStmt : public Stmt {
2018  enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2019  Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
2020  SourceLocation LParenLoc, RParenLoc;
2021 
2022 public:
2023  ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
2024  Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
2025  SourceLocation RP);
2026 
2027  /// Build an empty for statement.
2028  explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) {}
2029 
2030  Stmt *getInit() { return SubExprs[INIT]; }
2031 
2032  /// Retrieve the variable declared in this "for" statement, if any.
2033  ///
2034  /// In the following example, "y" is the condition variable.
2035  /// \code
2036  /// for (int x = random(); int y = mangle(x); ++x) {
2037  /// // ...
2038  /// }
2039  /// \endcode
2040  VarDecl *getConditionVariable() const;
2041  void setConditionVariable(const ASTContext &C, VarDecl *V);
2042 
2043  /// If this ForStmt has a condition variable, return the faux DeclStmt
2044  /// associated with the creation of that condition variable.
2046  return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
2047  }
2048 
2049  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
2050  Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
2051  Stmt *getBody() { return SubExprs[BODY]; }
2052 
2053  const Stmt *getInit() const { return SubExprs[INIT]; }
2054  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
2055  const Expr *getInc() const { return reinterpret_cast<Expr*>(SubExprs[INC]); }
2056  const Stmt *getBody() const { return SubExprs[BODY]; }
2057 
2058  void setInit(Stmt *S) { SubExprs[INIT] = S; }
2059  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
2060  void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
2061  void setBody(Stmt *S) { SubExprs[BODY] = S; }
2062 
2063  SourceLocation getForLoc() const { return ForStmtBits.ForLoc; }
2064  void setForLoc(SourceLocation L) { ForStmtBits.ForLoc = L; }
2065  SourceLocation getLParenLoc() const { return LParenLoc; }
2066  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2067  SourceLocation getRParenLoc() const { return RParenLoc; }
2068  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2069 
2070  SourceLocation getBeginLoc() const { return getForLoc(); }
2071  SourceLocation getEndLoc() const { return getBody()->getEndLoc(); }
2072 
2073  static bool classof(const Stmt *T) {
2074  return T->getStmtClass() == ForStmtClass;
2075  }
2076 
2077  // Iterators
2079  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2080  }
2081 };
2082 
2083 /// GotoStmt - This represents a direct goto.
2084 class GotoStmt : public Stmt {
2085  LabelDecl *Label;
2086  SourceLocation LabelLoc;
2087 
2088 public:
2090  : Stmt(GotoStmtClass), Label(label), LabelLoc(LL) {
2091  setGotoLoc(GL);
2092  }
2093 
2094  /// Build an empty goto statement.
2095  explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) {}
2096 
2097  LabelDecl *getLabel() const { return Label; }
2098  void setLabel(LabelDecl *D) { Label = D; }
2099 
2100  SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; }
2101  void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; }
2102  SourceLocation getLabelLoc() const { return LabelLoc; }
2103  void setLabelLoc(SourceLocation L) { LabelLoc = L; }
2104 
2105  SourceLocation getBeginLoc() const { return getGotoLoc(); }
2106  SourceLocation getEndLoc() const { return getLabelLoc(); }
2107 
2108  static bool classof(const Stmt *T) {
2109  return T->getStmtClass() == GotoStmtClass;
2110  }
2111 
2112  // Iterators
2115  }
2116 };
2117 
2118 /// IndirectGotoStmt - This represents an indirect goto.
2119 class IndirectGotoStmt : public Stmt {
2120  SourceLocation StarLoc;
2121  Stmt *Target;
2122 
2123 public:
2125  : Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2126  setTarget(target);
2127  setGotoLoc(gotoLoc);
2128  }
2129 
2130  /// Build an empty indirect goto statement.
2132  : Stmt(IndirectGotoStmtClass, Empty) {}
2133 
2134  void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; }
2135  SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; }
2136  void setStarLoc(SourceLocation L) { StarLoc = L; }
2137  SourceLocation getStarLoc() const { return StarLoc; }
2138 
2139  Expr *getTarget() { return reinterpret_cast<Expr *>(Target); }
2140  const Expr *getTarget() const {
2141  return reinterpret_cast<const Expr *>(Target);
2142  }
2143  void setTarget(Expr *E) { Target = reinterpret_cast<Stmt *>(E); }
2144 
2145  /// getConstantTarget - Returns the fixed target of this indirect
2146  /// goto, if one exists.
2147  LabelDecl *getConstantTarget();
2148  const LabelDecl *getConstantTarget() const {
2149  return const_cast<IndirectGotoStmt *>(this)->getConstantTarget();
2150  }
2151 
2152  SourceLocation getBeginLoc() const { return getGotoLoc(); }
2153  SourceLocation getEndLoc() const LLVM_READONLY { return Target->getEndLoc(); }
2154 
2155  static bool classof(const Stmt *T) {
2156  return T->getStmtClass() == IndirectGotoStmtClass;
2157  }
2158 
2159  // Iterators
2160  child_range children() { return child_range(&Target, &Target + 1); }
2161 };
2162 
2163 /// ContinueStmt - This represents a continue.
2164 class ContinueStmt : public Stmt {
2165 public:
2166  ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) {
2167  setContinueLoc(CL);
2168  }
2169 
2170  /// Build an empty continue statement.
2171  explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {}
2172 
2173  SourceLocation getContinueLoc() const { return ContinueStmtBits.ContinueLoc; }
2174  void setContinueLoc(SourceLocation L) { ContinueStmtBits.ContinueLoc = L; }
2175 
2176  SourceLocation getBeginLoc() const { return getContinueLoc(); }
2177  SourceLocation getEndLoc() const { return getContinueLoc(); }
2178 
2179  static bool classof(const Stmt *T) {
2180  return T->getStmtClass() == ContinueStmtClass;
2181  }
2182 
2183  // Iterators
2186  }
2187 };
2188 
2189 /// BreakStmt - This represents a break.
2190 class BreakStmt : public Stmt {
2191 public:
2192  BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass) {
2193  setBreakLoc(BL);
2194  }
2195 
2196  /// Build an empty break statement.
2197  explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) {}
2198 
2199  SourceLocation getBreakLoc() const { return BreakStmtBits.BreakLoc; }
2200  void setBreakLoc(SourceLocation L) { BreakStmtBits.BreakLoc = L; }
2201 
2202  SourceLocation getBeginLoc() const { return getBreakLoc(); }
2203  SourceLocation getEndLoc() const { return getBreakLoc(); }
2204 
2205  static bool classof(const Stmt *T) {
2206  return T->getStmtClass() == BreakStmtClass;
2207  }
2208 
2209  // Iterators
2212  }
2213 };
2214 
2215 /// ReturnStmt - This represents a return, optionally of an expression:
2216 /// return;
2217 /// return 4;
2218 ///
2219 /// Note that GCC allows return with no argument in a function declared to
2220 /// return a value, and it allows returning a value in functions declared to
2221 /// return void. We explicitly model this in the AST, which means you can't
2222 /// depend on the return type of the function and the presence of an argument.
2223 class ReturnStmt final
2224  : public Stmt,
2225  private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
2226  friend TrailingObjects;
2227 
2228  /// The return expression.
2229  Stmt *RetExpr;
2230 
2231  // ReturnStmt is followed optionally by a trailing "const VarDecl *"
2232  // for the NRVO candidate. Present if and only if hasNRVOCandidate().
2233 
2234  /// True if this ReturnStmt has storage for an NRVO candidate.
2235  bool hasNRVOCandidate() const { return ReturnStmtBits.HasNRVOCandidate; }
2236 
2237  unsigned numTrailingObjects(OverloadToken<const VarDecl *>) const {
2238  return hasNRVOCandidate();
2239  }
2240 
2241  /// Build a return statement.
2242  ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate);
2243 
2244  /// Build an empty return statement.
2245  explicit ReturnStmt(EmptyShell Empty, bool HasNRVOCandidate);
2246 
2247 public:
2248  /// Create a return statement.
2249  static ReturnStmt *Create(const ASTContext &Ctx, SourceLocation RL, Expr *E,
2250  const VarDecl *NRVOCandidate);
2251 
2252  /// Create an empty return statement, optionally with
2253  /// storage for an NRVO candidate.
2254  static ReturnStmt *CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate);
2255 
2256  Expr *getRetValue() { return reinterpret_cast<Expr *>(RetExpr); }
2257  const Expr *getRetValue() const { return reinterpret_cast<Expr *>(RetExpr); }
2258  void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt *>(E); }
2259 
2260  /// Retrieve the variable that might be used for the named return
2261  /// value optimization.
2262  ///
2263  /// The optimization itself can only be performed if the variable is
2264  /// also marked as an NRVO object.
2265  const VarDecl *getNRVOCandidate() const {
2266  return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>()
2267  : nullptr;
2268  }
2269 
2270  /// Set the variable that might be used for the named return value
2271  /// optimization. The return statement must have storage for it,
2272  /// which is the case if and only if hasNRVOCandidate() is true.
2273  void setNRVOCandidate(const VarDecl *Var) {
2274  assert(hasNRVOCandidate() &&
2275  "This return statement has no storage for an NRVO candidate!");
2276  *getTrailingObjects<const VarDecl *>() = Var;
2277  }
2278 
2279  SourceLocation getReturnLoc() const { return ReturnStmtBits.RetLoc; }
2280  void setReturnLoc(SourceLocation L) { ReturnStmtBits.RetLoc = L; }
2281 
2282  SourceLocation getBeginLoc() const { return getReturnLoc(); }
2283  SourceLocation getEndLoc() const LLVM_READONLY {
2284  return RetExpr ? RetExpr->getEndLoc() : getReturnLoc();
2285  }
2286 
2287  static bool classof(const Stmt *T) {
2288  return T->getStmtClass() == ReturnStmtClass;
2289  }
2290 
2291  // Iterators
2293  if (RetExpr)
2294  return child_range(&RetExpr, &RetExpr + 1);
2296  }
2297 };
2298 
2299 /// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
2300 class AsmStmt : public Stmt {
2301 protected:
2302  friend class ASTStmtReader;
2303 
2305 
2306  /// True if the assembly statement does not have any input or output
2307  /// operands.
2308  bool IsSimple;
2309 
2310  /// If true, treat this inline assembly as having side effects.
2311  /// This assembly statement should not be optimized, deleted or moved.
2313 
2314  unsigned NumOutputs;
2315  unsigned NumInputs;
2316  unsigned NumClobbers;
2317 
2318  Stmt **Exprs = nullptr;
2319 
2320  AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile,
2321  unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
2322  : Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
2323  NumOutputs(numoutputs), NumInputs(numinputs),
2324  NumClobbers(numclobbers) {}
2325 
2326 public:
2327  /// Build an empty inline-assembly statement.
2328  explicit AsmStmt(StmtClass SC, EmptyShell Empty) : Stmt(SC, Empty) {}
2329 
2330  SourceLocation getAsmLoc() const { return AsmLoc; }
2331  void setAsmLoc(SourceLocation L) { AsmLoc = L; }
2332 
2333  bool isSimple() const { return IsSimple; }
2334  void setSimple(bool V) { IsSimple = V; }
2335 
2336  bool isVolatile() const { return IsVolatile; }
2337  void setVolatile(bool V) { IsVolatile = V; }
2338 
2339  SourceLocation getBeginLoc() const LLVM_READONLY { return {}; }
2340  SourceLocation getEndLoc() const LLVM_READONLY { return {}; }
2341 
2342  //===--- Asm String Analysis ---===//
2343 
2344  /// Assemble final IR asm string.
2345  std::string generateAsmString(const ASTContext &C) const;
2346 
2347  //===--- Output operands ---===//
2348 
2349  unsigned getNumOutputs() const { return NumOutputs; }
2350 
2351  /// getOutputConstraint - Return the constraint string for the specified
2352  /// output operand. All output constraints are known to be non-empty (either
2353  /// '=' or '+').
2354  StringRef getOutputConstraint(unsigned i) const;
2355 
2356  /// isOutputPlusConstraint - Return true if the specified output constraint
2357  /// is a "+" constraint (which is both an input and an output) or false if it
2358  /// is an "=" constraint (just an output).
2359  bool isOutputPlusConstraint(unsigned i) const {
2360  return getOutputConstraint(i)[0] == '+';
2361  }
2362 
2363  const Expr *getOutputExpr(unsigned i) const;
2364 
2365  /// getNumPlusOperands - Return the number of output operands that have a "+"
2366  /// constraint.
2367  unsigned getNumPlusOperands() const;
2368 
2369  //===--- Input operands ---===//
2370 
2371  unsigned getNumInputs() const { return NumInputs; }
2372 
2373  /// getInputConstraint - Return the specified input constraint. Unlike output
2374  /// constraints, these can be empty.
2375  StringRef getInputConstraint(unsigned i) const;
2376 
2377  const Expr *getInputExpr(unsigned i) const;
2378 
2379  //===--- Other ---===//
2380 
2381  unsigned getNumClobbers() const { return NumClobbers; }
2382  StringRef getClobber(unsigned i) const;
2383 
2384  static bool classof(const Stmt *T) {
2385  return T->getStmtClass() == GCCAsmStmtClass ||
2386  T->getStmtClass() == MSAsmStmtClass;
2387  }
2388 
2389  // Input expr iterators.
2390 
2393  using inputs_range = llvm::iterator_range<inputs_iterator>;
2394  using inputs_const_range = llvm::iterator_range<const_inputs_iterator>;
2395 
2397  return &Exprs[0] + NumOutputs;
2398  }
2399 
2401  return &Exprs[0] + NumOutputs + NumInputs;
2402  }
2403 
2404  inputs_range inputs() { return inputs_range(begin_inputs(), end_inputs()); }
2405 
2407  return &Exprs[0] + NumOutputs;
2408  }
2409 
2411  return &Exprs[0] + NumOutputs + NumInputs;
2412  }
2413 
2415  return inputs_const_range(begin_inputs(), end_inputs());
2416  }
2417 
2418  // Output expr iterators.
2419 
2422  using outputs_range = llvm::iterator_range<outputs_iterator>;
2423  using outputs_const_range = llvm::iterator_range<const_outputs_iterator>;
2424 
2426  return &Exprs[0];
2427  }
2428 
2430  return &Exprs[0] + NumOutputs;
2431  }
2432 
2434  return outputs_range(begin_outputs(), end_outputs());
2435  }
2436 
2438  return &Exprs[0];
2439  }
2440 
2442  return &Exprs[0] + NumOutputs;
2443  }
2444 
2446  return outputs_const_range(begin_outputs(), end_outputs());
2447  }
2448 
2450  return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
2451  }
2452 };
2453 
2454 /// This represents a GCC inline-assembly statement extension.
2455 class GCCAsmStmt : public AsmStmt {
2456  friend class ASTStmtReader;
2457 
2458  SourceLocation RParenLoc;
2459  StringLiteral *AsmStr;
2460 
2461  // FIXME: If we wanted to, we could allocate all of these in one big array.
2462  StringLiteral **Constraints = nullptr;
2463  StringLiteral **Clobbers = nullptr;
2464  IdentifierInfo **Names = nullptr;
2465 
2466 public:
2467  GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple,
2468  bool isvolatile, unsigned numoutputs, unsigned numinputs,
2469  IdentifierInfo **names, StringLiteral **constraints, Expr **exprs,
2470  StringLiteral *asmstr, unsigned numclobbers,
2471  StringLiteral **clobbers, SourceLocation rparenloc);
2472 
2473  /// Build an empty inline-assembly statement.
2474  explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty) {}
2475 
2476  SourceLocation getRParenLoc() const { return RParenLoc; }
2477  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2478 
2479  //===--- Asm String Analysis ---===//
2480 
2481  const StringLiteral *getAsmString() const { return AsmStr; }
2482  StringLiteral *getAsmString() { return AsmStr; }
2483  void setAsmString(StringLiteral *E) { AsmStr = E; }
2484 
2485  /// AsmStringPiece - this is part of a decomposed asm string specification
2486  /// (for use with the AnalyzeAsmString function below). An asm string is
2487  /// considered to be a concatenation of these parts.
2489  public:
2490  enum Kind {
2491  String, // String in .ll asm string form, "$" -> "$$" and "%%" -> "%".
2492  Operand // Operand reference, with optional modifier %c4.
2493  };
2494 
2495  private:
2496  Kind MyKind;
2497  std::string Str;
2498  unsigned OperandNo;
2499 
2500  // Source range for operand references.
2501  CharSourceRange Range;
2502 
2503  public:
2504  AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {}
2505  AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin,
2507  : MyKind(Operand), Str(S), OperandNo(OpNo),
2508  Range(CharSourceRange::getCharRange(Begin, End)) {}
2509 
2510  bool isString() const { return MyKind == String; }
2511  bool isOperand() const { return MyKind == Operand; }
2512 
2513  const std::string &getString() const { return Str; }
2514 
2515  unsigned getOperandNo() const {
2516  assert(isOperand());
2517  return OperandNo;
2518  }
2519 
2521  assert(isOperand() && "Range is currently used only for Operands.");
2522  return Range;
2523  }
2524 
2525  /// getModifier - Get the modifier for this operand, if present. This
2526  /// returns '\0' if there was no modifier.
2527  char getModifier() const;
2528  };
2529 
2530  /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
2531  /// it into pieces. If the asm string is erroneous, emit errors and return
2532  /// true, otherwise return false. This handles canonicalization and
2533  /// translation of strings from GCC syntax to LLVM IR syntax, and handles
2534  //// flattening of named references like %[foo] to Operand AsmStringPiece's.
2535  unsigned AnalyzeAsmString(SmallVectorImpl<AsmStringPiece> &Pieces,
2536  const ASTContext &C, unsigned &DiagOffs) const;
2537 
2538  /// Assemble final IR asm string.
2539  std::string generateAsmString(const ASTContext &C) const;
2540 
2541  //===--- Output operands ---===//
2542 
2543  IdentifierInfo *getOutputIdentifier(unsigned i) const { return Names[i]; }
2544 
2545  StringRef getOutputName(unsigned i) const {
2546  if (IdentifierInfo *II = getOutputIdentifier(i))
2547  return II->getName();
2548 
2549  return {};
2550  }
2551 
2552  StringRef getOutputConstraint(unsigned i) const;
2553 
2554  const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
2555  return Constraints[i];
2556  }
2558  return Constraints[i];
2559  }
2560 
2561  Expr *getOutputExpr(unsigned i);
2562 
2563  const Expr *getOutputExpr(unsigned i) const {
2564  return const_cast<GCCAsmStmt*>(this)->getOutputExpr(i);
2565  }
2566 
2567  //===--- Input operands ---===//
2568 
2569  IdentifierInfo *getInputIdentifier(unsigned i) const {
2570  return Names[i + NumOutputs];
2571  }
2572 
2573  StringRef getInputName(unsigned i) const {
2574  if (IdentifierInfo *II = getInputIdentifier(i))
2575  return II->getName();
2576 
2577  return {};
2578  }
2579 
2580  StringRef getInputConstraint(unsigned i) const;
2581 
2582  const StringLiteral *getInputConstraintLiteral(unsigned i) const {
2583  return Constraints[i + NumOutputs];
2584  }
2586  return Constraints[i + NumOutputs];
2587  }
2588 
2589  Expr *getInputExpr(unsigned i);
2590  void setInputExpr(unsigned i, Expr *E);
2591 
2592  const Expr *getInputExpr(unsigned i) const {
2593  return const_cast<GCCAsmStmt*>(this)->getInputExpr(i);
2594  }
2595 
2596 private:
2597  void setOutputsAndInputsAndClobbers(const ASTContext &C,
2598  IdentifierInfo **Names,
2599  StringLiteral **Constraints,
2600  Stmt **Exprs,
2601  unsigned NumOutputs,
2602  unsigned NumInputs,
2603  StringLiteral **Clobbers,
2604  unsigned NumClobbers);
2605 
2606 public:
2607  //===--- Other ---===//
2608 
2609  /// getNamedOperand - Given a symbolic operand reference like %[foo],
2610  /// translate this into a numeric value needed to reference the same operand.
2611  /// This returns -1 if the operand name is invalid.
2612  int getNamedOperand(StringRef SymbolicName) const;
2613 
2614  StringRef getClobber(unsigned i) const;
2615 
2616  StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; }
2617  const StringLiteral *getClobberStringLiteral(unsigned i) const {
2618  return Clobbers[i];
2619  }
2620 
2621  SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; }
2622  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
2623 
2624  static bool classof(const Stmt *T) {
2625  return T->getStmtClass() == GCCAsmStmtClass;
2626  }
2627 };
2628 
2629 /// This represents a Microsoft inline-assembly statement extension.
2630 class MSAsmStmt : public AsmStmt {
2631  friend class ASTStmtReader;
2632 
2633  SourceLocation LBraceLoc, EndLoc;
2634  StringRef AsmStr;
2635 
2636  unsigned NumAsmToks = 0;
2637 
2638  Token *AsmToks = nullptr;
2639  StringRef *Constraints = nullptr;
2640  StringRef *Clobbers = nullptr;
2641 
2642 public:
2643  MSAsmStmt(const ASTContext &C, SourceLocation asmloc,
2644  SourceLocation lbraceloc, bool issimple, bool isvolatile,
2645  ArrayRef<Token> asmtoks, unsigned numoutputs, unsigned numinputs,
2646  ArrayRef<StringRef> constraints,
2647  ArrayRef<Expr*> exprs, StringRef asmstr,
2648  ArrayRef<StringRef> clobbers, SourceLocation endloc);
2649 
2650  /// Build an empty MS-style inline-assembly statement.
2651  explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty) {}
2652 
2653  SourceLocation getLBraceLoc() const { return LBraceLoc; }
2654  void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
2655  SourceLocation getEndLoc() const { return EndLoc; }
2656  void setEndLoc(SourceLocation L) { EndLoc = L; }
2657 
2658  bool hasBraces() const { return LBraceLoc.isValid(); }
2659 
2660  unsigned getNumAsmToks() { return NumAsmToks; }
2661  Token *getAsmToks() { return AsmToks; }
2662 
2663  //===--- Asm String Analysis ---===//
2664  StringRef getAsmString() const { return AsmStr; }
2665 
2666  /// Assemble final IR asm string.
2667  std::string generateAsmString(const ASTContext &C) const;
2668 
2669  //===--- Output operands ---===//
2670 
2671  StringRef getOutputConstraint(unsigned i) const {
2672  assert(i < NumOutputs);
2673  return Constraints[i];
2674  }
2675 
2676  Expr *getOutputExpr(unsigned i);
2677 
2678  const Expr *getOutputExpr(unsigned i) const {
2679  return const_cast<MSAsmStmt*>(this)->getOutputExpr(i);
2680  }
2681 
2682  //===--- Input operands ---===//
2683 
2684  StringRef getInputConstraint(unsigned i) const {
2685  assert(i < NumInputs);
2686  return Constraints[i + NumOutputs];
2687  }
2688 
2689  Expr *getInputExpr(unsigned i);
2690  void setInputExpr(unsigned i, Expr *E);
2691 
2692  const Expr *getInputExpr(unsigned i) const {
2693  return const_cast<MSAsmStmt*>(this)->getInputExpr(i);
2694  }
2695 
2696  //===--- Other ---===//
2697 
2699  return llvm::makeArrayRef(Constraints, NumInputs + NumOutputs);
2700  }
2701 
2703  return llvm::makeArrayRef(Clobbers, NumClobbers);
2704  }
2705 
2707  return llvm::makeArrayRef(reinterpret_cast<Expr**>(Exprs),
2708  NumInputs + NumOutputs);
2709  }
2710 
2711  StringRef getClobber(unsigned i) const { return getClobbers()[i]; }
2712 
2713 private:
2714  void initialize(const ASTContext &C, StringRef AsmString,
2715  ArrayRef<Token> AsmToks, ArrayRef<StringRef> Constraints,
2716  ArrayRef<Expr*> Exprs, ArrayRef<StringRef> Clobbers);
2717 
2718 public:
2719  SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; }
2720 
2721  static bool classof(const Stmt *T) {
2722  return T->getStmtClass() == MSAsmStmtClass;
2723  }
2724 
2726  return child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]);
2727  }
2728 };
2729 
2730 class SEHExceptStmt : public Stmt {
2731  friend class ASTReader;
2732  friend class ASTStmtReader;
2733 
2734  SourceLocation Loc;
2735  Stmt *Children[2];
2736 
2737  enum { FILTER_EXPR, BLOCK };
2738 
2739  SEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block);
2740  explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) {}
2741 
2742 public:
2743  static SEHExceptStmt* Create(const ASTContext &C,
2744  SourceLocation ExceptLoc,
2745  Expr *FilterExpr,
2746  Stmt *Block);
2747 
2748  SourceLocation getBeginLoc() const LLVM_READONLY { return getExceptLoc(); }
2749 
2750  SourceLocation getExceptLoc() const { return Loc; }
2751  SourceLocation getEndLoc() const { return getBlock()->getEndLoc(); }
2752 
2753  Expr *getFilterExpr() const {
2754  return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
2755  }
2756 
2758  return cast<CompoundStmt>(Children[BLOCK]);
2759  }
2760 
2762  return child_range(Children, Children+2);
2763  }
2764 
2765  static bool classof(const Stmt *T) {
2766  return T->getStmtClass() == SEHExceptStmtClass;
2767  }
2768 };
2769 
2770 class SEHFinallyStmt : public Stmt {
2771  friend class ASTReader;
2772  friend class ASTStmtReader;
2773 
2774  SourceLocation Loc;
2775  Stmt *Block;
2776 
2777  SEHFinallyStmt(SourceLocation Loc, Stmt *Block);
2778  explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) {}
2779 
2780 public:
2781  static SEHFinallyStmt* Create(const ASTContext &C,
2782  SourceLocation FinallyLoc,
2783  Stmt *Block);
2784 
2785  SourceLocation getBeginLoc() const LLVM_READONLY { return getFinallyLoc(); }
2786 
2787  SourceLocation getFinallyLoc() const { return Loc; }
2788  SourceLocation getEndLoc() const { return Block->getEndLoc(); }
2789 
2790  CompoundStmt *getBlock() const { return cast<CompoundStmt>(Block); }
2791 
2793  return child_range(&Block,&Block+1);
2794  }
2795 
2796  static bool classof(const Stmt *T) {
2797  return T->getStmtClass() == SEHFinallyStmtClass;
2798  }
2799 };
2800 
2801 class SEHTryStmt : public Stmt {
2802  friend class ASTReader;
2803  friend class ASTStmtReader;
2804 
2805  bool IsCXXTry;
2806  SourceLocation TryLoc;
2807  Stmt *Children[2];
2808 
2809  enum { TRY = 0, HANDLER = 1 };
2810 
2811  SEHTryStmt(bool isCXXTry, // true if 'try' otherwise '__try'
2812  SourceLocation TryLoc,
2813  Stmt *TryBlock,
2814  Stmt *Handler);
2815 
2816  explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) {}
2817 
2818 public:
2819  static SEHTryStmt* Create(const ASTContext &C, bool isCXXTry,
2820  SourceLocation TryLoc, Stmt *TryBlock,
2821  Stmt *Handler);
2822 
2823  SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); }
2824 
2825  SourceLocation getTryLoc() const { return TryLoc; }
2826  SourceLocation getEndLoc() const { return Children[HANDLER]->getEndLoc(); }
2827 
2828  bool getIsCXXTry() const { return IsCXXTry; }
2829 
2831  return cast<CompoundStmt>(Children[TRY]);
2832  }
2833 
2834  Stmt *getHandler() const { return Children[HANDLER]; }
2835 
2836  /// Returns 0 if not defined
2837  SEHExceptStmt *getExceptHandler() const;
2838  SEHFinallyStmt *getFinallyHandler() const;
2839 
2841  return child_range(Children, Children+2);
2842  }
2843 
2844  static bool classof(const Stmt *T) {
2845  return T->getStmtClass() == SEHTryStmtClass;
2846  }
2847 };
2848 
2849 /// Represents a __leave statement.
2850 class SEHLeaveStmt : public Stmt {
2851  SourceLocation LeaveLoc;
2852 
2853 public:
2855  : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
2856 
2857  /// Build an empty __leave statement.
2858  explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) {}
2859 
2860  SourceLocation getLeaveLoc() const { return LeaveLoc; }
2861  void setLeaveLoc(SourceLocation L) { LeaveLoc = L; }
2862 
2863  SourceLocation getBeginLoc() const LLVM_READONLY { return LeaveLoc; }
2864  SourceLocation getEndLoc() const LLVM_READONLY { return LeaveLoc; }
2865 
2866  static bool classof(const Stmt *T) {
2867  return T->getStmtClass() == SEHLeaveStmtClass;
2868  }
2869 
2870  // Iterators
2873  }
2874 };
2875 
2876 /// This captures a statement into a function. For example, the following
2877 /// pragma annotated compound statement can be represented as a CapturedStmt,
2878 /// and this compound statement is the body of an anonymous outlined function.
2879 /// @code
2880 /// #pragma omp parallel
2881 /// {
2882 /// compute();
2883 /// }
2884 /// @endcode
2885 class CapturedStmt : public Stmt {
2886 public:
2887  /// The different capture forms: by 'this', by reference, capture for
2888  /// variable-length array type etc.
2894  };
2895 
2896  /// Describes the capture of either a variable, or 'this', or
2897  /// variable-length array type.
2898  class Capture {
2899  llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
2900  SourceLocation Loc;
2901 
2902  public:
2903  friend class ASTStmtReader;
2904 
2905  /// Create a new capture.
2906  ///
2907  /// \param Loc The source location associated with this capture.
2908  ///
2909  /// \param Kind The kind of capture (this, ByRef, ...).
2910  ///
2911  /// \param Var The variable being captured, or null if capturing this.
2913  VarDecl *Var = nullptr);
2914 
2915  /// Determine the kind of capture.
2916  VariableCaptureKind getCaptureKind() const;
2917 
2918  /// Retrieve the source location at which the variable or 'this' was
2919  /// first used.
2920  SourceLocation getLocation() const { return Loc; }
2921 
2922  /// Determine whether this capture handles the C++ 'this' pointer.
2923  bool capturesThis() const { return getCaptureKind() == VCK_This; }
2924 
2925  /// Determine whether this capture handles a variable (by reference).
2926  bool capturesVariable() const { return getCaptureKind() == VCK_ByRef; }
2927 
2928  /// Determine whether this capture handles a variable by copy.
2929  bool capturesVariableByCopy() const {
2930  return getCaptureKind() == VCK_ByCopy;
2931  }
2932 
2933  /// Determine whether this capture handles a variable-length array
2934  /// type.
2936  return getCaptureKind() == VCK_VLAType;
2937  }
2938 
2939  /// Retrieve the declaration of the variable being captured.
2940  ///
2941  /// This operation is only valid if this capture captures a variable.
2942  VarDecl *getCapturedVar() const;
2943  };
2944 
2945 private:
2946  /// The number of variable captured, including 'this'.
2947  unsigned NumCaptures;
2948 
2949  /// The pointer part is the implicit the outlined function and the
2950  /// int part is the captured region kind, 'CR_Default' etc.
2951  llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
2952 
2953  /// The record for captured variables, a RecordDecl or CXXRecordDecl.
2954  RecordDecl *TheRecordDecl = nullptr;
2955 
2956  /// Construct a captured statement.
2958  ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD);
2959 
2960  /// Construct an empty captured statement.
2961  CapturedStmt(EmptyShell Empty, unsigned NumCaptures);
2962 
2963  Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); }
2964 
2965  Stmt *const *getStoredStmts() const {
2966  return reinterpret_cast<Stmt *const *>(this + 1);
2967  }
2968 
2969  Capture *getStoredCaptures() const;
2970 
2971  void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; }
2972 
2973 public:
2974  friend class ASTStmtReader;
2975 
2976  static CapturedStmt *Create(const ASTContext &Context, Stmt *S,
2977  CapturedRegionKind Kind,
2978  ArrayRef<Capture> Captures,
2979  ArrayRef<Expr *> CaptureInits,
2980  CapturedDecl *CD, RecordDecl *RD);
2981 
2982  static CapturedStmt *CreateDeserialized(const ASTContext &Context,
2983  unsigned NumCaptures);
2984 
2985  /// Retrieve the statement being captured.
2986  Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; }
2987  const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; }
2988 
2989  /// Retrieve the outlined function declaration.
2990  CapturedDecl *getCapturedDecl();
2991  const CapturedDecl *getCapturedDecl() const;
2992 
2993  /// Set the outlined function declaration.
2994  void setCapturedDecl(CapturedDecl *D);
2995 
2996  /// Retrieve the captured region kind.
2997  CapturedRegionKind getCapturedRegionKind() const;
2998 
2999  /// Set the captured region kind.
3000  void setCapturedRegionKind(CapturedRegionKind Kind);
3001 
3002  /// Retrieve the record declaration for captured variables.
3003  const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; }
3004 
3005  /// Set the record declaration for captured variables.
3007  assert(D && "null RecordDecl");
3008  TheRecordDecl = D;
3009  }
3010 
3011  /// True if this variable has been captured.
3012  bool capturesVariable(const VarDecl *Var) const;
3013 
3014  /// An iterator that walks over the captures.
3017  using capture_range = llvm::iterator_range<capture_iterator>;
3018  using capture_const_range = llvm::iterator_range<const_capture_iterator>;
3019 
3021  return capture_range(capture_begin(), capture_end());
3022  }
3024  return capture_const_range(capture_begin(), capture_end());
3025  }
3026 
3027  /// Retrieve an iterator pointing to the first capture.
3028  capture_iterator capture_begin() { return getStoredCaptures(); }
3029  const_capture_iterator capture_begin() const { return getStoredCaptures(); }
3030 
3031  /// Retrieve an iterator pointing past the end of the sequence of
3032  /// captures.
3034  return getStoredCaptures() + NumCaptures;
3035  }
3036 
3037  /// Retrieve the number of captures, including 'this'.
3038  unsigned capture_size() const { return NumCaptures; }
3039 
3040  /// Iterator that walks over the capture initialization arguments.
3042  using capture_init_range = llvm::iterator_range<capture_init_iterator>;
3043 
3044  /// Const iterator that walks over the capture initialization
3045  /// arguments.
3047  using const_capture_init_range =
3048  llvm::iterator_range<const_capture_init_iterator>;
3049 
3051  return capture_init_range(capture_init_begin(), capture_init_end());
3052  }
3053 
3055  return const_capture_init_range(capture_init_begin(), capture_init_end());
3056  }
3057 
3058  /// Retrieve the first initialization argument.
3060  return reinterpret_cast<Expr **>(getStoredStmts());
3061  }
3062 
3064  return reinterpret_cast<Expr *const *>(getStoredStmts());
3065  }
3066 
3067  /// Retrieve the iterator pointing one past the last initialization
3068  /// argument.
3070  return capture_init_begin() + NumCaptures;
3071  }
3072 
3074  return capture_init_begin() + NumCaptures;
3075  }
3076 
3077  SourceLocation getBeginLoc() const LLVM_READONLY {
3078  return getCapturedStmt()->getBeginLoc();
3079  }
3080 
3081  SourceLocation getEndLoc() const LLVM_READONLY {
3082  return getCapturedStmt()->getEndLoc();
3083  }
3084 
3085  SourceRange getSourceRange() const LLVM_READONLY {
3086  return getCapturedStmt()->getSourceRange();
3087  }
3088 
3089  static bool classof(const Stmt *T) {
3090  return T->getStmtClass() == CapturedStmtClass;
3091  }
3092 
3094 };
3095 
3096 } // namespace clang
3097 
3098 #endif // LLVM_CLANG_AST_STMT_H
SourceLocation getRParenLoc() const
Definition: Stmt.h:1998
child_iterator child_begin()
Definition: Stmt.h:888
Expr * getInc()
Definition: Stmt.h:2050
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1825
static std::enable_if< std::is_base_of< Attr, AttrInfo >::value, SourceLocation >::type getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
void setCond(Expr *Cond)
Definition: Stmt.h:1900
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1518
GotoStmt(EmptyShell Empty)
Build an empty goto statement.
Definition: Stmt.h:2095
SourceLocation getRBracLoc() const
Definition: Stmt.h:1114
APFloatSemantics
Definition: Stmt.h:351
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:2569
static bool classof(const Stmt *T)
Definition: Stmt.h:1660
child_range children()
Definition: Stmt.h:1831
SourceLocation getRParenLoc() const
Definition: Stmt.h:2476
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:591
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2455
Stmt * body_back()
Definition: Stmt.h:1059
SourceLocation getBeginLoc() const
Definition: Stmt.h:2070
const Stmt * getElse() const
Definition: Stmt.h:1568
body_iterator body_end()
Definition: Stmt.h:1056
unsigned getNumInputs() const
Definition: Stmt.h:2371
SourceLocation getBeginLoc() const
Definition: Stmt.h:2282
CompoundStmt * getBlock() const
Definition: Stmt.h:2790
SourceLocation getForLoc() const
Definition: Stmt.h:2063
SourceLocation getEndLoc() const
Definition: Stmt.h:2177
const Stmt * getBody() const
Definition: Stmt.h:1991
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument.
Definition: Stmt.h:3059
capture_const_range captures() const
Definition: Stmt.h:3023
const_child_iterator child_end() const
Definition: Stmt.h:892
CXXDeleteExprBitfields CXXDeleteExprBits
Definition: Stmt.h:720
ConstExprIterator(const Stmt *const *I)
Definition: Stmt.h:782
DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt)
Definition: Stmt.h:1328
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
Definition: Stmt.h:1249
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
Definition: Stmt.h:2273
static bool classof(const Stmt *T)
Definition: Stmt.h:2721
Expr * getCond()
Definition: Stmt.h:1892
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
Definition: opencl-c.h:68
inputs_range inputs()
Definition: Stmt.h:2404
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2355
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
Definition: Stmt.h:1537
unsigned getNumAsmToks()
Definition: Stmt.h:2660
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:1102
outputs_iterator end_outputs()
Definition: Stmt.h:2429
const DeclStmt * getConditionVariableDeclStmt() const
If this ForStmt has a condition variable, return the faux DeclStmt associated with the creation of th...
Definition: Stmt.h:2045
CXXThisExprBitfields CXXThisExprBits
Definition: Stmt.h:716
IndirectGotoStmt(EmptyShell Empty)
Build an empty indirect goto statement.
Definition: Stmt.h:2131
std::reverse_iterator< const_body_iterator > const_reverse_body_iterator
Definition: Stmt.h:1100
Stmt - This represents one statement.
Definition: Stmt.h:66
SourceLocation getEndLoc() const
Definition: Stmt.h:2071
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1467
AsmStmt(StmtClass SC, EmptyShell Empty)
Build an empty inline-assembly statement.
Definition: Stmt.h:2328
bool capturesThis() const
Determine whether this capture handles the C++ &#39;this&#39; pointer.
Definition: Stmt.h:2923
unsigned getNumOutputs() const
Definition: Stmt.h:2349
llvm::iterator_range< body_iterator > body_range
Definition: Stmt.h:1052
ContinueStmt(EmptyShell Empty)
Build an empty continue statement.
Definition: Stmt.h:2171
const StringLiteral * getAsmString() const
Definition: Stmt.h:2481
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:2477
void setContinueLoc(SourceLocation L)
Definition: Stmt.h:2174
iterator end()
Definition: DeclGroup.h:106
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:87
void setDeclGroup(DeclGroupRef DGR)
Definition: Stmt.h:943
bool hasLeadingEmptyMacro() const
Definition: Stmt.h:1004
LabelStmtBitfields LabelStmtBits
Definition: Stmt.h:682
FloatingLiteralBitfields FloatingLiteralBits
Definition: Stmt.h:699
NullStmt(EmptyShell Empty)
Build an empty null statement.
Definition: Stmt.h:999
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.h:2678
SourceLocation getIdentLoc() const
Definition: Stmt.h:1387
Represents an attribute applied to a statement.
Definition: Stmt.h:1413
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.h:2563
llvm::iterator_range< child_iterator > child_range
Definition: Stmt.h:878
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Definition: Stmt.h:3003
DeclRefExprBitfields DeclRefExprBits
Definition: Stmt.h:698
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1257
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:949
unsigned NumOutputs
Definition: Stmt.h:2314
bool getIsCXXTry() const
Definition: Stmt.h:2828
child_range children()
Definition: Stmt.h:2871
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void setSwitchCaseList(SwitchCase *SC)
Definition: Stmt.h:1797
NullStmt(SourceLocation L, bool hasLeadingEmptyMacro=false)
Definition: Stmt.h:992
bool hasVarStorage() const
True if this SwitchStmt has storage for a condition variable.
Definition: Stmt.h:1724
void setStartLoc(SourceLocation L)
Definition: Stmt.h:945
SourceLocation getGotoLoc() const
Definition: Stmt.h:2135
void setForLoc(SourceLocation L)
Definition: Stmt.h:2064
const_child_iterator child_begin() const
Definition: Stmt.h:891
Stmt * getSubStmt()
Definition: Stmt.h:1335
Represents a variable declaration or definition.
Definition: Decl.h:812
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
Definition: Stmt.h:2265
SourceLocation getLParenLoc() const
Definition: Stmt.h:2065
static bool classof(const Stmt *T)
Definition: Stmt.h:1116
void setAsmLoc(SourceLocation L)
Definition: Stmt.h:2331
ExprIterator(Stmt **I)
Definition: Stmt.h:767
AttributedStmtBitfields AttributedStmtBits
Definition: Stmt.h:683
bool hasInitStorage() const
True if this SwitchStmt has storage for an init statement.
Definition: Stmt.h:1721
const_outputs_iterator begin_outputs() const
Definition: Stmt.h:2437
const Expr * getCond() const
Definition: Stmt.h:2054
Stmt * getThen()
Definition: Stmt.h:1554
SourceLocation getIfLoc() const
Definition: Stmt.h:1626
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
Definition: Stmt.h:3028
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:120
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1010
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3012
llvm::iterator_range< decl_iterator > decl_range
Definition: Stmt.h:963
StringRef getInputName(unsigned i) const
Definition: Stmt.h:2573
void setThen(Stmt *Then)
Definition: Stmt.h:1559
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
void setBody(Stmt *S, SourceLocation SL)
Definition: Stmt.h:1802
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition: Stmt.h:797
void setTarget(Expr *E)
Definition: Stmt.h:2143
CoawaitExprBitfields CoawaitBits
Definition: Stmt.h:725
static bool classof(const Stmt *T)
Definition: Stmt.h:2844
ArraySubscriptExprBitfields ArraySubscriptExprBits
Definition: Stmt.h:704
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1373
Represents a struct/union/class.
Definition: Decl.h:3602
Represents a C99 designated initializer expression.
Definition: Expr.h:4365
const Expr * getTarget() const
Definition: Stmt.h:2140
inputs_iterator begin_inputs()
Definition: Stmt.h:2396
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:1990
const_outputs_iterator end_outputs() const
Definition: Stmt.h:2441
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3792
SourceLocation ColonLoc
The location of the ":".
Definition: Stmt.h:1132
DeclGroupRef::const_iterator const_decl_iterator
Definition: Stmt.h:962
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Definition: Stmt.h:1783
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
child_range children()
Definition: Stmt.h:2792
const_body_iterator body_begin() const
Definition: Stmt.h:1075
SourceLocation getEndLoc() const
Definition: Stmt.h:946
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2863
LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
Build a label statement.
Definition: Stmt.h:1379
CharSourceRange getRange() const
Definition: Stmt.h:2520
CharacterLiteralBitfields CharacterLiteralBits
Definition: Stmt.h:701
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:2706
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2823
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2339
SourceLocation getBeginLoc() const
Definition: Stmt.h:1008
SourceLocation getEndLoc() const
Definition: Stmt.h:2826
Token - This structure provides full information about a lexed token.
Definition: Token.h:35
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits
Definition: Stmt.h:728
Stmt *const * const_body_iterator
Definition: Stmt.h:1068
Stmt * body_front()
Definition: Stmt.h:1057
void setReturnLoc(SourceLocation L)
Definition: Stmt.h:2280
llvm::iterator_range< const_inputs_iterator > inputs_const_range
Definition: Stmt.h:2394
MSAsmStmt(EmptyShell Empty)
Build an empty MS-style inline-assembly statement.
Definition: Stmt.h:2651
const VarDecl * getConditionVariable() const
Definition: Stmt.h:1588
void setCond(Expr *Cond)
Definition: Stmt.h:1734
const DeclGroupRef getDeclGroup() const
Definition: Stmt.h:941
void setIfLoc(SourceLocation IfLoc)
Definition: Stmt.h:1627
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:1820
static bool classof(const Stmt *T)
Definition: Stmt.h:2384
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:171
child_range children()
Definition: Stmt.h:2725
void setSubStmt(Stmt *S)
Definition: Stmt.h:1298
child_range children()
Definition: Stmt.h:2009
SwitchCase(StmtClass SC, SourceLocation KWLoc, SourceLocation ColonLoc)
Definition: Stmt.h:1141
WhileStmtBitfields WhileStmtBits
Definition: Stmt.h:686
const Stmt * getSubStmt() const
Definition: Stmt.h:1396
void addSwitchCase(SwitchCase *SC)
Definition: Stmt.h:1807
child_range children()
Definition: Stmt.h:1015
child_range children()
Definition: Stmt.h:2840
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2864
static bool classof(const Stmt *T)
Definition: Stmt.h:1952
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2119
Describes an C or C++ initializer list.
Definition: Expr.h:4131
SwitchCase(StmtClass SC, EmptyShell)
Definition: Stmt.h:1146
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: Stmt.h:3046
GCCAsmStmt(EmptyShell Empty)
Build an empty inline-assembly statement.
Definition: Stmt.h:2474
child_range children()
Definition: Stmt.h:1459
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:2017
SourceLocation getBeginLoc() const
Definition: Stmt.h:1302
outputs_iterator begin_outputs()
Definition: Stmt.h:2425
Decl * getSingleDecl()
Definition: DeclGroup.h:84
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1457
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
LabelDecl * getDecl() const
Definition: Stmt.h:1390
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceLocation getLBracLoc() const
Definition: Stmt.h:1113
void setEndLoc(SourceLocation L)
Definition: Stmt.h:947
DeclStmt(EmptyShell Empty)
Build an empty declaration statement.
Definition: Stmt.h:932
Stmt * getBody()
Definition: Stmt.h:2051
SwitchCaseBitfields SwitchCaseBits
Definition: Stmt.h:693
llvm::iterator_range< const_outputs_iterator > outputs_const_range
Definition: Stmt.h:2423
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3233
Stmt * getInit()
Definition: Stmt.h:2030
DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL, SourceLocation RP)
Definition: Stmt.h:1972
SwitchStmtBitfields SwitchStmtBits
Definition: Stmt.h:685
iterator begin()
Definition: DeclGroup.h:100
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2582
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2719
bool hasElseStorage() const
True if this IfStmt has storage for an else statement.
Definition: Stmt.h:1540
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1400
child_range children()
Definition: Stmt.h:1402
void setAsmString(StringLiteral *E)
Definition: Stmt.h:2483
static bool classof(const Stmt *T)
Definition: Stmt.h:2287
AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
Definition: Stmt.h:2320
const Stmt * getInit() const
Definition: Stmt.h:1752
SourceLocation getEndLoc() const
Definition: Stmt.h:2203
const VarDecl * getConditionVariable() const
Definition: Stmt.h:1922
const Expr * getInc() const
Definition: Stmt.h:2055
CaseStmt - Represent a case statement.
Definition: Stmt.h:1174
Expr * getCond()
Definition: Stmt.h:2049
SourceLocation getContinueLoc() const
Definition: Stmt.h:2173
void setLHS(Expr *Val)
Definition: Stmt.h:1271
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2917
void setInit(Stmt *Init)
Definition: Stmt.h:1757
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:2616
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:2545
ReturnStmtBitfields ReturnStmtBits
Definition: Stmt.h:692
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1948
void setCond(Expr *E)
Definition: Stmt.h:2059
bool isOutputPlusConstraint(unsigned i) const
isOutputPlusConstraint - Return true if the specified output constraint is a "+" constraint (which is...
Definition: Stmt.h:2359
decl_iterator decl_end()
Definition: Stmt.h:973
const Expr * getCond() const
Definition: Stmt.h:1896
SourceLocation getTryLoc() const
Definition: Stmt.h:2825
void setEndLoc(SourceLocation L)
Definition: Stmt.h:2656
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3213
child_range children()
Definition: Stmt.h:1121
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4053
StmtClass
Definition: Stmt.h:68
Stmt * getBody()
Definition: Stmt.h:1738
const Expr * getLHS() const
Definition: Stmt.h:1267
Stmt * getInit()
Definition: Stmt.h:1610
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1068
const_body_iterator body_end() const
Definition: Stmt.h:1079
Iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:763
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2283
unsigned NumClobbers
Definition: Stmt.h:2316
Represents the this expression in C++.
Definition: ExprCXX.h:971
PredefinedExprBitfields PredefinedExprBits
Definition: Stmt.h:697
const_decl_iterator decl_begin() const
Definition: Stmt.h:974
StringLiteral * getAsmString()
Definition: Stmt.h:2482
StmtBitfields StmtBits
Definition: Stmt.h:679
Const iterator for iterating over Stmt * arrays that contain only Expr *.
Definition: Stmt.h:777
child_range children()
Definition: Stmt.h:1317
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:879
void setBreakLoc(SourceLocation L)
Definition: Stmt.h:2200
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1021
Describes the capture of either a variable, or &#39;this&#39;, or variable-length array type.
Definition: Stmt.h:2898
Stmt * stripLabelLikeStatements()
Definition: Stmt.h:867
Decl * getSingleDecl()
Definition: Stmt.h:939
static bool classof(const Stmt *T)
Definition: Stmt.h:2155
const_inputs_iterator begin_inputs() const
Definition: Stmt.h:2406
void setSemiLoc(SourceLocation L)
Definition: Stmt.h:1002
const Expr * getRetValue() const
Definition: Stmt.h:2257
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2748
child_range children()
Definition: Stmt.h:2449
bool IsVolatile
If true, treat this inline assembly as having side effects.
Definition: Stmt.h:2312
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2233
BreakStmtBitfields BreakStmtBits
Definition: Stmt.h:691
static bool classof(const Stmt *T)
Definition: Stmt.h:2765
static bool classof(const Stmt *T)
Definition: Stmt.h:2073
bool isConstexpr() const
Definition: Stmt.h:1640
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1646
unsigned getOperandNo() const
Definition: Stmt.h:2515
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:1604
SourceLocation getBeginLoc() const
Definition: Stmt.h:1342
SourceLocation getLabelLoc() const
Definition: Stmt.h:2102
llvm::iterator_range< const_capture_iterator > capture_const_range
Definition: Stmt.h:3018
void setLeaveLoc(SourceLocation L)
Definition: Stmt.h:2861
const Stmt * getSubStmt() const
Definition: Stmt.h:1454
const Stmt * getSubStmt() const
Definition: Stmt.h:1336
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:1999
SourceLocation getFinallyLoc() const
Definition: Stmt.h:2787
GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL)
Definition: Stmt.h:2089
This represents one expression.
Definition: Expr.h:106
SourceRange getSourceRange() const LLVM_READONLY
Definition: Stmt.h:3085
void setInit(Stmt *Init)
Definition: Stmt.h:1620
SourceLocation getElseLoc() const
Definition: Stmt.h:1629
SourceLocation End
void setWhileLoc(SourceLocation L)
Definition: Stmt.h:1945
Represents a character-granular source range.
inputs_const_range inputs() const
Definition: Stmt.h:2414
llvm::iterator_range< const_capture_init_iterator > const_capture_init_range
Definition: Stmt.h:3048
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:2702
std::string Label
InitListExprBitfields InitListExprBits
Definition: Stmt.h:709
static bool classof(const Stmt *T)
Definition: Stmt.h:2866
StringRef getClobber(unsigned i) const
Definition: Stmt.h:2711
SourceLocation getDefaultLoc() const
Definition: Stmt.h:1339
void setLParenLoc(SourceLocation L)
Definition: Stmt.h:2066
const StringLiteral * getClobberStringLiteral(unsigned i) const
Definition: Stmt.h:2617
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1303
SourceLocation getWhileLoc() const
Definition: Stmt.h:1944
const Stmt * getThen() const
Definition: Stmt.h:1555
SourceLocation getEndLoc() const
Definition: Stmt.h:2106
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
Definition: Stmt.h:2488
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.h:2592
const Stmt * getCapturedStmt() const
Definition: Stmt.h:2987
void setInc(Expr *E)
Definition: Stmt.h:2060
Stmt * getBody()
Definition: Stmt.h:1904
void setRetValue(Expr *E)
Definition: Stmt.h:2258
void setBody(Stmt *S)
Definition: Stmt.h:2061
GotoStmtBitfields GotoStmtBits
Definition: Stmt.h:689
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:288
Expr * getRHS()
Definition: Stmt.h:1275
ExprBitfields ExprBits
Definition: Stmt.h:696
void setBody(Stmt *Body)
Definition: Stmt.h:1743
SourceLocation Begin
child_range children()
Definition: Stmt.h:1654
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition: Stmt.h:719
unsigned size() const
Definition: Stmt.h:1049
SourceLocation getBeginLoc() const
Definition: Stmt.h:1645
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition: Stmt.h:722
std::reverse_iterator< body_iterator > reverse_body_iterator
Definition: Stmt.h:1089
static bool classof(const Stmt *T)
Definition: Stmt.h:1011
CompoundStmtBitfields CompoundStmtBits
Definition: Stmt.h:681
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
capture_init_range capture_inits()
Definition: Stmt.h:3050
StringLiteralBitfields StringLiteralBits
Definition: Stmt.h:700
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:2504
ForStmt(EmptyShell Empty)
Build an empty for statement.
Definition: Stmt.h:2028
SourceLocation getSwitchLoc() const
Definition: Stmt.h:1799
StringLiteral * getOutputConstraintLiteral(unsigned i)
Definition: Stmt.h:2557
LabelDecl * getLabel() const
Definition: Stmt.h:2097
child_range children()
Definition: Stmt.h:2160
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2223
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:904
void setBody(Stmt *Body)
Definition: Stmt.h:1909
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:2630
void setColonLoc(SourceLocation L)
Definition: Stmt.h:1156
SourceLocation getDoLoc() const
Definition: Stmt.h:1994
SwitchCase * getSwitchCaseList()
Definition: Stmt.h:1795
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1907
llvm::iterator_range< const_decl_iterator > decl_const_range
Definition: Stmt.h:964
child_range children()
Definition: Stmt.h:1352
child_range children()
Definition: Stmt.h:2184
Expr * getCond()
Definition: Stmt.h:1542
SourceLocation getEndLoc() const
Definition: Stmt.h:1009
SourceLocation getBeginLoc() const
Definition: Stmt.h:1947
static bool classof(const Stmt *T)
Definition: Stmt.h:2108
const SourceManager & SM
Definition: Format.cpp:1490
SourceLocation getEndLoc() const
Definition: Stmt.h:1111
const_inputs_iterator end_inputs() const
Definition: Stmt.h:2410
const Expr * getCond() const
Definition: Stmt.h:1984
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:301
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:1965
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:2300
child_range children()
Definition: Stmt.h:2210
std::reverse_iterator< decl_iterator > reverse_decl_iterator
Definition: Stmt.h:977
const Stmt * IgnoreContainers(bool IgnoreCaptured=false) const
Definition: Stmt.h:862
SourceLocation getEndLoc() const
Definition: Stmt.h:2751
OpaqueValueExprBitfields OpaqueValueExprBits
Definition: Stmt.h:731
llvm::DOTGraphTraits< ExplodedGraph * > DefaultDOTGraphTraits const ExplodedNode const ExplodedNode *Out<< "\l\|";Out<< "StateID: ST"<< State-> getID()<< "
decl_const_range decls() const
Definition: Stmt.h:968
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:945
void setDecl(LabelDecl *D)
Definition: Stmt.h:1391
ParenListExprBitfields ParenListExprBits
Definition: Stmt.h:710
static bool classof(const Stmt *T)
Definition: Stmt.h:3089
Kind
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2560
This captures a statement into a function.
Definition: Stmt.h:2885
Token * getAsmToks()
Definition: Stmt.h:2661
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5245
void setSubStmt(Stmt *S)
Definition: Stmt.h:1337
SourceLocation getBeginLoc() const
Definition: Stmt.h:1824
void setGotoLoc(SourceLocation L)
Definition: Stmt.h:2134
ContinueStmtBitfields ContinueStmtBits
Definition: Stmt.h:690
Encodes a location in the source.
body_range body()
Definition: Stmt.h:1054
Expr * getRetValue()
Definition: Stmt.h:2256
StringRef getOutputConstraint(unsigned i) const
Definition: Stmt.h:2671
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
Definition: Stmt.h:1890
PseudoObjectExprBitfields PseudoObjectExprBits
Definition: Stmt.h:711
IfStmtBitfields IfStmtBits
Definition: Stmt.h:684
CXXThrowExprBitfields CXXThrowExprBits
Definition: Stmt.h:717
SEHLeaveStmt(EmptyShell Empty)
Build an empty __leave statement.
Definition: Stmt.h:2858
const SwitchCase * getSwitchCaseList() const
Definition: Stmt.h:1796
void setDoLoc(SourceLocation L)
Definition: Stmt.h:1995
child_range children()
Definition: Stmt.h:2761
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1868
Expr * getLHS()
Definition: Stmt.h:1263
void setLastStmt(Stmt *S)
Definition: Stmt.h:1063
void setConstexpr(bool C)
Definition: Stmt.h:1641
SourceLocation getExceptLoc() const
Definition: Stmt.h:2750
const_capture_iterator capture_begin() const
Definition: Stmt.h:3029
void setIdentLoc(SourceLocation L)
Definition: Stmt.h:1388
Stmt * getElse()
Definition: Stmt.h:1563
const_child_range children() const
Definition: Stmt.h:1123
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:923
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:2926
reverse_body_iterator body_rend()
Definition: Stmt.h:1095
ForStmtBitfields ForStmtBits
Definition: Stmt.h:688
SourceLocation getLBraceLoc() const
Definition: Stmt.h:2653
const std::string & getString() const
Definition: Stmt.h:2513
Expr * getCond()
Definition: Stmt.h:1726
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:1816
CompoundStmt(SourceLocation Loc)
Definition: Stmt.h:1039
reference operator*() const
Definition: Stmt.h:769
static bool classof(const Stmt *T)
Definition: Stmt.h:2205
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:5379
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2621
decl_iterator decl_begin()
Definition: Stmt.h:972
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2785
SourceLocation getGotoLoc() const
Definition: Stmt.h:2100
reverse_decl_iterator decl_rbegin()
Definition: Stmt.h:979
SEHLeaveStmt(SourceLocation LL)
Definition: Stmt.h:2854
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2554
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3051
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:2986
const Stmt * body_front() const
Definition: Stmt.h:1081
const VarDecl * getConditionVariable() const
Definition: Stmt.h:1773
unsigned capture_size() const
Retrieve the number of captures, including &#39;this&#39;.
Definition: Stmt.h:3038
const Stmt * getBody() const
Definition: Stmt.h:2056
void setCaseLoc(SourceLocation L)
Definition: Stmt.h:1246
SourceLocation getEndLoc() const
Definition: Stmt.h:2655
DoStmtBitfields DoStmtBits
Definition: Stmt.h:687
NullStmtBitfields NullStmtBits
Definition: Stmt.h:680
LabelStmt(EmptyShell Empty)
Build an empty label statement.
Definition: Stmt.h:1385
const_capture_init_range capture_inits() const
Definition: Stmt.h:3054
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition: Stmt.h:1932
SourceLocation getKeywordLoc() const
Definition: Stmt.h:1153
MemberExprBitfields MemberExprBits
Definition: Stmt.h:706
SourceLocation getBeginLoc() const
Definition: Stmt.h:2176
SourceLocation getStarLoc() const
Definition: Stmt.h:2137
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:1938
void setCapturedRecordDecl(RecordDecl *D)
Set the record declaration for captured variables.
Definition: Stmt.h:3006
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
Definition: Stmt.h:756
void setSimple(bool V)
Definition: Stmt.h:2334
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:2866
const_child_range children() const
Definition: Stmt.h:883
void setGotoLoc(SourceLocation L)
Definition: Stmt.h:2101
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:990
StringRef getInputConstraint(unsigned i) const
Definition: Stmt.h:2684
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isVolatile() const
Definition: Stmt.h:2336
child_range children()
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1769
CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits
Definition: Stmt.h:715
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2095
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:2543
bool isSimple() const
Definition: Stmt.h:2333
llvm::iterator_range< outputs_iterator > outputs_range
Definition: Stmt.h:2422
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1449
SourceRange getSourceRange(const SourceRange &Range)
Returns the SourceRange of a SourceRange.
Definition: FixIt.h:34
bool hasInitStorage() const
True if this IfStmt has the storage for an init statement.
Definition: Stmt.h:1534
const Stmt * body_back() const
Definition: Stmt.h:1085
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:355
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1343
static bool classof(const Stmt *T)
Definition: Stmt.h:1166
DoStmt(EmptyShell Empty)
Build an empty do-while statement.
Definition: Stmt.h:1981
Stmt * getHandler() const
Definition: Stmt.h:2834
SourceLocation getSemiLoc() const
Definition: Stmt.h:1001
StmtClass getStmtClass() const
Definition: Stmt.h:809
reference operator*() const
Definition: Stmt.h:784
SwitchCase * getNextSwitchCase()
Definition: Stmt.h:1150
bool isSingleDecl() const
Definition: DeclGroup.h:81
UnaryOperatorBitfields UnaryOperatorBits
Definition: Stmt.h:702
static bool classof(const Stmt *T)
Definition: Stmt.h:2796
SourceLocation getEndLoc() const
Definition: Stmt.h:2002
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:3081
void setEllipsisLoc(SourceLocation L)
Set the location of the ...
Definition: Stmt.h:1256
const Decl * getSingleDecl() const
Definition: Stmt.h:938
static bool classof(const Stmt *T)
Definition: Stmt.h:2624
BreakStmt(EmptyShell Empty)
Build an empty break statement.
Definition: Stmt.h:2197
child_range children()
Definition: Stmt.h:2113
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3077
const Stmt * getSubStmt() const
Definition: Stmt.h:1159
Stmt(StmtClass SC)
Definition: Stmt.h:800
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl. ...
Definition: Stmt.h:936
body_iterator body_begin()
Definition: Stmt.h:1055
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition: Stmt.h:1598
static bool classof(const Stmt *T)
Definition: Stmt.h:951
IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target)
Definition: Stmt.h:2124
const Stmt * getBody() const
Definition: Stmt.h:1739
llvm::iterator_range< const_body_iterator > body_const_range
Definition: Stmt.h:1069
Represents a __leave statement.
Definition: Stmt.h:2850
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
Definition: Stmt.h:2929
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1666
bool body_empty() const
Definition: Stmt.h:1048
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2323
SourceLocation getLeaveLoc() const
Definition: Stmt.h:2860
bool hasBraces() const
Definition: Stmt.h:2658
const_capture_init_iterator capture_init_end() const
Definition: Stmt.h:3073
void setRHS(Expr *Val)
Definition: Stmt.h:1287
void setVolatile(bool V)
Definition: Stmt.h:2337
friend TrailingObjects
Definition: OpenMPClause.h:99
static bool classof(const Stmt *T)
Definition: Stmt.h:1404
DefaultStmt(EmptyShell Empty)
Build an empty default statement.
Definition: Stmt.h:1332
reverse_decl_iterator decl_rend()
Definition: Stmt.h:983
SourceLocation getBeginLoc() const
Definition: Stmt.h:2105
StringLiteral * getInputConstraintLiteral(unsigned i)
Definition: Stmt.h:2585
DeclGroupRef getDeclGroup()
Definition: Stmt.h:942
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4310
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.h:2692
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:721
void setSwitchLoc(SourceLocation L)
Definition: Stmt.h:1800
Stmt * getInit()
Definition: Stmt.h:1747
const Stmt * IgnoreImplicit() const
Definition: Stmt.h:855
static bool classof(const Stmt *T)
Definition: Stmt.h:1347
decl_range decls()
Definition: Stmt.h:966
CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits
Definition: Stmt.h:714
void setBody(Stmt *Body)
Definition: Stmt.h:1992
AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin, SourceLocation End)
Definition: Stmt.h:2505
bool IsSimple
True if the assembly statement does not have any input or output operands.
Definition: Stmt.h:2308
static bool classof(const Stmt *T)
Definition: Stmt.h:1461
StringRef getAsmString() const
Definition: Stmt.h:2664
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:2698
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2153
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Definition: Stmt.h:703
SourceLocation getColonLoc() const
Definition: Stmt.h:1155
unsigned getNumClobbers() const
Definition: Stmt.h:2381
SourceLocation getRParenLoc() const
Definition: Stmt.h:2067
child_range children()
Definition: Stmt.h:1957
void setElseLoc(SourceLocation ElseLoc)
Definition: Stmt.h:1634
void setStarLoc(SourceLocation L)
Definition: Stmt.h:2136
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3092
SourceLocation getAsmLoc() const
Definition: Stmt.h:2330
outputs_range outputs()
Definition: Stmt.h:2433
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2084
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1132
Expr * getTarget()
Definition: Stmt.h:2139
Decl *const * const_iterator
Definition: DeclGroup.h:78
const SwitchCase * getNextSwitchCase() const
Definition: Stmt.h:1149
void setCond(Expr *Cond)
Definition: Stmt.h:1988
SourceLocation getBeginLoc() const
Definition: Stmt.h:2202
Expr * getCond()
Definition: Stmt.h:1983
static bool classof(const Stmt *T)
Definition: Stmt.h:2004
llvm::iterator_range< capture_iterator > capture_range
Definition: Stmt.h:3017
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2601
SourceLocation getWhileLoc() const
Definition: Stmt.h:1996
Defines the clang::SourceLocation class and associated facilities.
llvm::iterator_range< inputs_iterator > inputs_range
Definition: Stmt.h:2393
ContinueStmt - This represents a continue.
Definition: Stmt.h:2164
SourceLocation getBeginLoc() const
Definition: Stmt.h:1399
const_decl_iterator decl_end() const
Definition: Stmt.h:975
const Expr * getRHS() const
Definition: Stmt.h:1281
reverse_body_iterator body_rbegin()
Definition: Stmt.h:1091
void setLBraceLoc(SourceLocation L)
Definition: Stmt.h:2654
child_range children()
Definition: Stmt.h:956
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition: Stmt.h:718
Expr * getFilterExpr() const
Definition: Stmt.h:2753
SourceLocation getAttrLoc() const
Definition: Stmt.h:1448
ContinueStmt(SourceLocation CL)
Definition: Stmt.h:2166
const Stmt * getInit() const
Definition: Stmt.h:2053
OpenMPLinearClauseKind getModifier() const
Return modifier.
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1843
llvm::iterator_range< capture_init_iterator > capture_init_range
Definition: Stmt.h:3042
SourceLocation AsmLoc
Definition: Stmt.h:2304
static bool classof(const Stmt *T)
Definition: Stmt.h:2179
SourceLocation getBeginLoc() const
Definition: Stmt.h:2001
const Stmt * getSubStmt() const
Definition: Stmt.h:1294
void setDefaultLoc(SourceLocation L)
Definition: Stmt.h:1340
SourceLocation getBreakLoc() const
Definition: Stmt.h:2199
SourceLocation getCaseLoc() const
Definition: Stmt.h:1245
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition: Stmt.h:3033
VariableCaptureKind
The different capture forms: by &#39;this&#39;, by reference, capture for variable-length array type etc...
Definition: Stmt.h:2889
void setElse(Stmt *Else)
Definition: Stmt.h:1573
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1577
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2407
static bool classof(const Stmt *T)
Definition: Stmt.h:1837
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2340
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:2068
void setNextSwitchCase(SwitchCase *SC)
Definition: Stmt.h:1151
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
SourceLocation getBeginLoc() const
Definition: Stmt.h:2152
child_range children()
Definition: Stmt.h:2078
body_const_range body() const
Definition: Stmt.h:1071
capture_range captures()
Definition: Stmt.h:3020
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1042
SourceLocation getBeginLoc() const
Definition: Stmt.h:1163
void setLabel(LabelDecl *D)
Definition: Stmt.h:2098
SourceLocation getBeginLoc() const
Definition: Stmt.h:1110
static bool classof(const Stmt *T)
Definition: Stmt.h:1312
BreakStmt - This represents a break.
Definition: Stmt.h:2190
const Stmt * getInit() const
Definition: Stmt.h:1615
SourceLocation getBeginLoc() const
Definition: Stmt.h:1456
void setSubStmt(Stmt *SS)
Definition: Stmt.h:1397
CallExprBitfields CallExprBits
Definition: Stmt.h:705
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:17
const Stmt * getBody() const
Definition: Stmt.h:1905
CastExprBitfields CastExprBits
Definition: Stmt.h:707
Stmt * getSubStmt()
Definition: Stmt.h:1394
DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc)
Definition: Stmt.h:928
const Expr * getCond() const
Definition: Stmt.h:1546
A trivial tuple used to represent a source range.
void setInit(Stmt *S)
Definition: Stmt.h:2058
unsigned NumInputs
Definition: Stmt.h:2315
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:557
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2128
const_reverse_body_iterator body_rend() const
Definition: Stmt.h:1106
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2622
const Expr * getCond() const
Definition: Stmt.h:1730
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
Definition: Stmt.h:3069
BinaryOperatorBitfields BinaryOperatorBits
Definition: Stmt.h:708
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:108
void setWhileLoc(SourceLocation L)
Definition: Stmt.h:1997
child_range children()
Definition: Stmt.h:2292
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ...
Definition: Stmt.h:1243
This class handles loading and caching of source files into memory.
BreakStmt(SourceLocation BL)
Definition: Stmt.h:2192
CompoundStmt * getTryBlock() const
Definition: Stmt.h:2830
Stmt * getSubStmt()
Definition: Stmt.h:1453
CompoundStmt * getBlock() const
Definition: Stmt.h:2757
void setKeywordLoc(SourceLocation L)
Definition: Stmt.h:1154
SourceLocation getReturnLoc() const
Definition: Stmt.h:2279
bool capturesVariableArrayType() const
Determine whether this capture handles a variable-length array type.
Definition: Stmt.h:2935
void setCond(Expr *Cond)
Definition: Stmt.h:1550
Attr - This represents one attribute.
Definition: Attr.h:43
void setLabelLoc(SourceLocation L)
Definition: Stmt.h:2103
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:889
#define BLOCK(DERIVED, BASE)
Definition: Template.h:470
SourceLocation getEndLoc() const
Definition: Stmt.h:2788
const_capture_init_iterator capture_init_begin() const
Definition: Stmt.h:3063
SourceLocation getLocation() const
Retrieve the source location at which the variable or &#39;this&#39; was first used.
Definition: Stmt.h:2920
Stmt * getSubStmt()
Definition: Stmt.h:1293
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:1789
inputs_iterator end_inputs()
Definition: Stmt.h:2400
outputs_const_range outputs() const
Definition: Stmt.h:2445
const LabelDecl * getConstantTarget() const
Definition: Stmt.h:2148