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