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