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