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