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