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