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