clang  10.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  using const_body_iterator = Stmt *const *;
1353  using body_const_range = llvm::iterator_range<const_body_iterator>;
1354 
1356  return body_const_range(body_begin(), body_end());
1357  }
1358 
1360  return getTrailingObjects<Stmt *>();
1361  }
1362 
1363  const_body_iterator body_end() const { return body_begin() + size(); }
1364 
1365  const Stmt *body_front() const {
1366  return !body_empty() ? body_begin()[0] : nullptr;
1367  }
1368 
1369  const Stmt *body_back() const {
1370  return !body_empty() ? body_begin()[size() - 1] : nullptr;
1371  }
1372 
1373  using reverse_body_iterator = std::reverse_iterator<body_iterator>;
1374 
1376  return reverse_body_iterator(body_end());
1377  }
1378 
1380  return reverse_body_iterator(body_begin());
1381  }
1382 
1384  std::reverse_iterator<const_body_iterator>;
1385 
1387  return const_reverse_body_iterator(body_end());
1388  }
1389 
1391  return const_reverse_body_iterator(body_begin());
1392  }
1393 
1394  // Get the Stmt that StmtExpr would consider to be the result of this
1395  // compound statement. This is used by StmtExpr to properly emulate the GCC
1396  // compound expression extension, which ignores trailing NullStmts when
1397  // getting the result of the expression.
1398  // i.e. ({ 5;;; })
1399  // ^^ ignored
1400  // If we don't find something that isn't a NullStmt, just return the last
1401  // Stmt.
1403  for (auto *B : llvm::reverse(body())) {
1404  if (!isa<NullStmt>(B))
1405  return B;
1406  }
1407  return body_back();
1408  }
1409 
1410  const Stmt *getStmtExprResult() const {
1411  return const_cast<CompoundStmt *>(this)->getStmtExprResult();
1412  }
1413 
1414  SourceLocation getBeginLoc() const { return CompoundStmtBits.LBraceLoc; }
1415  SourceLocation getEndLoc() const { return RBraceLoc; }
1416 
1417  SourceLocation getLBracLoc() const { return CompoundStmtBits.LBraceLoc; }
1418  SourceLocation getRBracLoc() const { return RBraceLoc; }
1419 
1420  static bool classof(const Stmt *T) {
1421  return T->getStmtClass() == CompoundStmtClass;
1422  }
1423 
1424  // Iterators
1425  child_range children() { return child_range(body_begin(), body_end()); }
1426 
1428  return const_child_range(body_begin(), body_end());
1429  }
1430 };
1431 
1432 // SwitchCase is the base class for CaseStmt and DefaultStmt,
1433 class SwitchCase : public Stmt {
1434 protected:
1435  /// The location of the ":".
1437 
1438  // The location of the "case" or "default" keyword. Stored in SwitchCaseBits.
1439  // SourceLocation KeywordLoc;
1440 
1441  /// A pointer to the following CaseStmt or DefaultStmt class,
1442  /// used by SwitchStmt.
1443  SwitchCase *NextSwitchCase = nullptr;
1444 
1446  : Stmt(SC), ColonLoc(ColonLoc) {
1447  setKeywordLoc(KWLoc);
1448  }
1449 
1451 
1452 public:
1453  const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; }
1454  SwitchCase *getNextSwitchCase() { return NextSwitchCase; }
1455  void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; }
1456 
1457  SourceLocation getKeywordLoc() const { return SwitchCaseBits.KeywordLoc; }
1458  void setKeywordLoc(SourceLocation L) { SwitchCaseBits.KeywordLoc = L; }
1460  void setColonLoc(SourceLocation L) { ColonLoc = L; }
1461 
1462  inline Stmt *getSubStmt();
1463  const Stmt *getSubStmt() const {
1464  return const_cast<SwitchCase *>(this)->getSubStmt();
1465  }
1466 
1467  SourceLocation getBeginLoc() const { return getKeywordLoc(); }
1468  inline SourceLocation getEndLoc() const LLVM_READONLY;
1469 
1470  static bool classof(const Stmt *T) {
1471  return T->getStmtClass() == CaseStmtClass ||
1472  T->getStmtClass() == DefaultStmtClass;
1473  }
1474 };
1475 
1476 /// CaseStmt - Represent a case statement. It can optionally be a GNU case
1477 /// statement of the form LHS ... RHS representing a range of cases.
1478 class CaseStmt final
1479  : public SwitchCase,
1480  private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1481  friend TrailingObjects;
1482 
1483  // CaseStmt is followed by several trailing objects, some of which optional.
1484  // Note that it would be more convenient to put the optional trailing objects
1485  // at the end but this would impact children().
1486  // The trailing objects are in order:
1487  //
1488  // * A "Stmt *" for the LHS of the case statement. Always present.
1489  //
1490  // * A "Stmt *" for the RHS of the case statement. This is a GNU extension
1491  // which allow ranges in cases statement of the form LHS ... RHS.
1492  // Present if and only if caseStmtIsGNURange() is true.
1493  //
1494  // * A "Stmt *" for the substatement of the case statement. Always present.
1495  //
1496  // * A SourceLocation for the location of the ... if this is a case statement
1497  // with a range. Present if and only if caseStmtIsGNURange() is true.
1498  enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1499  enum { NumMandatoryStmtPtr = 2 };
1500 
1501  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1502  return NumMandatoryStmtPtr + caseStmtIsGNURange();
1503  }
1504 
1505  unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
1506  return caseStmtIsGNURange();
1507  }
1508 
1509  unsigned lhsOffset() const { return LhsOffset; }
1510  unsigned rhsOffset() const { return LhsOffset + caseStmtIsGNURange(); }
1511  unsigned subStmtOffset() const { return rhsOffset() + SubStmtOffsetFromRhs; }
1512 
1513  /// Build a case statement assuming that the storage for the
1514  /// trailing objects has been properly allocated.
1515  CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
1516  SourceLocation ellipsisLoc, SourceLocation colonLoc)
1517  : SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1518  // Handle GNU case statements of the form LHS ... RHS.
1519  bool IsGNURange = rhs != nullptr;
1520  SwitchCaseBits.CaseStmtIsGNURange = IsGNURange;
1521  setLHS(lhs);
1522  setSubStmt(nullptr);
1523  if (IsGNURange) {
1524  setRHS(rhs);
1525  setEllipsisLoc(ellipsisLoc);
1526  }
1527  }
1528 
1529  /// Build an empty switch case statement.
1530  explicit CaseStmt(EmptyShell Empty, bool CaseStmtIsGNURange)
1531  : SwitchCase(CaseStmtClass, Empty) {
1532  SwitchCaseBits.CaseStmtIsGNURange = CaseStmtIsGNURange;
1533  }
1534 
1535 public:
1536  /// Build a case statement.
1537  static CaseStmt *Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs,
1538  SourceLocation caseLoc, SourceLocation ellipsisLoc,
1539  SourceLocation colonLoc);
1540 
1541  /// Build an empty case statement.
1542  static CaseStmt *CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange);
1543 
1544  /// True if this case statement is of the form case LHS ... RHS, which
1545  /// is a GNU extension. In this case the RHS can be obtained with getRHS()
1546  /// and the location of the ellipsis can be obtained with getEllipsisLoc().
1547  bool caseStmtIsGNURange() const { return SwitchCaseBits.CaseStmtIsGNURange; }
1548 
1549  SourceLocation getCaseLoc() const { return getKeywordLoc(); }
1550  void setCaseLoc(SourceLocation L) { setKeywordLoc(L); }
1551 
1552  /// Get the location of the ... in a case statement of the form LHS ... RHS.
1554  return caseStmtIsGNURange() ? *getTrailingObjects<SourceLocation>()
1555  : SourceLocation();
1556  }
1557 
1558  /// Set the location of the ... in a case statement of the form LHS ... RHS.
1559  /// Assert that this case statement is of this form.
1561  assert(
1562  caseStmtIsGNURange() &&
1563  "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1564  *getTrailingObjects<SourceLocation>() = L;
1565  }
1566 
1568  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1569  }
1570 
1571  const Expr *getLHS() const {
1572  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1573  }
1574 
1575  void setLHS(Expr *Val) {
1576  getTrailingObjects<Stmt *>()[lhsOffset()] = reinterpret_cast<Stmt *>(Val);
1577  }
1578 
1580  return caseStmtIsGNURange() ? reinterpret_cast<Expr *>(
1581  getTrailingObjects<Stmt *>()[rhsOffset()])
1582  : nullptr;
1583  }
1584 
1585  const Expr *getRHS() const {
1586  return caseStmtIsGNURange() ? reinterpret_cast<Expr *>(
1587  getTrailingObjects<Stmt *>()[rhsOffset()])
1588  : nullptr;
1589  }
1590 
1591  void setRHS(Expr *Val) {
1592  assert(caseStmtIsGNURange() &&
1593  "setRHS but this is not a case stmt of the form LHS ... RHS!");
1594  getTrailingObjects<Stmt *>()[rhsOffset()] = reinterpret_cast<Stmt *>(Val);
1595  }
1596 
1597  Stmt *getSubStmt() { return getTrailingObjects<Stmt *>()[subStmtOffset()]; }
1598  const Stmt *getSubStmt() const {
1599  return getTrailingObjects<Stmt *>()[subStmtOffset()];
1600  }
1601 
1602  void setSubStmt(Stmt *S) {
1603  getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
1604  }
1605 
1606  SourceLocation getBeginLoc() const { return getKeywordLoc(); }
1607  SourceLocation getEndLoc() const LLVM_READONLY {
1608  // Handle deeply nested case statements with iteration instead of recursion.
1609  const CaseStmt *CS = this;
1610  while (const auto *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
1611  CS = CS2;
1612 
1613  return CS->getSubStmt()->getEndLoc();
1614  }
1615 
1616  static bool classof(const Stmt *T) {
1617  return T->getStmtClass() == CaseStmtClass;
1618  }
1619 
1620  // Iterators
1622  return child_range(getTrailingObjects<Stmt *>(),
1623  getTrailingObjects<Stmt *>() +
1624  numTrailingObjects(OverloadToken<Stmt *>()));
1625  }
1626 
1628  return const_child_range(getTrailingObjects<Stmt *>(),
1629  getTrailingObjects<Stmt *>() +
1630  numTrailingObjects(OverloadToken<Stmt *>()));
1631  }
1632 };
1633 
1634 class DefaultStmt : public SwitchCase {
1635  Stmt *SubStmt;
1636 
1637 public:
1639  : SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
1640 
1641  /// Build an empty default statement.
1642  explicit DefaultStmt(EmptyShell Empty)
1643  : SwitchCase(DefaultStmtClass, Empty) {}
1644 
1645  Stmt *getSubStmt() { return SubStmt; }
1646  const Stmt *getSubStmt() const { return SubStmt; }
1647  void setSubStmt(Stmt *S) { SubStmt = S; }
1648 
1649  SourceLocation getDefaultLoc() const { return getKeywordLoc(); }
1650  void setDefaultLoc(SourceLocation L) { setKeywordLoc(L); }
1651 
1652  SourceLocation getBeginLoc() const { return getKeywordLoc(); }
1653  SourceLocation getEndLoc() const LLVM_READONLY {
1654  return SubStmt->getEndLoc();
1655  }
1656 
1657  static bool classof(const Stmt *T) {
1658  return T->getStmtClass() == DefaultStmtClass;
1659  }
1660 
1661  // Iterators
1662  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
1663 
1665  return const_child_range(&SubStmt, &SubStmt + 1);
1666  }
1667 };
1668 
1669 SourceLocation SwitchCase::getEndLoc() const {
1670  if (const auto *CS = dyn_cast<CaseStmt>(this))
1671  return CS->getEndLoc();
1672  else if (const auto *DS = dyn_cast<DefaultStmt>(this))
1673  return DS->getEndLoc();
1674  llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1675 }
1676 
1677 Stmt *SwitchCase::getSubStmt() {
1678  if (auto *CS = dyn_cast<CaseStmt>(this))
1679  return CS->getSubStmt();
1680  else if (auto *DS = dyn_cast<DefaultStmt>(this))
1681  return DS->getSubStmt();
1682  llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!");
1683 }
1684 
1685 /// Represents a statement that could possibly have a value and type. This
1686 /// covers expression-statements, as well as labels and attributed statements.
1687 ///
1688 /// Value statements have a special meaning when they are the last non-null
1689 /// statement in a GNU statement expression, where they determine the value
1690 /// of the statement expression.
1691 class ValueStmt : public Stmt {
1692 protected:
1693  using Stmt::Stmt;
1694 
1695 public:
1696  const Expr *getExprStmt() const;
1698  const ValueStmt *ConstThis = this;
1699  return const_cast<Expr*>(ConstThis->getExprStmt());
1700  }
1701 
1702  static bool classof(const Stmt *T) {
1703  return T->getStmtClass() >= firstValueStmtConstant &&
1704  T->getStmtClass() <= lastValueStmtConstant;
1705  }
1706 };
1707 
1708 /// LabelStmt - Represents a label, which has a substatement. For example:
1709 /// foo: return;
1710 class LabelStmt : public ValueStmt {
1711  LabelDecl *TheDecl;
1712  Stmt *SubStmt;
1713 
1714 public:
1715  /// Build a label statement.
1717  : ValueStmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) {
1718  setIdentLoc(IL);
1719  }
1720 
1721  /// Build an empty label statement.
1722  explicit LabelStmt(EmptyShell Empty) : ValueStmt(LabelStmtClass, Empty) {}
1723 
1724  SourceLocation getIdentLoc() const { return LabelStmtBits.IdentLoc; }
1725  void setIdentLoc(SourceLocation L) { LabelStmtBits.IdentLoc = L; }
1726 
1727  LabelDecl *getDecl() const { return TheDecl; }
1728  void setDecl(LabelDecl *D) { TheDecl = D; }
1729 
1730  const char *getName() const;
1731  Stmt *getSubStmt() { return SubStmt; }
1732 
1733  const Stmt *getSubStmt() const { return SubStmt; }
1734  void setSubStmt(Stmt *SS) { SubStmt = SS; }
1735 
1736  SourceLocation getBeginLoc() const { return getIdentLoc(); }
1737  SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
1738 
1739  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
1740 
1742  return const_child_range(&SubStmt, &SubStmt + 1);
1743  }
1744 
1745  static bool classof(const Stmt *T) {
1746  return T->getStmtClass() == LabelStmtClass;
1747  }
1748 };
1749 
1750 /// Represents an attribute applied to a statement.
1751 ///
1752 /// Represents an attribute applied to a statement. For example:
1753 /// [[omp::for(...)]] for (...) { ... }
1754 class AttributedStmt final
1755  : public ValueStmt,
1756  private llvm::TrailingObjects<AttributedStmt, const Attr *> {
1757  friend class ASTStmtReader;
1758  friend TrailingObjects;
1759 
1760  Stmt *SubStmt;
1761 
1763  Stmt *SubStmt)
1764  : ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
1765  AttributedStmtBits.NumAttrs = Attrs.size();
1766  AttributedStmtBits.AttrLoc = Loc;
1767  std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr());
1768  }
1769 
1770  explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)
1771  : ValueStmt(AttributedStmtClass, Empty) {
1772  AttributedStmtBits.NumAttrs = NumAttrs;
1773  AttributedStmtBits.AttrLoc = SourceLocation{};
1774  std::fill_n(getAttrArrayPtr(), NumAttrs, nullptr);
1775  }
1776 
1777  const Attr *const *getAttrArrayPtr() const {
1778  return getTrailingObjects<const Attr *>();
1779  }
1780  const Attr **getAttrArrayPtr() { return getTrailingObjects<const Attr *>(); }
1781 
1782 public:
1783  static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,
1784  ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
1785 
1786  // Build an empty attributed statement.
1787  static AttributedStmt *CreateEmpty(const ASTContext &C, unsigned NumAttrs);
1788 
1789  SourceLocation getAttrLoc() const { return AttributedStmtBits.AttrLoc; }
1791  return llvm::makeArrayRef(getAttrArrayPtr(), AttributedStmtBits.NumAttrs);
1792  }
1793 
1794  Stmt *getSubStmt() { return SubStmt; }
1795  const Stmt *getSubStmt() const { return SubStmt; }
1796 
1797  SourceLocation getBeginLoc() const { return getAttrLoc(); }
1798  SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
1799 
1800  child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
1801 
1803  return const_child_range(&SubStmt, &SubStmt + 1);
1804  }
1805 
1806  static bool classof(const Stmt *T) {
1807  return T->getStmtClass() == AttributedStmtClass;
1808  }
1809 };
1810 
1811 /// IfStmt - This represents an if/then/else.
1812 class IfStmt final
1813  : public Stmt,
1814  private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
1815  friend TrailingObjects;
1816 
1817  // IfStmt is followed by several trailing objects, some of which optional.
1818  // Note that it would be more convenient to put the optional trailing
1819  // objects at then end but this would change the order of the children.
1820  // The trailing objects are in order:
1821  //
1822  // * A "Stmt *" for the init statement.
1823  // Present if and only if hasInitStorage().
1824  //
1825  // * A "Stmt *" for the condition variable.
1826  // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
1827  //
1828  // * A "Stmt *" for the condition.
1829  // Always present. This is in fact a "Expr *".
1830  //
1831  // * A "Stmt *" for the then statement.
1832  // Always present.
1833  //
1834  // * A "Stmt *" for the else statement.
1835  // Present if and only if hasElseStorage().
1836  //
1837  // * A "SourceLocation" for the location of the "else".
1838  // Present if and only if hasElseStorage().
1839  enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
1840  enum { NumMandatoryStmtPtr = 2 };
1841 
1842  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1843  return NumMandatoryStmtPtr + hasElseStorage() + hasVarStorage() +
1844  hasInitStorage();
1845  }
1846 
1847  unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
1848  return hasElseStorage();
1849  }
1850 
1851  unsigned initOffset() const { return InitOffset; }
1852  unsigned varOffset() const { return InitOffset + hasInitStorage(); }
1853  unsigned condOffset() const {
1854  return InitOffset + hasInitStorage() + hasVarStorage();
1855  }
1856  unsigned thenOffset() const { return condOffset() + ThenOffsetFromCond; }
1857  unsigned elseOffset() const { return condOffset() + ElseOffsetFromCond; }
1858 
1859  /// Build an if/then/else statement.
1860  IfStmt(const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init,
1861  VarDecl *Var, Expr *Cond, Stmt *Then, SourceLocation EL, Stmt *Else);
1862 
1863  /// Build an empty if/then/else statement.
1864  explicit IfStmt(EmptyShell Empty, bool HasElse, bool HasVar, bool HasInit);
1865 
1866 public:
1867  /// Create an IfStmt.
1868  static IfStmt *Create(const ASTContext &Ctx, SourceLocation IL,
1869  bool IsConstexpr, Stmt *Init, VarDecl *Var, Expr *Cond,
1870  Stmt *Then, SourceLocation EL = SourceLocation(),
1871  Stmt *Else = nullptr);
1872 
1873  /// Create an empty IfStmt optionally with storage for an else statement,
1874  /// condition variable and init expression.
1875  static IfStmt *CreateEmpty(const ASTContext &Ctx, bool HasElse, bool HasVar,
1876  bool HasInit);
1877 
1878  /// True if this IfStmt has the storage for an init statement.
1879  bool hasInitStorage() const { return IfStmtBits.HasInit; }
1880 
1881  /// True if this IfStmt has storage for a variable declaration.
1882  bool hasVarStorage() const { return IfStmtBits.HasVar; }
1883 
1884  /// True if this IfStmt has storage for an else statement.
1885  bool hasElseStorage() const { return IfStmtBits.HasElse; }
1886 
1888  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1889  }
1890 
1891  const Expr *getCond() const {
1892  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
1893  }
1894 
1895  void setCond(Expr *Cond) {
1896  getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
1897  }
1898 
1899  Stmt *getThen() { return getTrailingObjects<Stmt *>()[thenOffset()]; }
1900  const Stmt *getThen() const {
1901  return getTrailingObjects<Stmt *>()[thenOffset()];
1902  }
1903 
1904  void setThen(Stmt *Then) {
1905  getTrailingObjects<Stmt *>()[thenOffset()] = Then;
1906  }
1907 
1909  return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
1910  : nullptr;
1911  }
1912 
1913  const Stmt *getElse() const {
1914  return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
1915  : nullptr;
1916  }
1917 
1918  void setElse(Stmt *Else) {
1919  assert(hasElseStorage() &&
1920  "This if statement has no storage for an else statement!");
1921  getTrailingObjects<Stmt *>()[elseOffset()] = Else;
1922  }
1923 
1924  /// Retrieve the variable declared in this "if" statement, if any.
1925  ///
1926  /// In the following example, "x" is the condition variable.
1927  /// \code
1928  /// if (int x = foo()) {
1929  /// printf("x is %d", x);
1930  /// }
1931  /// \endcode
1932  VarDecl *getConditionVariable();
1934  return const_cast<IfStmt *>(this)->getConditionVariable();
1935  }
1936 
1937  /// Set the condition variable for this if statement.
1938  /// The if statement must have storage for the condition variable.
1939  void setConditionVariable(const ASTContext &Ctx, VarDecl *V);
1940 
1941  /// If this IfStmt has a condition variable, return the faux DeclStmt
1942  /// associated with the creation of that condition variable.
1944  return hasVarStorage() ? static_cast<DeclStmt *>(
1945  getTrailingObjects<Stmt *>()[varOffset()])
1946  : nullptr;
1947  }
1948 
1950  return hasVarStorage() ? static_cast<DeclStmt *>(
1951  getTrailingObjects<Stmt *>()[varOffset()])
1952  : nullptr;
1953  }
1954 
1956  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
1957  : nullptr;
1958  }
1959 
1960  const Stmt *getInit() const {
1961  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
1962  : nullptr;
1963  }
1964 
1965  void setInit(Stmt *Init) {
1966  assert(hasInitStorage() &&
1967  "This if statement has no storage for an init statement!");
1968  getTrailingObjects<Stmt *>()[initOffset()] = Init;
1969  }
1970 
1971  SourceLocation getIfLoc() const { return IfStmtBits.IfLoc; }
1972  void setIfLoc(SourceLocation IfLoc) { IfStmtBits.IfLoc = IfLoc; }
1973 
1975  return hasElseStorage() ? *getTrailingObjects<SourceLocation>()
1976  : SourceLocation();
1977  }
1978 
1979  void setElseLoc(SourceLocation ElseLoc) {
1980  assert(hasElseStorage() &&
1981  "This if statement has no storage for an else statement!");
1982  *getTrailingObjects<SourceLocation>() = ElseLoc;
1983  }
1984 
1985  bool isConstexpr() const { return IfStmtBits.IsConstexpr; }
1986  void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; }
1987 
1988  bool isObjCAvailabilityCheck() const;
1989 
1990  SourceLocation getBeginLoc() const { return getIfLoc(); }
1991  SourceLocation getEndLoc() const LLVM_READONLY {
1992  if (getElse())
1993  return getElse()->getEndLoc();
1994  return getThen()->getEndLoc();
1995  }
1996 
1997  // Iterators over subexpressions. The iterators will include iterating
1998  // over the initialization expression referenced by the condition variable.
2000  return child_range(getTrailingObjects<Stmt *>(),
2001  getTrailingObjects<Stmt *>() +
2002  numTrailingObjects(OverloadToken<Stmt *>()));
2003  }
2004 
2006  return const_child_range(getTrailingObjects<Stmt *>(),
2007  getTrailingObjects<Stmt *>() +
2008  numTrailingObjects(OverloadToken<Stmt *>()));
2009  }
2010 
2011  static bool classof(const Stmt *T) {
2012  return T->getStmtClass() == IfStmtClass;
2013  }
2014 };
2015 
2016 /// SwitchStmt - This represents a 'switch' stmt.
2017 class SwitchStmt final : public Stmt,
2018  private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2019  friend TrailingObjects;
2020 
2021  /// Points to a linked list of case and default statements.
2022  SwitchCase *FirstCase;
2023 
2024  // SwitchStmt is followed by several trailing objects,
2025  // some of which optional. Note that it would be more convenient to
2026  // put the optional trailing objects at the end but this would change
2027  // the order in children().
2028  // The trailing objects are in order:
2029  //
2030  // * A "Stmt *" for the init statement.
2031  // Present if and only if hasInitStorage().
2032  //
2033  // * A "Stmt *" for the condition variable.
2034  // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
2035  //
2036  // * A "Stmt *" for the condition.
2037  // Always present. This is in fact an "Expr *".
2038  //
2039  // * A "Stmt *" for the body.
2040  // Always present.
2041  enum { InitOffset = 0, BodyOffsetFromCond = 1 };
2042  enum { NumMandatoryStmtPtr = 2 };
2043 
2044  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2045  return NumMandatoryStmtPtr + hasInitStorage() + hasVarStorage();
2046  }
2047 
2048  unsigned initOffset() const { return InitOffset; }
2049  unsigned varOffset() const { return InitOffset + hasInitStorage(); }
2050  unsigned condOffset() const {
2051  return InitOffset + hasInitStorage() + hasVarStorage();
2052  }
2053  unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
2054 
2055  /// Build a switch statement.
2056  SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond);
2057 
2058  /// Build a empty switch statement.
2059  explicit SwitchStmt(EmptyShell Empty, bool HasInit, bool HasVar);
2060 
2061 public:
2062  /// Create a switch statement.
2063  static SwitchStmt *Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var,
2064  Expr *Cond);
2065 
2066  /// Create an empty switch statement optionally with storage for
2067  /// an init expression and a condition variable.
2068  static SwitchStmt *CreateEmpty(const ASTContext &Ctx, bool HasInit,
2069  bool HasVar);
2070 
2071  /// True if this SwitchStmt has storage for an init statement.
2072  bool hasInitStorage() const { return SwitchStmtBits.HasInit; }
2073 
2074  /// True if this SwitchStmt has storage for a condition variable.
2075  bool hasVarStorage() const { return SwitchStmtBits.HasVar; }
2076 
2078  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2079  }
2080 
2081  const Expr *getCond() const {
2082  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2083  }
2084 
2085  void setCond(Expr *Cond) {
2086  getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2087  }
2088 
2089  Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2090  const Stmt *getBody() const {
2091  return getTrailingObjects<Stmt *>()[bodyOffset()];
2092  }
2093 
2094  void setBody(Stmt *Body) {
2095  getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2096  }
2097 
2099  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2100  : nullptr;
2101  }
2102 
2103  const Stmt *getInit() const {
2104  return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2105  : nullptr;
2106  }
2107 
2108  void setInit(Stmt *Init) {
2109  assert(hasInitStorage() &&
2110  "This switch statement has no storage for an init statement!");
2111  getTrailingObjects<Stmt *>()[initOffset()] = Init;
2112  }
2113 
2114  /// Retrieve the variable declared in this "switch" statement, if any.
2115  ///
2116  /// In the following example, "x" is the condition variable.
2117  /// \code
2118  /// switch (int x = foo()) {
2119  /// case 0: break;
2120  /// // ...
2121  /// }
2122  /// \endcode
2123  VarDecl *getConditionVariable();
2125  return const_cast<SwitchStmt *>(this)->getConditionVariable();
2126  }
2127 
2128  /// Set the condition variable in this switch statement.
2129  /// The switch statement must have storage for it.
2130  void setConditionVariable(const ASTContext &Ctx, VarDecl *VD);
2131 
2132  /// If this SwitchStmt has a condition variable, return the faux DeclStmt
2133  /// associated with the creation of that condition variable.
2135  return hasVarStorage() ? static_cast<DeclStmt *>(
2136  getTrailingObjects<Stmt *>()[varOffset()])
2137  : nullptr;
2138  }
2139 
2141  return hasVarStorage() ? static_cast<DeclStmt *>(
2142  getTrailingObjects<Stmt *>()[varOffset()])
2143  : nullptr;
2144  }
2145 
2146  SwitchCase *getSwitchCaseList() { return FirstCase; }
2147  const SwitchCase *getSwitchCaseList() const { return FirstCase; }
2148  void setSwitchCaseList(SwitchCase *SC) { FirstCase = SC; }
2149 
2150  SourceLocation getSwitchLoc() const { return SwitchStmtBits.SwitchLoc; }
2151  void setSwitchLoc(SourceLocation L) { SwitchStmtBits.SwitchLoc = L; }
2152 
2153  void setBody(Stmt *S, SourceLocation SL) {
2154  setBody(S);
2155  setSwitchLoc(SL);
2156  }
2157 
2159  assert(!SC->getNextSwitchCase() &&
2160  "case/default already added to a switch");
2161  SC->setNextSwitchCase(FirstCase);
2162  FirstCase = SC;
2163  }
2164 
2165  /// Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a
2166  /// switch over an enum value then all cases have been explicitly covered.
2167  void setAllEnumCasesCovered() { SwitchStmtBits.AllEnumCasesCovered = true; }
2168 
2169  /// Returns true if the SwitchStmt is a switch of an enum value and all cases
2170  /// have been explicitly covered.
2171  bool isAllEnumCasesCovered() const {
2172  return SwitchStmtBits.AllEnumCasesCovered;
2173  }
2174 
2175  SourceLocation getBeginLoc() const { return getSwitchLoc(); }
2176  SourceLocation getEndLoc() const LLVM_READONLY {
2177  return getBody() ? getBody()->getEndLoc()
2178  : reinterpret_cast<const Stmt *>(getCond())->getEndLoc();
2179  }
2180 
2181  // Iterators
2183  return child_range(getTrailingObjects<Stmt *>(),
2184  getTrailingObjects<Stmt *>() +
2185  numTrailingObjects(OverloadToken<Stmt *>()));
2186  }
2187 
2189  return const_child_range(getTrailingObjects<Stmt *>(),
2190  getTrailingObjects<Stmt *>() +
2191  numTrailingObjects(OverloadToken<Stmt *>()));
2192  }
2193 
2194  static bool classof(const Stmt *T) {
2195  return T->getStmtClass() == SwitchStmtClass;
2196  }
2197 };
2198 
2199 /// WhileStmt - This represents a 'while' stmt.
2200 class WhileStmt final : public Stmt,
2201  private llvm::TrailingObjects<WhileStmt, Stmt *> {
2202  friend TrailingObjects;
2203 
2204  // WhileStmt is followed by several trailing objects,
2205  // some of which optional. Note that it would be more
2206  // convenient to put the optional trailing object at the end
2207  // but this would affect children().
2208  // The trailing objects are in order:
2209  //
2210  // * A "Stmt *" for the condition variable.
2211  // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
2212  //
2213  // * A "Stmt *" for the condition.
2214  // Always present. This is in fact an "Expr *".
2215  //
2216  // * A "Stmt *" for the body.
2217  // Always present.
2218  //
2219  enum { VarOffset = 0, BodyOffsetFromCond = 1 };
2220  enum { NumMandatoryStmtPtr = 2 };
2221 
2222  unsigned varOffset() const { return VarOffset; }
2223  unsigned condOffset() const { return VarOffset + hasVarStorage(); }
2224  unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
2225 
2226  unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2227  return NumMandatoryStmtPtr + hasVarStorage();
2228  }
2229 
2230  /// Build a while statement.
2231  WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body,
2232  SourceLocation WL);
2233 
2234  /// Build an empty while statement.
2235  explicit WhileStmt(EmptyShell Empty, bool HasVar);
2236 
2237 public:
2238  /// Create a while statement.
2239  static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
2240  Stmt *Body, SourceLocation WL);
2241 
2242  /// Create an empty while statement optionally with storage for
2243  /// a condition variable.
2244  static WhileStmt *CreateEmpty(const ASTContext &Ctx, bool HasVar);
2245 
2246  /// True if this WhileStmt has storage for a condition variable.
2247  bool hasVarStorage() const { return WhileStmtBits.HasVar; }
2248 
2250  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2251  }
2252 
2253  const Expr *getCond() const {
2254  return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2255  }
2256 
2257  void setCond(Expr *Cond) {
2258  getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2259  }
2260 
2261  Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; }
2262  const Stmt *getBody() const {
2263  return getTrailingObjects<Stmt *>()[bodyOffset()];
2264  }
2265 
2266  void setBody(Stmt *Body) {
2267  getTrailingObjects<Stmt *>()[bodyOffset()] = Body;
2268  }
2269 
2270  /// Retrieve the variable declared in this "while" statement, if any.
2271  ///
2272  /// In the following example, "x" is the condition variable.
2273  /// \code
2274  /// while (int x = random()) {
2275  /// // ...
2276  /// }
2277  /// \endcode
2278  VarDecl *getConditionVariable();
2280  return const_cast<WhileStmt *>(this)->getConditionVariable();
2281  }
2282 
2283  /// Set the condition variable of this while statement.
2284  /// The while statement must have storage for it.
2285  void setConditionVariable(const ASTContext &Ctx, VarDecl *V);
2286 
2287  /// If this WhileStmt has a condition variable, return the faux DeclStmt
2288  /// associated with the creation of that condition variable.
2290  return hasVarStorage() ? static_cast<DeclStmt *>(
2291  getTrailingObjects<Stmt *>()[varOffset()])
2292  : nullptr;
2293  }
2294 
2296  return hasVarStorage() ? static_cast<DeclStmt *>(
2297  getTrailingObjects<Stmt *>()[varOffset()])
2298  : nullptr;
2299  }
2300 
2301  SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; }
2302  void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; }
2303 
2304  SourceLocation getBeginLoc() const { return getWhileLoc(); }
2305  SourceLocation getEndLoc() const LLVM_READONLY {
2306  return getBody()->getEndLoc();
2307  }
2308 
2309  static bool classof(const Stmt *T) {
2310  return T->getStmtClass() == WhileStmtClass;
2311  }
2312 
2313  // Iterators
2315  return child_range(getTrailingObjects<Stmt *>(),
2316  getTrailingObjects<Stmt *>() +
2317  numTrailingObjects(OverloadToken<Stmt *>()));
2318  }
2319 
2321  return const_child_range(getTrailingObjects<Stmt *>(),
2322  getTrailingObjects<Stmt *>() +
2323  numTrailingObjects(OverloadToken<Stmt *>()));
2324  }
2325 };
2326 
2327 /// DoStmt - This represents a 'do/while' stmt.
2328 class DoStmt : public Stmt {
2329  enum { BODY, COND, END_EXPR };
2330  Stmt *SubExprs[END_EXPR];
2331  SourceLocation WhileLoc;
2332  SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
2333 
2334 public:
2336  SourceLocation RP)
2337  : Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2338  setCond(Cond);
2339  setBody(Body);
2340  setDoLoc(DL);
2341  }
2342 
2343  /// Build an empty do-while statement.
2344  explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) {}
2345 
2346  Expr *getCond() { return reinterpret_cast<Expr *>(SubExprs[COND]); }
2347  const Expr *getCond() const {
2348  return reinterpret_cast<Expr *>(SubExprs[COND]);
2349  }
2350 
2351  void setCond(Expr *Cond) { SubExprs[COND] = reinterpret_cast<Stmt *>(Cond); }
2352 
2353  Stmt *getBody() { return SubExprs[BODY]; }
2354  const Stmt *getBody() const { return SubExprs[BODY]; }
2355  void setBody(Stmt *Body) { SubExprs[BODY] = Body; }
2356 
2357  SourceLocation getDoLoc() const { return DoStmtBits.DoLoc; }
2358  void setDoLoc(SourceLocation L) { DoStmtBits.DoLoc = L; }
2359  SourceLocation getWhileLoc() const { return WhileLoc; }
2360  void setWhileLoc(SourceLocation L) { WhileLoc = L; }
2361  SourceLocation getRParenLoc() const { return RParenLoc; }
2362  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2363 
2364  SourceLocation getBeginLoc() const { return getDoLoc(); }
2365  SourceLocation getEndLoc() const { return getRParenLoc(); }
2366 
2367  static bool classof(const Stmt *T) {
2368  return T->getStmtClass() == DoStmtClass;
2369  }
2370 
2371  // Iterators
2373  return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2374  }
2375 
2377  return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2378  }
2379 };
2380 
2381 /// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of
2382 /// the init/cond/inc parts of the ForStmt will be null if they were not
2383 /// specified in the source.
2384 class ForStmt : public Stmt {
2385  enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2386  Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
2387  SourceLocation LParenLoc, RParenLoc;
2388 
2389 public:
2390  ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
2391  Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
2392  SourceLocation RP);
2393 
2394  /// Build an empty for statement.
2395  explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) {}
2396 
2397  Stmt *getInit() { return SubExprs[INIT]; }
2398 
2399  /// Retrieve the variable declared in this "for" statement, if any.
2400  ///
2401  /// In the following example, "y" is the condition variable.
2402  /// \code
2403  /// for (int x = random(); int y = mangle(x); ++x) {
2404  /// // ...
2405  /// }
2406  /// \endcode
2407  VarDecl *getConditionVariable() const;
2408  void setConditionVariable(const ASTContext &C, VarDecl *V);
2409 
2410  /// If this ForStmt has a condition variable, return the faux DeclStmt
2411  /// associated with the creation of that condition variable.
2413  return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
2414  }
2415 
2416  Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
2417  Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
2418  Stmt *getBody() { return SubExprs[BODY]; }
2419 
2420  const Stmt *getInit() const { return SubExprs[INIT]; }
2421  const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
2422  const Expr *getInc() const { return reinterpret_cast<Expr*>(SubExprs[INC]); }
2423  const Stmt *getBody() const { return SubExprs[BODY]; }
2424 
2425  void setInit(Stmt *S) { SubExprs[INIT] = S; }
2426  void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
2427  void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
2428  void setBody(Stmt *S) { SubExprs[BODY] = S; }
2429 
2430  SourceLocation getForLoc() const { return ForStmtBits.ForLoc; }
2431  void setForLoc(SourceLocation L) { ForStmtBits.ForLoc = L; }
2432  SourceLocation getLParenLoc() const { return LParenLoc; }
2433  void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2434  SourceLocation getRParenLoc() const { return RParenLoc; }
2435  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2436 
2437  SourceLocation getBeginLoc() const { return getForLoc(); }
2438  SourceLocation getEndLoc() const { return getBody()->getEndLoc(); }
2439 
2440  static bool classof(const Stmt *T) {
2441  return T->getStmtClass() == ForStmtClass;
2442  }
2443 
2444  // Iterators
2446  return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2447  }
2448 
2450  return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2451  }
2452 };
2453 
2454 /// GotoStmt - This represents a direct goto.
2455 class GotoStmt : public Stmt {
2456  LabelDecl *Label;
2457  SourceLocation LabelLoc;
2458 
2459 public:
2461  : Stmt(GotoStmtClass), Label(label), LabelLoc(LL) {
2462  setGotoLoc(GL);
2463  }
2464 
2465  /// Build an empty goto statement.
2466  explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) {}
2467 
2468  LabelDecl *getLabel() const { return Label; }
2469  void setLabel(LabelDecl *D) { Label = D; }
2470 
2471  SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; }
2472  void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; }
2473  SourceLocation getLabelLoc() const { return LabelLoc; }
2474  void setLabelLoc(SourceLocation L) { LabelLoc = L; }
2475 
2476  SourceLocation getBeginLoc() const { return getGotoLoc(); }
2477  SourceLocation getEndLoc() const { return getLabelLoc(); }
2478 
2479  static bool classof(const Stmt *T) {
2480  return T->getStmtClass() == GotoStmtClass;
2481  }
2482 
2483  // Iterators
2486  }
2487 
2490  }
2491 };
2492 
2493 /// IndirectGotoStmt - This represents an indirect goto.
2494 class IndirectGotoStmt : public Stmt {
2495  SourceLocation StarLoc;
2496  Stmt *Target;
2497 
2498 public:
2500  : Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
2501  setTarget(target);
2502  setGotoLoc(gotoLoc);
2503  }
2504 
2505  /// Build an empty indirect goto statement.
2507  : Stmt(IndirectGotoStmtClass, Empty) {}
2508 
2509  void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; }
2510  SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; }
2511  void setStarLoc(SourceLocation L) { StarLoc = L; }
2512  SourceLocation getStarLoc() const { return StarLoc; }
2513 
2514  Expr *getTarget() { return reinterpret_cast<Expr *>(Target); }
2515  const Expr *getTarget() const {
2516  return reinterpret_cast<const Expr *>(Target);
2517  }
2518  void setTarget(Expr *E) { Target = reinterpret_cast<Stmt *>(E); }
2519 
2520  /// getConstantTarget - Returns the fixed target of this indirect
2521  /// goto, if one exists.
2522  LabelDecl *getConstantTarget();
2523  const LabelDecl *getConstantTarget() const {
2524  return const_cast<IndirectGotoStmt *>(this)->getConstantTarget();
2525  }
2526 
2527  SourceLocation getBeginLoc() const { return getGotoLoc(); }
2528  SourceLocation getEndLoc() const LLVM_READONLY { return Target->getEndLoc(); }
2529 
2530  static bool classof(const Stmt *T) {
2531  return T->getStmtClass() == IndirectGotoStmtClass;
2532  }
2533 
2534  // Iterators
2535  child_range children() { return child_range(&Target, &Target + 1); }
2536 
2538  return const_child_range(&Target, &Target + 1);
2539  }
2540 };
2541 
2542 /// ContinueStmt - This represents a continue.
2543 class ContinueStmt : public Stmt {
2544 public:
2545  ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) {
2546  setContinueLoc(CL);
2547  }
2548 
2549  /// Build an empty continue statement.
2550  explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {}
2551 
2552  SourceLocation getContinueLoc() const { return ContinueStmtBits.ContinueLoc; }
2553  void setContinueLoc(SourceLocation L) { ContinueStmtBits.ContinueLoc = L; }
2554 
2555  SourceLocation getBeginLoc() const { return getContinueLoc(); }
2556  SourceLocation getEndLoc() const { return getContinueLoc(); }
2557 
2558  static bool classof(const Stmt *T) {
2559  return T->getStmtClass() == ContinueStmtClass;
2560  }
2561 
2562  // Iterators
2565  }
2566 
2569  }
2570 };
2571 
2572 /// BreakStmt - This represents a break.
2573 class BreakStmt : public Stmt {
2574 public:
2575  BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass) {
2576  setBreakLoc(BL);
2577  }
2578 
2579  /// Build an empty break statement.
2580  explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) {}
2581 
2582  SourceLocation getBreakLoc() const { return BreakStmtBits.BreakLoc; }
2583  void setBreakLoc(SourceLocation L) { BreakStmtBits.BreakLoc = L; }
2584 
2585  SourceLocation getBeginLoc() const { return getBreakLoc(); }
2586  SourceLocation getEndLoc() const { return getBreakLoc(); }
2587 
2588  static bool classof(const Stmt *T) {
2589  return T->getStmtClass() == BreakStmtClass;
2590  }
2591 
2592  // Iterators
2595  }
2596 
2599  }
2600 };
2601 
2602 /// ReturnStmt - This represents a return, optionally of an expression:
2603 /// return;
2604 /// return 4;
2605 ///
2606 /// Note that GCC allows return with no argument in a function declared to
2607 /// return a value, and it allows returning a value in functions declared to
2608 /// return void. We explicitly model this in the AST, which means you can't
2609 /// depend on the return type of the function and the presence of an argument.
2610 class ReturnStmt final
2611  : public Stmt,
2612  private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
2613  friend TrailingObjects;
2614 
2615  /// The return expression.
2616  Stmt *RetExpr;
2617 
2618  // ReturnStmt is followed optionally by a trailing "const VarDecl *"
2619  // for the NRVO candidate. Present if and only if hasNRVOCandidate().
2620 
2621  /// True if this ReturnStmt has storage for an NRVO candidate.
2622  bool hasNRVOCandidate() const { return ReturnStmtBits.HasNRVOCandidate; }
2623 
2624  unsigned numTrailingObjects(OverloadToken<const VarDecl *>) const {
2625  return hasNRVOCandidate();
2626  }
2627 
2628  /// Build a return statement.
2629  ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate);
2630 
2631  /// Build an empty return statement.
2632  explicit ReturnStmt(EmptyShell Empty, bool HasNRVOCandidate);
2633 
2634 public:
2635  /// Create a return statement.
2636  static ReturnStmt *Create(const ASTContext &Ctx, SourceLocation RL, Expr *E,
2637  const VarDecl *NRVOCandidate);
2638 
2639  /// Create an empty return statement, optionally with
2640  /// storage for an NRVO candidate.
2641  static ReturnStmt *CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate);
2642 
2643  Expr *getRetValue() { return reinterpret_cast<Expr *>(RetExpr); }
2644  const Expr *getRetValue() const { return reinterpret_cast<Expr *>(RetExpr); }
2645  void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt *>(E); }
2646 
2647  /// Retrieve the variable that might be used for the named return
2648  /// value optimization.
2649  ///
2650  /// The optimization itself can only be performed if the variable is
2651  /// also marked as an NRVO object.
2652  const VarDecl *getNRVOCandidate() const {
2653  return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>()
2654  : nullptr;
2655  }
2656 
2657  /// Set the variable that might be used for the named return value
2658  /// optimization. The return statement must have storage for it,
2659  /// which is the case if and only if hasNRVOCandidate() is true.
2660  void setNRVOCandidate(const VarDecl *Var) {
2661  assert(hasNRVOCandidate() &&
2662  "This return statement has no storage for an NRVO candidate!");
2663  *getTrailingObjects<const VarDecl *>() = Var;
2664  }
2665 
2666  SourceLocation getReturnLoc() const { return ReturnStmtBits.RetLoc; }
2667  void setReturnLoc(SourceLocation L) { ReturnStmtBits.RetLoc = L; }
2668 
2669  SourceLocation getBeginLoc() const { return getReturnLoc(); }
2670  SourceLocation getEndLoc() const LLVM_READONLY {
2671  return RetExpr ? RetExpr->getEndLoc() : getReturnLoc();
2672  }
2673 
2674  static bool classof(const Stmt *T) {
2675  return T->getStmtClass() == ReturnStmtClass;
2676  }
2677 
2678  // Iterators
2680  if (RetExpr)
2681  return child_range(&RetExpr, &RetExpr + 1);
2683  }
2684 
2686  if (RetExpr)
2687  return const_child_range(&RetExpr, &RetExpr + 1);
2689  }
2690 };
2691 
2692 /// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
2693 class AsmStmt : public Stmt {
2694 protected:
2695  friend class ASTStmtReader;
2696 
2698 
2699  /// True if the assembly statement does not have any input or output
2700  /// operands.
2701  bool IsSimple;
2702 
2703  /// If true, treat this inline assembly as having side effects.
2704  /// This assembly statement should not be optimized, deleted or moved.
2706 
2707  unsigned NumOutputs;
2708  unsigned NumInputs;
2709  unsigned NumClobbers;
2710 
2711  Stmt **Exprs = nullptr;
2712 
2713  AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile,
2714  unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
2715  : Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
2716  NumOutputs(numoutputs), NumInputs(numinputs),
2717  NumClobbers(numclobbers) {}
2718 
2719 public:
2720  /// Build an empty inline-assembly statement.
2721  explicit AsmStmt(StmtClass SC, EmptyShell Empty) : Stmt(SC, Empty) {}
2722 
2723  SourceLocation getAsmLoc() const { return AsmLoc; }
2724  void setAsmLoc(SourceLocation L) { AsmLoc = L; }
2725 
2726  bool isSimple() const { return IsSimple; }
2727  void setSimple(bool V) { IsSimple = V; }
2728 
2729  bool isVolatile() const { return IsVolatile; }
2730  void setVolatile(bool V) { IsVolatile = V; }
2731 
2732  SourceLocation getBeginLoc() const LLVM_READONLY { return {}; }
2733  SourceLocation getEndLoc() const LLVM_READONLY { return {}; }
2734 
2735  //===--- Asm String Analysis ---===//
2736 
2737  /// Assemble final IR asm string.
2738  std::string generateAsmString(const ASTContext &C) const;
2739 
2740  //===--- Output operands ---===//
2741 
2742  unsigned getNumOutputs() const { return NumOutputs; }
2743 
2744  /// getOutputConstraint - Return the constraint string for the specified
2745  /// output operand. All output constraints are known to be non-empty (either
2746  /// '=' or '+').
2747  StringRef getOutputConstraint(unsigned i) const;
2748 
2749  /// isOutputPlusConstraint - Return true if the specified output constraint
2750  /// is a "+" constraint (which is both an input and an output) or false if it
2751  /// is an "=" constraint (just an output).
2752  bool isOutputPlusConstraint(unsigned i) const {
2753  return getOutputConstraint(i)[0] == '+';
2754  }
2755 
2756  const Expr *getOutputExpr(unsigned i) const;
2757 
2758  /// getNumPlusOperands - Return the number of output operands that have a "+"
2759  /// constraint.
2760  unsigned getNumPlusOperands() const;
2761 
2762  //===--- Input operands ---===//
2763 
2764  unsigned getNumInputs() const { return NumInputs; }
2765 
2766  /// getInputConstraint - Return the specified input constraint. Unlike output
2767  /// constraints, these can be empty.
2768  StringRef getInputConstraint(unsigned i) const;
2769 
2770  const Expr *getInputExpr(unsigned i) const;
2771 
2772  //===--- Other ---===//
2773 
2774  unsigned getNumClobbers() const { return NumClobbers; }
2775  StringRef getClobber(unsigned i) const;
2776 
2777  static bool classof(const Stmt *T) {
2778  return T->getStmtClass() == GCCAsmStmtClass ||
2779  T->getStmtClass() == MSAsmStmtClass;
2780  }
2781 
2782  // Input expr iterators.
2783 
2786  using inputs_range = llvm::iterator_range<inputs_iterator>;
2787  using inputs_const_range = llvm::iterator_range<const_inputs_iterator>;
2788 
2790  return &Exprs[0] + NumOutputs;
2791  }
2792 
2794  return &Exprs[0] + NumOutputs + NumInputs;
2795  }
2796 
2797  inputs_range inputs() { return inputs_range(begin_inputs(), end_inputs()); }
2798 
2800  return &Exprs[0] + NumOutputs;
2801  }
2802 
2804  return &Exprs[0] + NumOutputs + NumInputs;
2805  }
2806 
2808  return inputs_const_range(begin_inputs(), end_inputs());
2809  }
2810 
2811  // Output expr iterators.
2812 
2815  using outputs_range = llvm::iterator_range<outputs_iterator>;
2816  using outputs_const_range = llvm::iterator_range<const_outputs_iterator>;
2817 
2819  return &Exprs[0];
2820  }
2821 
2823  return &Exprs[0] + NumOutputs;
2824  }
2825 
2827  return outputs_range(begin_outputs(), end_outputs());
2828  }
2829 
2831  return &Exprs[0];
2832  }
2833 
2835  return &Exprs[0] + NumOutputs;
2836  }
2837 
2839  return outputs_const_range(begin_outputs(), end_outputs());
2840  }
2841 
2843  return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
2844  }
2845 
2847  return const_child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
2848  }
2849 };
2850 
2851 /// This represents a GCC inline-assembly statement extension.
2852 class GCCAsmStmt : public AsmStmt {
2853  friend class ASTStmtReader;
2854 
2855  SourceLocation RParenLoc;
2856  StringLiteral *AsmStr;
2857 
2858  // FIXME: If we wanted to, we could allocate all of these in one big array.
2859  StringLiteral **Constraints = nullptr;
2860  StringLiteral **Clobbers = nullptr;
2861  IdentifierInfo **Names = nullptr;
2862  unsigned NumLabels = 0;
2863 
2864 public:
2865  GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple,
2866  bool isvolatile, unsigned numoutputs, unsigned numinputs,
2867  IdentifierInfo **names, StringLiteral **constraints, Expr **exprs,
2868  StringLiteral *asmstr, unsigned numclobbers,
2869  StringLiteral **clobbers, unsigned numlabels,
2870  SourceLocation rparenloc);
2871 
2872  /// Build an empty inline-assembly statement.
2873  explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty) {}
2874 
2875  SourceLocation getRParenLoc() const { return RParenLoc; }
2876  void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2877 
2878  //===--- Asm String Analysis ---===//
2879 
2880  const StringLiteral *getAsmString() const { return AsmStr; }
2881  StringLiteral *getAsmString() { return AsmStr; }
2882  void setAsmString(StringLiteral *E) { AsmStr = E; }
2883 
2884  /// AsmStringPiece - this is part of a decomposed asm string specification
2885  /// (for use with the AnalyzeAsmString function below). An asm string is
2886  /// considered to be a concatenation of these parts.
2888  public:
2889  enum Kind {
2890  String, // String in .ll asm string form, "$" -> "$$" and "%%" -> "%".
2891  Operand // Operand reference, with optional modifier %c4.
2892  };
2893 
2894  private:
2895  Kind MyKind;
2896  std::string Str;
2897  unsigned OperandNo;
2898 
2899  // Source range for operand references.
2900  CharSourceRange Range;
2901 
2902  public:
2903  AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {}
2904  AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin,
2906  : MyKind(Operand), Str(S), OperandNo(OpNo),
2907  Range(CharSourceRange::getCharRange(Begin, End)) {}
2908 
2909  bool isString() const { return MyKind == String; }
2910  bool isOperand() const { return MyKind == Operand; }
2911 
2912  const std::string &getString() const { return Str; }
2913 
2914  unsigned getOperandNo() const {
2915  assert(isOperand());
2916  return OperandNo;
2917  }
2918 
2920  assert(isOperand() && "Range is currently used only for Operands.");
2921  return Range;
2922  }
2923 
2924  /// getModifier - Get the modifier for this operand, if present. This
2925  /// returns '\0' if there was no modifier.
2926  char getModifier() const;
2927  };
2928 
2929  /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
2930  /// it into pieces. If the asm string is erroneous, emit errors and return
2931  /// true, otherwise return false. This handles canonicalization and
2932  /// translation of strings from GCC syntax to LLVM IR syntax, and handles
2933  //// flattening of named references like %[foo] to Operand AsmStringPiece's.
2934  unsigned AnalyzeAsmString(SmallVectorImpl<AsmStringPiece> &Pieces,
2935  const ASTContext &C, unsigned &DiagOffs) const;
2936 
2937  /// Assemble final IR asm string.
2938  std::string generateAsmString(const ASTContext &C) const;
2939 
2940  //===--- Output operands ---===//
2941 
2942  IdentifierInfo *getOutputIdentifier(unsigned i) const { return Names[i]; }
2943 
2944  StringRef getOutputName(unsigned i) const {
2945  if (IdentifierInfo *II = getOutputIdentifier(i))
2946  return II->getName();
2947 
2948  return {};
2949  }
2950 
2951  StringRef getOutputConstraint(unsigned i) const;
2952 
2953  const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
2954  return Constraints[i];
2955  }
2957  return Constraints[i];
2958  }
2959 
2960  Expr *getOutputExpr(unsigned i);
2961 
2962  const Expr *getOutputExpr(unsigned i) const {
2963  return const_cast<GCCAsmStmt*>(this)->getOutputExpr(i);
2964  }
2965 
2966  //===--- Input operands ---===//
2967 
2968  IdentifierInfo *getInputIdentifier(unsigned i) const {
2969  return Names[i + NumOutputs];
2970  }
2971 
2972  StringRef getInputName(unsigned i) const {
2973  if (IdentifierInfo *II = getInputIdentifier(i))
2974  return II->getName();
2975 
2976  return {};
2977  }
2978 
2979  StringRef getInputConstraint(unsigned i) const;
2980 
2981  const StringLiteral *getInputConstraintLiteral(unsigned i) const {
2982  return Constraints[i + NumOutputs];
2983  }
2985  return Constraints[i + NumOutputs];
2986  }
2987 
2988  Expr *getInputExpr(unsigned i);
2989  void setInputExpr(unsigned i, Expr *E);
2990 
2991  const Expr *getInputExpr(unsigned i) const {
2992  return const_cast<GCCAsmStmt*>(this)->getInputExpr(i);
2993  }
2994 
2995  //===--- Labels ---===//
2996 
2997  bool isAsmGoto() const {
2998  return NumLabels > 0;
2999  }
3000 
3001  unsigned getNumLabels() const {
3002  return NumLabels;
3003  }
3004 
3005  IdentifierInfo *getLabelIdentifier(unsigned i) const {
3006  return Names[i + NumInputs];
3007  }
3008 
3009  AddrLabelExpr *getLabelExpr(unsigned i) const;
3010  StringRef getLabelName(unsigned i) const;
3013  using labels_range = llvm::iterator_range<labels_iterator>;
3014  using labels_const_range = llvm::iterator_range<const_labels_iterator>;
3015 
3017  return &Exprs[0] + NumInputs;
3018  }
3019 
3021  return &Exprs[0] + NumInputs + NumLabels;
3022  }
3023 
3025  return labels_range(begin_labels(), end_labels());
3026  }
3027 
3029  return &Exprs[0] + NumInputs;
3030  }
3031 
3033  return &Exprs[0] + NumInputs + NumLabels;
3034  }
3035 
3037  return labels_const_range(begin_labels(), end_labels());
3038  }
3039 
3040 private:
3041  void setOutputsAndInputsAndClobbers(const ASTContext &C,
3042  IdentifierInfo **Names,
3043  StringLiteral **Constraints,
3044  Stmt **Exprs,
3045  unsigned NumOutputs,
3046  unsigned NumInputs,
3047  unsigned NumLabels,
3048  StringLiteral **Clobbers,
3049  unsigned NumClobbers);
3050 
3051 public:
3052  //===--- Other ---===//
3053 
3054  /// getNamedOperand - Given a symbolic operand reference like %[foo],
3055  /// translate this into a numeric value needed to reference the same operand.
3056  /// This returns -1 if the operand name is invalid.
3057  int getNamedOperand(StringRef SymbolicName) const;
3058 
3059  StringRef getClobber(unsigned i) const;
3060 
3061  StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; }
3062  const StringLiteral *getClobberStringLiteral(unsigned i) const {
3063  return Clobbers[i];
3064  }
3065 
3066  SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; }
3067  SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
3068 
3069  static bool classof(const Stmt *T) {
3070  return T->getStmtClass() == GCCAsmStmtClass;
3071  }
3072 };
3073 
3074 /// This represents a Microsoft inline-assembly statement extension.
3075 class MSAsmStmt : public AsmStmt {
3076  friend class ASTStmtReader;
3077 
3078  SourceLocation LBraceLoc, EndLoc;
3079  StringRef AsmStr;
3080 
3081  unsigned NumAsmToks = 0;
3082 
3083  Token *AsmToks = nullptr;
3084  StringRef *Constraints = nullptr;
3085  StringRef *Clobbers = nullptr;
3086 
3087 public:
3088  MSAsmStmt(const ASTContext &C, SourceLocation asmloc,
3089  SourceLocation lbraceloc, bool issimple, bool isvolatile,
3090  ArrayRef<Token> asmtoks, unsigned numoutputs, unsigned numinputs,
3091  ArrayRef<StringRef> constraints,
3092  ArrayRef<Expr*> exprs, StringRef asmstr,
3093  ArrayRef<StringRef> clobbers, SourceLocation endloc);
3094 
3095  /// Build an empty MS-style inline-assembly statement.
3096  explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty) {}
3097 
3098  SourceLocation getLBraceLoc() const { return LBraceLoc; }
3099  void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
3100  SourceLocation getEndLoc() const { return EndLoc; }
3101  void setEndLoc(SourceLocation L) { EndLoc = L; }
3102 
3103  bool hasBraces() const { return LBraceLoc.isValid(); }
3104 
3105  unsigned getNumAsmToks() { return NumAsmToks; }
3106  Token *getAsmToks() { return AsmToks; }
3107 
3108  //===--- Asm String Analysis ---===//
3109  StringRef getAsmString() const { return AsmStr; }
3110 
3111  /// Assemble final IR asm string.
3112  std::string generateAsmString(const ASTContext &C) const;
3113 
3114  //===--- Output operands ---===//
3115 
3116  StringRef getOutputConstraint(unsigned i) const {
3117  assert(i < NumOutputs);
3118  return Constraints[i];
3119  }
3120 
3121  Expr *getOutputExpr(unsigned i);
3122 
3123  const Expr *getOutputExpr(unsigned i) const {
3124  return const_cast<MSAsmStmt*>(this)->getOutputExpr(i);
3125  }
3126 
3127  //===--- Input operands ---===//
3128 
3129  StringRef getInputConstraint(unsigned i) const {
3130  assert(i < NumInputs);
3131  return Constraints[i + NumOutputs];
3132  }
3133 
3134  Expr *getInputExpr(unsigned i);
3135  void setInputExpr(unsigned i, Expr *E);
3136 
3137  const Expr *getInputExpr(unsigned i) const {
3138  return const_cast<MSAsmStmt*>(this)->getInputExpr(i);
3139  }
3140 
3141  //===--- Other ---===//
3142 
3144  return llvm::makeArrayRef(Constraints, NumInputs + NumOutputs);
3145  }
3146 
3148  return llvm::makeArrayRef(Clobbers, NumClobbers);
3149  }
3150 
3152  return llvm::makeArrayRef(reinterpret_cast<Expr**>(Exprs),
3153  NumInputs + NumOutputs);
3154  }
3155 
3156  StringRef getClobber(unsigned i) const { return getClobbers()[i]; }
3157 
3158 private:
3159  void initialize(const ASTContext &C, StringRef AsmString,
3160  ArrayRef<Token> AsmToks, ArrayRef<StringRef> Constraints,
3161  ArrayRef<Expr*> Exprs, ArrayRef<StringRef> Clobbers);
3162 
3163 public:
3164  SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; }
3165 
3166  static bool classof(const Stmt *T) {
3167  return T->getStmtClass() == MSAsmStmtClass;
3168  }
3169 
3171  return child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]);
3172  }
3173 
3175  return const_child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]);
3176  }
3177 };
3178 
3179 class SEHExceptStmt : public Stmt {
3180  friend class ASTReader;
3181  friend class ASTStmtReader;
3182 
3183  SourceLocation Loc;
3184  Stmt *Children[2];
3185 
3186  enum { FILTER_EXPR, BLOCK };
3187 
3188  SEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block);
3189  explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) {}
3190 
3191 public:
3192  static SEHExceptStmt* Create(const ASTContext &C,
3193  SourceLocation ExceptLoc,
3194  Expr *FilterExpr,
3195  Stmt *Block);
3196 
3197  SourceLocation getBeginLoc() const LLVM_READONLY { return getExceptLoc(); }
3198 
3199  SourceLocation getExceptLoc() const { return Loc; }
3200  SourceLocation getEndLoc() const { return getBlock()->getEndLoc(); }
3201 
3202  Expr *getFilterExpr() const {
3203  return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
3204  }
3205 
3207  return cast<CompoundStmt>(Children[BLOCK]);
3208  }
3209 
3211  return child_range(Children, Children+2);
3212  }
3213 
3215  return const_child_range(Children, Children + 2);
3216  }
3217 
3218  static bool classof(const Stmt *T) {
3219  return T->getStmtClass() == SEHExceptStmtClass;
3220  }
3221 };
3222 
3223 class SEHFinallyStmt : public Stmt {
3224  friend class ASTReader;
3225  friend class ASTStmtReader;
3226 
3227  SourceLocation Loc;
3228  Stmt *Block;
3229 
3230  SEHFinallyStmt(SourceLocation Loc, Stmt *Block);
3231  explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) {}
3232 
3233 public:
3234  static SEHFinallyStmt* Create(const ASTContext &C,
3235  SourceLocation FinallyLoc,
3236  Stmt *Block);
3237 
3238  SourceLocation getBeginLoc() const LLVM_READONLY { return getFinallyLoc(); }
3239 
3240  SourceLocation getFinallyLoc() const { return Loc; }
3241  SourceLocation getEndLoc() const { return Block->getEndLoc(); }
3242 
3243  CompoundStmt *getBlock() const { return cast<CompoundStmt>(Block); }
3244 
3246  return child_range(&Block,&Block+1);
3247  }
3248 
3250  return const_child_range(&Block, &Block + 1);
3251  }
3252 
3253  static bool classof(const Stmt *T) {
3254  return T->getStmtClass() == SEHFinallyStmtClass;
3255  }
3256 };
3257 
3258 class SEHTryStmt : public Stmt {
3259  friend class ASTReader;
3260  friend class ASTStmtReader;
3261 
3262  bool IsCXXTry;
3263  SourceLocation TryLoc;
3264  Stmt *Children[2];
3265 
3266  enum { TRY = 0, HANDLER = 1 };
3267 
3268  SEHTryStmt(bool isCXXTry, // true if 'try' otherwise '__try'
3269  SourceLocation TryLoc,
3270  Stmt *TryBlock,
3271  Stmt *Handler);
3272 
3273  explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) {}
3274 
3275 public:
3276  static SEHTryStmt* Create(const ASTContext &C, bool isCXXTry,
3277  SourceLocation TryLoc, Stmt *TryBlock,
3278  Stmt *Handler);
3279 
3280  SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); }
3281 
3282  SourceLocation getTryLoc() const { return TryLoc; }
3283  SourceLocation getEndLoc() const { return Children[HANDLER]->getEndLoc(); }
3284 
3285  bool getIsCXXTry() const { return IsCXXTry; }
3286 
3288  return cast<CompoundStmt>(Children[TRY]);
3289  }
3290 
3291  Stmt *getHandler() const { return Children[HANDLER]; }
3292 
3293  /// Returns 0 if not defined
3294  SEHExceptStmt *getExceptHandler() const;
3295  SEHFinallyStmt *getFinallyHandler() const;
3296 
3298  return child_range(Children, Children+2);
3299  }
3300 
3302  return const_child_range(Children, Children + 2);
3303  }
3304 
3305  static bool classof(const Stmt *T) {
3306  return T->getStmtClass() == SEHTryStmtClass;
3307  }
3308 };
3309 
3310 /// Represents a __leave statement.
3311 class SEHLeaveStmt : public Stmt {
3312  SourceLocation LeaveLoc;
3313 
3314 public:
3316  : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3317 
3318  /// Build an empty __leave statement.
3319  explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) {}
3320 
3321  SourceLocation getLeaveLoc() const { return LeaveLoc; }
3322  void setLeaveLoc(SourceLocation L) { LeaveLoc = L; }
3323 
3324  SourceLocation getBeginLoc() const LLVM_READONLY { return LeaveLoc; }
3325  SourceLocation getEndLoc() const LLVM_READONLY { return LeaveLoc; }
3326 
3327  static bool classof(const Stmt *T) {
3328  return T->getStmtClass() == SEHLeaveStmtClass;
3329  }
3330 
3331  // Iterators
3334  }
3335 
3338  }
3339 };
3340 
3341 /// This captures a statement into a function. For example, the following
3342 /// pragma annotated compound statement can be represented as a CapturedStmt,
3343 /// and this compound statement is the body of an anonymous outlined function.
3344 /// @code
3345 /// #pragma omp parallel
3346 /// {
3347 /// compute();
3348 /// }
3349 /// @endcode
3350 class CapturedStmt : public Stmt {
3351 public:
3352  /// The different capture forms: by 'this', by reference, capture for
3353  /// variable-length array type etc.
3359  };
3360 
3361  /// Describes the capture of either a variable, or 'this', or
3362  /// variable-length array type.
3363  class Capture {
3364  llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
3365  SourceLocation Loc;
3366 
3367  public:
3368  friend class ASTStmtReader;
3369 
3370  /// Create a new capture.
3371  ///
3372  /// \param Loc The source location associated with this capture.
3373  ///
3374  /// \param Kind The kind of capture (this, ByRef, ...).
3375  ///
3376  /// \param Var The variable being captured, or null if capturing this.
3378  VarDecl *Var = nullptr);
3379 
3380  /// Determine the kind of capture.
3381  VariableCaptureKind getCaptureKind() const;
3382 
3383  /// Retrieve the source location at which the variable or 'this' was
3384  /// first used.
3385  SourceLocation getLocation() const { return Loc; }
3386 
3387  /// Determine whether this capture handles the C++ 'this' pointer.
3388  bool capturesThis() const { return getCaptureKind() == VCK_This; }
3389 
3390  /// Determine whether this capture handles a variable (by reference).
3391  bool capturesVariable() const { return getCaptureKind() == VCK_ByRef; }
3392 
3393  /// Determine whether this capture handles a variable by copy.
3394  bool capturesVariableByCopy() const {
3395  return getCaptureKind() == VCK_ByCopy;
3396  }
3397 
3398  /// Determine whether this capture handles a variable-length array
3399  /// type.
3401  return getCaptureKind() == VCK_VLAType;
3402  }
3403 
3404  /// Retrieve the declaration of the variable being captured.
3405  ///
3406  /// This operation is only valid if this capture captures a variable.
3407  VarDecl *getCapturedVar() const;
3408  };
3409 
3410 private:
3411  /// The number of variable captured, including 'this'.
3412  unsigned NumCaptures;
3413 
3414  /// The pointer part is the implicit the outlined function and the
3415  /// int part is the captured region kind, 'CR_Default' etc.
3416  llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
3417 
3418  /// The record for captured variables, a RecordDecl or CXXRecordDecl.
3419  RecordDecl *TheRecordDecl = nullptr;
3420 
3421  /// Construct a captured statement.
3423  ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD);
3424 
3425  /// Construct an empty captured statement.
3426  CapturedStmt(EmptyShell Empty, unsigned NumCaptures);
3427 
3428  Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); }
3429 
3430  Stmt *const *getStoredStmts() const {
3431  return reinterpret_cast<Stmt *const *>(this + 1);
3432  }
3433 
3434  Capture *getStoredCaptures() const;
3435 
3436  void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; }
3437 
3438 public:
3439  friend class ASTStmtReader;
3440 
3441  static CapturedStmt *Create(const ASTContext &Context, Stmt *S,
3442  CapturedRegionKind Kind,
3443  ArrayRef<Capture> Captures,
3444  ArrayRef<Expr *> CaptureInits,
3445  CapturedDecl *CD, RecordDecl *RD);
3446 
3447  static CapturedStmt *CreateDeserialized(const ASTContext &Context,
3448  unsigned NumCaptures);
3449 
3450  /// Retrieve the statement being captured.
3451  Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; }
3452  const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; }
3453 
3454  /// Retrieve the outlined function declaration.
3455  CapturedDecl *getCapturedDecl();
3456  const CapturedDecl *getCapturedDecl() const;
3457 
3458  /// Set the outlined function declaration.
3459  void setCapturedDecl(CapturedDecl *D);
3460 
3461  /// Retrieve the captured region kind.
3462  CapturedRegionKind getCapturedRegionKind() const;
3463 
3464  /// Set the captured region kind.
3465  void setCapturedRegionKind(CapturedRegionKind Kind);
3466 
3467  /// Retrieve the record declaration for captured variables.
3468  const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; }
3469 
3470  /// Set the record declaration for captured variables.
3472  assert(D && "null RecordDecl");
3473  TheRecordDecl = D;
3474  }
3475 
3476  /// True if this variable has been captured.
3477  bool capturesVariable(const VarDecl *Var) const;
3478 
3479  /// An iterator that walks over the captures.
3482  using capture_range = llvm::iterator_range<capture_iterator>;
3483  using capture_const_range = llvm::iterator_range<const_capture_iterator>;
3484 
3486  return capture_range(capture_begin(), capture_end());
3487  }
3489  return capture_const_range(capture_begin(), capture_end());
3490  }
3491 
3492  /// Retrieve an iterator pointing to the first capture.
3493  capture_iterator capture_begin() { return getStoredCaptures(); }
3494  const_capture_iterator capture_begin() const { return getStoredCaptures(); }
3495 
3496  /// Retrieve an iterator pointing past the end of the sequence of
3497  /// captures.
3499  return getStoredCaptures() + NumCaptures;
3500  }
3501 
3502  /// Retrieve the number of captures, including 'this'.
3503  unsigned capture_size() const { return NumCaptures; }
3504 
3505  /// Iterator that walks over the capture initialization arguments.
3507  using capture_init_range = llvm::iterator_range<capture_init_iterator>;
3508 
3509  /// Const iterator that walks over the capture initialization
3510  /// arguments.
3512  using const_capture_init_range =
3513  llvm::iterator_range<const_capture_init_iterator>;
3514 
3516  return capture_init_range(capture_init_begin(), capture_init_end());
3517  }
3518 
3520  return const_capture_init_range(capture_init_begin(), capture_init_end());
3521  }
3522 
3523  /// Retrieve the first initialization argument.
3525  return reinterpret_cast<Expr **>(getStoredStmts());
3526  }
3527 
3529  return reinterpret_cast<Expr *const *>(getStoredStmts());
3530  }
3531 
3532  /// Retrieve the iterator pointing one past the last initialization
3533  /// argument.
3535  return capture_init_begin() + NumCaptures;
3536  }
3537 
3539  return capture_init_begin() + NumCaptures;
3540  }
3541 
3542  SourceLocation getBeginLoc() const LLVM_READONLY {
3543  return getCapturedStmt()->getBeginLoc();
3544  }
3545 
3546  SourceLocation getEndLoc() const LLVM_READONLY {
3547  return getCapturedStmt()->getEndLoc();
3548  }
3549 
3550  SourceRange getSourceRange() const LLVM_READONLY {
3551  return getCapturedStmt()->getSourceRange();
3552  }
3553 
3554  static bool classof(const Stmt *T) {
3555  return T->getStmtClass() == CapturedStmtClass;
3556  }
3557 
3559 
3560  const_child_range children() const;
3561 };
3562 
3563 } // namespace clang
3564 
3565 #endif // LLVM_CLANG_AST_STMT_H
SourceLocation getRParenLoc() const
Definition: Stmt.h:2361
child_iterator child_begin()
Definition: Stmt.h:1168
Expr * getInc()
Definition: Stmt.h:2417
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2176
labels_iterator end_labels()
Definition: Stmt.h:3020
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:2257
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:78
GotoStmt(EmptyShell Empty)
Build an empty goto statement.
Definition: Stmt.h:2466
SourceLocation getRBracLoc() const
Definition: Stmt.h:1418
void setIsOMPStructuredBlock(bool IsOMPStructuredBlock)
Definition: Stmt.h:1094
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:2968
ConstantExprBitfields ConstantExprBits
Definition: Stmt.h:960
static bool classof(const Stmt *T)
Definition: Stmt.h:2011
child_range children()
Definition: Stmt.h:2182
SourceLocation getRParenLoc() const
Definition: Stmt.h:2875
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:593
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:2852
Stmt * body_back()
Definition: Stmt.h:1348
SourceLocation getBeginLoc() const
Definition: Stmt.h:2437
const Stmt * getElse() const
Definition: Stmt.h:1913
IdentifierInfo * getLabelIdentifier(unsigned i) const
Definition: Stmt.h:3005
body_iterator body_end()
Definition: Stmt.h:1345
unsigned getNumInputs() const
Definition: Stmt.h:2764
SourceLocation getBeginLoc() const
Definition: Stmt.h:2669
UnresolvedMemberExprBitfields UnresolvedMemberExprBits
Definition: Stmt.h:998
CompoundStmt * getBlock() const
Definition: Stmt.h:3243
SourceLocation getForLoc() const
Definition: Stmt.h:2430
SourceLocation getEndLoc() const
Definition: Stmt.h:2556
const Stmt * getBody() const
Definition: Stmt.h:2354
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument.
Definition: Stmt.h:3524
capture_const_range captures() const
Definition: Stmt.h:3488
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:1638
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
Definition: Stmt.h:1553
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
Definition: Stmt.h:2660
static bool classof(const Stmt *T)
Definition: Stmt.h:3166
Expr * getCond()
Definition: Stmt.h:2249
inputs_range inputs()
Definition: Stmt.h:2797
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2537
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
Definition: Stmt.h:1882
const_labels_iterator end_labels() const
Definition: Stmt.h:3032
unsigned getNumAsmToks()
Definition: Stmt.h:3105
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Definition: Dominators.h:30
const_reverse_body_iterator body_rbegin() const
Definition: Stmt.h:1386
outputs_iterator end_outputs()
Definition: Stmt.h:2822
const DeclStmt * getConditionVariableDeclStmt() const
If this ForStmt has a condition variable, return the faux DeclStmt associated with the creation of th...
Definition: Stmt.h:2412
CXXThisExprBitfields CXXThisExprBits
Definition: Stmt.h:983
IndirectGotoStmt(EmptyShell Empty)
Build an empty indirect goto statement.
Definition: Stmt.h:2506
std::reverse_iterator< const_body_iterator > const_reverse_body_iterator
Definition: Stmt.h:1384
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
Definition: Stmt.h:994
Stmt - This represents one statement.
Definition: Stmt.h:66
SourceLocation getEndLoc() const
Definition: Stmt.h:2438
IfStmt - This represents an if/then/else.
Definition: Stmt.h:1812
AsmStmt(StmtClass SC, EmptyShell Empty)
Build an empty inline-assembly statement.
Definition: Stmt.h:2721
bool capturesThis() const
Determine whether this capture handles the C++ &#39;this&#39; pointer.
Definition: Stmt.h:3388
unsigned getNumOutputs() const
Definition: Stmt.h:2742
llvm::iterator_range< body_iterator > body_range
Definition: Stmt.h:1341
ContinueStmt(EmptyShell Empty)
Build an empty continue statement.
Definition: Stmt.h:2550
llvm::iterator_range< labels_iterator > labels_range
Definition: Stmt.h:3013
const StringLiteral * getAsmString() const
Definition: Stmt.h:2880
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:2876
void setContinueLoc(SourceLocation L)
Definition: Stmt.h:2553
const_child_range children() const
Definition: Stmt.h:2488
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:2947
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.h:3123
SourceLocation getIdentLoc() const
Definition: Stmt.h:1724
Represents an attribute applied to a statement.
Definition: Stmt.h:1754
const_child_range children() const
Definition: Stmt.h:2005
const Expr * getOutputExpr(unsigned i) const
Definition: Stmt.h:2962
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:3468
DeclRefExprBitfields DeclRefExprBits
Definition: Stmt.h:962
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1332
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:1229
unsigned NumOutputs
Definition: Stmt.h:2707
bool getIsCXXTry() const
Definition: Stmt.h:3285
child_range children()
Definition: Stmt.h:3332
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:2148
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:2075
void setStartLoc(SourceLocation L)
Definition: Stmt.h:1225
SourceLocation getGotoLoc() const
Definition: Stmt.h:2510
void setForLoc(SourceLocation L)
Definition: Stmt.h:2431
const_child_iterator child_begin() const
Definition: Stmt.h:1171
Stmt * getSubStmt()
Definition: Stmt.h:1645
Represents a variable declaration or definition.
Definition: Decl.h:827
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
Definition: Stmt.h:2652
SourceLocation getLParenLoc() const
Definition: Stmt.h:2432
const_child_range children() const
Definition: Stmt.h:1802
const_child_range children() const
Definition: Stmt.h:2685
static bool classof(const Stmt *T)
Definition: Stmt.h:1420
void setAsmLoc(SourceLocation L)
Definition: Stmt.h:2724
AttributedStmtBitfields AttributedStmtBits
Definition: Stmt.h:946
bool hasInitStorage() const
True if this SwitchStmt has storage for an init statement.
Definition: Stmt.h:2072
const_outputs_iterator begin_outputs() const
Definition: Stmt.h:2830
const Expr * getCond() const
Definition: Stmt.h:2421
Stmt * getThen()
Definition: Stmt.h:1899
SourceLocation getIfLoc() const
Definition: Stmt.h:1971
const Expr * getExprStmt() const
Definition: Stmt.cpp:334
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:3493
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:1050
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3216
llvm::iterator_range< decl_iterator > decl_range
Definition: Stmt.h:1248
StringRef getInputName(unsigned i) const
Definition: Stmt.h:2972
void setThen(Stmt *Then)
Definition: Stmt.h:1904
void setBody(Stmt *S, SourceLocation SL)
Definition: Stmt.h:2153
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition: Stmt.h:1068
void setTarget(Expr *E)
Definition: Stmt.h:2518
CoawaitExprBitfields CoawaitBits
Definition: Stmt.h:1003
static bool classof(const Stmt *T)
Definition: Stmt.h:3305
ArraySubscriptExprBitfields ArraySubscriptExprBits
Definition: Stmt.h:968
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:1710
Represents a struct/union/class.
Definition: Decl.h:3662
Represents a C99 designated initializer expression.
Definition: Expr.h:4611
const Expr * getTarget() const
Definition: Stmt.h:2515
inputs_iterator begin_inputs()
Definition: Stmt.h:2789
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:2353
Represents a statement that could possibly have a value and type.
Definition: Stmt.h:1691
const_outputs_iterator end_outputs() const
Definition: Stmt.h:2834
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), or __builtin_FILE().
Definition: Expr.h:4267
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3971
SourceLocation ColonLoc
The location of the ":".
Definition: Stmt.h:1436
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:2134
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:160
child_range children()
Definition: Stmt.h:3245
const_body_iterator body_begin() const
Definition: Stmt.h:1359
SourceLocation getEndLoc() const
Definition: Stmt.h:1226
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3324
LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
Build a label statement.
Definition: Stmt.h:1716
CharSourceRange getRange() const
Definition: Stmt.h:2919
CharacterLiteralBitfields CharacterLiteralBits
Definition: Stmt.h:965
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:3151
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3280
Stmt * getStmtExprResult()
Definition: Stmt.h:1402
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:2732
SourceLocation getBeginLoc() const
Definition: Stmt.h:1293
SourceLocation getEndLoc() const
Definition: Stmt.h:3283
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:1352
Stmt * body_front()
Definition: Stmt.h:1346
void setReturnLoc(SourceLocation L)
Definition: Stmt.h:2667
llvm::iterator_range< const_inputs_iterator > inputs_const_range
Definition: Stmt.h:2787
MSAsmStmt(EmptyShell Empty)
Build an empty MS-style inline-assembly statement.
Definition: Stmt.h:3096
bool isAsmGoto() const
Definition: Stmt.h:2997
const VarDecl * getConditionVariable() const
Definition: Stmt.h:1933
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3681
void setCond(Expr *Cond)
Definition: Stmt.h:2085
const DeclGroupRef getDeclGroup() const
Definition: Stmt.h:1221
void setIfLoc(SourceLocation IfLoc)
Definition: Stmt.h:1972
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:2171
static bool classof(const Stmt *T)
Definition: Stmt.h:2777
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:188
child_range children()
Definition: Stmt.h:3170
void setSubStmt(Stmt *S)
Definition: Stmt.h:1602
child_range children()
Definition: Stmt.h:2372
SwitchCase(StmtClass SC, SourceLocation KWLoc, SourceLocation ColonLoc)
Definition: Stmt.h:1445
WhileStmtBitfields WhileStmtBits
Definition: Stmt.h:949
const Stmt * getSubStmt() const
Definition: Stmt.h:1733
void addSwitchCase(SwitchCase *SC)
Definition: Stmt.h:2158
child_range children()
Definition: Stmt.h:1300
child_range children()
Definition: Stmt.h:3297
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:3325
static bool classof(const Stmt *T)
Definition: Stmt.h:2309
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:2494
Describes an C or C++ initializer list.
Definition: Expr.h:4375
SwitchCase(StmtClass SC, EmptyShell)
Definition: Stmt.h:1450
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition: Stmt.h:3511
GCCAsmStmt(EmptyShell Empty)
Build an empty inline-assembly statement.
Definition: Stmt.h:2873
child_range children()
Definition: Stmt.h:1800
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:2384
SourceLocation getBeginLoc() const
Definition: Stmt.h:1606
outputs_iterator begin_outputs()
Definition: Stmt.h:2818
Decl * getSingleDecl()
Definition: DeclGroup.h:83
CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits
Definition: Stmt.h:987
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1798
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
LabelDecl * getDecl() const
Definition: Stmt.h:1727
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
SourceLocation getLBracLoc() const
Definition: Stmt.h:1417
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:1702
Stmt * getBody()
Definition: Stmt.h:2418
SwitchCaseBitfields SwitchCaseBits
Definition: Stmt.h:956
llvm::iterator_range< const_outputs_iterator > outputs_const_range
Definition: Stmt.h:2816
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3409
Stmt * getInit()
Definition: Stmt.h:2397
DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL, SourceLocation RP)
Definition: Stmt.h:2335
const_child_range children() const
Definition: Stmt.h:3214
SwitchStmtBitfields SwitchStmtBits
Definition: Stmt.h:948
iterator begin()
Definition: DeclGroup.h:99
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2981
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3164
bool hasElseStorage() const
True if this IfStmt has storage for an else statement.
Definition: Stmt.h:1885
labels_range labels()
Definition: Stmt.h:3024
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1737
child_range children()
Definition: Stmt.h:1739
void setAsmString(StringLiteral *E)
Definition: Stmt.h:2882
static bool classof(const Stmt *T)
Definition: Stmt.h:2674
AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
Definition: Stmt.h:2713
const Stmt * getInit() const
Definition: Stmt.h:2103
SourceLocation getEndLoc() const
Definition: Stmt.h:2586
const VarDecl * getConditionVariable() const
Definition: Stmt.h:2279
const Expr * getInc() const
Definition: Stmt.h:2422
CaseStmt - Represent a case statement.
Definition: Stmt.h:1478
Expr * getCond()
Definition: Stmt.h:2416
SourceLocation getContinueLoc() const
Definition: Stmt.h:2552
void setLHS(Expr *Val)
Definition: Stmt.h:1575
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3125
void setInit(Stmt *Init)
Definition: Stmt.h:2108
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:3061
StringRef getOutputName(unsigned i) const
Definition: Stmt.h:2944
ReturnStmtBitfields ReturnStmtBits
Definition: Stmt.h:955
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2305
void setCond(Expr *E)
Definition: Stmt.h:2426
bool isOutputPlusConstraint(unsigned i) const
isOutputPlusConstraint - Return true if the specified output constraint is a "+" constraint (which is...
Definition: Stmt.h:2752
decl_iterator decl_end()
Definition: Stmt.h:1258
const Expr * getCond() const
Definition: Stmt.h:2253
SourceLocation getTryLoc() const
Definition: Stmt.h:3282
void setEndLoc(SourceLocation L)
Definition: Stmt.h:3101
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3421
child_range children()
Definition: Stmt.h:1425
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4140
StmtClass
Definition: Stmt.h:68
Stmt * getBody()
Definition: Stmt.h:2089
const Expr * getLHS() const
Definition: Stmt.h:1571
Stmt * getInit()
Definition: Stmt.h:1955
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1112
const_child_range children() const
Definition: Stmt.h:3301
const_body_iterator body_end() const
Definition: Stmt.h:1363
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2670
const_labels_iterator begin_labels() const
Definition: Stmt.h:3028
unsigned NumClobbers
Definition: Stmt.h:2709
Represents the this expression in C++.
Definition: ExprCXX.h:1007
PredefinedExprBitfields PredefinedExprBits
Definition: Stmt.h:961
const_decl_iterator decl_begin() const
Definition: Stmt.h:1259
StringLiteral * getAsmString()
Definition: Stmt.h:2881
StmtBitfields StmtBits
Definition: Stmt.h:942
child_range children()
Definition: Stmt.h:1621
llvm::iterator_range< const_child_iterator > const_child_range
Definition: Stmt.h:1159
const_child_range children() const
Definition: Stmt.h:3174
void setBreakLoc(SourceLocation L)
Definition: Stmt.h:2583
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1310
const_child_range children() const
Definition: Stmt.h:2846
Describes the capture of either a variable, or &#39;this&#39;, or variable-length array type.
Definition: Stmt.h:3363
Stmt * stripLabelLikeStatements()
Definition: Stmt.h:1147
Decl * getSingleDecl()
Definition: Stmt.h:1219
static bool classof(const Stmt *T)
Definition: Stmt.h:2530
const_inputs_iterator begin_inputs() const
Definition: Stmt.h:2799
void setSemiLoc(SourceLocation L)
Definition: Stmt.h:1287
const Expr * getRetValue() const
Definition: Stmt.h:2644
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3197
child_range children()
Definition: Stmt.h:2842
bool IsVolatile
If true, treat this inline assembly as having side effects.
Definition: Stmt.h:2705
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2347
BreakStmtBitfields BreakStmtBits
Definition: Stmt.h:954
static bool classof(const Stmt *T)
Definition: Stmt.h:3218
static bool classof(const Stmt *T)
Definition: Stmt.h:2440
bool isConstexpr() const
Definition: Stmt.h:1985
CastIterator(StmtPtr *I)
Definition: Stmt.h:1048
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1991
unsigned getOperandNo() const
Definition: Stmt.h:2914
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:953
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:1949
SourceLocation getBeginLoc() const
Definition: Stmt.h:1652
SourceLocation getLabelLoc() const
Definition: Stmt.h:2473
llvm::iterator_range< const_capture_iterator > capture_const_range
Definition: Stmt.h:3483
void setLeaveLoc(SourceLocation L)
Definition: Stmt.h:3322
const Stmt * getSubStmt() const
Definition: Stmt.h:1795
SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits
Definition: Stmt.h:1000
const Stmt * getSubStmt() const
Definition: Stmt.h:1646
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:2362
SourceLocation getFinallyLoc() const
Definition: Stmt.h:3240
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1963
GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL)
Definition: Stmt.h:2460
This represents one expression.
Definition: Expr.h:108
SourceRange getSourceRange() const LLVM_READONLY
Definition: Stmt.h:3550
void setInit(Stmt *Init)
Definition: Stmt.h:1965
SourceLocation getElseLoc() const
Definition: Stmt.h:1974
SourceLocation End
void setWhileLoc(SourceLocation L)
Definition: Stmt.h:2302
Represents a character-granular source range.
inputs_const_range inputs() const
Definition: Stmt.h:2807
llvm::iterator_range< const_capture_init_iterator > const_capture_init_range
Definition: Stmt.h:3513
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:3147
std::string Label
InitListExprBitfields InitListExprBits
Definition: Stmt.h:973
static bool classof(const Stmt *T)
Definition: Stmt.h:3327
StringRef getClobber(unsigned i) const
Definition: Stmt.h:3156
SourceLocation getDefaultLoc() const
Definition: Stmt.h:1649
void setLParenLoc(SourceLocation L)
Definition: Stmt.h:2433
const StringLiteral * getClobberStringLiteral(unsigned i) const
Definition: Stmt.h:3062
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1607
SourceLocation getWhileLoc() const
Definition: Stmt.h:2301
const Stmt * getThen() const
Definition: Stmt.h:1900
SourceLocation getEndLoc() const
Definition: Stmt.h:2477
AsmStringPiece - this is part of a decomposed asm string specification (for use with the AnalyzeAsmSt...
Definition: Stmt.h:2887
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.h:2991
#define V(N, I)
Definition: ASTContext.h:2921
const Stmt * getCapturedStmt() const
Definition: Stmt.h:3452
void setInc(Expr *E)
Definition: Stmt.h:2427
Stmt * getBody()
Definition: Stmt.h:2261
void setRetValue(Expr *E)
Definition: Stmt.h:2645
void setBody(Stmt *S)
Definition: Stmt.h:2428
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:1579
ExprBitfields ExprBits
Definition: Stmt.h:959
void setBody(Stmt *Body)
Definition: Stmt.h:2094
SourceLocation Begin
child_range children()
Definition: Stmt.h:1999
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition: Stmt.h:986
unsigned size() const
Definition: Stmt.h:1338
SourceLocation getBeginLoc() const
Definition: Stmt.h:1990
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition: Stmt.h:993
std::reverse_iterator< body_iterator > reverse_body_iterator
Definition: Stmt.h:1373
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:3515
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:2903
ForStmt(EmptyShell Empty)
Build an empty for statement.
Definition: Stmt.h:2395
SourceLocation getSwitchLoc() const
Definition: Stmt.h:2150
StringLiteral * getOutputConstraintLiteral(unsigned i)
Definition: Stmt.h:2956
LabelDecl * getLabel() const
Definition: Stmt.h:2468
child_range children()
Definition: Stmt.h:2535
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:2610
const_child_range children() const
Definition: Stmt.h:3249
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:2266
This represents a Microsoft inline-assembly statement extension.
Definition: Stmt.h:3075
void setColonLoc(SourceLocation L)
Definition: Stmt.h:1460
SourceLocation getDoLoc() const
Definition: Stmt.h:2357
SwitchCase * getSwitchCaseList()
Definition: Stmt.h:2146
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:2021
llvm::iterator_range< const_decl_iterator > decl_const_range
Definition: Stmt.h:1249
child_range children()
Definition: Stmt.h:1662
child_range children()
Definition: Stmt.h:2563
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4119
Expr * getCond()
Definition: Stmt.h:1887
SourceLocation getEndLoc() const
Definition: Stmt.h:1294
SourceLocation getBeginLoc() const
Definition: Stmt.h:2304
static bool classof(const Stmt *T)
Definition: Stmt.h:2479
const SourceManager & SM
Definition: Format.cpp:1667
SourceLocation getEndLoc() const
Definition: Stmt.h:1415
const_child_range children() const
Definition: Stmt.h:2320
const_inputs_iterator end_inputs() const
Definition: Stmt.h:2803
const Expr * getCond() const
Definition: Stmt.h:2347
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:287
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:2328
AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
Definition: Stmt.h:2693
const_child_range children() const
Definition: Stmt.h:1627
child_range children()
Definition: Stmt.h:2593
std::reverse_iterator< decl_iterator > reverse_decl_iterator
Definition: Stmt.h:1262
const_child_range children() const
Definition: Stmt.h:2537
const Stmt * IgnoreContainers(bool IgnoreCaptured=false) const
Definition: Stmt.h:1142
SourceLocation getEndLoc() const
Definition: Stmt.h:3200
OpaqueValueExprBitfields OpaqueValueExprBits
Definition: Stmt.h:1009
const_child_range children() const
Definition: Stmt.h:1741
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:1050
const_child_range children() const
Definition: Stmt.h:2188
void setDecl(LabelDecl *D)
Definition: Stmt.h:1728
ParenListExprBitfields ParenListExprBits
Definition: Stmt.h:974
static bool classof(const Stmt *T)
Definition: Stmt.h:3554
Kind
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2754
This captures a statement into a function.
Definition: Stmt.h:3350
Token * getAsmToks()
Definition: Stmt.h:3106
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5673
void setSubStmt(Stmt *S)
Definition: Stmt.h:1647
SourceLocation getBeginLoc() const
Definition: Stmt.h:2175
void setGotoLoc(SourceLocation L)
Definition: Stmt.h:2509
ContinueStmtBitfields ContinueStmtBits
Definition: Stmt.h:953
Encodes a location in the source.
body_range body()
Definition: Stmt.h:1343
Expr * getRetValue()
Definition: Stmt.h:2643
StringRef getOutputConstraint(unsigned i) const
Definition: Stmt.h:3116
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
Definition: Stmt.h:2247
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:3319
const SwitchCase * getSwitchCaseList() const
Definition: Stmt.h:2147
void setDoLoc(SourceLocation L)
Definition: Stmt.h:2358
child_range children()
Definition: Stmt.h:3210
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:2010
Expr * getLHS()
Definition: Stmt.h:1567
void setConstexpr(bool C)
Definition: Stmt.h:1986
SourceLocation getExceptLoc() const
Definition: Stmt.h:3199
const_capture_iterator capture_begin() const
Definition: Stmt.h:3494
void setIdentLoc(SourceLocation L)
Definition: Stmt.h:1725
Stmt * getElse()
Definition: Stmt.h:1908
const_child_range children() const
Definition: Stmt.h:1427
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:476
bool capturesVariable() const
Determine whether this capture handles a variable (by reference).
Definition: Stmt.h:3391
reverse_body_iterator body_rend()
Definition: Stmt.h:1379
ForStmtBitfields ForStmtBits
Definition: Stmt.h:951
SourceLocation getLBraceLoc() const
Definition: Stmt.h:3098
const std::string & getString() const
Definition: Stmt.h:2912
labels_const_range labels() const
Definition: Stmt.h:3036
Expr * getCond()
Definition: Stmt.h:2077
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:2167
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:2449
const_child_range children() const
Definition: Stmt.h:1241
static bool classof(const Stmt *T)
Definition: Stmt.h:2588
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:5807
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3066
decl_iterator decl_begin()
Definition: Stmt.h:1257
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3238
SourceLocation getGotoLoc() const
Definition: Stmt.h:2471
const_child_range children() const
Definition: Stmt.h:1664
reverse_decl_iterator decl_rbegin()
Definition: Stmt.h:1264
SEHLeaveStmt(SourceLocation LL)
Definition: Stmt.h:3315
Expr * getExprStmt()
Definition: Stmt.h:1697
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:2953
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3249
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:3451
const Stmt * body_front() const
Definition: Stmt.h:1365
const VarDecl * getConditionVariable() const
Definition: Stmt.h:2124
unsigned capture_size() const
Retrieve the number of captures, including &#39;this&#39;.
Definition: Stmt.h:3503
const Stmt * getBody() const
Definition: Stmt.h:2423
void setCaseLoc(SourceLocation L)
Definition: Stmt.h:1550
SourceLocation getEndLoc() const
Definition: Stmt.h:3100
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:1722
const_capture_init_range capture_inits() const
Definition: Stmt.h:3519
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition: Stmt.h:2289
SourceLocation getKeywordLoc() const
Definition: Stmt.h:1457
MemberExprBitfields MemberExprBits
Definition: Stmt.h:970
SourceLocation getBeginLoc() const
Definition: Stmt.h:2555
SourceLocation getStarLoc() const
Definition: Stmt.h:2512
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:2295
void setCapturedRecordDecl(RecordDecl *D)
Set the record declaration for captured variables.
Definition: Stmt.h:3471
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:2727
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3065
Represents a C11 generic selection.
Definition: Expr.h:5206
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3882
const_child_range children() const
Definition: Stmt.h:1163
void setGotoLoc(SourceLocation L)
Definition: Stmt.h:2472
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:3014
StringRef getInputConstraint(unsigned i) const
Definition: Stmt.h:3129
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isVolatile() const
Definition: Stmt.h:2729
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1878
CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits
Definition: Stmt.h:982
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2269
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:2942
bool isSimple() const
Definition: Stmt.h:2726
static std::string getName(const CallEvent &Call)
llvm::iterator_range< outputs_iterator > outputs_range
Definition: Stmt.h:2815
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:1790
bool hasInitStorage() const
True if this IfStmt has the storage for an init statement.
Definition: Stmt.h:1879
const Stmt * body_back() const
Definition: Stmt.h:1369
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:1653
static bool classof(const Stmt *T)
Definition: Stmt.h:1470
DoStmt(EmptyShell Empty)
Build an empty do-while statement.
Definition: Stmt.h:2344
Stmt * getHandler() const
Definition: Stmt.h:3291
SourceLocation getSemiLoc() const
Definition: Stmt.h:1286
StmtClass getStmtClass() const
Definition: Stmt.h:1087
SwitchCase * getNextSwitchCase()
Definition: Stmt.h:1454
bool isSingleDecl() const
Definition: DeclGroup.h:80
UnaryOperatorBitfields UnaryOperatorBits
Definition: Stmt.h:966
static bool classof(const Stmt *T)
Definition: Stmt.h:3253
SourceLocation getEndLoc() const
Definition: Stmt.h:2365
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:3546
void setEllipsisLoc(SourceLocation L)
Set the location of the ...
Definition: Stmt.h:1560
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition: Stmt.h:991
const Decl * getSingleDecl() const
Definition: Stmt.h:1218
static bool classof(const Stmt *T)
Definition: Stmt.h:3069
BreakStmt(EmptyShell Empty)
Build an empty break statement.
Definition: Stmt.h:2580
child_range children()
Definition: Stmt.h:2484
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.h:3542
const Stmt * getSubStmt() const
Definition: Stmt.h:1463
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:1943
static bool classof(const Stmt *T)
Definition: Stmt.h:1231
IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target)
Definition: Stmt.h:2499
const Stmt * getBody() const
Definition: Stmt.h:2090
CXXNewExprBitfields CXXNewExprBits
Definition: Stmt.h:988
llvm::iterator_range< const_body_iterator > body_const_range
Definition: Stmt.h:1353
Represents a __leave statement.
Definition: Stmt.h:3311
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3868
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
Definition: Stmt.h:3394
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:2017
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:2437
SourceLocation getLeaveLoc() const
Definition: Stmt.h:3321
bool hasBraces() const
Definition: Stmt.h:3103
const_capture_init_iterator capture_init_end() const
Definition: Stmt.h:3538
void setRHS(Expr *Val)
Definition: Stmt.h:1591
void setVolatile(bool V)
Definition: Stmt.h:2730
friend TrailingObjects
Definition: OpenMPClause.h:98
static bool classof(const Stmt *T)
Definition: Stmt.h:1745
DefaultStmt(EmptyShell Empty)
Build an empty default statement.
Definition: Stmt.h:1642
reverse_decl_iterator decl_rend()
Definition: Stmt.h:1268
SourceLocation getBeginLoc() const
Definition: Stmt.h:2476
StringLiteral * getInputConstraintLiteral(unsigned i)
Definition: Stmt.h:2984
DeclGroupRef getDeclGroup()
Definition: Stmt.h:1222
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4615
const Expr * getInputExpr(unsigned i) const
Definition: Stmt.h:3137
TypeTraitExprBitfields TypeTraitExprBits
Definition: Stmt.h:990
void setSwitchLoc(SourceLocation L)
Definition: Stmt.h:2151
Stmt * getInit()
Definition: Stmt.h:2098
static bool classof(const Stmt *T)
Definition: Stmt.h:1657
decl_range decls()
Definition: Stmt.h:1251
CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits
Definition: Stmt.h:981
void setBody(Stmt *Body)
Definition: Stmt.h:2355
AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin, SourceLocation End)
Definition: Stmt.h:2904
bool IsSimple
True if the assembly statement does not have any input or output operands.
Definition: Stmt.h:2701
static bool classof(const Stmt *T)
Definition: Stmt.h:1806
StringRef getAsmString() const
Definition: Stmt.h:3109
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:3143
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2528
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Definition: Stmt.h:967
SourceLocation getColonLoc() const
Definition: Stmt.h:1459
unsigned getNumClobbers() const
Definition: Stmt.h:2774
SourceLocation getRParenLoc() const
Definition: Stmt.h:2434
child_range children()
Definition: Stmt.h:2314
void setElseLoc(SourceLocation ElseLoc)
Definition: Stmt.h:1979
void setStarLoc(SourceLocation L)
Definition: Stmt.h:2511
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3300
SourceLocation getAsmLoc() const
Definition: Stmt.h:2723
outputs_range outputs()
Definition: Stmt.h:2826
GotoStmt - This represents a direct goto.
Definition: Stmt.h:2455
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1189
Expr * getTarget()
Definition: Stmt.h:2514
Decl *const * const_iterator
Definition: DeclGroup.h:77
child_range children()
const SwitchCase * getNextSwitchCase() const
Definition: Stmt.h:1453
OverloadExprBitfields OverloadExprBits
Definition: Stmt.h:996
void setCond(Expr *Cond)
Definition: Stmt.h:2351
SourceLocation getBeginLoc() const
Definition: Stmt.h:2585
Expr * getCond()
Definition: Stmt.h:2346
static bool classof(const Stmt *T)
Definition: Stmt.h:2367
const_child_range children() const
Definition: Stmt.h:3336
llvm::iterator_range< capture_iterator > capture_range
Definition: Stmt.h:3482
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2811
SourceLocation getWhileLoc() const
Definition: Stmt.h:2359
Defines the clang::SourceLocation class and associated facilities.
llvm::iterator_range< inputs_iterator > inputs_range
Definition: Stmt.h:2786
ContinueStmt - This represents a continue.
Definition: Stmt.h:2543
SourceLocation getBeginLoc() const
Definition: Stmt.h:1736
const_decl_iterator decl_end() const
Definition: Stmt.h:1260
const Expr * getRHS() const
Definition: Stmt.h:1585
reverse_body_iterator body_rbegin()
Definition: Stmt.h:1375
void setLBraceLoc(SourceLocation L)
Definition: Stmt.h:3099
child_range children()
Definition: Stmt.h:1236
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition: Stmt.h:985
Expr * getFilterExpr() const
Definition: Stmt.h:3202
SourceLocation getAttrLoc() const
Definition: Stmt.h:1789
ContinueStmt(SourceLocation CL)
Definition: Stmt.h:2545
const Stmt * getInit() const
Definition: Stmt.h:2420
OpenMPLinearClauseKind getModifier() const
Return modifier.
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:2200
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition: Stmt.h:980
llvm::iterator_range< capture_init_iterator > capture_init_range
Definition: Stmt.h:3507
SourceLocation AsmLoc
Definition: Stmt.h:2697
const_child_range children() const
Definition: Stmt.h:2376
labels_iterator begin_labels()
Definition: Stmt.h:3016
const_child_range children() const
Definition: Stmt.h:2567
static bool classof(const Stmt *T)
Definition: Stmt.h:2558
SourceLocation getBeginLoc() const
Definition: Stmt.h:2364
const Stmt * getSubStmt() const
Definition: Stmt.h:1598
void setDefaultLoc(SourceLocation L)
Definition: Stmt.h:1650
SourceLocation getBreakLoc() const
Definition: Stmt.h:2582
SourceLocation getCaseLoc() const
Definition: Stmt.h:1549
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition: Stmt.h:3498
VariableCaptureKind
The different capture forms: by &#39;this&#39;, by reference, capture for variable-length array type etc...
Definition: Stmt.h:3354
void setElse(Stmt *Else)
Definition: Stmt.h:1918
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1686
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2521
static bool classof(const Stmt *T)
Definition: Stmt.h:2194
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:2733
void setRParenLoc(SourceLocation L)
Definition: Stmt.h:2435
SourceLocExprBitfields SourceLocExprBits
Definition: Stmt.h:977
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
Definition: Specifiers.h:160
void setNextSwitchCase(SwitchCase *SC)
Definition: Stmt.h:1455
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
const_child_range children() const
Definition: Stmt.h:2597
SourceLocation getBeginLoc() const
Definition: Stmt.h:2527
child_range children()
Definition: Stmt.h:2445
body_const_range body() const
Definition: Stmt.h:1355
capture_range captures()
Definition: Stmt.h:3485
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1146
SourceLocation getBeginLoc() const
Definition: Stmt.h:1467
void setLabel(LabelDecl *D)
Definition: Stmt.h:2469
SourceLocation getBeginLoc() const
Definition: Stmt.h:1414
static bool classof(const Stmt *T)
Definition: Stmt.h:1616
BreakStmt - This represents a break.
Definition: Stmt.h:2573
const Stmt * getInit() const
Definition: Stmt.h:1960
SourceLocation getBeginLoc() const
Definition: Stmt.h:1797
void setSubStmt(Stmt *SS)
Definition: Stmt.h:1734
CallExprBitfields CallExprBits
Definition: Stmt.h:969
CapturedRegionKind
The different kinds of captured statement.
Definition: CapturedStmt.h:16
unsigned getNumLabels() const
Definition: Stmt.h:3001
const Stmt * getBody() const
Definition: Stmt.h:2262
CastExprBitfields CastExprBits
Definition: Stmt.h:971
Stmt * getSubStmt()
Definition: Stmt.h:1731
DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc)
Definition: Stmt.h:1208
CXXNoexceptExprBitfields CXXNoexceptExprBits
Definition: Stmt.h:999
const Expr * getCond() const
Definition: Stmt.h:1891
A trivial tuple used to represent a source range.
void setInit(Stmt *S)
Definition: Stmt.h:2425
unsigned NumInputs
Definition: Stmt.h:2708
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:555
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2242
const_reverse_body_iterator body_rend() const
Definition: Stmt.h:1390
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.h:3067
const Expr * getCond() const
Definition: Stmt.h:2081
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
Definition: Stmt.h:3534
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:2360
child_range children()
Definition: Stmt.h:2679
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ...
Definition: Stmt.h:1547
This class handles loading and caching of source files into memory.
BreakStmt(SourceLocation BL)
Definition: Stmt.h:2575
CompoundStmt * getTryBlock() const
Definition: Stmt.h:3287
Stmt * getSubStmt()
Definition: Stmt.h:1794
CompoundStmt * getBlock() const
Definition: Stmt.h:3206
void setKeywordLoc(SourceLocation L)
Definition: Stmt.h:1458
SourceLocation getReturnLoc() const
Definition: Stmt.h:2666
bool capturesVariableArrayType() const
Determine whether this capture handles a variable-length array type.
Definition: Stmt.h:3400
void setCond(Expr *Cond)
Definition: Stmt.h:1895
Attr - This represents one attribute.
Definition: Attr.h:45
void setLabelLoc(SourceLocation L)
Definition: Stmt.h:2474
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
const Stmt * getStmtExprResult() const
Definition: Stmt.h:1410
SourceLocation getEndLoc() const
Definition: Stmt.h:3241
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition: Stmt.h:995
const_capture_init_iterator capture_init_begin() const
Definition: Stmt.h:3528
SourceLocation getLocation() const
Retrieve the source location at which the variable or &#39;this&#39; was first used.
Definition: Stmt.h:3385
Stmt * getSubStmt()
Definition: Stmt.h:1597
const DeclStmt * getConditionVariableDeclStmt() const
Definition: Stmt.h:2140
inputs_iterator end_inputs()
Definition: Stmt.h:2793
outputs_const_range outputs() const
Definition: Stmt.h:2838
const LabelDecl * getConstantTarget() const
Definition: Stmt.h:2523