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