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