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