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