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