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