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