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
791 friend class ASTStmtReader;
793
794 LLVM_PREFERRED_TYPE(CallExprBitfields)
796
797 LLVM_PREFERRED_TYPE(bool)
798 unsigned IsReversed : 1;
799 };
800
802 friend class CXXBoolLiteralExpr;
803
804 LLVM_PREFERRED_TYPE(ExprBitfields)
806
807 /// The value of the boolean literal.
808 LLVM_PREFERRED_TYPE(bool)
809 unsigned Value : 1;
810
811 /// The location of the boolean literal.
812 SourceLocation Loc;
813 };
814
817
818 LLVM_PREFERRED_TYPE(ExprBitfields)
820
821 /// The location of the null pointer literal.
822 SourceLocation Loc;
823 };
824
826 friend class CXXThisExpr;
827
828 LLVM_PREFERRED_TYPE(ExprBitfields)
830
831 /// Whether this is an implicit "this".
832 LLVM_PREFERRED_TYPE(bool)
833 unsigned IsImplicit : 1;
834
835 /// Whether there is a lambda with an explicit object parameter that
836 /// captures this "this" by copy.
837 LLVM_PREFERRED_TYPE(bool)
838 unsigned CapturedByCopyInLambdaWithExplicitObjectParameter : 1;
839
840 /// The location of the "this".
841 SourceLocation Loc;
842 };
843
845 friend class ASTStmtReader;
846 friend class CXXThrowExpr;
847
848 LLVM_PREFERRED_TYPE(ExprBitfields)
850
851 /// Whether the thrown variable (if any) is in scope.
852 LLVM_PREFERRED_TYPE(bool)
853 unsigned IsThrownVariableInScope : 1;
854
855 /// The location of the "throw".
856 SourceLocation ThrowLoc;
857 };
858
860 friend class ASTStmtReader;
861 friend class CXXDefaultArgExpr;
862
863 LLVM_PREFERRED_TYPE(ExprBitfields)
865
866 /// Whether this CXXDefaultArgExpr rewrote its argument and stores a copy.
867 LLVM_PREFERRED_TYPE(bool)
868 unsigned HasRewrittenInit : 1;
869
870 /// The location where the default argument expression was used.
871 SourceLocation Loc;
872 };
873
875 friend class ASTStmtReader;
876 friend class CXXDefaultInitExpr;
877
878 LLVM_PREFERRED_TYPE(ExprBitfields)
880
881 /// Whether this CXXDefaultInitExprBitfields rewrote its argument and stores
882 /// a copy.
883 LLVM_PREFERRED_TYPE(bool)
884 unsigned HasRewrittenInit : 1;
885
886 /// The location where the default initializer expression was used.
887 SourceLocation Loc;
888 };
889
891 friend class ASTStmtReader;
893
894 LLVM_PREFERRED_TYPE(ExprBitfields)
896
897 SourceLocation RParenLoc;
898 };
899
901 friend class ASTStmtReader;
902 friend class ASTStmtWriter;
903 friend class CXXNewExpr;
904
905 LLVM_PREFERRED_TYPE(ExprBitfields)
907
908 /// Was the usage ::new, i.e. is the global new to be used?
909 LLVM_PREFERRED_TYPE(bool)
910 unsigned IsGlobalNew : 1;
911
912 /// Do we allocate an array? If so, the first trailing "Stmt *" is the
913 /// size expression.
914 LLVM_PREFERRED_TYPE(bool)
915 unsigned IsArray : 1;
916
917 /// Should the alignment be passed to the allocation function?
918 LLVM_PREFERRED_TYPE(bool)
919 unsigned ShouldPassAlignment : 1;
920
921 /// Should the type identity be passed to the allocation function?
922 LLVM_PREFERRED_TYPE(bool)
923 unsigned ShouldPassTypeIdentity : 1;
924
925 /// If this is an array allocation, does the usual deallocation
926 /// function for the allocated type want to know the allocated size?
927 LLVM_PREFERRED_TYPE(bool)
928 unsigned UsualArrayDeleteWantsSize : 1;
929
930 // Is initializer expr present?
931 LLVM_PREFERRED_TYPE(bool)
932 unsigned HasInitializer : 1;
933
934 /// What kind of initializer syntax used? Could be none, parens, or braces.
935 LLVM_PREFERRED_TYPE(CXXNewInitializationStyle)
936 unsigned StoredInitializationStyle : 2;
937
938 /// True if the allocated type was expressed as a parenthesized type-id.
939 LLVM_PREFERRED_TYPE(bool)
940 unsigned IsParenTypeId : 1;
941
942 /// The number of placement new arguments.
943 unsigned NumPlacementArgs;
944 };
945
947 friend class ASTStmtReader;
948 friend class CXXDeleteExpr;
949
950 LLVM_PREFERRED_TYPE(ExprBitfields)
952
953 /// Is this a forced global delete, i.e. "::delete"?
954 LLVM_PREFERRED_TYPE(bool)
955 unsigned GlobalDelete : 1;
956
957 /// Is this the array form of delete, i.e. "delete[]"?
958 LLVM_PREFERRED_TYPE(bool)
959 unsigned ArrayForm : 1;
960
961 /// ArrayFormAsWritten can be different from ArrayForm if 'delete' is
962 /// applied to pointer-to-array type (ArrayFormAsWritten will be false
963 /// while ArrayForm will be true).
964 LLVM_PREFERRED_TYPE(bool)
965 unsigned ArrayFormAsWritten : 1;
966
967 /// Does the usual deallocation function for the element type require
968 /// a size_t argument?
969 LLVM_PREFERRED_TYPE(bool)
970 unsigned UsualArrayDeleteWantsSize : 1;
971
972 /// Location of the expression.
973 SourceLocation Loc;
974 };
975
977 friend class ASTStmtReader;
978 friend class ASTStmtWriter;
979 friend class TypeTraitExpr;
980
981 LLVM_PREFERRED_TYPE(ExprBitfields)
983
984 /// The kind of type trait, which is a value of a TypeTrait enumerator.
985 LLVM_PREFERRED_TYPE(TypeTrait)
986 unsigned Kind : 8;
987
988 LLVM_PREFERRED_TYPE(bool)
989 unsigned IsBooleanTypeTrait : 1;
990
991 /// If this expression is a non value-dependent boolean trait,
992 /// this indicates whether the trait evaluated true or false.
993 LLVM_PREFERRED_TYPE(bool)
994 unsigned Value : 1;
995 /// The number of arguments to this type trait. According to [implimits]
996 /// 8 bits would be enough, but we require (and test for) at least 16 bits
997 /// to mirror FunctionType.
998 unsigned NumArgs;
999 };
1000
1002 friend class ASTStmtReader;
1003 friend class ASTStmtWriter;
1005
1006 LLVM_PREFERRED_TYPE(ExprBitfields)
1008
1009 /// Whether the name includes info for explicit template
1010 /// keyword and arguments.
1011 LLVM_PREFERRED_TYPE(bool)
1012 unsigned HasTemplateKWAndArgsInfo : 1;
1013 };
1014
1016 friend class ASTStmtReader;
1017 friend class CXXConstructExpr;
1018
1019 LLVM_PREFERRED_TYPE(ExprBitfields)
1021
1022 LLVM_PREFERRED_TYPE(bool)
1023 unsigned Elidable : 1;
1024 LLVM_PREFERRED_TYPE(bool)
1025 unsigned HadMultipleCandidates : 1;
1026 LLVM_PREFERRED_TYPE(bool)
1027 unsigned ListInitialization : 1;
1028 LLVM_PREFERRED_TYPE(bool)
1029 unsigned StdInitListInitialization : 1;
1030 LLVM_PREFERRED_TYPE(bool)
1031 unsigned ZeroInitialization : 1;
1032 LLVM_PREFERRED_TYPE(CXXConstructionKind)
1033 unsigned ConstructionKind : 3;
1034 LLVM_PREFERRED_TYPE(bool)
1035 unsigned IsImmediateEscalating : 1;
1036
1037 SourceLocation Loc;
1038 };
1039
1041 friend class ASTStmtReader; // deserialization
1042 friend class ExprWithCleanups;
1043
1044 LLVM_PREFERRED_TYPE(ExprBitfields)
1046
1047 // When false, it must not have side effects.
1048 LLVM_PREFERRED_TYPE(bool)
1049 unsigned CleanupsHaveSideEffects : 1;
1050
1051 unsigned NumObjects : 32 - 1 - NumExprBits;
1052 };
1053
1055 friend class ASTStmtReader;
1057
1058 LLVM_PREFERRED_TYPE(ExprBitfields)
1060
1061 /// The number of arguments used to construct the type.
1062 unsigned NumArgs;
1063 };
1064
1066 friend class ASTStmtReader;
1068
1069 LLVM_PREFERRED_TYPE(ExprBitfields)
1071
1072 /// Whether this member expression used the '->' operator or
1073 /// the '.' operator.
1074 LLVM_PREFERRED_TYPE(bool)
1075 unsigned IsArrow : 1;
1076
1077 /// Whether this member expression has info for explicit template
1078 /// keyword and arguments.
1079 LLVM_PREFERRED_TYPE(bool)
1080 unsigned HasTemplateKWAndArgsInfo : 1;
1081
1082 /// See getFirstQualifierFoundInScope() and the comment listing
1083 /// the trailing objects.
1084 LLVM_PREFERRED_TYPE(bool)
1085 unsigned HasFirstQualifierFoundInScope : 1;
1086
1087 /// The location of the '->' or '.' operator.
1088 SourceLocation OperatorLoc;
1089 };
1090
1092 friend class ASTStmtReader;
1093 friend class OverloadExpr;
1094
1095 LLVM_PREFERRED_TYPE(ExprBitfields)
1097
1098 /// Whether the name includes info for explicit template
1099 /// keyword and arguments.
1100 LLVM_PREFERRED_TYPE(bool)
1101 unsigned HasTemplateKWAndArgsInfo : 1;
1102
1103 /// Padding used by the derived classes to store various bits. If you
1104 /// need to add some data here, shrink this padding and add your data
1105 /// above. NumOverloadExprBits also needs to be updated.
1106 unsigned : 32 - NumExprBits - 1;
1107
1108 /// The number of results.
1109 unsigned NumResults;
1110 };
1112
1114 friend class ASTStmtReader;
1116
1117 LLVM_PREFERRED_TYPE(OverloadExprBitfields)
1119
1120 /// True if these lookup results should be extended by
1121 /// argument-dependent lookup if this is the operand of a function call.
1122 LLVM_PREFERRED_TYPE(bool)
1123 unsigned RequiresADL : 1;
1124 };
1125 static_assert(sizeof(UnresolvedLookupExprBitfields) <= 4,
1126 "UnresolvedLookupExprBitfields must be <= than 4 bytes to"
1127 "avoid trashing OverloadExprBitfields::NumResults!");
1128
1130 friend class ASTStmtReader;
1132
1133 LLVM_PREFERRED_TYPE(OverloadExprBitfields)
1135
1136 /// Whether this member expression used the '->' operator or
1137 /// the '.' operator.
1138 LLVM_PREFERRED_TYPE(bool)
1139 unsigned IsArrow : 1;
1140
1141 /// Whether the lookup results contain an unresolved using declaration.
1142 LLVM_PREFERRED_TYPE(bool)
1143 unsigned HasUnresolvedUsing : 1;
1144 };
1145 static_assert(sizeof(UnresolvedMemberExprBitfields) <= 4,
1146 "UnresolvedMemberExprBitfields must be <= than 4 bytes to"
1147 "avoid trashing OverloadExprBitfields::NumResults!");
1148
1150 friend class ASTStmtReader;
1151 friend class CXXNoexceptExpr;
1152
1153 LLVM_PREFERRED_TYPE(ExprBitfields)
1155
1156 LLVM_PREFERRED_TYPE(bool)
1157 unsigned Value : 1;
1158 };
1159
1161 friend class ASTStmtReader;
1163
1164 LLVM_PREFERRED_TYPE(ExprBitfields)
1166
1167 /// The location of the non-type template parameter reference.
1168 SourceLocation NameLoc;
1169 };
1170
1172 friend class ASTStmtReader;
1173 friend class ASTStmtWriter;
1174 friend class LambdaExpr;
1175
1176 LLVM_PREFERRED_TYPE(ExprBitfields)
1178
1179 /// The default capture kind, which is a value of type
1180 /// LambdaCaptureDefault.
1181 LLVM_PREFERRED_TYPE(LambdaCaptureDefault)
1182 unsigned CaptureDefault : 2;
1183
1184 /// Whether this lambda had an explicit parameter list vs. an
1185 /// implicit (and empty) parameter list.
1186 LLVM_PREFERRED_TYPE(bool)
1187 unsigned ExplicitParams : 1;
1188
1189 /// Whether this lambda had the result type explicitly specified.
1190 LLVM_PREFERRED_TYPE(bool)
1191 unsigned ExplicitResultType : 1;
1192
1193 /// The number of captures.
1194 unsigned NumCaptures : 16;
1195 };
1196
1198 friend class ASTStmtReader;
1199 friend class ASTStmtWriter;
1200 friend class RequiresExpr;
1201
1202 LLVM_PREFERRED_TYPE(ExprBitfields)
1204
1205 LLVM_PREFERRED_TYPE(bool)
1206 unsigned IsSatisfied : 1;
1207 SourceLocation RequiresKWLoc;
1208 };
1209
1212 friend class ASTStmtReader;
1213 LLVM_PREFERRED_TYPE(ExprBitfields)
1215
1216 /// The trait. An ArrayTypeTrait enum in MSVC compat unsigned.
1217 LLVM_PREFERRED_TYPE(ArrayTypeTrait)
1218 unsigned ATT : 2;
1219 };
1220
1223 friend class ASTStmtReader;
1224 LLVM_PREFERRED_TYPE(ExprBitfields)
1226
1227 /// The trait. A ExpressionTrait enum in MSVC compatible unsigned.
1228 LLVM_PREFERRED_TYPE(ExpressionTrait)
1229 unsigned ET : 31;
1230
1231 /// The value of the type trait. Unspecified if dependent.
1232 LLVM_PREFERRED_TYPE(bool)
1233 unsigned Value : 1;
1234 };
1235
1237 friend class CXXFoldExpr;
1238 friend class ASTStmtReader;
1239 friend class ASTStmtWriter;
1240
1241 LLVM_PREFERRED_TYPE(ExprBitfields)
1243
1244 BinaryOperatorKind Opcode;
1245 };
1246
1248 friend class PackIndexingExpr;
1249 friend class ASTStmtWriter;
1250 friend class ASTStmtReader;
1251
1252 LLVM_PREFERRED_TYPE(ExprBitfields)
1254 // The size of the trailing expressions.
1255 unsigned TransformedExpressions : 31;
1256
1257 LLVM_PREFERRED_TYPE(bool)
1258 unsigned FullySubstituted : 1;
1259 };
1260
1261 //===--- C++ Coroutines bitfields classes ---===//
1262
1264 friend class CoawaitExpr;
1265
1266 LLVM_PREFERRED_TYPE(ExprBitfields)
1268
1269 LLVM_PREFERRED_TYPE(bool)
1270 unsigned IsImplicit : 1;
1271 };
1272
1273 //===--- Obj-C Expression bitfields classes ---===//
1274
1277
1278 LLVM_PREFERRED_TYPE(ExprBitfields)
1280
1281 LLVM_PREFERRED_TYPE(bool)
1282 unsigned ShouldCopy : 1;
1283 };
1284
1285 //===--- Clang Extensions bitfields classes ---===//
1286
1288 friend class ASTStmtReader;
1289 friend class OpaqueValueExpr;
1290
1291 LLVM_PREFERRED_TYPE(ExprBitfields)
1293
1294 /// The OVE is a unique semantic reference to its source expression if this
1295 /// bit is set to true.
1296 LLVM_PREFERRED_TYPE(bool)
1297 unsigned IsUnique : 1;
1298
1299 SourceLocation Loc;
1300 };
1301
1303 friend class ConvertVectorExpr;
1304
1305 LLVM_PREFERRED_TYPE(ExprBitfields)
1307
1308 //
1309 /// This is only meaningful for operations on floating point
1310 /// types when additional values need to be in trailing storage.
1311 /// It is 0 otherwise.
1312 LLVM_PREFERRED_TYPE(bool)
1313 unsigned HasFPFeatures : 1;
1314 };
1315
1316 union {
1317 // Same order as in StmtNodes.td.
1318 // Statements
1334
1335 // Expressions
1357
1358 // GNU Extensions.
1361
1362 // C++ Expressions
1391
1392 // C++ Coroutines expressions
1394
1395 // Obj-C Expressions
1397
1398 // Clang Extensions
1401 };
1402
1403public:
1404 // Only allow allocation of Stmts using the allocator in ASTContext
1405 // or by doing a placement new.
1406 void* operator new(size_t bytes, const ASTContext& C,
1407 unsigned alignment = 8);
1408
1409 void* operator new(size_t bytes, const ASTContext* C,
1410 unsigned alignment = 8) {
1411 return operator new(bytes, *C, alignment);
1412 }
1413
1414 void *operator new(size_t bytes, void *mem) noexcept { return mem; }
1415
1416 void operator delete(void *, const ASTContext &, unsigned) noexcept {}
1417 void operator delete(void *, const ASTContext *, unsigned) noexcept {}
1418 void operator delete(void *, size_t) noexcept {}
1419 void operator delete(void *, void *) noexcept {}
1420
1421public:
1422 /// A placeholder type used to construct an empty shell of a
1423 /// type, that will be filled in later (e.g., by some
1424 /// de-serialization).
1425 struct EmptyShell {};
1426
1427 /// The likelihood of a branch being taken.
1429 LH_Unlikely = -1, ///< Branch has the [[unlikely]] attribute.
1430 LH_None, ///< No attribute set or branches of the IfStmt have
1431 ///< the same attribute.
1432 LH_Likely ///< Branch has the [[likely]] attribute.
1433 };
1434
1435protected:
1436 /// Iterator for iterating over Stmt * arrays that contain only T *.
1437 ///
1438 /// This is needed because AST nodes use Stmt* arrays to store
1439 /// references to children (to be compatible with StmtIterator).
1440 template<typename T, typename TPtr = T *, typename StmtPtr = Stmt *>
1442 : llvm::iterator_adaptor_base<CastIterator<T, TPtr, StmtPtr>, StmtPtr *,
1443 std::random_access_iterator_tag, TPtr> {
1444 using Base = typename CastIterator::iterator_adaptor_base;
1445
1447 CastIterator(StmtPtr *I) : Base(I) {}
1448
1449 typename Base::value_type operator*() const {
1450 return cast_or_null<T>(*this->I);
1451 }
1452 };
1453
1454 /// Const iterator for iterating over Stmt * arrays that contain only T *.
1455 template <typename T>
1457
1460
1461private:
1462 /// Whether statistic collection is enabled.
1463 static bool StatisticsEnabled;
1464
1465protected:
1466 /// Construct an empty statement.
1467 explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {}
1468
1469public:
1470 Stmt() = delete;
1471 Stmt(const Stmt &) = delete;
1472 Stmt(Stmt &&) = delete;
1473 Stmt &operator=(const Stmt &) = delete;
1474 Stmt &operator=(Stmt &&) = delete;
1475
1477 static_assert(sizeof(*this) <= 8,
1478 "changing bitfields changed sizeof(Stmt)");
1479 static_assert(sizeof(*this) % alignof(void *) == 0,
1480 "Insufficient alignment!");
1481 StmtBits.sClass = SC;
1482 if (StatisticsEnabled) Stmt::addStmtClass(SC);
1483 }
1484
1486 return static_cast<StmtClass>(StmtBits.sClass);
1487 }
1488
1489 const char *getStmtClassName() const;
1490
1491 /// SourceLocation tokens are not useful in isolation - they are low level
1492 /// value objects created/interpreted by SourceManager. We assume AST
1493 /// clients will have a pointer to the respective SourceManager.
1494 SourceRange getSourceRange() const LLVM_READONLY;
1495 SourceLocation getBeginLoc() const LLVM_READONLY;
1496 SourceLocation getEndLoc() const LLVM_READONLY;
1497
1498 // global temp stats (until we have a per-module visitor)
1499 static void addStmtClass(const StmtClass s);
1500 static void EnableStatistics();
1501 static void PrintStats();
1502
1503 /// \returns the likelihood of a set of attributes.
1504 static Likelihood getLikelihood(ArrayRef<const Attr *> Attrs);
1505
1506 /// \returns the likelihood of a statement.
1507 static Likelihood getLikelihood(const Stmt *S);
1508
1509 /// \returns the likelihood attribute of a statement.
1510 static const Attr *getLikelihoodAttr(const Stmt *S);
1511
1512 /// \returns the likelihood of the 'then' branch of an 'if' statement. The
1513 /// 'else' branch is required to determine whether both branches specify the
1514 /// same likelihood, which affects the result.
1515 static Likelihood getLikelihood(const Stmt *Then, const Stmt *Else);
1516
1517 /// \returns whether the likelihood of the branches of an if statement are
1518 /// conflicting. When the first element is \c true there's a conflict and
1519 /// the Attr's are the conflicting attributes of the Then and Else Stmt.
1520 static std::tuple<bool, const Attr *, const Attr *>
1521 determineLikelihoodConflict(const Stmt *Then, const Stmt *Else);
1522
1523 /// Dumps the specified AST fragment and all subtrees to
1524 /// \c llvm::errs().
1525 void dump() const;
1526 void dump(raw_ostream &OS, const ASTContext &Context) const;
1527
1528 /// \return Unique reproducible object identifier
1529 int64_t getID(const ASTContext &Context) const;
1530
1531 /// dumpColor - same as dump(), but forces color highlighting.
1532 void dumpColor() const;
1533
1534 /// dumpPretty/printPretty - These two methods do a "pretty print" of the AST
1535 /// back to its original source language syntax.
1536 void dumpPretty(const ASTContext &Context) const;
1537 void printPretty(raw_ostream &OS, PrinterHelper *Helper,
1538 const PrintingPolicy &Policy, unsigned Indentation = 0,
1539 StringRef NewlineSymbol = "\n",
1540 const ASTContext *Context = nullptr) const;
1541 void printPrettyControlled(raw_ostream &OS, PrinterHelper *Helper,
1542 const PrintingPolicy &Policy,
1543 unsigned Indentation = 0,
1544 StringRef NewlineSymbol = "\n",
1545 const ASTContext *Context = nullptr) const;
1546
1547 /// Pretty-prints in JSON format.
1548 void printJson(raw_ostream &Out, PrinterHelper *Helper,
1549 const PrintingPolicy &Policy, bool AddQuotes) const;
1550
1551 /// viewAST - Visualize an AST rooted at this Stmt* using GraphViz. Only
1552 /// works on systems with GraphViz (Mac OS X) or dot+gv installed.
1553 void viewAST() const;
1554
1555 /// Skip no-op (attributed, compound) container stmts and skip captured
1556 /// stmt at the top, if \a IgnoreCaptured is true.
1557 Stmt *IgnoreContainers(bool IgnoreCaptured = false);
1558 const Stmt *IgnoreContainers(bool IgnoreCaptured = false) const {
1559 return const_cast<Stmt *>(this)->IgnoreContainers(IgnoreCaptured);
1560 }
1561
1562 const Stmt *stripLabelLikeStatements() const;
1564 return const_cast<Stmt*>(
1565 const_cast<const Stmt*>(this)->stripLabelLikeStatements());
1566 }
1567
1568 /// Child Iterators: All subclasses must implement 'children'
1569 /// to permit easy iteration over the substatements/subexpressions of an
1570 /// AST node. This permits easy iteration over all nodes in the AST.
1573
1574 using child_range = llvm::iterator_range<child_iterator>;
1575 using const_child_range = llvm::iterator_range<const_child_iterator>;
1576
1578
1580 return const_cast<Stmt *>(this)->children();
1581 }
1582
1583 child_iterator child_begin() { return children().begin(); }
1584 child_iterator child_end() { return children().end(); }
1585
1586 const_child_iterator child_begin() const { return children().begin(); }
1587 const_child_iterator child_end() const { return children().end(); }
1588
1589 /// Produce a unique representation of the given statement.
1590 ///
1591 /// \param ID once the profiling operation is complete, will contain
1592 /// the unique representation of the given statement.
1593 ///
1594 /// \param Context the AST context in which the statement resides
1595 ///
1596 /// \param Canonical whether the profile should be based on the canonical
1597 /// representation of this statement (e.g., where non-type template
1598 /// parameters are identified by index/level rather than their
1599 /// declaration pointers) or the exact representation of the statement as
1600 /// written in the source.
1601 /// \param ProfileLambdaExpr whether or not to profile lambda expressions.
1602 /// When false, the lambda expressions are never considered to be equal to
1603 /// other lambda expressions. When true, the lambda expressions with the same
1604 /// implementation will be considered to be the same. ProfileLambdaExpr should
1605 /// only be true when we try to merge two declarations within modules.
1606 void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
1607 bool Canonical, bool ProfileLambdaExpr = false) const;
1608
1609 /// Calculate a unique representation for a statement that is
1610 /// stable across compiler invocations.
1611 ///
1612 /// \param ID profile information will be stored in ID.
1613 ///
1614 /// \param Hash an ODRHash object which will be called where pointers would
1615 /// have been used in the Profile function.
1616 void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash& Hash) const;
1617};
1618
1619/// DeclStmt - Adaptor class for mixing declarations with statements and
1620/// expressions. For example, CompoundStmt mixes statements, expressions
1621/// and declarations (variables, types). Another example is ForStmt, where
1622/// the first statement can be an expression or a declaration.
1623class DeclStmt : public Stmt {
1624 DeclGroupRef DG;
1625 SourceLocation StartLoc, EndLoc;
1626
1627public:
1629 : Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {}
1630
1631 /// Build an empty declaration statement.
1632 explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) {}
1633
1634 /// isSingleDecl - This method returns true if this DeclStmt refers
1635 /// to a single Decl.
1636 bool isSingleDecl() const { return DG.isSingleDecl(); }
1637
1638 const Decl *getSingleDecl() const { return DG.getSingleDecl(); }
1639 Decl *getSingleDecl() { return DG.getSingleDecl(); }
1640
1641 const DeclGroupRef getDeclGroup() const { return DG; }
1643 void setDeclGroup(DeclGroupRef DGR) { DG = DGR; }
1644
1645 void setStartLoc(SourceLocation L) { StartLoc = L; }
1646 SourceLocation getEndLoc() const { return EndLoc; }
1647 void setEndLoc(SourceLocation L) { EndLoc = L; }
1648
1649 SourceLocation getBeginLoc() const LLVM_READONLY { return StartLoc; }
1650
1651 static bool classof(const Stmt *T) {
1652 return T->getStmtClass() == DeclStmtClass;
1653 }
1654
1655 // Iterators over subexpressions.
1657 return child_range(child_iterator(DG.begin(), DG.end()),
1658 child_iterator(DG.end(), DG.end()));
1659 }
1660
1662 auto Children = const_cast<DeclStmt *>(this)->children();
1664 }
1665
1668 using decl_range = llvm::iterator_range<decl_iterator>;
1669 using decl_const_range = llvm::iterator_range<const_decl_iterator>;
1670
1672
1675 }
1676
1677 decl_iterator decl_begin() { return DG.begin(); }
1678 decl_iterator decl_end() { return DG.end(); }
1679 const_decl_iterator decl_begin() const { return DG.begin(); }
1680 const_decl_iterator decl_end() const { return DG.end(); }
1681
1682 using reverse_decl_iterator = std::reverse_iterator<decl_iterator>;
1683
1687
1691};
1692
1693/// NullStmt - This is the null statement ";": C99 6.8.3p3.
1694///
1695class NullStmt : public Stmt {
1696public:
1698 : Stmt(NullStmtClass) {
1699 NullStmtBits.HasLeadingEmptyMacro = hasLeadingEmptyMacro;
1700 setSemiLoc(L);
1701 }
1702
1703 /// Build an empty null statement.
1704 explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {}
1705
1706 SourceLocation getSemiLoc() const { return NullStmtBits.SemiLoc; }
1707 void setSemiLoc(SourceLocation L) { NullStmtBits.SemiLoc = L; }
1708
1710 return NullStmtBits.HasLeadingEmptyMacro;
1711 }
1712
1715
1716 static bool classof(const Stmt *T) {
1717 return T->getStmtClass() == NullStmtClass;
1718 }
1719
1723
1727};
1728
1729/// CompoundStmt - This represents a group of statements like { stmt stmt }.
1730class CompoundStmt final
1731 : public Stmt,
1732 private llvm::TrailingObjects<CompoundStmt, Stmt *, FPOptionsOverride> {
1733 friend class ASTStmtReader;
1734 friend TrailingObjects;
1735
1736 /// The location of the opening "{".
1737 SourceLocation LBraceLoc;
1738
1739 /// The location of the closing "}".
1740 SourceLocation RBraceLoc;
1741
1744 explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {}
1745
1746 void setStmts(ArrayRef<Stmt *> Stmts);
1747
1748 /// Set FPOptionsOverride in trailing storage. Used only by Serialization.
1749 void setStoredFPFeatures(FPOptionsOverride F) {
1750 assert(hasStoredFPFeatures());
1751 *getTrailingObjects<FPOptionsOverride>() = F;
1752 }
1753
1754 size_t numTrailingObjects(OverloadToken<Stmt *>) const {
1755 return CompoundStmtBits.NumStmts;
1756 }
1757
1758public:
1759 static CompoundStmt *Create(const ASTContext &C, ArrayRef<Stmt *> Stmts,
1760 FPOptionsOverride FPFeatures, SourceLocation LB,
1761 SourceLocation RB);
1762
1763 // Build an empty compound statement with a location.
1764 explicit CompoundStmt(SourceLocation Loc) : CompoundStmt(Loc, Loc) {}
1765
1767 : Stmt(CompoundStmtClass), LBraceLoc(Loc), RBraceLoc(EndLoc) {
1768 CompoundStmtBits.NumStmts = 0;
1769 CompoundStmtBits.HasFPFeatures = 0;
1770 }
1771
1772 // Build an empty compound statement.
1773 static CompoundStmt *CreateEmpty(const ASTContext &C, unsigned NumStmts,
1774 bool HasFPFeatures);
1775
1776 bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
1777 unsigned size() const { return CompoundStmtBits.NumStmts; }
1778
1779 bool hasStoredFPFeatures() const { return CompoundStmtBits.HasFPFeatures; }
1780
1781 /// Get FPOptionsOverride from trailing storage.
1783 assert(hasStoredFPFeatures());
1784 return *getTrailingObjects<FPOptionsOverride>();
1785 }
1786
1787 /// Get the store FPOptionsOverride or default if not stored.
1791
1793 using body_range = llvm::iterator_range<body_iterator>;
1794
1796 body_iterator body_begin() { return getTrailingObjects<Stmt *>(); }
1798 Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; }
1799
1801 return !body_empty() ? body_begin()[size() - 1] : nullptr;
1802 }
1803
1804 using const_body_iterator = Stmt *const *;
1805 using body_const_range = llvm::iterator_range<const_body_iterator>;
1806
1809 }
1810
1812 return getTrailingObjects<Stmt *>();
1813 }
1814
1816
1817 const Stmt *body_front() const {
1818 return !body_empty() ? body_begin()[0] : nullptr;
1819 }
1820
1821 const Stmt *body_back() const {
1822 return !body_empty() ? body_begin()[size() - 1] : nullptr;
1823 }
1824
1825 using reverse_body_iterator = std::reverse_iterator<body_iterator>;
1826
1830
1834
1836 std::reverse_iterator<const_body_iterator>;
1837
1841
1845
1846 SourceLocation getBeginLoc() const { return LBraceLoc; }
1847 SourceLocation getEndLoc() const { return RBraceLoc; }
1848
1849 SourceLocation getLBracLoc() const { return LBraceLoc; }
1850 SourceLocation getRBracLoc() const { return RBraceLoc; }
1851
1852 static bool classof(const Stmt *T) {
1853 return T->getStmtClass() == CompoundStmtClass;
1854 }
1855
1856 // Iterators
1858
1862};
1863
1864// SwitchCase is the base class for CaseStmt and DefaultStmt,
1865class SwitchCase : public Stmt {
1866protected:
1867 /// The location of the ":".
1869
1870 // The location of the "case" or "default" keyword. Stored in SwitchCaseBits.
1871 // SourceLocation KeywordLoc;
1872
1873 /// A pointer to the following CaseStmt or DefaultStmt class,
1874 /// used by SwitchStmt.
1876
1881
1883
1884public:
1888
1889 SourceLocation getKeywordLoc() const { return SwitchCaseBits.KeywordLoc; }
1890 void setKeywordLoc(SourceLocation L) { SwitchCaseBits.KeywordLoc = L; }
1893
1894 inline Stmt *getSubStmt();
1895 const Stmt *getSubStmt() const {
1896 return const_cast<SwitchCase *>(this)->getSubStmt();
1897 }
1898
1900 inline SourceLocation getEndLoc() const LLVM_READONLY;
1901
1902 static bool classof(const Stmt *T) {
1903 return T->getStmtClass() == CaseStmtClass ||
1904 T->getStmtClass() == DefaultStmtClass;
1905 }
1906};
1907
1908/// CaseStmt - Represent a case statement. It can optionally be a GNU case
1909/// statement of the form LHS ... RHS representing a range of cases.
1910class CaseStmt final
1911 : public SwitchCase,
1912 private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> {
1913 friend TrailingObjects;
1914
1915 // CaseStmt is followed by several trailing objects, some of which optional.
1916 // Note that it would be more convenient to put the optional trailing objects
1917 // at the end but this would impact children().
1918 // The trailing objects are in order:
1919 //
1920 // * A "Stmt *" for the LHS of the case statement. Always present.
1921 //
1922 // * A "Stmt *" for the RHS of the case statement. This is a GNU extension
1923 // which allow ranges in cases statement of the form LHS ... RHS.
1924 // Present if and only if caseStmtIsGNURange() is true.
1925 //
1926 // * A "Stmt *" for the substatement of the case statement. Always present.
1927 //
1928 // * A SourceLocation for the location of the ... if this is a case statement
1929 // with a range. Present if and only if caseStmtIsGNURange() is true.
1930 enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 };
1931 enum { NumMandatoryStmtPtr = 2 };
1932
1933 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
1934 return NumMandatoryStmtPtr + caseStmtIsGNURange();
1935 }
1936
1937 unsigned lhsOffset() const { return LhsOffset; }
1938 unsigned rhsOffset() const { return LhsOffset + caseStmtIsGNURange(); }
1939 unsigned subStmtOffset() const { return rhsOffset() + SubStmtOffsetFromRhs; }
1940
1941 /// Build a case statement assuming that the storage for the
1942 /// trailing objects has been properly allocated.
1943 CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc,
1944 SourceLocation ellipsisLoc, SourceLocation colonLoc)
1945 : SwitchCase(CaseStmtClass, caseLoc, colonLoc) {
1946 // Handle GNU case statements of the form LHS ... RHS.
1947 bool IsGNURange = rhs != nullptr;
1948 SwitchCaseBits.CaseStmtIsGNURange = IsGNURange;
1949 setLHS(lhs);
1950 setSubStmt(nullptr);
1951 if (IsGNURange) {
1952 setRHS(rhs);
1953 setEllipsisLoc(ellipsisLoc);
1954 }
1955 }
1956
1957 /// Build an empty switch case statement.
1958 explicit CaseStmt(EmptyShell Empty, bool CaseStmtIsGNURange)
1959 : SwitchCase(CaseStmtClass, Empty) {
1960 SwitchCaseBits.CaseStmtIsGNURange = CaseStmtIsGNURange;
1961 }
1962
1963public:
1964 /// Build a case statement.
1965 static CaseStmt *Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs,
1966 SourceLocation caseLoc, SourceLocation ellipsisLoc,
1967 SourceLocation colonLoc);
1968
1969 /// Build an empty case statement.
1970 static CaseStmt *CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange);
1971
1972 /// True if this case statement is of the form case LHS ... RHS, which
1973 /// is a GNU extension. In this case the RHS can be obtained with getRHS()
1974 /// and the location of the ellipsis can be obtained with getEllipsisLoc().
1975 bool caseStmtIsGNURange() const { return SwitchCaseBits.CaseStmtIsGNURange; }
1976
1979
1980 /// Get the location of the ... in a case statement of the form LHS ... RHS.
1982 return caseStmtIsGNURange() ? *getTrailingObjects<SourceLocation>()
1983 : SourceLocation();
1984 }
1985
1986 /// Set the location of the ... in a case statement of the form LHS ... RHS.
1987 /// Assert that this case statement is of this form.
1989 assert(
1991 "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!");
1992 *getTrailingObjects<SourceLocation>() = L;
1993 }
1994
1996 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
1997 }
1998
1999 const Expr *getLHS() const {
2000 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]);
2001 }
2002
2003 void setLHS(Expr *Val) {
2004 getTrailingObjects<Stmt *>()[lhsOffset()] = reinterpret_cast<Stmt *>(Val);
2005 }
2006
2008 return caseStmtIsGNURange() ? reinterpret_cast<Expr *>(
2009 getTrailingObjects<Stmt *>()[rhsOffset()])
2010 : nullptr;
2011 }
2012
2013 const Expr *getRHS() const {
2014 return caseStmtIsGNURange() ? reinterpret_cast<Expr *>(
2015 getTrailingObjects<Stmt *>()[rhsOffset()])
2016 : nullptr;
2017 }
2018
2019 void setRHS(Expr *Val) {
2020 assert(caseStmtIsGNURange() &&
2021 "setRHS but this is not a case stmt of the form LHS ... RHS!");
2022 getTrailingObjects<Stmt *>()[rhsOffset()] = reinterpret_cast<Stmt *>(Val);
2023 }
2024
2025 Stmt *getSubStmt() { return getTrailingObjects<Stmt *>()[subStmtOffset()]; }
2026 const Stmt *getSubStmt() const {
2027 return getTrailingObjects<Stmt *>()[subStmtOffset()];
2028 }
2029
2030 void setSubStmt(Stmt *S) {
2031 getTrailingObjects<Stmt *>()[subStmtOffset()] = S;
2032 }
2033
2035 SourceLocation getEndLoc() const LLVM_READONLY {
2036 // Handle deeply nested case statements with iteration instead of recursion.
2037 const CaseStmt *CS = this;
2038 while (const auto *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
2039 CS = CS2;
2040
2041 return CS->getSubStmt()->getEndLoc();
2042 }
2043
2044 static bool classof(const Stmt *T) {
2045 return T->getStmtClass() == CaseStmtClass;
2046 }
2047
2048 // Iterators
2050 return child_range(getTrailingObjects<Stmt *>(),
2051 getTrailingObjects<Stmt *>() +
2052 numTrailingObjects(OverloadToken<Stmt *>()));
2053 }
2054
2056 return const_child_range(getTrailingObjects<Stmt *>(),
2057 getTrailingObjects<Stmt *>() +
2058 numTrailingObjects(OverloadToken<Stmt *>()));
2059 }
2060};
2061
2062class DefaultStmt : public SwitchCase {
2063 Stmt *SubStmt;
2064
2065public:
2067 : SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {}
2068
2069 /// Build an empty default statement.
2071 : SwitchCase(DefaultStmtClass, Empty) {}
2072
2073 Stmt *getSubStmt() { return SubStmt; }
2074 const Stmt *getSubStmt() const { return SubStmt; }
2075 void setSubStmt(Stmt *S) { SubStmt = S; }
2076
2079
2081 SourceLocation getEndLoc() const LLVM_READONLY {
2082 return SubStmt->getEndLoc();
2083 }
2084
2085 static bool classof(const Stmt *T) {
2086 return T->getStmtClass() == DefaultStmtClass;
2087 }
2088
2089 // Iterators
2090 child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
2091
2093 return const_child_range(&SubStmt, &SubStmt + 1);
2094 }
2095};
2096
2098 if (const auto *CS = dyn_cast<CaseStmt>(this))
2099 return CS->getEndLoc();
2100 else if (const auto *DS = dyn_cast<DefaultStmt>(this))
2101 return DS->getEndLoc();
2102 llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!");
2103}
2104
2106 if (auto *CS = dyn_cast<CaseStmt>(this))
2107 return CS->getSubStmt();
2108 else if (auto *DS = dyn_cast<DefaultStmt>(this))
2109 return DS->getSubStmt();
2110 llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!");
2111}
2112
2113/// Represents a statement that could possibly have a value and type. This
2114/// covers expression-statements, as well as labels and attributed statements.
2115///
2116/// Value statements have a special meaning when they are the last non-null
2117/// statement in a GNU statement expression, where they determine the value
2118/// of the statement expression.
2119class ValueStmt : public Stmt {
2120protected:
2121 using Stmt::Stmt;
2122
2123public:
2124 const Expr *getExprStmt() const;
2126 const ValueStmt *ConstThis = this;
2127 return const_cast<Expr*>(ConstThis->getExprStmt());
2128 }
2129
2130 static bool classof(const Stmt *T) {
2131 return T->getStmtClass() >= firstValueStmtConstant &&
2132 T->getStmtClass() <= lastValueStmtConstant;
2133 }
2134};
2135
2136/// LabelStmt - Represents a label, which has a substatement. For example:
2137/// foo: return;
2138class LabelStmt : public ValueStmt {
2139 LabelDecl *TheDecl;
2140 Stmt *SubStmt;
2141 bool SideEntry = false;
2142
2143public:
2144 /// Build a label statement.
2146 : ValueStmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) {
2147 setIdentLoc(IL);
2148 }
2149
2150 /// Build an empty label statement.
2151 explicit LabelStmt(EmptyShell Empty) : ValueStmt(LabelStmtClass, Empty) {}
2152
2153 SourceLocation getIdentLoc() const { return LabelStmtBits.IdentLoc; }
2154 void setIdentLoc(SourceLocation L) { LabelStmtBits.IdentLoc = L; }
2155
2156 LabelDecl *getDecl() const { return TheDecl; }
2157 void setDecl(LabelDecl *D) { TheDecl = D; }
2158
2159 const char *getName() const;
2160 Stmt *getSubStmt() { return SubStmt; }
2161
2162 const Stmt *getSubStmt() const { return SubStmt; }
2163 void setSubStmt(Stmt *SS) { SubStmt = SS; }
2164
2166 SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
2167
2168 /// Look through nested labels and return the first non-label statement; e.g.
2169 /// if this is 'a:' in 'a: b: c: for(;;)', this returns the for loop.
2170 const Stmt *getInnermostLabeledStmt() const;
2172 return const_cast<Stmt *>(
2173 const_cast<const LabelStmt *>(this)->getInnermostLabeledStmt());
2174 }
2175
2176 child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
2177
2179 return const_child_range(&SubStmt, &SubStmt + 1);
2180 }
2181
2182 static bool classof(const Stmt *T) {
2183 return T->getStmtClass() == LabelStmtClass;
2184 }
2185 bool isSideEntry() const { return SideEntry; }
2186 void setSideEntry(bool SE) { SideEntry = SE; }
2187};
2188
2189/// Represents an attribute applied to a statement.
2190///
2191/// Represents an attribute applied to a statement. For example:
2192/// [[omp::for(...)]] for (...) { ... }
2193class AttributedStmt final
2194 : public ValueStmt,
2195 private llvm::TrailingObjects<AttributedStmt, const Attr *> {
2196 friend class ASTStmtReader;
2197 friend TrailingObjects;
2198
2199 Stmt *SubStmt;
2200
2201 AttributedStmt(SourceLocation Loc, ArrayRef<const Attr *> Attrs,
2202 Stmt *SubStmt)
2203 : ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
2204 AttributedStmtBits.NumAttrs = Attrs.size();
2205 AttributedStmtBits.AttrLoc = Loc;
2206 llvm::copy(Attrs, getAttrArrayPtr());
2207 }
2208
2209 explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)
2210 : ValueStmt(AttributedStmtClass, Empty) {
2211 AttributedStmtBits.NumAttrs = NumAttrs;
2213 std::fill_n(getAttrArrayPtr(), NumAttrs, nullptr);
2214 }
2215
2216 const Attr *const *getAttrArrayPtr() const { return getTrailingObjects(); }
2217 const Attr **getAttrArrayPtr() { return getTrailingObjects(); }
2218
2219public:
2220 static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,
2221 ArrayRef<const Attr *> Attrs, Stmt *SubStmt);
2222
2223 // Build an empty attributed statement.
2224 static AttributedStmt *CreateEmpty(const ASTContext &C, unsigned NumAttrs);
2225
2228 return {getAttrArrayPtr(), AttributedStmtBits.NumAttrs};
2229 }
2230
2231 Stmt *getSubStmt() { return SubStmt; }
2232 const Stmt *getSubStmt() const { return SubStmt; }
2233
2235 SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();}
2236
2237 child_range children() { return child_range(&SubStmt, &SubStmt + 1); }
2238
2240 return const_child_range(&SubStmt, &SubStmt + 1);
2241 }
2242
2243 static bool classof(const Stmt *T) {
2244 return T->getStmtClass() == AttributedStmtClass;
2245 }
2246};
2247
2248/// IfStmt - This represents an if/then/else.
2249class IfStmt final
2250 : public Stmt,
2251 private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> {
2252 friend TrailingObjects;
2253
2254 // IfStmt is followed by several trailing objects, some of which optional.
2255 // Note that it would be more convenient to put the optional trailing
2256 // objects at then end but this would change the order of the children.
2257 // The trailing objects are in order:
2258 //
2259 // * A "Stmt *" for the init statement.
2260 // Present if and only if hasInitStorage().
2261 //
2262 // * A "Stmt *" for the condition variable.
2263 // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
2264 //
2265 // * A "Stmt *" for the condition.
2266 // Always present. This is in fact a "Expr *".
2267 //
2268 // * A "Stmt *" for the then statement.
2269 // Always present.
2270 //
2271 // * A "Stmt *" for the else statement.
2272 // Present if and only if hasElseStorage().
2273 //
2274 // * A "SourceLocation" for the location of the "else".
2275 // Present if and only if hasElseStorage().
2276 enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 };
2277 enum { NumMandatoryStmtPtr = 2 };
2278 SourceLocation LParenLoc;
2279 SourceLocation RParenLoc;
2280
2281 unsigned numTrailingObjects(OverloadToken<Stmt *>) const {
2282 return NumMandatoryStmtPtr + hasElseStorage() + hasVarStorage() +
2284 }
2285
2286 unsigned numTrailingObjects(OverloadToken<SourceLocation>) const {
2287 return hasElseStorage();
2288 }
2289
2290 unsigned initOffset() const { return InitOffset; }
2291 unsigned varOffset() const { return InitOffset + hasInitStorage(); }
2292 unsigned condOffset() const {
2293 return InitOffset + hasInitStorage() + hasVarStorage();
2294 }
2295 unsigned thenOffset() const { return condOffset() + ThenOffsetFromCond; }
2296 unsigned elseOffset() const { return condOffset() + ElseOffsetFromCond; }
2297
2298 /// Build an if/then/else statement.
2299 IfStmt(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind,
2300 Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc,
2301 SourceLocation RParenLoc, Stmt *Then, SourceLocation EL, Stmt *Else);
2302
2303 /// Build an empty if/then/else statement.
2304 explicit IfStmt(EmptyShell Empty, bool HasElse, bool HasVar, bool HasInit);
2305
2306public:
2307 /// Create an IfStmt.
2308 static IfStmt *Create(const ASTContext &Ctx, SourceLocation IL,
2309 IfStatementKind Kind, Stmt *Init, VarDecl *Var,
2311 Stmt *Then, SourceLocation EL = SourceLocation(),
2312 Stmt *Else = nullptr);
2313
2314 /// Create an empty IfStmt optionally with storage for an else statement,
2315 /// condition variable and init expression.
2316 static IfStmt *CreateEmpty(const ASTContext &Ctx, bool HasElse, bool HasVar,
2317 bool HasInit);
2318
2319 /// True if this IfStmt has the storage for an init statement.
2320 bool hasInitStorage() const { return IfStmtBits.HasInit; }
2321
2322 /// True if this IfStmt has storage for a variable declaration.
2323 bool hasVarStorage() const { return IfStmtBits.HasVar; }
2324
2325 /// True if this IfStmt has storage for an else statement.
2326 bool hasElseStorage() const { return IfStmtBits.HasElse; }
2327
2329 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2330 }
2331
2332 const Expr *getCond() const {
2333 return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]);
2334 }
2335
2337 getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2338 }
2339
2340 Stmt *getThen() { return getTrailingObjects<Stmt *>()[thenOffset()]; }
2341 const Stmt *getThen() const {
2342 return getTrailingObjects<Stmt *>()[thenOffset()];
2343 }
2344
2345 void setThen(Stmt *Then) {
2346 getTrailingObjects<Stmt *>()[thenOffset()] = Then;
2347 }
2348
2350 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2351 : nullptr;
2352 }
2353
2354 const Stmt *getElse() const {
2355 return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()]
2356 : nullptr;
2357 }
2358
2359 void setElse(Stmt *Else) {
2360 assert(hasElseStorage() &&
2361 "This if statement has no storage for an else statement!");
2362 getTrailingObjects<Stmt *>()[elseOffset()] = Else;
2363 }
2364
2365 /// Retrieve the variable declared in this "if" statement, if any.
2366 ///
2367 /// In the following example, "x" is the condition variable.
2368 /// \code
2369 /// if (int x = foo()) {
2370 /// printf("x is %d", x);
2371 /// }
2372 /// \endcode
2375 return const_cast<IfStmt *>(this)->getConditionVariable();
2376 }
2377
2378 /// Set the condition variable for this if statement.
2379 /// The if statement must have storage for the condition variable.
2380 void setConditionVariable(const ASTContext &Ctx, VarDecl *V);
2381
2382 /// If this IfStmt has a condition variable, return the faux DeclStmt
2383 /// associated with the creation of that condition variable.
2385 return hasVarStorage() ? static_cast<DeclStmt *>(
2386 getTrailingObjects<Stmt *>()[varOffset()])
2387 : nullptr;
2388 }
2389
2391 return hasVarStorage() ? static_cast<DeclStmt *>(
2392 getTrailingObjects<Stmt *>()[varOffset()])
2393 : nullptr;
2394 }
2395
2397 assert(hasVarStorage());
2398 getTrailingObjects<Stmt *>()[varOffset()] = CondVar;
2399 }
2400
2402 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2403 : nullptr;
2404 }
2405
2406 const Stmt *getInit() const {
2407 return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()]
2408 : nullptr;
2409 }
2410
2412 assert(hasInitStorage() &&
2413 "This if statement has no storage for an init statement!");
2414 getTrailingObjects<Stmt *>()[initOffset()] = Init;
2415 }
2416
2417 SourceLocation getIfLoc() const { return IfStmtBits.IfLoc; }
2418 void setIfLoc(SourceLocation IfLoc) { IfStmtBits.IfLoc = IfLoc; }
2419
2421 return hasElseStorage() ? *getTrailingObjects<SourceLocation>()
2422 : SourceLocation();
2423 }
2424
2426 assert(hasElseStorage() &&
2427 "This if statement has no storage for an else statement!");
2428 *getTrailingObjects<SourceLocation>() = ElseLoc;
2429 }
2430
2435
2439
2443
2444 bool isConstexpr() const {
2446 }
2447
2449 IfStmtBits.Kind = static_cast<unsigned>(Kind);
2450 }
2451
2453 return static_cast<IfStatementKind>(IfStmtBits.Kind);
2454 }
2455
2456 /// If this is an 'if constexpr', determine which substatement will be taken.
2457 /// Otherwise, or if the condition is value-dependent, returns std::nullopt.
2458 std::optional<const Stmt *> getNondiscardedCase(const ASTContext &Ctx) const;
2459 std::optional<Stmt *> getNondiscardedCase(const ASTContext &Ctx);
2460
2461 bool isObjCAvailabilityCheck() const;
2462
2464 SourceLocation getEndLoc() const LLVM_READONLY {
2465 if (getElse())
2466 return getElse()->getEndLoc();
2467 return getThen()->getEndLoc();
2468 }
2469 SourceLocation getLParenLoc() const { return LParenLoc; }
2470 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2471 SourceLocation getRParenLoc() const { return RParenLoc; }
2472 void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
2473
2474 // Iterators over subexpressions. The iterators will include iterating
2475 // over the initialization expression referenced by the condition variable.
2477 // We always store a condition, but there is none for consteval if
2478 // statements, so skip it.
2479 return child_range(getTrailingObjects<Stmt *>() +
2480 (isConsteval() ? thenOffset() : 0),
2481 getTrailingObjects<Stmt *>() +
2482 numTrailingObjects(OverloadToken<Stmt *>()));
2483 }
2484
2486 // We always store a condition, but there is none for consteval if
2487 // statements, so skip it.
2488 return const_child_range(getTrailingObjects<Stmt *>() +
2489 (isConsteval() ? thenOffset() : 0),
2490 getTrailingObjects<Stmt *>() +
2491 numTrailingObjects(OverloadToken<Stmt *>()));
2492 }
2493
2494 static bool classof(const Stmt *T) {
2495 return T->getStmtClass() == IfStmtClass;
2496 }
2497};
2498
2499/// SwitchStmt - This represents a 'switch' stmt.
2500class SwitchStmt final : public Stmt,
2501 private llvm::TrailingObjects<SwitchStmt, Stmt *> {
2502 friend TrailingObjects;
2503
2504 /// Points to a linked list of case and default statements.
2505 SwitchCase *FirstCase = nullptr;
2506
2507 // SwitchStmt is followed by several trailing objects,
2508 // some of which optional. Note that it would be more convenient to
2509 // put the optional trailing objects at the end but this would change
2510 // the order in children().
2511 // The trailing objects are in order:
2512 //
2513 // * A "Stmt *" for the init statement.
2514 // Present if and only if hasInitStorage().
2515 //
2516 // * A "Stmt *" for the condition variable.
2517 // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
2518 //
2519 // * A "Stmt *" for the condition.
2520 // Always present. This is in fact an "Expr *".
2521 //
2522 // * A "Stmt *" for the body.
2523 // Always present.
2524 enum { InitOffset = 0, BodyOffsetFromCond = 1 };
2525 enum { NumMandatoryStmtPtr = 2 };
2526 SourceLocation LParenLoc;
2527 SourceLocation RParenLoc;
2528
2529 unsigned numTrailingStatements() const {
2530 return NumMandatoryStmtPtr + hasInitStorage() + hasVarStorage();
2531 }
2532
2533 unsigned initOffset() const { return InitOffset; }
2534 unsigned varOffset() const { return InitOffset + hasInitStorage(); }
2535 unsigned condOffset() const {
2536 return InitOffset + hasInitStorage() + hasVarStorage();
2537 }
2538 unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
2539
2540 /// Build a switch statement.
2541 SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond,
2542 SourceLocation LParenLoc, SourceLocation RParenLoc);
2543
2544 /// Build a empty switch statement.
2545 explicit SwitchStmt(EmptyShell Empty, bool HasInit, bool HasVar);
2546
2547public:
2548 /// Create a switch statement.
2549 static SwitchStmt *Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var,
2550 Expr *Cond, SourceLocation LParenLoc,
2551 SourceLocation RParenLoc);
2552
2553 /// Create an empty switch statement optionally with storage for
2554 /// an init expression and a condition variable.
2555 static SwitchStmt *CreateEmpty(const ASTContext &Ctx, bool HasInit,
2556 bool HasVar);
2557
2558 /// True if this SwitchStmt has storage for an init statement.
2559 bool hasInitStorage() const { return SwitchStmtBits.HasInit; }
2560
2561 /// True if this SwitchStmt has storage for a condition variable.
2562 bool hasVarStorage() const { return SwitchStmtBits.HasVar; }
2563
2565 return reinterpret_cast<Expr *>(getTrailingObjects()[condOffset()]);
2566 }
2567
2568 const Expr *getCond() const {
2569 return reinterpret_cast<Expr *>(getTrailingObjects()[condOffset()]);
2570 }
2571
2573 getTrailingObjects()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2574 }
2575
2576 Stmt *getBody() { return getTrailingObjects()[bodyOffset()]; }
2577 const Stmt *getBody() const { return getTrailingObjects()[bodyOffset()]; }
2578
2579 void setBody(Stmt *Body) { getTrailingObjects()[bodyOffset()] = Body; }
2580
2582 return hasInitStorage() ? getTrailingObjects()[initOffset()] : nullptr;
2583 }
2584
2585 const Stmt *getInit() const {
2586 return hasInitStorage() ? getTrailingObjects()[initOffset()] : nullptr;
2587 }
2588
2590 assert(hasInitStorage() &&
2591 "This switch statement has no storage for an init statement!");
2592 getTrailingObjects()[initOffset()] = Init;
2593 }
2594
2595 /// Retrieve the variable declared in this "switch" statement, if any.
2596 ///
2597 /// In the following example, "x" is the condition variable.
2598 /// \code
2599 /// switch (int x = foo()) {
2600 /// case 0: break;
2601 /// // ...
2602 /// }
2603 /// \endcode
2606 return const_cast<SwitchStmt *>(this)->getConditionVariable();
2607 }
2608
2609 /// Set the condition variable in this switch statement.
2610 /// The switch statement must have storage for it.
2611 void setConditionVariable(const ASTContext &Ctx, VarDecl *VD);
2612
2613 /// If this SwitchStmt has a condition variable, return the faux DeclStmt
2614 /// associated with the creation of that condition variable.
2616 return hasVarStorage()
2617 ? static_cast<DeclStmt *>(getTrailingObjects()[varOffset()])
2618 : nullptr;
2619 }
2620
2622 return hasVarStorage()
2623 ? static_cast<DeclStmt *>(getTrailingObjects()[varOffset()])
2624 : nullptr;
2625 }
2626
2628 assert(hasVarStorage());
2629 getTrailingObjects()[varOffset()] = CondVar;
2630 }
2631
2632 SwitchCase *getSwitchCaseList() { return FirstCase; }
2633 const SwitchCase *getSwitchCaseList() const { return FirstCase; }
2634 void setSwitchCaseList(SwitchCase *SC) { FirstCase = SC; }
2635
2636 SourceLocation getSwitchLoc() const { return SwitchStmtBits.SwitchLoc; }
2637 void setSwitchLoc(SourceLocation L) { SwitchStmtBits.SwitchLoc = L; }
2638 SourceLocation getLParenLoc() const { return LParenLoc; }
2639 void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2640 SourceLocation getRParenLoc() const { return RParenLoc; }
2641 void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
2642
2644 setBody(S);
2645 setSwitchLoc(SL);
2646 }
2647
2649 assert(!SC->getNextSwitchCase() &&
2650 "case/default already added to a switch");
2651 SC->setNextSwitchCase(FirstCase);
2652 FirstCase = SC;
2653 }
2654
2655 /// Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a
2656 /// switch over an enum value then all cases have been explicitly covered.
2657 void setAllEnumCasesCovered() { SwitchStmtBits.AllEnumCasesCovered = true; }
2658
2659 /// Returns true if the SwitchStmt is a switch of an enum value and all cases
2660 /// have been explicitly covered.
2662 return SwitchStmtBits.AllEnumCasesCovered;
2663 }
2664
2666 SourceLocation getEndLoc() const LLVM_READONLY {
2667 return getBody() ? getBody()->getEndLoc()
2668 : reinterpret_cast<const Stmt *>(getCond())->getEndLoc();
2669 }
2670
2671 // Iterators
2673 return child_range(getTrailingObjects(),
2674 getTrailingObjects() + numTrailingStatements());
2675 }
2676
2678 return const_child_range(getTrailingObjects(),
2679 getTrailingObjects() + numTrailingStatements());
2680 }
2681
2682 static bool classof(const Stmt *T) {
2683 return T->getStmtClass() == SwitchStmtClass;
2684 }
2685};
2686
2687/// WhileStmt - This represents a 'while' stmt.
2688class WhileStmt final : public Stmt,
2689 private llvm::TrailingObjects<WhileStmt, Stmt *> {
2690 friend TrailingObjects;
2691
2692 // WhileStmt is followed by several trailing objects,
2693 // some of which optional. Note that it would be more
2694 // convenient to put the optional trailing object at the end
2695 // but this would affect children().
2696 // The trailing objects are in order:
2697 //
2698 // * A "Stmt *" for the condition variable.
2699 // Present if and only if hasVarStorage(). This is in fact a "DeclStmt *".
2700 //
2701 // * A "Stmt *" for the condition.
2702 // Always present. This is in fact an "Expr *".
2703 //
2704 // * A "Stmt *" for the body.
2705 // Always present.
2706 //
2707 enum { VarOffset = 0, BodyOffsetFromCond = 1 };
2708 enum { NumMandatoryStmtPtr = 2 };
2709
2710 SourceLocation LParenLoc, RParenLoc;
2711
2712 unsigned varOffset() const { return VarOffset; }
2713 unsigned condOffset() const { return VarOffset + hasVarStorage(); }
2714 unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; }
2715
2716 unsigned numTrailingStatements() const {
2717 return NumMandatoryStmtPtr + hasVarStorage();
2718 }
2719
2720 /// Build a while statement.
2721 WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body,
2722 SourceLocation WL, SourceLocation LParenLoc,
2723 SourceLocation RParenLoc);
2724
2725 /// Build an empty while statement.
2726 explicit WhileStmt(EmptyShell Empty, bool HasVar);
2727
2728public:
2729 /// Create a while statement.
2730 static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond,
2731 Stmt *Body, SourceLocation WL,
2732 SourceLocation LParenLoc, SourceLocation RParenLoc);
2733
2734 /// Create an empty while statement optionally with storage for
2735 /// a condition variable.
2736 static WhileStmt *CreateEmpty(const ASTContext &Ctx, bool HasVar);
2737
2738 /// True if this WhileStmt has storage for a condition variable.
2739 bool hasVarStorage() const { return WhileStmtBits.HasVar; }
2740
2742 return reinterpret_cast<Expr *>(getTrailingObjects()[condOffset()]);
2743 }
2744
2745 const Expr *getCond() const {
2746 return reinterpret_cast<Expr *>(getTrailingObjects()[condOffset()]);
2747 }
2748
2750 getTrailingObjects()[condOffset()] = reinterpret_cast<Stmt *>(Cond);
2751 }
2752
2753 Stmt *getBody() { return getTrailingObjects()[bodyOffset()]; }
2754 const Stmt *getBody() const { return getTrailingObjects()[bodyOffset()]; }
2755
2756 void setBody(Stmt *Body) { getTrailingObjects()[bodyOffset()] = Body; }
2757
2758 /// Retrieve the variable declared in this "while" statement, if any.
2759 ///
2760 /// In the following example, "x" is the condition variable.
2761 /// \code
2762 /// while (int x = random()) {
2763 /// // ...
2764 /// }
2765 /// \endcode
2768 return const_cast<WhileStmt *>(this)->getConditionVariable();
2769 }
2770
2771 /// Set the condition variable of this while statement.
2772 /// The while statement must have storage for it.
2773 void setConditionVariable(const ASTContext &Ctx, VarDecl *V);
2774
2775 /// If this WhileStmt has a condition variable, return the faux DeclStmt
2776 /// associated with the creation of that condition variable.
2778 return hasVarStorage()
2779 ? static_cast<DeclStmt *>(getTrailingObjects()[varOffset()])
2780 : nullptr;
2781 }
2782
2784 return hasVarStorage()
2785 ? static_cast<DeclStmt *>(getTrailingObjects()[varOffset()])
2786 : nullptr;
2787 }
2788
2790 assert(hasVarStorage());
2791 getTrailingObjects()[varOffset()] = CondVar;
2792 }
2793
2794 SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; }
2795 void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; }
2796
2797 SourceLocation getLParenLoc() const { return LParenLoc; }
2798 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2799 SourceLocation getRParenLoc() const { return RParenLoc; }
2800 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2801
2803 SourceLocation getEndLoc() const LLVM_READONLY {
2804 return getBody()->getEndLoc();
2805 }
2806
2807 static bool classof(const Stmt *T) {
2808 return T->getStmtClass() == WhileStmtClass;
2809 }
2810
2811 // Iterators
2813 return child_range(getTrailingObjects(),
2814 getTrailingObjects() + numTrailingStatements());
2815 }
2816
2818 return const_child_range(getTrailingObjects(),
2819 getTrailingObjects() + numTrailingStatements());
2820 }
2821};
2822
2823/// DoStmt - This represents a 'do/while' stmt.
2824class DoStmt : public Stmt {
2825 enum { BODY, COND, END_EXPR };
2826 Stmt *SubExprs[END_EXPR];
2827 SourceLocation WhileLoc;
2828 SourceLocation RParenLoc; // Location of final ')' in do stmt condition.
2829
2830public:
2832 SourceLocation RP)
2833 : Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) {
2834 setCond(Cond);
2835 setBody(Body);
2836 setDoLoc(DL);
2837 }
2838
2839 /// Build an empty do-while statement.
2840 explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) {}
2841
2842 Expr *getCond() { return reinterpret_cast<Expr *>(SubExprs[COND]); }
2843 const Expr *getCond() const {
2844 return reinterpret_cast<Expr *>(SubExprs[COND]);
2845 }
2846
2847 void setCond(Expr *Cond) { SubExprs[COND] = reinterpret_cast<Stmt *>(Cond); }
2848
2849 Stmt *getBody() { return SubExprs[BODY]; }
2850 const Stmt *getBody() const { return SubExprs[BODY]; }
2851 void setBody(Stmt *Body) { SubExprs[BODY] = Body; }
2852
2853 SourceLocation getDoLoc() const { return DoStmtBits.DoLoc; }
2854 void setDoLoc(SourceLocation L) { DoStmtBits.DoLoc = L; }
2855 SourceLocation getWhileLoc() const { return WhileLoc; }
2856 void setWhileLoc(SourceLocation L) { WhileLoc = L; }
2857 SourceLocation getRParenLoc() const { return RParenLoc; }
2858 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2859
2862
2863 static bool classof(const Stmt *T) {
2864 return T->getStmtClass() == DoStmtClass;
2865 }
2866
2867 // Iterators
2869 return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2870 }
2871
2873 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2874 }
2875};
2876
2877/// ForStmt - This represents a 'for (init;cond;inc)' stmt. Note that any of
2878/// the init/cond/inc parts of the ForStmt will be null if they were not
2879/// specified in the source.
2880class ForStmt : public Stmt {
2881 friend class ASTStmtReader;
2882
2883 enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR };
2884 Stmt* SubExprs[END_EXPR]; // SubExprs[INIT] is an expression or declstmt.
2885 SourceLocation LParenLoc, RParenLoc;
2886
2887public:
2888 ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar,
2889 Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
2890 SourceLocation RP);
2891
2892 /// Build an empty for statement.
2893 explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) {}
2894
2895 Stmt *getInit() { return SubExprs[INIT]; }
2896
2897 /// Retrieve the variable declared in this "for" statement, if any.
2898 ///
2899 /// In the following example, "y" is the condition variable.
2900 /// \code
2901 /// for (int x = random(); int y = mangle(x); ++x) {
2902 /// // ...
2903 /// }
2904 /// \endcode
2906 void setConditionVariable(const ASTContext &C, VarDecl *V);
2907
2908 /// If this ForStmt has a condition variable, return the faux DeclStmt
2909 /// associated with the creation of that condition variable.
2911 return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
2912 }
2913
2915 return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]);
2916 }
2917
2919 SubExprs[CONDVAR] = CondVar;
2920 }
2921
2922 Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); }
2923 Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); }
2924 Stmt *getBody() { return SubExprs[BODY]; }
2925
2926 const Stmt *getInit() const { return SubExprs[INIT]; }
2927 const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);}
2928 const Expr *getInc() const { return reinterpret_cast<Expr*>(SubExprs[INC]); }
2929 const Stmt *getBody() const { return SubExprs[BODY]; }
2930
2931 void setInit(Stmt *S) { SubExprs[INIT] = S; }
2932 void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); }
2933 void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); }
2934 void setBody(Stmt *S) { SubExprs[BODY] = S; }
2935
2936 SourceLocation getForLoc() const { return ForStmtBits.ForLoc; }
2937 void setForLoc(SourceLocation L) { ForStmtBits.ForLoc = L; }
2938 SourceLocation getLParenLoc() const { return LParenLoc; }
2939 void setLParenLoc(SourceLocation L) { LParenLoc = L; }
2940 SourceLocation getRParenLoc() const { return RParenLoc; }
2941 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
2942
2945
2946 static bool classof(const Stmt *T) {
2947 return T->getStmtClass() == ForStmtClass;
2948 }
2949
2950 // Iterators
2952 return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR);
2953 }
2954
2956 return const_child_range(&SubExprs[0], &SubExprs[0] + END_EXPR);
2957 }
2958};
2959
2960/// GotoStmt - This represents a direct goto.
2961class GotoStmt : public Stmt {
2962 LabelDecl *Label;
2963 SourceLocation LabelLoc;
2964
2965public:
2967 : Stmt(GotoStmtClass), Label(label), LabelLoc(LL) {
2968 setGotoLoc(GL);
2969 }
2970
2971 /// Build an empty goto statement.
2972 explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) {}
2973
2974 LabelDecl *getLabel() const { return Label; }
2975 void setLabel(LabelDecl *D) { Label = D; }
2976
2977 SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; }
2978 void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; }
2979 SourceLocation getLabelLoc() const { return LabelLoc; }
2980 void setLabelLoc(SourceLocation L) { LabelLoc = L; }
2981
2984
2985 static bool classof(const Stmt *T) {
2986 return T->getStmtClass() == GotoStmtClass;
2987 }
2988
2989 // Iterators
2993
2997};
2998
2999/// IndirectGotoStmt - This represents an indirect goto.
3000class IndirectGotoStmt : public Stmt {
3001 SourceLocation StarLoc;
3002 Stmt *Target;
3003
3004public:
3006 : Stmt(IndirectGotoStmtClass), StarLoc(starLoc) {
3007 setTarget(target);
3008 setGotoLoc(gotoLoc);
3009 }
3010
3011 /// Build an empty indirect goto statement.
3013 : Stmt(IndirectGotoStmtClass, Empty) {}
3014
3015 void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; }
3016 SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; }
3017 void setStarLoc(SourceLocation L) { StarLoc = L; }
3018 SourceLocation getStarLoc() const { return StarLoc; }
3019
3020 Expr *getTarget() { return reinterpret_cast<Expr *>(Target); }
3021 const Expr *getTarget() const {
3022 return reinterpret_cast<const Expr *>(Target);
3023 }
3024 void setTarget(Expr *E) { Target = reinterpret_cast<Stmt *>(E); }
3025
3026 /// getConstantTarget - Returns the fixed target of this indirect
3027 /// goto, if one exists.
3030 return const_cast<IndirectGotoStmt *>(this)->getConstantTarget();
3031 }
3032
3034 SourceLocation getEndLoc() const LLVM_READONLY { return Target->getEndLoc(); }
3035
3036 static bool classof(const Stmt *T) {
3037 return T->getStmtClass() == IndirectGotoStmtClass;
3038 }
3039
3040 // Iterators
3041 child_range children() { return child_range(&Target, &Target + 1); }
3042
3044 return const_child_range(&Target, &Target + 1);
3045 }
3046};
3047
3048/// Base class for BreakStmt and ContinueStmt.
3049class LoopControlStmt : public Stmt {
3050 /// If this is a named break/continue, the label whose statement we're
3051 /// targeting, as well as the source location of the label after the
3052 /// keyword; for example:
3053 ///
3054 /// a: // <-- TargetLabel
3055 /// for (;;)
3056 /// break a; // <-- LabelLoc
3057 ///
3058 LabelDecl *TargetLabel = nullptr;
3059 SourceLocation LabelLoc;
3060
3061protected:
3064 : Stmt(Class), TargetLabel(Target), LabelLoc(LabelLoc) {
3065 setKwLoc(Loc);
3066 }
3067
3070
3072
3073public:
3076
3079 return hasLabelTarget() ? getLabelLoc() : getKwLoc();
3080 }
3081
3082 bool hasLabelTarget() const { return TargetLabel != nullptr; }
3083
3084 SourceLocation getLabelLoc() const { return LabelLoc; }
3085 void setLabelLoc(SourceLocation L) { LabelLoc = L; }
3086
3087 LabelDecl *getLabelDecl() { return TargetLabel; }
3088 const LabelDecl *getLabelDecl() const { return TargetLabel; }
3089 void setLabelDecl(LabelDecl *S) { TargetLabel = S; }
3090
3091 /// If this is a named break/continue, get the loop or switch statement
3092 /// that this targets.
3093 const Stmt *getNamedLoopOrSwitch() const;
3094
3095 // Iterators
3099
3103
3104 static bool classof(const Stmt *T) {
3105 StmtClass Class = T->getStmtClass();
3106 return Class == ContinueStmtClass || Class == BreakStmtClass;
3107 }
3108};
3109
3110/// ContinueStmt - This represents a continue.
3112public:
3115 : LoopControlStmt(ContinueStmtClass, CL, LabelLoc, Target) {}
3116
3117 /// Build an empty continue statement.
3119 : LoopControlStmt(ContinueStmtClass, Empty) {}
3120
3121 static bool classof(const Stmt *T) {
3122 return T->getStmtClass() == ContinueStmtClass;
3123 }
3124};
3125
3126/// BreakStmt - This represents a break.
3128public:
3129 BreakStmt(SourceLocation BL) : LoopControlStmt(BreakStmtClass, BL) {}
3131 : LoopControlStmt(BreakStmtClass, CL, LabelLoc, Target) {}
3132
3133 /// Build an empty break statement.
3135 : LoopControlStmt(BreakStmtClass, Empty) {}
3136
3137 static bool classof(const Stmt *T) {
3138 return T->getStmtClass() == BreakStmtClass;
3139 }
3140};
3141
3142/// ReturnStmt - This represents a return, optionally of an expression:
3143/// return;
3144/// return 4;
3145///
3146/// Note that GCC allows return with no argument in a function declared to
3147/// return a value, and it allows returning a value in functions declared to
3148/// return void. We explicitly model this in the AST, which means you can't
3149/// depend on the return type of the function and the presence of an argument.
3150class ReturnStmt final
3151 : public Stmt,
3152 private llvm::TrailingObjects<ReturnStmt, const VarDecl *> {
3153 friend TrailingObjects;
3154
3155 /// The return expression.
3156 Stmt *RetExpr;
3157
3158 // ReturnStmt is followed optionally by a trailing "const VarDecl *"
3159 // for the NRVO candidate. Present if and only if hasNRVOCandidate().
3160
3161 /// True if this ReturnStmt has storage for an NRVO candidate.
3162 bool hasNRVOCandidate() const { return ReturnStmtBits.HasNRVOCandidate; }
3163
3164 /// Build a return statement.
3165 ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate);
3166
3167 /// Build an empty return statement.
3168 explicit ReturnStmt(EmptyShell Empty, bool HasNRVOCandidate);
3169
3170public:
3171 /// Create a return statement.
3172 static ReturnStmt *Create(const ASTContext &Ctx, SourceLocation RL, Expr *E,
3173 const VarDecl *NRVOCandidate);
3174
3175 /// Create an empty return statement, optionally with
3176 /// storage for an NRVO candidate.
3177 static ReturnStmt *CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate);
3178
3179 Expr *getRetValue() { return reinterpret_cast<Expr *>(RetExpr); }
3180 const Expr *getRetValue() const { return reinterpret_cast<Expr *>(RetExpr); }
3181 void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt *>(E); }
3182
3183 /// Retrieve the variable that might be used for the named return
3184 /// value optimization.
3185 ///
3186 /// The optimization itself can only be performed if the variable is
3187 /// also marked as an NRVO object.
3188 const VarDecl *getNRVOCandidate() const {
3189 return hasNRVOCandidate() ? *getTrailingObjects() : nullptr;
3190 }
3191
3192 /// Set the variable that might be used for the named return value
3193 /// optimization. The return statement must have storage for it,
3194 /// which is the case if and only if hasNRVOCandidate() is true.
3195 void setNRVOCandidate(const VarDecl *Var) {
3196 assert(hasNRVOCandidate() &&
3197 "This return statement has no storage for an NRVO candidate!");
3198 *getTrailingObjects() = Var;
3199 }
3200
3201 SourceLocation getReturnLoc() const { return ReturnStmtBits.RetLoc; }
3203
3205 SourceLocation getEndLoc() const LLVM_READONLY {
3206 return RetExpr ? RetExpr->getEndLoc() : getReturnLoc();
3207 }
3208
3209 static bool classof(const Stmt *T) {
3210 return T->getStmtClass() == ReturnStmtClass;
3211 }
3212
3213 // Iterators
3215 if (RetExpr)
3216 return child_range(&RetExpr, &RetExpr + 1);
3218 }
3219
3221 if (RetExpr)
3222 return const_child_range(&RetExpr, &RetExpr + 1);
3224 }
3225};
3226
3227/// DeferStmt - This represents a deferred statement.
3228class DeferStmt : public Stmt {
3229 friend class ASTStmtReader;
3230
3231 /// The deferred statement.
3232 Stmt *Body;
3233
3234 DeferStmt(EmptyShell Empty);
3235 DeferStmt(SourceLocation DeferLoc, Stmt *Body);
3236
3237public:
3238 static DeferStmt *CreateEmpty(ASTContext &Context, EmptyShell Empty);
3239 static DeferStmt *Create(ASTContext &Context, SourceLocation DeferLoc,
3240 Stmt *Body);
3241
3242 SourceLocation getDeferLoc() const { return DeferStmtBits.DeferLoc; }
3244 DeferStmtBits.DeferLoc = DeferLoc;
3245 }
3246
3247 Stmt *getBody() { return Body; }
3248 const Stmt *getBody() const { return Body; }
3249 void setBody(Stmt *S) {
3250 assert(S && "defer body must not be null");
3251 Body = S;
3252 }
3253
3255 SourceLocation getEndLoc() const { return Body->getEndLoc(); }
3256
3257 child_range children() { return child_range(&Body, &Body + 1); }
3258
3260 return const_child_range(&Body, &Body + 1);
3261 }
3262
3263 static bool classof(const Stmt *S) {
3264 return S->getStmtClass() == DeferStmtClass;
3265 }
3266};
3267
3268/// AsmStmt is the base class for GCCAsmStmt and MSAsmStmt.
3269class AsmStmt : public Stmt {
3270protected:
3271 friend class ASTStmtReader;
3272
3274
3275 /// True if the assembly statement does not have any input or output
3276 /// operands.
3278
3279 /// If true, treat this inline assembly as having side effects.
3280 /// This assembly statement should not be optimized, deleted or moved.
3282
3283 unsigned NumOutputs;
3284 unsigned NumInputs;
3285 unsigned NumClobbers;
3286
3287 Stmt **Exprs = nullptr;
3288
3289 AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile,
3290 unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
3291 : Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
3292 NumOutputs(numoutputs), NumInputs(numinputs),
3293 NumClobbers(numclobbers) {}
3294
3295public:
3296 /// Build an empty inline-assembly statement.
3297 explicit AsmStmt(StmtClass SC, EmptyShell Empty) : Stmt(SC, Empty) {}
3298
3299 SourceLocation getAsmLoc() const { return AsmLoc; }
3301
3302 bool isSimple() const { return IsSimple; }
3303 void setSimple(bool V) { IsSimple = V; }
3304
3305 bool isVolatile() const { return IsVolatile; }
3306 void setVolatile(bool V) { IsVolatile = V; }
3307
3308 SourceLocation getBeginLoc() const LLVM_READONLY { return {}; }
3309 SourceLocation getEndLoc() const LLVM_READONLY { return {}; }
3310
3311 //===--- Asm String Analysis ---===//
3312
3313 /// Assemble final IR asm string.
3314 std::string generateAsmString(const ASTContext &C) const;
3315
3317 llvm::function_ref<void(const Stmt *, StringRef)>;
3318 /// Look at AsmExpr and if it is a variable declared as using a particular
3319 /// register add that as a constraint that will be used in this asm stmt.
3320 std::string
3321 addVariableConstraints(StringRef Constraint, const Expr &AsmExpr,
3322 const TargetInfo &Target, bool EarlyClobber,
3323 UnsupportedConstraintCallbackTy UnsupportedCB,
3324 std::string *GCCReg = nullptr) const;
3325
3326 //===--- Output operands ---===//
3327
3328 unsigned getNumOutputs() const { return NumOutputs; }
3329
3330 /// getOutputConstraint - Return the constraint string for the specified
3331 /// output operand. All output constraints are known to be non-empty (either
3332 /// '=' or '+').
3333 std::string getOutputConstraint(unsigned i) const;
3334
3335 /// isOutputPlusConstraint - Return true if the specified output constraint
3336 /// is a "+" constraint (which is both an input and an output) or false if it
3337 /// is an "=" constraint (just an output).
3338 bool isOutputPlusConstraint(unsigned i) const {
3339 return getOutputConstraint(i)[0] == '+';
3340 }
3341
3342 const Expr *getOutputExpr(unsigned i) const;
3343
3344 /// getNumPlusOperands - Return the number of output operands that have a "+"
3345 /// constraint.
3346 unsigned getNumPlusOperands() const;
3347
3348 //===--- Input operands ---===//
3349
3350 unsigned getNumInputs() const { return NumInputs; }
3351
3352 /// getInputConstraint - Return the specified input constraint. Unlike output
3353 /// constraints, these can be empty.
3354 std::string getInputConstraint(unsigned i) const;
3355
3356 const Expr *getInputExpr(unsigned i) const;
3357
3358 //===--- Other ---===//
3359
3360 unsigned getNumClobbers() const { return NumClobbers; }
3361 std::string getClobber(unsigned i) const;
3362
3363 static bool classof(const Stmt *T) {
3364 return T->getStmtClass() == GCCAsmStmtClass ||
3365 T->getStmtClass() == MSAsmStmtClass;
3366 }
3367
3368 // Input expr iterators.
3369
3372 using inputs_range = llvm::iterator_range<inputs_iterator>;
3373 using inputs_const_range = llvm::iterator_range<const_inputs_iterator>;
3374
3376 return &Exprs[0] + NumOutputs;
3377 }
3378
3380 return &Exprs[0] + NumOutputs + NumInputs;
3381 }
3382
3384
3386 return &Exprs[0] + NumOutputs;
3387 }
3388
3390 return &Exprs[0] + NumOutputs + NumInputs;
3391 }
3392
3396
3397 // Output expr iterators.
3398
3401 using outputs_range = llvm::iterator_range<outputs_iterator>;
3402 using outputs_const_range = llvm::iterator_range<const_outputs_iterator>;
3403
3405 return &Exprs[0];
3406 }
3407
3409 return &Exprs[0] + NumOutputs;
3410 }
3411
3415
3417 return &Exprs[0];
3418 }
3419
3421 return &Exprs[0] + NumOutputs;
3422 }
3423
3427
3429 return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
3430 }
3431
3433 return const_child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs);
3434 }
3435};
3436
3437/// This represents a GCC inline-assembly statement extension.
3438class GCCAsmStmt : public AsmStmt {
3439 friend class ASTStmtReader;
3440
3441 SourceLocation RParenLoc;
3442 Expr *AsmStr;
3443
3444 // FIXME: If we wanted to, we could allocate all of these in one big array.
3445 Expr **Constraints = nullptr;
3446 Expr **Clobbers = nullptr;
3447 IdentifierInfo **Names = nullptr;
3448 unsigned NumLabels = 0;
3449
3450public:
3451 GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple,
3452 bool isvolatile, unsigned numoutputs, unsigned numinputs,
3453 IdentifierInfo **names, Expr **constraints, Expr **exprs,
3454 Expr *asmstr, unsigned numclobbers, Expr **clobbers,
3455 unsigned numlabels, SourceLocation rparenloc);
3456
3457 /// Build an empty inline-assembly statement.
3458 explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty) {}
3459
3460 SourceLocation getRParenLoc() const { return RParenLoc; }
3461 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
3462
3463 //===--- Asm String Analysis ---===//
3464
3465 const Expr *getAsmStringExpr() const { return AsmStr; }
3466 Expr *getAsmStringExpr() { return AsmStr; }
3467 void setAsmStringExpr(Expr *E) { AsmStr = E; }
3468
3469 std::string getAsmString() const;
3470
3471 /// AsmStringPiece - this is part of a decomposed asm string specification
3472 /// (for use with the AnalyzeAsmString function below). An asm string is
3473 /// considered to be a concatenation of these parts.
3475 public:
3476 enum Kind {
3477 String, // String in .ll asm string form, "$" -> "$$" and "%%" -> "%".
3478 Operand // Operand reference, with optional modifier %c4.
3479 };
3480
3481 private:
3482 Kind MyKind;
3483 std::string Str;
3484 unsigned OperandNo;
3485
3486 // Source range for operand references.
3487 CharSourceRange Range;
3488
3489 public:
3490 AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {}
3491 AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin,
3492 SourceLocation End)
3493 : MyKind(Operand), Str(S), OperandNo(OpNo),
3494 Range(CharSourceRange::getCharRange(Begin, End)) {}
3495
3496 bool isString() const { return MyKind == String; }
3497 bool isOperand() const { return MyKind == Operand; }
3498
3499 const std::string &getString() const { return Str; }
3500
3501 unsigned getOperandNo() const {
3502 assert(isOperand());
3503 return OperandNo;
3504 }
3505
3507 assert(isOperand() && "Range is currently used only for Operands.");
3508 return Range;
3509 }
3510
3511 /// getModifier - Get the modifier for this operand, if present. This
3512 /// returns '\0' if there was no modifier.
3513 char getModifier() const;
3514 };
3515
3516 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
3517 /// it into pieces. If the asm string is erroneous, emit errors and return
3518 /// true, otherwise return false. This handles canonicalization and
3519 /// translation of strings from GCC syntax to LLVM IR syntax, and handles
3520 //// flattening of named references like %[foo] to Operand AsmStringPiece's.
3522 const ASTContext &C, unsigned &DiagOffs) const;
3523
3524 /// Assemble final IR asm string.
3525 std::string generateAsmString(const ASTContext &C) const;
3526
3527 //===--- Output operands ---===//
3528
3529 IdentifierInfo *getOutputIdentifier(unsigned i) const { return Names[i]; }
3530
3531 StringRef getOutputName(unsigned i) const {
3533 return II->getName();
3534
3535 return {};
3536 }
3537
3538 std::string getOutputConstraint(unsigned i) const;
3539
3540 const Expr *getOutputConstraintExpr(unsigned i) const {
3541 return Constraints[i];
3542 }
3543 Expr *getOutputConstraintExpr(unsigned i) { return Constraints[i]; }
3544
3545 Expr *getOutputExpr(unsigned i);
3546
3547 const Expr *getOutputExpr(unsigned i) const {
3548 return const_cast<GCCAsmStmt*>(this)->getOutputExpr(i);
3549 }
3550
3551 //===--- Input operands ---===//
3552
3554 return Names[i + NumOutputs];
3555 }
3556
3557 StringRef getInputName(unsigned i) const {
3559 return II->getName();
3560
3561 return {};
3562 }
3563
3564 std::string getInputConstraint(unsigned i) const;
3565
3566 const Expr *getInputConstraintExpr(unsigned i) const {
3567 return Constraints[i + NumOutputs];
3568 }
3570 return Constraints[i + NumOutputs];
3571 }
3572
3573 Expr *getInputExpr(unsigned i);
3574 void setInputExpr(unsigned i, Expr *E);
3575
3576 const Expr *getInputExpr(unsigned i) const {
3577 return const_cast<GCCAsmStmt*>(this)->getInputExpr(i);
3578 }
3579
3580 static std::string ExtractStringFromGCCAsmStmtComponent(const Expr *E);
3581
3582 //===--- Labels ---===//
3583
3584 bool isAsmGoto() const {
3585 return NumLabels > 0;
3586 }
3587
3588 unsigned getNumLabels() const {
3589 return NumLabels;
3590 }
3591
3593 return Names[i + NumOutputs + NumInputs];
3594 }
3595
3596 AddrLabelExpr *getLabelExpr(unsigned i) const;
3597 StringRef getLabelName(unsigned i) const;
3600 using labels_range = llvm::iterator_range<labels_iterator>;
3601 using labels_const_range = llvm::iterator_range<const_labels_iterator>;
3602
3604 return &Exprs[0] + NumOutputs + NumInputs;
3605 }
3606
3608 return &Exprs[0] + NumOutputs + NumInputs + NumLabels;
3609 }
3610
3614
3616 return &Exprs[0] + NumOutputs + NumInputs;
3617 }
3618
3620 return &Exprs[0] + NumOutputs + NumInputs + NumLabels;
3621 }
3622
3626
3627private:
3628 void setOutputsAndInputsAndClobbers(const ASTContext &C,
3629 IdentifierInfo **Names,
3630 Expr **Constraints, Stmt **Exprs,
3631 unsigned NumOutputs, unsigned NumInputs,
3632 unsigned NumLabels, Expr **Clobbers,
3633 unsigned NumClobbers);
3634
3635public:
3636 //===--- Other ---===//
3637
3638 /// getNamedOperand - Given a symbolic operand reference like %[foo],
3639 /// translate this into a numeric value needed to reference the same operand.
3640 /// This returns -1 if the operand name is invalid.
3641 int getNamedOperand(StringRef SymbolicName) const;
3642
3643 std::string getClobber(unsigned i) const;
3644
3645 Expr *getClobberExpr(unsigned i) { return Clobbers[i]; }
3646 const Expr *getClobberExpr(unsigned i) const { return Clobbers[i]; }
3647
3648 SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; }
3649 SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }
3650
3651 static bool classof(const Stmt *T) {
3652 return T->getStmtClass() == GCCAsmStmtClass;
3653 }
3654};
3655
3656/// This represents a Microsoft inline-assembly statement extension.
3657class MSAsmStmt : public AsmStmt {
3658 friend class ASTStmtReader;
3659
3660 SourceLocation LBraceLoc, EndLoc;
3661 StringRef AsmStr;
3662
3663 unsigned NumAsmToks = 0;
3664
3665 Token *AsmToks = nullptr;
3666 StringRef *Constraints = nullptr;
3667 StringRef *Clobbers = nullptr;
3668
3669public:
3670 MSAsmStmt(const ASTContext &C, SourceLocation asmloc,
3671 SourceLocation lbraceloc, bool issimple, bool isvolatile,
3672 ArrayRef<Token> asmtoks, unsigned numoutputs, unsigned numinputs,
3673 ArrayRef<StringRef> constraints,
3674 ArrayRef<Expr*> exprs, StringRef asmstr,
3675 ArrayRef<StringRef> clobbers, SourceLocation endloc);
3676
3677 /// Build an empty MS-style inline-assembly statement.
3678 explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty) {}
3679
3680 SourceLocation getLBraceLoc() const { return LBraceLoc; }
3681 void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
3682 SourceLocation getEndLoc() const { return EndLoc; }
3683 void setEndLoc(SourceLocation L) { EndLoc = L; }
3684
3685 bool hasBraces() const { return LBraceLoc.isValid(); }
3686
3687 unsigned getNumAsmToks() { return NumAsmToks; }
3688 Token *getAsmToks() { return AsmToks; }
3689
3690 //===--- Asm String Analysis ---===//
3691 StringRef getAsmString() const { return AsmStr; }
3692
3693 /// Assemble final IR asm string.
3694 std::string generateAsmString(const ASTContext &C) const;
3695
3696 //===--- Output operands ---===//
3697
3698 StringRef getOutputConstraint(unsigned i) const {
3699 assert(i < NumOutputs);
3700 return Constraints[i];
3701 }
3702
3703 Expr *getOutputExpr(unsigned i);
3704
3705 const Expr *getOutputExpr(unsigned i) const {
3706 return const_cast<MSAsmStmt*>(this)->getOutputExpr(i);
3707 }
3708
3709 //===--- Input operands ---===//
3710
3711 StringRef getInputConstraint(unsigned i) const {
3712 assert(i < NumInputs);
3713 return Constraints[i + NumOutputs];
3714 }
3715
3716 Expr *getInputExpr(unsigned i);
3717 void setInputExpr(unsigned i, Expr *E);
3718
3719 const Expr *getInputExpr(unsigned i) const {
3720 return const_cast<MSAsmStmt*>(this)->getInputExpr(i);
3721 }
3722
3723 //===--- Other ---===//
3724
3726 return {Constraints, NumInputs + NumOutputs};
3727 }
3728
3729 ArrayRef<StringRef> getClobbers() const { return {Clobbers, NumClobbers}; }
3730
3732 return {reinterpret_cast<Expr **>(Exprs), NumInputs + NumOutputs};
3733 }
3734
3735 StringRef getClobber(unsigned i) const { return getClobbers()[i]; }
3736
3737private:
3738 void initialize(const ASTContext &C, StringRef AsmString,
3739 ArrayRef<Token> AsmToks, ArrayRef<StringRef> Constraints,
3741
3742public:
3743 SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; }
3744
3745 static bool classof(const Stmt *T) {
3746 return T->getStmtClass() == MSAsmStmtClass;
3747 }
3748
3752
3756};
3757
3758class SEHExceptStmt : public Stmt {
3759 friend class ASTReader;
3760 friend class ASTStmtReader;
3761
3762 SourceLocation Loc;
3763 Stmt *Children[2];
3764
3765 enum { FILTER_EXPR, BLOCK };
3766
3767 SEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block);
3768 explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) {}
3769
3770public:
3771 static SEHExceptStmt* Create(const ASTContext &C,
3772 SourceLocation ExceptLoc,
3773 Expr *FilterExpr,
3774 Stmt *Block);
3775
3776 SourceLocation getBeginLoc() const LLVM_READONLY { return getExceptLoc(); }
3777
3778 SourceLocation getExceptLoc() const { return Loc; }
3780
3782 return reinterpret_cast<Expr*>(Children[FILTER_EXPR]);
3783 }
3784
3786 return cast<CompoundStmt>(Children[BLOCK]);
3787 }
3788
3790 return child_range(Children, Children+2);
3791 }
3792
3794 return const_child_range(Children, Children + 2);
3795 }
3796
3797 static bool classof(const Stmt *T) {
3798 return T->getStmtClass() == SEHExceptStmtClass;
3799 }
3800};
3801
3802class SEHFinallyStmt : public Stmt {
3803 friend class ASTReader;
3804 friend class ASTStmtReader;
3805
3806 SourceLocation Loc;
3807 Stmt *Block;
3808
3809 SEHFinallyStmt(SourceLocation Loc, Stmt *Block);
3810 explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) {}
3811
3812public:
3813 static SEHFinallyStmt* Create(const ASTContext &C,
3814 SourceLocation FinallyLoc,
3815 Stmt *Block);
3816
3817 SourceLocation getBeginLoc() const LLVM_READONLY { return getFinallyLoc(); }
3818
3819 SourceLocation getFinallyLoc() const { return Loc; }
3820 SourceLocation getEndLoc() const { return Block->getEndLoc(); }
3821
3822 CompoundStmt *getBlock() const { return cast<CompoundStmt>(Block); }
3823
3825 return child_range(&Block,&Block+1);
3826 }
3827
3829 return const_child_range(&Block, &Block + 1);
3830 }
3831
3832 static bool classof(const Stmt *T) {
3833 return T->getStmtClass() == SEHFinallyStmtClass;
3834 }
3835};
3836
3837class SEHTryStmt : public Stmt {
3838 friend class ASTReader;
3839 friend class ASTStmtReader;
3840
3841 bool IsCXXTry;
3842 SourceLocation TryLoc;
3843 Stmt *Children[2];
3844
3845 enum { TRY = 0, HANDLER = 1 };
3846
3847 SEHTryStmt(bool isCXXTry, // true if 'try' otherwise '__try'
3848 SourceLocation TryLoc,
3849 Stmt *TryBlock,
3850 Stmt *Handler);
3851
3852 explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) {}
3853
3854public:
3855 static SEHTryStmt* Create(const ASTContext &C, bool isCXXTry,
3856 SourceLocation TryLoc, Stmt *TryBlock,
3857 Stmt *Handler);
3858
3859 SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); }
3860
3861 SourceLocation getTryLoc() const { return TryLoc; }
3862 SourceLocation getEndLoc() const { return Children[HANDLER]->getEndLoc(); }
3863
3864 bool getIsCXXTry() const { return IsCXXTry; }
3865
3867 return cast<CompoundStmt>(Children[TRY]);
3868 }
3869
3870 Stmt *getHandler() const { return Children[HANDLER]; }
3871
3872 /// Returns 0 if not defined
3875
3877 return child_range(Children, Children+2);
3878 }
3879
3881 return const_child_range(Children, Children + 2);
3882 }
3883
3884 static bool classof(const Stmt *T) {
3885 return T->getStmtClass() == SEHTryStmtClass;
3886 }
3887};
3888
3889/// Represents a __leave statement.
3890class SEHLeaveStmt : public Stmt {
3891 SourceLocation LeaveLoc;
3892
3893public:
3895 : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {}
3896
3897 /// Build an empty __leave statement.
3898 explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) {}
3899
3900 SourceLocation getLeaveLoc() const { return LeaveLoc; }
3901 void setLeaveLoc(SourceLocation L) { LeaveLoc = L; }
3902
3903 SourceLocation getBeginLoc() const LLVM_READONLY { return LeaveLoc; }
3904 SourceLocation getEndLoc() const LLVM_READONLY { return LeaveLoc; }
3905
3906 static bool classof(const Stmt *T) {
3907 return T->getStmtClass() == SEHLeaveStmtClass;
3908 }
3909
3910 // Iterators
3914
3918};
3919
3920/// This captures a statement into a function. For example, the following
3921/// pragma annotated compound statement can be represented as a CapturedStmt,
3922/// and this compound statement is the body of an anonymous outlined function.
3923/// @code
3924/// #pragma omp parallel
3925/// {
3926/// compute();
3927/// }
3928/// @endcode
3929class CapturedStmt : public Stmt {
3930public:
3931 /// The different capture forms: by 'this', by reference, capture for
3932 /// variable-length array type etc.
3939
3940 /// Describes the capture of either a variable, or 'this', or
3941 /// variable-length array type.
3942 class Capture {
3943 llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind;
3944 SourceLocation Loc;
3945
3946 Capture() = default;
3947
3948 public:
3949 friend class ASTStmtReader;
3950 friend class CapturedStmt;
3951
3952 /// Create a new capture.
3953 ///
3954 /// \param Loc The source location associated with this capture.
3955 ///
3956 /// \param Kind The kind of capture (this, ByRef, ...).
3957 ///
3958 /// \param Var The variable being captured, or null if capturing this.
3960 VarDecl *Var = nullptr);
3961
3962 /// Determine the kind of capture.
3964
3965 /// Retrieve the source location at which the variable or 'this' was
3966 /// first used.
3967 SourceLocation getLocation() const { return Loc; }
3968
3969 /// Determine whether this capture handles the C++ 'this' pointer.
3970 bool capturesThis() const { return getCaptureKind() == VCK_This; }
3971
3972 /// Determine whether this capture handles a variable (by reference).
3973 bool capturesVariable() const { return getCaptureKind() == VCK_ByRef; }
3974
3975 /// Determine whether this capture handles a variable by copy.
3977 return getCaptureKind() == VCK_ByCopy;
3978 }
3979
3980 /// Determine whether this capture handles a variable-length array
3981 /// type.
3983 return getCaptureKind() == VCK_VLAType;
3984 }
3985
3986 /// Retrieve the declaration of the variable being captured.
3987 ///
3988 /// This operation is only valid if this capture captures a variable.
3989 VarDecl *getCapturedVar() const;
3990 };
3991
3992private:
3993 /// The number of variable captured, including 'this'.
3994 unsigned NumCaptures;
3995
3996 /// The pointer part is the implicit the outlined function and the
3997 /// int part is the captured region kind, 'CR_Default' etc.
3998 llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind;
3999
4000 /// The record for captured variables, a RecordDecl or CXXRecordDecl.
4001 RecordDecl *TheRecordDecl = nullptr;
4002
4003 /// Construct a captured statement.
4005 ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD);
4006
4007 /// Construct an empty captured statement.
4008 CapturedStmt(EmptyShell Empty, unsigned NumCaptures);
4009
4010 Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); }
4011
4012 Stmt *const *getStoredStmts() const {
4013 return reinterpret_cast<Stmt *const *>(this + 1);
4014 }
4015
4016 Capture *getStoredCaptures() const;
4017
4018 void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; }
4019
4020public:
4021 friend class ASTStmtReader;
4022
4023 static CapturedStmt *Create(const ASTContext &Context, Stmt *S,
4024 CapturedRegionKind Kind,
4025 ArrayRef<Capture> Captures,
4026 ArrayRef<Expr *> CaptureInits,
4027 CapturedDecl *CD, RecordDecl *RD);
4028
4029 static CapturedStmt *CreateDeserialized(const ASTContext &Context,
4030 unsigned NumCaptures);
4031
4032 /// Retrieve the statement being captured.
4033 Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; }
4034 const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; }
4035
4036 /// Retrieve the outlined function declaration.
4038 const CapturedDecl *getCapturedDecl() const;
4039
4040 /// Set the outlined function declaration.
4042
4043 /// Retrieve the captured region kind.
4045
4046 /// Set the captured region kind.
4048
4049 /// Retrieve the record declaration for captured variables.
4050 const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; }
4051
4052 /// Set the record declaration for captured variables.
4054 assert(D && "null RecordDecl");
4055 TheRecordDecl = D;
4056 }
4057
4058 /// True if this variable has been captured.
4059 bool capturesVariable(const VarDecl *Var) const;
4060
4061 /// An iterator that walks over the captures.
4064 using capture_range = llvm::iterator_range<capture_iterator>;
4065 using capture_const_range = llvm::iterator_range<const_capture_iterator>;
4066
4073
4074 /// Retrieve an iterator pointing to the first capture.
4075 capture_iterator capture_begin() { return getStoredCaptures(); }
4076 const_capture_iterator capture_begin() const { return getStoredCaptures(); }
4077
4078 /// Retrieve an iterator pointing past the end of the sequence of
4079 /// captures.
4081 return getStoredCaptures() + NumCaptures;
4082 }
4083
4084 /// Retrieve the number of captures, including 'this'.
4085 unsigned capture_size() const { return NumCaptures; }
4086
4087 /// Iterator that walks over the capture initialization arguments.
4089 using capture_init_range = llvm::iterator_range<capture_init_iterator>;
4090
4091 /// Const iterator that walks over the capture initialization
4092 /// arguments.
4095 llvm::iterator_range<const_capture_init_iterator>;
4096
4100
4104
4105 /// Retrieve the first initialization argument.
4107 return reinterpret_cast<Expr **>(getStoredStmts());
4108 }
4109
4111 return reinterpret_cast<Expr *const *>(getStoredStmts());
4112 }
4113
4114 /// Retrieve the iterator pointing one past the last initialization
4115 /// argument.
4117 return capture_init_begin() + NumCaptures;
4118 }
4119
4121 return capture_init_begin() + NumCaptures;
4122 }
4123
4124 SourceLocation getBeginLoc() const LLVM_READONLY {
4125 return getCapturedStmt()->getBeginLoc();
4126 }
4127
4128 SourceLocation getEndLoc() const LLVM_READONLY {
4129 return getCapturedStmt()->getEndLoc();
4130 }
4131
4132 SourceRange getSourceRange() const LLVM_READONLY {
4133 return getCapturedStmt()->getSourceRange();
4134 }
4135
4136 static bool classof(const Stmt *T) {
4137 return T->getStmtClass() == CapturedStmtClass;
4138 }
4139
4141
4143};
4144
4145} // namespace clang
4146
4147#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:144
#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:220
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:220
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4550
Stmt ** Exprs
Definition Stmt.h:3287
void setSimple(bool V)
Definition Stmt.h:3303
outputs_iterator begin_outputs()
Definition Stmt.h:3404
void setAsmLoc(SourceLocation L)
Definition Stmt.h:3300
const_outputs_iterator end_outputs() const
Definition Stmt.h:3420
std::string getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
Definition Stmt.cpp:510
SourceLocation AsmLoc
Definition Stmt.h:3273
bool isVolatile() const
Definition Stmt.h:3305
llvm::function_ref< void(const Stmt *, StringRef)> UnsupportedConstraintCallbackTy
Definition Stmt.h:3316
outputs_iterator end_outputs()
Definition Stmt.h:3408
const_inputs_iterator begin_inputs() const
Definition Stmt.h:3385
unsigned getNumPlusOperands() const
getNumPlusOperands - Return the number of output operands that have a "+" constraint.
Definition Stmt.cpp:536
std::string getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
Definition Stmt.cpp:494
AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, unsigned numoutputs, unsigned numinputs, unsigned numclobbers)
Definition Stmt.h:3289
void setVolatile(bool V)
Definition Stmt.h:3306
static bool classof(const Stmt *T)
Definition Stmt.h:3363
outputs_range outputs()
Definition Stmt.h:3412
inputs_const_range inputs() const
Definition Stmt.h:3393
SourceLocation getAsmLoc() const
Definition Stmt.h:3299
const Expr * getInputExpr(unsigned i) const
Definition Stmt.cpp:518
unsigned NumInputs
Definition Stmt.h:3284
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:3309
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:454
inputs_range inputs()
Definition Stmt.h:3383
llvm::iterator_range< inputs_iterator > inputs_range
Definition Stmt.h:3372
bool isOutputPlusConstraint(unsigned i) const
isOutputPlusConstraint - Return true if the specified output constraint is a "+" constraint (which is...
Definition Stmt.h:3338
unsigned getNumClobbers() const
Definition Stmt.h:3360
ExprIterator outputs_iterator
Definition Stmt.h:3399
const_inputs_iterator end_inputs() const
Definition Stmt.h:3389
llvm::iterator_range< const_inputs_iterator > inputs_const_range
Definition Stmt.h:3373
const_child_range children() const
Definition Stmt.h:3432
ExprIterator inputs_iterator
Definition Stmt.h:3370
bool IsSimple
True if the assembly statement does not have any input or output operands.
Definition Stmt.h:3277
const Expr * getOutputExpr(unsigned i) const
Definition Stmt.cpp:502
outputs_const_range outputs() const
Definition Stmt.h:3424
inputs_iterator end_inputs()
Definition Stmt.h:3379
unsigned getNumOutputs() const
Definition Stmt.h:3328
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3308
inputs_iterator begin_inputs()
Definition Stmt.h:3375
AsmStmt(StmtClass SC, EmptyShell Empty)
Build an empty inline-assembly statement.
Definition Stmt.h:3297
unsigned NumOutputs
Definition Stmt.h:3283
child_range children()
Definition Stmt.h:3428
ConstExprIterator const_outputs_iterator
Definition Stmt.h:3400
ConstExprIterator const_inputs_iterator
Definition Stmt.h:3371
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition Stmt.cpp:486
unsigned NumClobbers
Definition Stmt.h:3285
bool IsVolatile
If true, treat this inline assembly as having side effects.
Definition Stmt.h:3281
friend class ASTStmtReader
Definition Stmt.h:3271
unsigned getNumInputs() const
Definition Stmt.h:3350
bool isSimple() const
Definition Stmt.h:3302
llvm::iterator_range< outputs_iterator > outputs_range
Definition Stmt.h:3401
const_outputs_iterator begin_outputs() const
Definition Stmt.h:3416
std::string getClobber(unsigned i) const
Definition Stmt.cpp:526
llvm::iterator_range< const_outputs_iterator > outputs_const_range
Definition Stmt.h:3402
Attr - This represents one attribute.
Definition Attr.h:46
Represents an attribute applied to a statement.
Definition Stmt.h:2195
static AttributedStmt * CreateEmpty(const ASTContext &C, unsigned NumAttrs)
Definition Stmt.cpp:445
Stmt * getSubStmt()
Definition Stmt.h:2231
const Stmt * getSubStmt() const
Definition Stmt.h:2232
SourceLocation getAttrLoc() const
Definition Stmt.h:2226
ArrayRef< const Attr * > getAttrs() const
Definition Stmt.h:2227
child_range children()
Definition Stmt.h:2237
const_child_range children() const
Definition Stmt.h:2239
friend class ASTStmtReader
Definition Stmt.h:2196
static bool classof(const Stmt *T)
Definition Stmt.h:2243
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2235
SourceLocation getBeginLoc() const
Definition Stmt.h:2234
BreakStmt(SourceLocation BL)
Definition Stmt.h:3129
static bool classof(const Stmt *T)
Definition Stmt.h:3137
BreakStmt(EmptyShell Empty)
Build an empty break statement.
Definition Stmt.h:3134
BreakStmt(SourceLocation CL, SourceLocation LabelLoc, LabelDecl *Target)
Definition Stmt.h:3130
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:4943
Describes the capture of either a variable, or 'this', or variable-length array type.
Definition Stmt.h:3942
bool capturesVariableByCopy() const
Determine whether this capture handles a variable by copy.
Definition Stmt.h:3976
VariableCaptureKind getCaptureKind() const
Determine the kind of capture.
Definition Stmt.cpp:1382
VarDecl * getCapturedVar() const
Retrieve the declaration of the variable being captured.
Definition Stmt.cpp:1386
bool capturesVariableArrayType() const
Determine whether this capture handles a variable-length array type.
Definition Stmt.h:3982
friend class CapturedStmt
Definition Stmt.h:3950
bool capturesThis() const
Determine whether this capture handles the C++ 'this' pointer.
Definition Stmt.h:3970
bool capturesVariable() const
Determine whether this capture handles a variable (by reference).
Definition Stmt.h:3973
SourceLocation getLocation() const
Retrieve the source location at which the variable or 'this' was first used.
Definition Stmt.h:3967
friend class ASTStmtReader
Definition Stmt.h:3949
This captures a statement into a function.
Definition Stmt.h:3929
unsigned capture_size() const
Retrieve the number of captures, including 'this'.
Definition Stmt.h:4085
const_capture_iterator capture_begin() const
Definition Stmt.h:4076
static CapturedStmt * CreateDeserialized(const ASTContext &Context, unsigned NumCaptures)
Definition Stmt.cpp:1466
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:4128
capture_init_range capture_inits()
Definition Stmt.h:4097
Expr ** capture_init_iterator
Iterator that walks over the capture initialization arguments.
Definition Stmt.h:4088
void setCapturedRegionKind(CapturedRegionKind Kind)
Set the captured region kind.
Definition Stmt.cpp:1508
const_capture_init_iterator capture_init_begin() const
Definition Stmt.h:4110
const Capture * const_capture_iterator
Definition Stmt.h:4063
CapturedDecl * getCapturedDecl()
Retrieve the outlined function declaration.
Definition Stmt.cpp:1488
SourceRange getSourceRange() const LLVM_READONLY
Definition Stmt.h:4132
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of captures.
Definition Stmt.h:4080
child_range children()
Definition Stmt.cpp:1479
const RecordDecl * getCapturedRecordDecl() const
Retrieve the record declaration for captured variables.
Definition Stmt.h:4050
llvm::iterator_range< const_capture_init_iterator > const_capture_init_range
Definition Stmt.h:4094
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition Stmt.h:4033
llvm::iterator_range< capture_init_iterator > capture_init_range
Definition Stmt.h:4089
Capture * capture_iterator
An iterator that walks over the captures.
Definition Stmt.h:4062
llvm::iterator_range< capture_iterator > capture_range
Definition Stmt.h:4064
bool capturesVariable(const VarDecl *Var) const
True if this variable has been captured.
Definition Stmt.cpp:1512
static bool classof(const Stmt *T)
Definition Stmt.h:4136
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument.
Definition Stmt.h:4106
void setCapturedDecl(CapturedDecl *D)
Set the outlined function declaration.
Definition Stmt.cpp:1497
capture_iterator capture_begin()
Retrieve an iterator pointing to the first capture.
Definition Stmt.h:4075
const_capture_init_iterator capture_init_end() const
Definition Stmt.h:4120
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:4124
void setCapturedRecordDecl(RecordDecl *D)
Set the record declaration for captured variables.
Definition Stmt.h:4053
friend class ASTStmtReader
Definition Stmt.h:4021
llvm::iterator_range< const_capture_iterator > capture_const_range
Definition Stmt.h:4065
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument.
Definition Stmt.h:4116
capture_range captures()
Definition Stmt.h:4067
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
Definition Stmt.h:4093
const Stmt * getCapturedStmt() const
Definition Stmt.h:4034
capture_const_range captures() const
Definition Stmt.h:4070
CapturedRegionKind getCapturedRegionKind() const
Retrieve the captured region kind.
Definition Stmt.cpp:1503
VariableCaptureKind
The different capture forms: by 'this', by reference, capture for variable-length array type etc.
Definition Stmt.h:3933
const_capture_init_range capture_inits() const
Definition Stmt.h:4101
Stmt * getSubStmt()
Definition Stmt.h:2025
const Expr * getRHS() const
Definition Stmt.h:2013
Expr * getLHS()
Definition Stmt.h:1995
const_child_range children() const
Definition Stmt.h:2055
SourceLocation getBeginLoc() const
Definition Stmt.h:2034
void setEllipsisLoc(SourceLocation L)
Set the location of the ... in a case statement of the form LHS ... RHS.
Definition Stmt.h:1988
static bool classof(const Stmt *T)
Definition Stmt.h:2044
bool caseStmtIsGNURange() const
True if this case statement is of the form case LHS ... RHS, which is a GNU extension.
Definition Stmt.h:1975
const Expr * getLHS() const
Definition Stmt.h:1999
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
Definition Stmt.h:1981
void setCaseLoc(SourceLocation L)
Definition Stmt.h:1978
child_range children()
Definition Stmt.h:2049
SourceLocation getCaseLoc() const
Definition Stmt.h:1977
static CaseStmt * CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange)
Build an empty case statement.
Definition Stmt.cpp:1312
void setLHS(Expr *Val)
Definition Stmt.h:2003
void setSubStmt(Stmt *S)
Definition Stmt.h:2030
const Stmt * getSubStmt() const
Definition Stmt.h:2026
Expr * getRHS()
Definition Stmt.h:2007
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2035
void setRHS(Expr *Val)
Definition Stmt.h:2019
Represents a character-granular source range.
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1732
Stmt * body_front()
Definition Stmt.h:1798
static bool classof(const Stmt *T)
Definition Stmt.h:1852
bool body_empty() const
Definition Stmt.h:1776
unsigned size() const
Definition Stmt.h:1777
body_const_range body() const
Definition Stmt.h:1807
Stmt *const * const_body_iterator
Definition Stmt.h:1804
const_reverse_body_iterator body_rend() const
Definition Stmt.h:1842
llvm::iterator_range< const_body_iterator > body_const_range
Definition Stmt.h:1805
std::reverse_iterator< body_iterator > reverse_body_iterator
Definition Stmt.h:1825
reverse_body_iterator body_rbegin()
Definition Stmt.h:1827
llvm::iterator_range< body_iterator > body_range
Definition Stmt.h:1793
std::reverse_iterator< const_body_iterator > const_reverse_body_iterator
Definition Stmt.h:1835
body_iterator body_end()
Definition Stmt.h:1797
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
Definition Stmt.h:1782
const Stmt * body_front() const
Definition Stmt.h:1817
body_range body()
Definition Stmt.h:1795
SourceLocation getBeginLoc() const
Definition Stmt.h:1846
static CompoundStmt * CreateEmpty(const ASTContext &C, unsigned NumStmts, bool HasFPFeatures)
Definition Stmt.cpp:404
SourceLocation getLBracLoc() const
Definition Stmt.h:1849
body_iterator body_begin()
Definition Stmt.h:1796
SourceLocation getEndLoc() const
Definition Stmt.h:1847
bool hasStoredFPFeatures() const
Definition Stmt.h:1779
const_child_range children() const
Definition Stmt.h:1859
CompoundStmt(SourceLocation Loc, SourceLocation EndLoc)
Definition Stmt.h:1766
reverse_body_iterator body_rend()
Definition Stmt.h:1831
CompoundStmt(SourceLocation Loc)
Definition Stmt.h:1764
const_body_iterator body_begin() const
Definition Stmt.h:1811
Stmt ** body_iterator
Definition Stmt.h:1792
const Stmt * body_back() const
Definition Stmt.h:1821
friend class ASTStmtReader
Definition Stmt.h:1733
const_reverse_body_iterator body_rbegin() const
Definition Stmt.h:1838
child_range children()
Definition Stmt.h:1857
Stmt * body_back()
Definition Stmt.h:1800
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
Definition Stmt.h:1788
SourceLocation getRBracLoc() const
Definition Stmt.h:1850
const_body_iterator body_end() const
Definition Stmt.h:1815
ContinueStmt(EmptyShell Empty)
Build an empty continue statement.
Definition Stmt.h:3118
ContinueStmt(SourceLocation CL)
Definition Stmt.h:3113
static bool classof(const Stmt *T)
Definition Stmt.h:3121
ContinueStmt(SourceLocation CL, SourceLocation LabelLoc, LabelDecl *Target)
Definition Stmt.h:3114
Decl *const * const_iterator
Definition DeclGroup.h:73
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1623
std::reverse_iterator< decl_iterator > reverse_decl_iterator
Definition Stmt.h:1682
llvm::iterator_range< decl_iterator > decl_range
Definition Stmt.h:1668
child_range children()
Definition Stmt.h:1656
const_child_range children() const
Definition Stmt.h:1661
Decl * getSingleDecl()
Definition Stmt.h:1639
SourceLocation getEndLoc() const
Definition Stmt.h:1646
const DeclGroupRef getDeclGroup() const
Definition Stmt.h:1641
DeclStmt(EmptyShell Empty)
Build an empty declaration statement.
Definition Stmt.h:1632
bool isSingleDecl() const
isSingleDecl - This method returns true if this DeclStmt refers to a single Decl.
Definition Stmt.h:1636
decl_iterator decl_end()
Definition Stmt.h:1678
const_decl_iterator decl_begin() const
Definition Stmt.h:1679
void setStartLoc(SourceLocation L)
Definition Stmt.h:1645
DeclGroupRef::const_iterator const_decl_iterator
Definition Stmt.h:1667
static bool classof(const Stmt *T)
Definition Stmt.h:1651
void setEndLoc(SourceLocation L)
Definition Stmt.h:1647
decl_iterator decl_begin()
Definition Stmt.h:1677
decl_range decls()
Definition Stmt.h:1671
void setDeclGroup(DeclGroupRef DGR)
Definition Stmt.h:1643
const Decl * getSingleDecl() const
Definition Stmt.h:1638
decl_const_range decls() const
Definition Stmt.h:1673
const_decl_iterator decl_end() const
Definition Stmt.h:1680
DeclGroupRef::iterator decl_iterator
Definition Stmt.h:1666
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:1649
DeclGroupRef getDeclGroup()
Definition Stmt.h:1642
reverse_decl_iterator decl_rend()
Definition Stmt.h:1688
llvm::iterator_range< const_decl_iterator > decl_const_range
Definition Stmt.h:1669
reverse_decl_iterator decl_rbegin()
Definition Stmt.h:1684
DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc)
Definition Stmt.h:1628
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
void setSubStmt(Stmt *S)
Definition Stmt.h:2075
const Stmt * getSubStmt() const
Definition Stmt.h:2074
child_range children()
Definition Stmt.h:2090
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2081
void setDefaultLoc(SourceLocation L)
Definition Stmt.h:2078
SourceLocation getDefaultLoc() const
Definition Stmt.h:2077
DefaultStmt(EmptyShell Empty)
Build an empty default statement.
Definition Stmt.h:2070
static bool classof(const Stmt *T)
Definition Stmt.h:2085
DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt)
Definition Stmt.h:2066
const_child_range children() const
Definition Stmt.h:2092
SourceLocation getBeginLoc() const
Definition Stmt.h:2080
Stmt * getSubStmt()
Definition Stmt.h:2073
const Stmt * getBody() const
Definition Stmt.h:3248
SourceLocation getEndLoc() const
Definition Stmt.h:3255
void setBody(Stmt *S)
Definition Stmt.h:3249
SourceLocation getBeginLoc() const
Definition Stmt.h:3254
void setDeferLoc(SourceLocation DeferLoc)
Definition Stmt.h:3243
Stmt * getBody()
Definition Stmt.h:3247
const_child_range children() const
Definition Stmt.h:3259
SourceLocation getDeferLoc() const
Definition Stmt.h:3242
static bool classof(const Stmt *S)
Definition Stmt.h:3263
static DeferStmt * CreateEmpty(ASTContext &Context, EmptyShell Empty)
Definition Stmt.cpp:1543
friend class ASTStmtReader
Definition Stmt.h:3229
child_range children()
Definition Stmt.h:3257
void setWhileLoc(SourceLocation L)
Definition Stmt.h:2856
SourceLocation getBeginLoc() const
Definition Stmt.h:2860
Stmt * getBody()
Definition Stmt.h:2849
Expr * getCond()
Definition Stmt.h:2842
void setDoLoc(SourceLocation L)
Definition Stmt.h:2854
SourceLocation getEndLoc() const
Definition Stmt.h:2861
SourceLocation getWhileLoc() const
Definition Stmt.h:2855
static bool classof(const Stmt *T)
Definition Stmt.h:2863
const_child_range children() const
Definition Stmt.h:2872
DoStmt(EmptyShell Empty)
Build an empty do-while statement.
Definition Stmt.h:2840
SourceLocation getDoLoc() const
Definition Stmt.h:2853
void setRParenLoc(SourceLocation L)
Definition Stmt.h:2858
SourceLocation getRParenLoc() const
Definition Stmt.h:2857
const Stmt * getBody() const
Definition Stmt.h:2850
child_range children()
Definition Stmt.h:2868
void setBody(Stmt *Body)
Definition Stmt.h:2851
DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL, SourceLocation RP)
Definition Stmt.h:2831
const Expr * getCond() const
Definition Stmt.h:2843
void setCond(Expr *Cond)
Definition Stmt.h:2847
This represents one expression.
Definition Expr.h:112
Represents difference between two FPOptions values.
Stmt * getInit()
Definition Stmt.h:2895
ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, SourceLocation RP)
Definition Stmt.cpp:1102
child_range children()
Definition Stmt.h:2951
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition Stmt.cpp:1115
SourceLocation getEndLoc() const
Definition Stmt.h:2944
void setBody(Stmt *S)
Definition Stmt.h:2934
SourceLocation getRParenLoc() const
Definition Stmt.h:2940
const_child_range children() const
Definition Stmt.h:2955
void setCond(Expr *E)
Definition Stmt.h:2932
const DeclStmt * getConditionVariableDeclStmt() const
Definition Stmt.h:2914
void setForLoc(SourceLocation L)
Definition Stmt.h:2937
Stmt * getBody()
Definition Stmt.h:2924
const Expr * getInc() const
Definition Stmt.h:2928
ForStmt(EmptyShell Empty)
Build an empty for statement.
Definition Stmt.h:2893
void setInc(Expr *E)
Definition Stmt.h:2933
void setLParenLoc(SourceLocation L)
Definition Stmt.h:2939
Expr * getInc()
Definition Stmt.h:2923
const Expr * getCond() const
Definition Stmt.h:2927
void setInit(Stmt *S)
Definition Stmt.h:2931
void setConditionVariableDeclStmt(DeclStmt *CondVar)
Definition Stmt.h:2918
SourceLocation getBeginLoc() const
Definition Stmt.h:2943
static bool classof(const Stmt *T)
Definition Stmt.h:2946
const Stmt * getInit() const
Definition Stmt.h:2926
void setConditionVariable(const ASTContext &C, VarDecl *V)
Definition Stmt.cpp:1123
SourceLocation getForLoc() const
Definition Stmt.h:2936
friend class ASTStmtReader
Definition Stmt.h:2881
const Stmt * getBody() const
Definition Stmt.h:2929
Expr * getCond()
Definition Stmt.h:2922
SourceLocation getLParenLoc() const
Definition Stmt.h:2938
DeclStmt * getConditionVariableDeclStmt()
If this ForStmt has a condition variable, return the faux DeclStmt associated with the creation of th...
Definition Stmt.h:2910
void setRParenLoc(SourceLocation L)
Definition Stmt.h:2941
AsmStringPiece(const std::string &S)
Definition Stmt.h:3490
const std::string & getString() const
Definition Stmt.h:3499
unsigned getOperandNo() const
Definition Stmt.h:3501
CharSourceRange getRange() const
Definition Stmt.h:3506
AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin, SourceLocation End)
Definition Stmt.h:3491
char getModifier() const
getModifier - Get the modifier for this operand, if present.
Definition Stmt.cpp:544
const Expr * getInputExpr(unsigned i) const
Definition Stmt.h:3576
const_labels_iterator end_labels() const
Definition Stmt.h:3619
std::string getOutputConstraint(unsigned i) const
getOutputConstraint - Return the constraint string for the specified output operand.
Definition Stmt.cpp:584
unsigned getNumLabels() const
Definition Stmt.h:3588
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition Stmt.cpp:867
labels_range labels()
Definition Stmt.h:3611
SourceLocation getRParenLoc() const
Definition Stmt.h:3460
std::string getAsmString() const
Definition Stmt.cpp:569
labels_const_range labels() const
Definition Stmt.h:3623
llvm::iterator_range< labels_iterator > labels_range
Definition Stmt.h:3600
Expr * getInputConstraintExpr(unsigned i)
Definition Stmt.h:3569
void setAsmStringExpr(Expr *E)
Definition Stmt.h:3467
labels_iterator begin_labels()
Definition Stmt.h:3603
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition Stmt.h:3553
bool isAsmGoto() const
Definition Stmt.h:3584
ConstCastIterator< AddrLabelExpr > const_labels_iterator
Definition Stmt.h:3599
CastIterator< AddrLabelExpr > labels_iterator
Definition Stmt.h:3598
const Expr * getClobberExpr(unsigned i) const
Definition Stmt.h:3646
std::string getInputConstraint(unsigned i) const
getInputConstraint - Return the specified input constraint.
Definition Stmt.cpp:606
labels_iterator end_labels()
Definition Stmt.h:3607
const Expr * getOutputConstraintExpr(unsigned i) const
Definition Stmt.h:3540
StringRef getLabelName(unsigned i) const
Definition Stmt.cpp:600
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:665
void setRParenLoc(SourceLocation L)
Definition Stmt.h:3461
void setInputExpr(unsigned i, Expr *E)
Definition Stmt.cpp:592
Expr * getAsmStringExpr()
Definition Stmt.h:3466
std::string getClobber(unsigned i) const
Definition Stmt.cpp:573
static bool classof(const Stmt *T)
Definition Stmt.h:3651
StringRef getInputName(unsigned i) const
Definition Stmt.h:3557
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:3649
StringRef getOutputName(unsigned i) const
Definition Stmt.h:3531
const_labels_iterator begin_labels() const
Definition Stmt.h:3615
GCCAsmStmt(EmptyShell Empty)
Build an empty inline-assembly statement.
Definition Stmt.h:3458
IdentifierInfo * getLabelIdentifier(unsigned i) const
Definition Stmt.h:3592
const Expr * getInputConstraintExpr(unsigned i) const
Definition Stmt.h:3566
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition Stmt.h:3529
const Expr * getAsmStringExpr() const
Definition Stmt.h:3465
Expr * getOutputExpr(unsigned i)
Definition Stmt.cpp:577
llvm::iterator_range< const_labels_iterator > labels_const_range
Definition Stmt.h:3601
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:930
Expr * getOutputConstraintExpr(unsigned i)
Definition Stmt.h:3543
Expr * getClobberExpr(unsigned i)
Definition Stmt.h:3645
int getNamedOperand(StringRef SymbolicName) const
getNamedOperand - Given a symbolic operand reference like %[foo], translate this into a numeric value...
Definition Stmt.cpp:642
friend class ASTStmtReader
Definition Stmt.h:3439
const Expr * getOutputExpr(unsigned i) const
Definition Stmt.h:3547
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3648
Expr * getInputExpr(unsigned i)
Definition Stmt.cpp:588
AddrLabelExpr * getLabelExpr(unsigned i) const
Definition Stmt.cpp:596
static std::string ExtractStringFromGCCAsmStmtComponent(const Expr *E)
Definition Stmt.cpp:549
GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL)
Definition Stmt.h:2966
SourceLocation getLabelLoc() const
Definition Stmt.h:2979
SourceLocation getGotoLoc() const
Definition Stmt.h:2977
child_range children()
Definition Stmt.h:2990
void setLabel(LabelDecl *D)
Definition Stmt.h:2975
GotoStmt(EmptyShell Empty)
Build an empty goto statement.
Definition Stmt.h:2972
void setLabelLoc(SourceLocation L)
Definition Stmt.h:2980
LabelDecl * getLabel() const
Definition Stmt.h:2974
SourceLocation getEndLoc() const
Definition Stmt.h:2983
const_child_range children() const
Definition Stmt.h:2994
static bool classof(const Stmt *T)
Definition Stmt.h:2985
void setGotoLoc(SourceLocation L)
Definition Stmt.h:2978
SourceLocation getBeginLoc() const
Definition Stmt.h:2982
One of these records is kept for each identifier that is lexed.
Stmt * getThen()
Definition Stmt.h:2340
bool hasElseStorage() const
True if this IfStmt has storage for an else statement.
Definition Stmt.h:2326
const Stmt * getElse() const
Definition Stmt.h:2354
void setThen(Stmt *Then)
Definition Stmt.h:2345
void setConditionVariableDeclStmt(DeclStmt *CondVar)
Definition Stmt.h:2396
void setCond(Expr *Cond)
Definition Stmt.h:2336
void setLParenLoc(SourceLocation Loc)
Definition Stmt.h:2470
SourceLocation getIfLoc() const
Definition Stmt.h:2417
void setConditionVariable(const ASTContext &Ctx, VarDecl *V)
Set the condition variable for this if statement.
Definition Stmt.cpp:1070
bool hasVarStorage() const
True if this IfStmt has storage for a variable declaration.
Definition Stmt.h:2323
const DeclStmt * getConditionVariableDeclStmt() const
Definition Stmt.h:2390
IfStatementKind getStatementKind() const
Definition Stmt.h:2452
SourceLocation getElseLoc() const
Definition Stmt.h:2420
Stmt * getInit()
Definition Stmt.h:2401
bool isNonNegatedConsteval() const
Definition Stmt.h:2436
SourceLocation getLParenLoc() const
Definition Stmt.h:2469
static bool classof(const Stmt *T)
Definition Stmt.h:2494
void setElse(Stmt *Else)
Definition Stmt.h:2359
Expr * getCond()
Definition Stmt.h:2328
const Stmt * getThen() const
Definition Stmt.h:2341
bool isConstexpr() const
Definition Stmt.h:2444
const Expr * getCond() const
Definition Stmt.h:2332
const VarDecl * getConditionVariable() const
Definition Stmt.h:2374
void setElseLoc(SourceLocation ElseLoc)
Definition Stmt.h:2425
const Stmt * getInit() const
Definition Stmt.h:2406
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:1054
bool hasInitStorage() const
True if this IfStmt has the storage for an init statement.
Definition Stmt.h:2320
void setStatementKind(IfStatementKind Kind)
Definition Stmt.h:2448
std::optional< const Stmt * > getNondiscardedCase(const ASTContext &Ctx) const
If this is an 'if constexpr', determine which substatement will be taken.
Definition Stmt.cpp:1095
bool isObjCAvailabilityCheck() const
Definition Stmt.cpp:1084
child_range children()
Definition Stmt.h:2476
bool isNegatedConsteval() const
Definition Stmt.h:2440
Stmt * getElse()
Definition Stmt.h:2349
DeclStmt * getConditionVariableDeclStmt()
If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of tha...
Definition Stmt.h:2384
const_child_range children() const
Definition Stmt.h:2485
SourceLocation getRParenLoc() const
Definition Stmt.h:2471
void setRParenLoc(SourceLocation Loc)
Definition Stmt.h:2472
SourceLocation getBeginLoc() const
Definition Stmt.h:2463
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2464
bool isConsteval() const
Definition Stmt.h:2431
void setIfLoc(SourceLocation IfLoc)
Definition Stmt.h:2418
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
Definition Stmt.cpp:1063
void setInit(Stmt *Init)
Definition Stmt.h:2411
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:3034
static bool classof(const Stmt *T)
Definition Stmt.h:3036
LabelDecl * getConstantTarget()
getConstantTarget - Returns the fixed target of this indirect goto, if one exists.
Definition Stmt.cpp:1264
IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target)
Definition Stmt.h:3005
void setTarget(Expr *E)
Definition Stmt.h:3024
SourceLocation getGotoLoc() const
Definition Stmt.h:3016
SourceLocation getBeginLoc() const
Definition Stmt.h:3033
child_range children()
Definition Stmt.h:3041
void setGotoLoc(SourceLocation L)
Definition Stmt.h:3015
const_child_range children() const
Definition Stmt.h:3043
const LabelDecl * getConstantTarget() const
Definition Stmt.h:3029
void setStarLoc(SourceLocation L)
Definition Stmt.h:3017
IndirectGotoStmt(EmptyShell Empty)
Build an empty indirect goto statement.
Definition Stmt.h:3012
const Expr * getTarget() const
Definition Stmt.h:3021
SourceLocation getStarLoc() const
Definition Stmt.h:3018
Represents the declaration of a label.
Definition Decl.h:524
Stmt * getInnermostLabeledStmt()
Definition Stmt.h:2171
LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt)
Build a label statement.
Definition Stmt.h:2145
static bool classof(const Stmt *T)
Definition Stmt.h:2182
LabelDecl * getDecl() const
Definition Stmt.h:2156
LabelStmt(EmptyShell Empty)
Build an empty label statement.
Definition Stmt.h:2151
bool isSideEntry() const
Definition Stmt.h:2185
Stmt * getSubStmt()
Definition Stmt.h:2160
SourceLocation getIdentLoc() const
Definition Stmt.h:2153
void setSubStmt(Stmt *SS)
Definition Stmt.h:2163
void setDecl(LabelDecl *D)
Definition Stmt.h:2157
SourceLocation getBeginLoc() const
Definition Stmt.h:2165
void setIdentLoc(SourceLocation L)
Definition Stmt.h:2154
const_child_range children() const
Definition Stmt.h:2178
const Stmt * getInnermostLabeledStmt() const
Look through nested labels and return the first non-label statement; e.g.
Definition Stmt.cpp:1523
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2166
child_range children()
Definition Stmt.h:2176
void setSideEntry(bool SE)
Definition Stmt.h:2186
const char * getName() const
Definition Stmt.cpp:432
const Stmt * getSubStmt() const
Definition Stmt.h:2162
SourceLocation getBeginLoc() const
Definition Stmt.h:3077
LoopControlStmt(StmtClass Class, SourceLocation Loc)
Definition Stmt.h:3068
LoopControlStmt(StmtClass Class, EmptyShell ES)
Definition Stmt.h:3071
void setLabelDecl(LabelDecl *S)
Definition Stmt.h:3089
LoopControlStmt(StmtClass Class, SourceLocation Loc, SourceLocation LabelLoc, LabelDecl *Target)
Definition Stmt.h:3062
static bool classof(const Stmt *T)
Definition Stmt.h:3104
SourceLocation getLabelLoc() const
Definition Stmt.h:3084
LabelDecl * getLabelDecl()
Definition Stmt.h:3087
const LabelDecl * getLabelDecl() const
Definition Stmt.h:3088
void setLabelLoc(SourceLocation L)
Definition Stmt.h:3085
const_child_range children() const
Definition Stmt.h:3100
SourceLocation getKwLoc() const
Definition Stmt.h:3074
child_range children()
Definition Stmt.h:3096
void setKwLoc(SourceLocation L)
Definition Stmt.h:3075
const Stmt * getNamedLoopOrSwitch() const
If this is a named break/continue, get the loop or switch statement that this targets.
Definition Stmt.cpp:1530
bool hasLabelTarget() const
Definition Stmt.h:3082
SourceLocation getEndLoc() const
Definition Stmt.h:3078
Token * getAsmToks()
Definition Stmt.h:3688
const Expr * getOutputExpr(unsigned i) const
Definition Stmt.h:3705
Expr * getOutputExpr(unsigned i)
Definition Stmt.cpp:914
ArrayRef< StringRef > getClobbers() const
Definition Stmt.h:3729
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3743
StringRef getAsmString() const
Definition Stmt.h:3691
child_range children()
Definition Stmt.h:3749
SourceLocation getLBraceLoc() const
Definition Stmt.h:3680
bool hasBraces() const
Definition Stmt.h:3685
SourceLocation getEndLoc() const
Definition Stmt.h:3682
StringRef getInputConstraint(unsigned i) const
Definition Stmt.h:3711
void setEndLoc(SourceLocation L)
Definition Stmt.h:3683
void setInputExpr(unsigned i, Expr *E)
Definition Stmt.cpp:922
StringRef getOutputConstraint(unsigned i) const
Definition Stmt.h:3698
ArrayRef< StringRef > getAllConstraints() const
Definition Stmt.h:3725
static bool classof(const Stmt *T)
Definition Stmt.h:3745
friend class ASTStmtReader
Definition Stmt.h:3658
StringRef getClobber(unsigned i) const
Definition Stmt.h:3735
const Expr * getInputExpr(unsigned i) const
Definition Stmt.h:3719
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:955
unsigned getNumAsmToks()
Definition Stmt.h:3687
void setLBraceLoc(SourceLocation L)
Definition Stmt.h:3681
MSAsmStmt(EmptyShell Empty)
Build an empty MS-style inline-assembly statement.
Definition Stmt.h:3678
std::string generateAsmString(const ASTContext &C) const
Assemble final IR asm string.
Definition Stmt.cpp:888
const_child_range children() const
Definition Stmt.h:3753
ArrayRef< Expr * > getAllExprs() const
Definition Stmt.h:3731
Expr * getInputExpr(unsigned i)
Definition Stmt.cpp:918
void setSemiLoc(SourceLocation L)
Definition Stmt.h:1707
bool hasLeadingEmptyMacro() const
Definition Stmt.h:1709
SourceLocation getBeginLoc() const
Definition Stmt.h:1713
child_range children()
Definition Stmt.h:1720
SourceLocation getSemiLoc() const
Definition Stmt.h:1706
static bool classof(const Stmt *T)
Definition Stmt.h:1716
NullStmt(SourceLocation L, bool hasLeadingEmptyMacro=false)
Definition Stmt.h:1697
NullStmt(EmptyShell Empty)
Build an empty null statement.
Definition Stmt.h:1704
const_child_range children() const
Definition Stmt.h:1724
SourceLocation getEndLoc() const
Definition Stmt.h:1714
Represents a struct/union/class.
Definition Decl.h:4324
void setRetValue(Expr *E)
Definition Stmt.h:3181
void setReturnLoc(SourceLocation L)
Definition Stmt.h:3202
SourceLocation getReturnLoc() const
Definition Stmt.h:3201
static bool classof(const Stmt *T)
Definition Stmt.h:3209
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:3205
void setNRVOCandidate(const VarDecl *Var)
Set the variable that might be used for the named return value optimization.
Definition Stmt.h:3195
SourceLocation getBeginLoc() const
Definition Stmt.h:3204
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
Definition Stmt.h:3188
const_child_range children() const
Definition Stmt.h:3220
Expr * getRetValue()
Definition Stmt.h:3179
static ReturnStmt * CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate)
Create an empty return statement, optionally with storage for an NRVO candidate.
Definition Stmt.cpp:1293
child_range children()
Definition Stmt.h:3214
const Expr * getRetValue() const
Definition Stmt.h:3180
const_child_range children() const
Definition Stmt.h:3793
child_range children()
Definition Stmt.h:3789
CompoundStmt * getBlock() const
Definition Stmt.h:3785
friend class ASTReader
Definition Stmt.h:3759
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3776
SourceLocation getExceptLoc() const
Definition Stmt.h:3778
friend class ASTStmtReader
Definition Stmt.h:3760
SourceLocation getEndLoc() const
Definition Stmt.h:3779
static bool classof(const Stmt *T)
Definition Stmt.h:3797
Expr * getFilterExpr() const
Definition Stmt.h:3781
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3817
SourceLocation getEndLoc() const
Definition Stmt.h:3820
const_child_range children() const
Definition Stmt.h:3828
child_range children()
Definition Stmt.h:3824
friend class ASTReader
Definition Stmt.h:3803
SourceLocation getFinallyLoc() const
Definition Stmt.h:3819
static bool classof(const Stmt *T)
Definition Stmt.h:3832
friend class ASTStmtReader
Definition Stmt.h:3804
CompoundStmt * getBlock() const
Definition Stmt.h:3822
SourceLocation getLeaveLoc() const
Definition Stmt.h:3900
child_range children()
Definition Stmt.h:3911
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:3904
SEHLeaveStmt(EmptyShell Empty)
Build an empty __leave statement.
Definition Stmt.h:3898
SEHLeaveStmt(SourceLocation LL)
Definition Stmt.h:3894
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3903
static bool classof(const Stmt *T)
Definition Stmt.h:3906
void setLeaveLoc(SourceLocation L)
Definition Stmt.h:3901
const_child_range children() const
Definition Stmt.h:3915
child_range children()
Definition Stmt.h:3876
const_child_range children() const
Definition Stmt.h:3880
CompoundStmt * getTryBlock() const
Definition Stmt.h:3866
static bool classof(const Stmt *T)
Definition Stmt.h:3884
SourceLocation getTryLoc() const
Definition Stmt.h:3861
bool getIsCXXTry() const
Definition Stmt.h:3864
SEHFinallyStmt * getFinallyHandler() const
Definition Stmt.cpp:1338
friend class ASTReader
Definition Stmt.h:3838
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.h:3859
friend class ASTStmtReader
Definition Stmt.h:3839
SourceLocation getEndLoc() const
Definition Stmt.h:3862
SEHExceptStmt * getExceptHandler() const
Returns 0 if not defined.
Definition Stmt.cpp:1334
Stmt * getHandler() const
Definition Stmt.h:3870
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:1388
LoopControlStmtBitfields LoopControlStmtBits
Definition Stmt.h:1330
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.cpp:362
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:1344
CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits
Definition Stmt.h:1378
WhileStmtBitfields WhileStmtBits
Definition Stmt.h:1326
SwitchCaseBitfields SwitchCaseBits
Definition Stmt.h:1332
GenericSelectionExprBitfields GenericSelectionExprBits
Definition Stmt.h:1352
InitListExprBitfields InitListExprBits
Definition Stmt.h:1350
static void EnableStatistics()
Definition Stmt.cpp:139
LambdaExprBitfields LambdaExprBits
Definition Stmt.h:1385
AttributedStmtBitfields AttributedStmtBits
Definition Stmt.h:1323
Stmt(StmtClass SC)
Definition Stmt.h:1476
ParenListExprBitfields ParenListExprBits
Definition Stmt.h:1351
ArrayOrMatrixSubscriptExprBitfields ArrayOrMatrixSubscriptExprBits
Definition Stmt.h:1345
UnresolvedLookupExprBitfields UnresolvedLookupExprBits
Definition Stmt.h:1381
SwitchStmtBitfields SwitchStmtBits
Definition Stmt.h:1325
SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits
Definition Stmt.h:1384
CXXNoexceptExprBitfields CXXNoexceptExprBits
Definition Stmt.h:1383
ParenExprBitfields ParenExprBits
Definition Stmt.h:1355
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
Definition Stmt.h:1571
CXXRewrittenBinaryOperatorBitfields CXXRewrittenBinaryOperatorBits
Definition Stmt.h:1364
CallExprBitfields CallExprBits
Definition Stmt.h:1346
Stmt * stripLabelLikeStatements()
Definition Stmt.h:1563
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:1456
const Stmt * stripLabelLikeStatements() const
Strip off all label-like statements.
Definition Stmt.cpp:227
child_range children()
Definition Stmt.cpp:299
ShuffleVectorExprBitfields ShuffleVectorExprBits
Definition Stmt.h:1356
ExprWithCleanupsBitfields ExprWithCleanupsBits
Definition Stmt.h:1377
FloatingLiteralBitfields FloatingLiteralBits
Definition Stmt.h:1340
const_child_range children() const
Definition Stmt.h:1579
child_iterator child_begin()
Definition Stmt.h:1583
void printJson(raw_ostream &Out, PrinterHelper *Helper, const PrintingPolicy &Policy, bool AddQuotes) const
Pretty-prints in JSON format.
StmtClass getStmtClass() const
Definition Stmt.h:1485
CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits
Definition Stmt.h:1371
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:338
CharacterLiteralBitfields CharacterLiteralBits
Definition Stmt.h:1342
OverloadExprBitfields OverloadExprBits
Definition Stmt.h:1380
CXXConstructExprBitfields CXXConstructExprBits
Definition Stmt.h:1376
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:1343
static std::tuple< bool, const Attr *, const Attr * > determineLikelihoodConflict(const Stmt *Then, const Stmt *Else)
Definition Stmt.cpp:193
CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits
Definition Stmt.h:1379
static void PrintStats()
Definition Stmt.cpp:109
GotoStmtBitfields GotoStmtBits
Definition Stmt.h:1329
child_iterator child_end()
Definition Stmt.h:1584
ConstCastIterator< Expr > ConstExprIterator
Definition Stmt.h:1459
TypeTraitExprBitfields TypeTraitExprBits
Definition Stmt.h:1374
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:1372
SourceLocExprBitfields SourceLocExprBits
Definition Stmt.h:1354
CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits
Definition Stmt.h:1366
CoawaitExprBitfields CoawaitBits
Definition Stmt.h:1393
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition Stmt.h:1467
ChooseExprBitfields ChooseExprBits
Definition Stmt.h:1360
ConstantExprBitfields ConstantExprBits
Definition Stmt.h:1337
llvm::iterator_range< child_iterator > child_range
Definition Stmt.h:1574
DeferStmtBitfields DeferStmtBits
Definition Stmt.h:1333
CompoundStmtBitfields CompoundStmtBits
Definition Stmt.h:1321
RequiresExprBitfields RequiresExprBits
Definition Stmt.h:1386
CXXFoldExprBitfields CXXFoldExprBits
Definition Stmt.h:1389
StmtExprBitfields StmtExprBits
Definition Stmt.h:1359
StringLiteralBitfields StringLiteralBits
Definition Stmt.h:1341
OpaqueValueExprBitfields OpaqueValueExprBits
Definition Stmt.h:1399
CastExprBitfields CastExprBits
Definition Stmt.h:1348
Likelihood
The likelihood of a branch being taken.
Definition Stmt.h:1428
@ LH_Unlikely
Branch has the [[unlikely]] attribute.
Definition Stmt.h:1429
@ LH_None
No attribute set or branches of the IfStmt have the same attribute.
Definition Stmt.h:1430
@ LH_Likely
Branch has the [[likely]] attribute.
Definition Stmt.h:1432
CXXThrowExprBitfields CXXThrowExprBits
Definition Stmt.h:1368
static void addStmtClass(const StmtClass s)
Definition Stmt.cpp:134
MemberExprBitfields MemberExprBits
Definition Stmt.h:1347
PackIndexingExprBitfields PackIndexingExprBits
Definition Stmt.h:1390
friend class ASTStmtWriter
Definition Stmt.h:102
ForStmtBitfields ForStmtBits
Definition Stmt.h:1328
@ NumOverloadExprBits
Definition Stmt.h:1111
DeclRefExprBitfields DeclRefExprBits
Definition Stmt.h:1339
const_child_iterator child_end() const
Definition Stmt.h:1587
const char * getStmtClassName() const
Definition Stmt.cpp:87
ConstStmtIterator const_child_iterator
Definition Stmt.h:1572
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:1365
CXXOperatorCallExprBitfields CXXOperatorCallExprBits
Definition Stmt.h:1363
Stmt(Stmt &&)=delete
CXXDefaultInitExprBitfields CXXDefaultInitExprBits
Definition Stmt.h:1370
Stmt & operator=(const Stmt &)=delete
NullStmtBitfields NullStmtBits
Definition Stmt.h:1320
static const Attr * getLikelihoodAttr(const Stmt *S)
Definition Stmt.cpp:171
Stmt * IgnoreContainers(bool IgnoreCaptured=false)
Skip no-op (attributed, compound) container stmts and skip captured stmt at the top,...
Definition Stmt.cpp:205
DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits
Definition Stmt.h:1375
friend class ASTStmtReader
Definition Stmt.h:101
ArrayTypeTraitExprBitfields ArrayTypeTraitExprBits
Definition Stmt.h:1387
StmtBitfields StmtBits
Definition Stmt.h:1319
IfStmtBitfields IfStmtBits
Definition Stmt.h:1324
Stmt & operator=(Stmt &&)=delete
PredefinedExprBitfields PredefinedExprBits
Definition Stmt.h:1338
ConvertVectorExprBitfields ConvertVectorExprBits
Definition Stmt.h:1400
@ NumExprBits
Definition Stmt.h:367
int64_t getID(const ASTContext &Context) const
Definition Stmt.cpp:374
ReturnStmtBitfields ReturnStmtBits
Definition Stmt.h:1331
LabelStmtBitfields LabelStmtBits
Definition Stmt.h:1322
ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits
Definition Stmt.h:1396
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Stmt.cpp:350
void dumpColor() const
dumpColor - same as dump(), but forces color highlighting.
BinaryOperatorBitfields BinaryOperatorBits
Definition Stmt.h:1349
Stmt()=delete
UnresolvedMemberExprBitfields UnresolvedMemberExprBits
Definition Stmt.h:1382
PseudoObjectExprBitfields PseudoObjectExprBits
Definition Stmt.h:1353
ExprBitfields ExprBits
Definition Stmt.h:1336
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:1575
const_child_iterator child_begin() const
Definition Stmt.h:1586
CXXDeleteExprBitfields CXXDeleteExprBits
Definition Stmt.h:1373
CXXDefaultArgExprBitfields CXXDefaultArgExprBits
Definition Stmt.h:1369
DoStmtBitfields DoStmtBits
Definition Stmt.h:1327
@ NumCallExprBits
Definition Stmt.h:583
CXXThisExprBitfields CXXThisExprBits
Definition Stmt.h:1367
CastIterator< Expr > ExprIterator
Definition Stmt.h:1458
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1799
SwitchCase * NextSwitchCase
A pointer to the following CaseStmt or DefaultStmt class, used by SwitchStmt.
Definition Stmt.h:1875
void setColonLoc(SourceLocation L)
Definition Stmt.h:1892
static bool classof(const Stmt *T)
Definition Stmt.h:1902
SwitchCase(StmtClass SC, EmptyShell)
Definition Stmt.h:1882
SourceLocation getKeywordLoc() const
Definition Stmt.h:1889
Stmt * getSubStmt()
Definition Stmt.h:2105
SwitchCase(StmtClass SC, SourceLocation KWLoc, SourceLocation ColonLoc)
Definition Stmt.h:1877
void setKeywordLoc(SourceLocation L)
Definition Stmt.h:1890
const Stmt * getSubStmt() const
Definition Stmt.h:1895
void setNextSwitchCase(SwitchCase *SC)
Definition Stmt.h:1887
SourceLocation getColonLoc() const
Definition Stmt.h:1891
SourceLocation getBeginLoc() const
Definition Stmt.h:1899
const SwitchCase * getNextSwitchCase() const
Definition Stmt.h:1885
SourceLocation ColonLoc
The location of the ":".
Definition Stmt.h:1868
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2097
SwitchCase * getNextSwitchCase()
Definition Stmt.h:1886
void setCond(Expr *Cond)
Definition Stmt.h:2572
const Stmt * getInit() const
Definition Stmt.h:2585
SourceLocation getSwitchLoc() const
Definition Stmt.h:2636
void addSwitchCase(SwitchCase *SC)
Definition Stmt.h:2648
void setBody(Stmt *S, SourceLocation SL)
Definition Stmt.h:2643
SourceLocation getLParenLoc() const
Definition Stmt.h:2638
const Expr * getCond() const
Definition Stmt.h:2568
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:2661
void setSwitchLoc(SourceLocation L)
Definition Stmt.h:2637
void setConditionVariableDeclStmt(DeclStmt *CondVar)
Definition Stmt.h:2627
void setBody(Stmt *Body)
Definition Stmt.h:2579
void setRParenLoc(SourceLocation Loc)
Definition Stmt.h:2641
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2666
SourceLocation getRParenLoc() const
Definition Stmt.h:2640
void setInit(Stmt *Init)
Definition Stmt.h:2589
void setConditionVariable(const ASTContext &Ctx, VarDecl *VD)
Set the condition variable in this switch statement.
Definition Stmt.cpp:1188
void setLParenLoc(SourceLocation Loc)
Definition Stmt.h:2639
child_range children()
Definition Stmt.h:2672
const Stmt * getBody() const
Definition Stmt.h:2577
const VarDecl * getConditionVariable() const
Definition Stmt.h:2605
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:1173
const DeclStmt * getConditionVariableDeclStmt() const
Definition Stmt.h:2621
Expr * getCond()
Definition Stmt.h:2564
bool hasVarStorage() const
True if this SwitchStmt has storage for a condition variable.
Definition Stmt.h:2562
Stmt * getBody()
Definition Stmt.h:2576
const_child_range children() const
Definition Stmt.h:2677
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
Definition Stmt.cpp:1181
Stmt * getInit()
Definition Stmt.h:2581
SourceLocation getBeginLoc() const
Definition Stmt.h:2665
bool hasInitStorage() const
True if this SwitchStmt has storage for an init statement.
Definition Stmt.h:2559
SwitchCase * getSwitchCaseList()
Definition Stmt.h:2632
const SwitchCase * getSwitchCaseList() const
Definition Stmt.h:2633
DeclStmt * getConditionVariableDeclStmt()
If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of...
Definition Stmt.h:2615
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:2657
void setSwitchCaseList(SwitchCase *SC)
Definition Stmt.h:2634
static bool classof(const Stmt *T)
Definition Stmt.h:2682
Exposes information about the current target.
Definition TargetInfo.h:226
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:2119
const Expr * getExprStmt() const
Definition Stmt.cpp:415
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
Definition Stmt.h:1467
static bool classof(const Stmt *T)
Definition Stmt.h:2130
Expr * getExprStmt()
Definition Stmt.h:2125
Represents a variable declaration or definition.
Definition Decl.h:926
Expr * getCond()
Definition Stmt.h:2741
SourceLocation getWhileLoc() const
Definition Stmt.h:2794
void setCond(Expr *Cond)
Definition Stmt.h:2749
SourceLocation getRParenLoc() const
Definition Stmt.h:2799
DeclStmt * getConditionVariableDeclStmt()
If this WhileStmt has a condition variable, return the faux DeclStmt associated with the creation of ...
Definition Stmt.h:2777
void setBody(Stmt *Body)
Definition Stmt.h:2756
void setLParenLoc(SourceLocation L)
Definition Stmt.h:2798
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
Definition Stmt.cpp:1242
SourceLocation getEndLoc() const LLVM_READONLY
Definition Stmt.h:2803
void setConditionVariable(const ASTContext &Ctx, VarDecl *V)
Set the condition variable of this while statement.
Definition Stmt.cpp:1249
bool hasVarStorage() const
True if this WhileStmt has storage for a condition variable.
Definition Stmt.h:2739
SourceLocation getLParenLoc() const
Definition Stmt.h:2797
SourceLocation getBeginLoc() const
Definition Stmt.h:2802
const Stmt * getBody() const
Definition Stmt.h:2754
void setRParenLoc(SourceLocation L)
Definition Stmt.h:2800
const VarDecl * getConditionVariable() const
Definition Stmt.h:2767
void setWhileLoc(SourceLocation L)
Definition Stmt.h:2795
const Expr * getCond() const
Definition Stmt.h:2745
static WhileStmt * CreateEmpty(const ASTContext &Ctx, bool HasVar)
Create an empty while statement optionally with storage for a condition variable.
Definition Stmt.cpp:1235
const DeclStmt * getConditionVariableDeclStmt() const
Definition Stmt.h:2783
void setConditionVariableDeclStmt(DeclStmt *CondVar)
Definition Stmt.h:2789
static bool classof(const Stmt *T)
Definition Stmt.h:2807
const_child_range children() const
Definition Stmt.h:2817
child_range children()
Definition Stmt.h:2812
Stmt * getBody()
Definition Stmt.h:2753
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:1076
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:39
CXXConstructionKind
Definition ExprCXX.h:1540
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition Specifiers.h:149
@ 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
const FunctionProtoType * T
CastKind
CastKind - The kind of operation required for a conversion.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition Lambda.h:22
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition Specifiers.h:132
StringLiteralKind
Definition Expr.h:1763
U cast(CodeGen::Address addr)
Definition Address.h:327
SourceLocIdentKind
Definition Expr.h:5004
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:5879
TypeTrait
Names for traits that operate specifically on types.
Definition TypeTraits.h:21
CXXNewInitializationStyle
Definition ExprCXX.h:2240
PredefinedIdentKind
Definition Expr.h:1989
CharacterLiteralKind
Definition Expr.h:1603
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:1443
typename CastIterator::iterator_adaptor_base Base
Definition Stmt.h:1444
CastIterator(StmtPtr *I)
Definition Stmt.h:1447
Base::value_type operator*() const
Definition Stmt.h:1449
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
Definition Stmt.h:1425