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