1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | #ifndef LLVM_CLANG_AST_STMT_H |
14 | #define LLVM_CLANG_AST_STMT_H |
15 | |
16 | #include "clang/AST/DeclGroup.h" |
17 | #include "clang/AST/StmtIterator.h" |
18 | #include "clang/Basic/CapturedStmt.h" |
19 | #include "clang/Basic/IdentifierTable.h" |
20 | #include "clang/Basic/LLVM.h" |
21 | #include "clang/Basic/SourceLocation.h" |
22 | #include "llvm/ADT/ArrayRef.h" |
23 | #include "llvm/ADT/PointerIntPair.h" |
24 | #include "llvm/ADT/StringRef.h" |
25 | #include "llvm/ADT/iterator.h" |
26 | #include "llvm/ADT/iterator_range.h" |
27 | #include "llvm/Support/Casting.h" |
28 | #include "llvm/Support/Compiler.h" |
29 | #include "llvm/Support/ErrorHandling.h" |
30 | #include <algorithm> |
31 | #include <cassert> |
32 | #include <cstddef> |
33 | #include <iterator> |
34 | #include <string> |
35 | |
36 | namespace llvm { |
37 | |
38 | class FoldingSetNodeID; |
39 | |
40 | } |
41 | |
42 | namespace clang { |
43 | |
44 | class ASTContext; |
45 | class Attr; |
46 | class CapturedDecl; |
47 | class Decl; |
48 | class Expr; |
49 | class LabelDecl; |
50 | class ODRHash; |
51 | class PrinterHelper; |
52 | struct PrintingPolicy; |
53 | class RecordDecl; |
54 | class SourceManager; |
55 | class StringLiteral; |
56 | class Token; |
57 | class VarDecl; |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | class alignas(void *) Stmt { |
66 | public: |
67 | enum StmtClass { |
68 | NoStmtClass = 0, |
69 | #define STMT(CLASS, PARENT) CLASS##Class, |
70 | #define STMT_RANGE(BASE, FIRST, LAST) \ |
71 | first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class, |
72 | #define LAST_STMT_RANGE(BASE, FIRST, LAST) \ |
73 | first##BASE##Constant=FIRST##Class, last##BASE##Constant=LAST##Class |
74 | #define ABSTRACT_STMT(STMT) |
75 | #include "clang/AST/StmtNodes.inc" |
76 | }; |
77 | |
78 | |
79 | protected: |
80 | friend class ASTStmtReader; |
81 | friend class ASTStmtWriter; |
82 | |
83 | void *operator new(size_t bytes) noexcept { |
84 | llvm_unreachable("Stmts cannot be allocated with regular 'new'."); |
85 | } |
86 | |
87 | void operator delete(void *data) noexcept { |
88 | llvm_unreachable("Stmts cannot be released with regular 'delete'."); |
89 | } |
90 | |
91 | |
92 | |
93 | class StmtBitfields { |
94 | friend class ASTStmtReader; |
95 | friend class ASTStmtWriter; |
96 | friend class Stmt; |
97 | |
98 | |
99 | unsigned sClass : 8; |
100 | |
101 | |
102 | |
103 | |
104 | |
105 | unsigned IsOMPStructuredBlock : 1; |
106 | }; |
107 | enum { NumStmtBits = 9 }; |
108 | |
109 | class NullStmtBitfields { |
110 | friend class ASTStmtReader; |
111 | friend class ASTStmtWriter; |
112 | friend class NullStmt; |
113 | |
114 | unsigned : NumStmtBits; |
115 | |
116 | |
117 | |
118 | |
119 | |
120 | |
121 | unsigned HasLeadingEmptyMacro : 1; |
122 | |
123 | |
124 | SourceLocation SemiLoc; |
125 | }; |
126 | |
127 | class CompoundStmtBitfields { |
128 | friend class ASTStmtReader; |
129 | friend class CompoundStmt; |
130 | |
131 | unsigned : NumStmtBits; |
132 | |
133 | unsigned NumStmts : 32 - NumStmtBits; |
134 | |
135 | |
136 | SourceLocation LBraceLoc; |
137 | }; |
138 | |
139 | class LabelStmtBitfields { |
140 | friend class LabelStmt; |
141 | |
142 | unsigned : NumStmtBits; |
143 | |
144 | SourceLocation IdentLoc; |
145 | }; |
146 | |
147 | class AttributedStmtBitfields { |
148 | friend class ASTStmtReader; |
149 | friend class AttributedStmt; |
150 | |
151 | unsigned : NumStmtBits; |
152 | |
153 | |
154 | unsigned NumAttrs : 32 - NumStmtBits; |
155 | |
156 | |
157 | SourceLocation AttrLoc; |
158 | }; |
159 | |
160 | class IfStmtBitfields { |
161 | friend class ASTStmtReader; |
162 | friend class IfStmt; |
163 | |
164 | unsigned : NumStmtBits; |
165 | |
166 | |
167 | unsigned IsConstexpr : 1; |
168 | |
169 | |
170 | unsigned HasElse : 1; |
171 | |
172 | |
173 | unsigned HasVar : 1; |
174 | |
175 | |
176 | unsigned HasInit : 1; |
177 | |
178 | |
179 | SourceLocation IfLoc; |
180 | }; |
181 | |
182 | class SwitchStmtBitfields { |
183 | friend class SwitchStmt; |
184 | |
185 | unsigned : NumStmtBits; |
186 | |
187 | |
188 | unsigned HasInit : 1; |
189 | |
190 | |
191 | unsigned HasVar : 1; |
192 | |
193 | |
194 | |
195 | |
196 | unsigned AllEnumCasesCovered : 1; |
197 | |
198 | |
199 | SourceLocation SwitchLoc; |
200 | }; |
201 | |
202 | class WhileStmtBitfields { |
203 | friend class ASTStmtReader; |
204 | friend class WhileStmt; |
205 | |
206 | unsigned : NumStmtBits; |
207 | |
208 | |
209 | unsigned HasVar : 1; |
210 | |
211 | |
212 | SourceLocation WhileLoc; |
213 | }; |
214 | |
215 | class DoStmtBitfields { |
216 | friend class DoStmt; |
217 | |
218 | unsigned : NumStmtBits; |
219 | |
220 | |
221 | SourceLocation DoLoc; |
222 | }; |
223 | |
224 | class ForStmtBitfields { |
225 | friend class ForStmt; |
226 | |
227 | unsigned : NumStmtBits; |
228 | |
229 | |
230 | SourceLocation ForLoc; |
231 | }; |
232 | |
233 | class GotoStmtBitfields { |
234 | friend class GotoStmt; |
235 | friend class IndirectGotoStmt; |
236 | |
237 | unsigned : NumStmtBits; |
238 | |
239 | |
240 | SourceLocation GotoLoc; |
241 | }; |
242 | |
243 | class ContinueStmtBitfields { |
244 | friend class ContinueStmt; |
245 | |
246 | unsigned : NumStmtBits; |
247 | |
248 | |
249 | SourceLocation ContinueLoc; |
250 | }; |
251 | |
252 | class BreakStmtBitfields { |
253 | friend class BreakStmt; |
254 | |
255 | unsigned : NumStmtBits; |
256 | |
257 | |
258 | SourceLocation BreakLoc; |
259 | }; |
260 | |
261 | class ReturnStmtBitfields { |
262 | friend class ReturnStmt; |
263 | |
264 | unsigned : NumStmtBits; |
265 | |
266 | |
267 | unsigned HasNRVOCandidate : 1; |
268 | |
269 | |
270 | SourceLocation RetLoc; |
271 | }; |
272 | |
273 | class SwitchCaseBitfields { |
274 | friend class SwitchCase; |
275 | friend class CaseStmt; |
276 | |
277 | unsigned : NumStmtBits; |
278 | |
279 | |
280 | |
281 | unsigned CaseStmtIsGNURange : 1; |
282 | |
283 | |
284 | SourceLocation KeywordLoc; |
285 | }; |
286 | |
287 | |
288 | |
289 | class ExprBitfields { |
290 | friend class ASTStmtReader; |
291 | friend class AtomicExpr; |
292 | friend class BlockDeclRefExpr; |
293 | friend class CallExpr; |
294 | friend class CXXConstructExpr; |
295 | friend class CXXDependentScopeMemberExpr; |
296 | friend class CXXNewExpr; |
297 | friend class CXXUnresolvedConstructExpr; |
298 | friend class DeclRefExpr; |
299 | friend class DependentScopeDeclRefExpr; |
300 | friend class DesignatedInitExpr; |
301 | friend class Expr; |
302 | friend class InitListExpr; |
303 | friend class ObjCArrayLiteral; |
304 | friend class ObjCDictionaryLiteral; |
305 | friend class ObjCMessageExpr; |
306 | friend class OffsetOfExpr; |
307 | friend class OpaqueValueExpr; |
308 | friend class OverloadExpr; |
309 | friend class ParenListExpr; |
310 | friend class PseudoObjectExpr; |
311 | friend class ShuffleVectorExpr; |
312 | |
313 | unsigned : NumStmtBits; |
314 | |
315 | unsigned ValueKind : 2; |
316 | unsigned ObjectKind : 3; |
317 | unsigned TypeDependent : 1; |
318 | unsigned ValueDependent : 1; |
319 | unsigned InstantiationDependent : 1; |
320 | unsigned ContainsUnexpandedParameterPack : 1; |
321 | }; |
322 | enum { NumExprBits = NumStmtBits + 9 }; |
323 | |
324 | class PredefinedExprBitfields { |
325 | friend class ASTStmtReader; |
326 | friend class PredefinedExpr; |
327 | |
328 | unsigned : NumExprBits; |
329 | |
330 | |
331 | |
332 | unsigned Kind : 4; |
333 | |
334 | |
335 | |
336 | unsigned HasFunctionName : 1; |
337 | |
338 | |
339 | SourceLocation Loc; |
340 | }; |
341 | |
342 | class DeclRefExprBitfields { |
343 | friend class ASTStmtReader; |
344 | friend class DeclRefExpr; |
345 | |
346 | unsigned : NumExprBits; |
347 | |
348 | unsigned HasQualifier : 1; |
349 | unsigned HasTemplateKWAndArgsInfo : 1; |
350 | unsigned HasFoundDecl : 1; |
351 | unsigned HadMultipleCandidates : 1; |
352 | unsigned RefersToEnclosingVariableOrCapture : 1; |
353 | |
354 | |
355 | SourceLocation Loc; |
356 | }; |
357 | |
358 | enum APFloatSemantics { |
359 | IEEEhalf, |
360 | IEEEsingle, |
361 | IEEEdouble, |
362 | x87DoubleExtended, |
363 | IEEEquad, |
364 | PPCDoubleDouble |
365 | }; |
366 | |
367 | class FloatingLiteralBitfields { |
368 | friend class FloatingLiteral; |
369 | |
370 | unsigned : NumExprBits; |
371 | |
372 | unsigned Semantics : 3; |
373 | unsigned IsExact : 1; |
374 | }; |
375 | |
376 | class StringLiteralBitfields { |
377 | friend class ASTStmtReader; |
378 | friend class StringLiteral; |
379 | |
380 | unsigned : NumExprBits; |
381 | |
382 | |
383 | |
384 | unsigned Kind : 3; |
385 | |
386 | |
387 | |
388 | |
389 | unsigned CharByteWidth : 3; |
390 | |
391 | unsigned IsPascal : 1; |
392 | |
393 | |
394 | |
395 | unsigned NumConcatenated; |
396 | }; |
397 | |
398 | class CharacterLiteralBitfields { |
399 | friend class CharacterLiteral; |
400 | |
401 | unsigned : NumExprBits; |
402 | |
403 | unsigned Kind : 3; |
404 | }; |
405 | |
406 | class UnaryOperatorBitfields { |
407 | friend class UnaryOperator; |
408 | |
409 | unsigned : NumExprBits; |
410 | |
411 | unsigned Opc : 5; |
412 | unsigned CanOverflow : 1; |
413 | |
414 | SourceLocation Loc; |
415 | }; |
416 | |
417 | class UnaryExprOrTypeTraitExprBitfields { |
418 | friend class UnaryExprOrTypeTraitExpr; |
419 | |
420 | unsigned : NumExprBits; |
421 | |
422 | unsigned Kind : 3; |
423 | unsigned IsType : 1; |
424 | }; |
425 | |
426 | class ArraySubscriptExprBitfields { |
427 | friend class ArraySubscriptExpr; |
428 | |
429 | unsigned : NumExprBits; |
430 | |
431 | SourceLocation RBracketLoc; |
432 | }; |
433 | |
434 | class CallExprBitfields { |
435 | friend class CallExpr; |
436 | |
437 | unsigned : NumExprBits; |
438 | |
439 | unsigned NumPreArgs : 1; |
440 | |
441 | |
442 | unsigned UsesADL : 1; |
443 | |
444 | |
445 | unsigned : 24 - 2 - NumExprBits; |
446 | |
447 | |
448 | |
449 | |
450 | unsigned OffsetToTrailingObjects : 8; |
451 | }; |
452 | enum { NumCallExprBits = 32 }; |
453 | |
454 | class MemberExprBitfields { |
455 | friend class MemberExpr; |
456 | |
457 | unsigned : NumExprBits; |
458 | |
459 | |
460 | unsigned IsArrow : 1; |
461 | |
462 | |
463 | |
464 | |
465 | |
466 | unsigned HasQualifierOrFoundDecl : 1; |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | unsigned HasTemplateKWAndArgsInfo : 1; |
474 | |
475 | |
476 | |
477 | unsigned HadMultipleCandidates : 1; |
478 | |
479 | |
480 | SourceLocation OperatorLoc; |
481 | }; |
482 | |
483 | class CastExprBitfields { |
484 | friend class CastExpr; |
485 | friend class ImplicitCastExpr; |
486 | |
487 | unsigned : NumExprBits; |
488 | |
489 | unsigned Kind : 6; |
490 | unsigned PartOfExplicitCast : 1; |
491 | |
492 | |
493 | |
494 | unsigned BasePathSize; |
495 | }; |
496 | |
497 | class BinaryOperatorBitfields { |
498 | friend class BinaryOperator; |
499 | |
500 | unsigned : NumExprBits; |
501 | |
502 | unsigned Opc : 6; |
503 | |
504 | |
505 | |
506 | unsigned FPFeatures : 3; |
507 | |
508 | SourceLocation OpLoc; |
509 | }; |
510 | |
511 | class InitListExprBitfields { |
512 | friend class InitListExpr; |
513 | |
514 | unsigned : NumExprBits; |
515 | |
516 | |
517 | |
518 | unsigned HadArrayRangeDesignator : 1; |
519 | }; |
520 | |
521 | class ParenListExprBitfields { |
522 | friend class ASTStmtReader; |
523 | friend class ParenListExpr; |
524 | |
525 | unsigned : NumExprBits; |
526 | |
527 | |
528 | unsigned NumExprs; |
529 | }; |
530 | |
531 | class GenericSelectionExprBitfields { |
532 | friend class ASTStmtReader; |
533 | friend class GenericSelectionExpr; |
534 | |
535 | unsigned : NumExprBits; |
536 | |
537 | |
538 | SourceLocation GenericLoc; |
539 | }; |
540 | |
541 | class PseudoObjectExprBitfields { |
542 | friend class ASTStmtReader; |
543 | friend class PseudoObjectExpr; |
544 | |
545 | unsigned : NumExprBits; |
546 | |
547 | |
548 | |
549 | unsigned NumSubExprs : 8; |
550 | unsigned ResultIndex : 32 - 8 - NumExprBits; |
551 | }; |
552 | |
553 | |
554 | |
555 | class CXXOperatorCallExprBitfields { |
556 | friend class ASTStmtReader; |
557 | friend class CXXOperatorCallExpr; |
558 | |
559 | unsigned : NumCallExprBits; |
560 | |
561 | |
562 | |
563 | unsigned OperatorKind : 6; |
564 | |
565 | |
566 | unsigned FPFeatures : 3; |
567 | }; |
568 | |
569 | class CXXBoolLiteralExprBitfields { |
570 | friend class CXXBoolLiteralExpr; |
571 | |
572 | unsigned : NumExprBits; |
573 | |
574 | |
575 | unsigned Value : 1; |
576 | |
577 | |
578 | SourceLocation Loc; |
579 | }; |
580 | |
581 | class CXXNullPtrLiteralExprBitfields { |
582 | friend class CXXNullPtrLiteralExpr; |
583 | |
584 | unsigned : NumExprBits; |
585 | |
586 | |
587 | SourceLocation Loc; |
588 | }; |
589 | |
590 | class CXXThisExprBitfields { |
591 | friend class CXXThisExpr; |
592 | |
593 | unsigned : NumExprBits; |
594 | |
595 | |
596 | unsigned IsImplicit : 1; |
597 | |
598 | |
599 | SourceLocation Loc; |
600 | }; |
601 | |
602 | class CXXThrowExprBitfields { |
603 | friend class ASTStmtReader; |
604 | friend class CXXThrowExpr; |
605 | |
606 | unsigned : NumExprBits; |
607 | |
608 | |
609 | unsigned IsThrownVariableInScope : 1; |
610 | |
611 | |
612 | SourceLocation ThrowLoc; |
613 | }; |
614 | |
615 | class CXXDefaultArgExprBitfields { |
616 | friend class ASTStmtReader; |
617 | friend class CXXDefaultArgExpr; |
618 | |
619 | unsigned : NumExprBits; |
620 | |
621 | |
622 | SourceLocation Loc; |
623 | }; |
624 | |
625 | class CXXDefaultInitExprBitfields { |
626 | friend class ASTStmtReader; |
627 | friend class CXXDefaultInitExpr; |
628 | |
629 | unsigned : NumExprBits; |
630 | |
631 | |
632 | SourceLocation Loc; |
633 | }; |
634 | |
635 | class CXXScalarValueInitExprBitfields { |
636 | friend class ASTStmtReader; |
637 | friend class CXXScalarValueInitExpr; |
638 | |
639 | unsigned : NumExprBits; |
640 | |
641 | SourceLocation RParenLoc; |
642 | }; |
643 | |
644 | class CXXNewExprBitfields { |
645 | friend class ASTStmtReader; |
646 | friend class ASTStmtWriter; |
647 | friend class CXXNewExpr; |
648 | |
649 | unsigned : NumExprBits; |
650 | |
651 | |
652 | unsigned IsGlobalNew : 1; |
653 | |
654 | |
655 | |
656 | unsigned IsArray : 1; |
657 | |
658 | |
659 | unsigned ShouldPassAlignment : 1; |
660 | |
661 | |
662 | |
663 | unsigned UsualArrayDeleteWantsSize : 1; |
664 | |
665 | |
666 | |
667 | |
668 | unsigned StoredInitializationStyle : 2; |
669 | |
670 | |
671 | unsigned IsParenTypeId : 1; |
672 | |
673 | |
674 | unsigned NumPlacementArgs; |
675 | }; |
676 | |
677 | class CXXDeleteExprBitfields { |
678 | friend class ASTStmtReader; |
679 | friend class CXXDeleteExpr; |
680 | |
681 | unsigned : NumExprBits; |
682 | |
683 | |
684 | unsigned GlobalDelete : 1; |
685 | |
686 | |
687 | unsigned ArrayForm : 1; |
688 | |
689 | |
690 | |
691 | |
692 | unsigned ArrayFormAsWritten : 1; |
693 | |
694 | |
695 | |
696 | unsigned UsualArrayDeleteWantsSize : 1; |
697 | |
698 | |
699 | SourceLocation Loc; |
700 | }; |
701 | |
702 | class TypeTraitExprBitfields { |
703 | friend class ASTStmtReader; |
704 | friend class ASTStmtWriter; |
705 | friend class TypeTraitExpr; |
706 | |
707 | unsigned : NumExprBits; |
708 | |
709 | |
710 | unsigned Kind : 8; |
711 | |
712 | |
713 | |
714 | unsigned Value : 1; |
715 | |
716 | |
717 | unsigned NumArgs : 32 - 8 - 1 - NumExprBits; |
718 | }; |
719 | |
720 | class DependentScopeDeclRefExprBitfields { |
721 | friend class ASTStmtReader; |
722 | friend class ASTStmtWriter; |
723 | friend class DependentScopeDeclRefExpr; |
724 | |
725 | unsigned : NumExprBits; |
726 | |
727 | |
728 | |
729 | unsigned HasTemplateKWAndArgsInfo : 1; |
730 | }; |
731 | |
732 | class CXXConstructExprBitfields { |
733 | friend class ASTStmtReader; |
734 | friend class CXXConstructExpr; |
735 | |
736 | unsigned : NumExprBits; |
737 | |
738 | unsigned Elidable : 1; |
739 | unsigned HadMultipleCandidates : 1; |
740 | unsigned ListInitialization : 1; |
741 | unsigned StdInitListInitialization : 1; |
742 | unsigned ZeroInitialization : 1; |
743 | unsigned ConstructionKind : 3; |
744 | |
745 | SourceLocation Loc; |
746 | }; |
747 | |
748 | class ExprWithCleanupsBitfields { |
749 | friend class ASTStmtReader; |
750 | friend class ExprWithCleanups; |
751 | |
752 | unsigned : NumExprBits; |
753 | |
754 | |
755 | unsigned CleanupsHaveSideEffects : 1; |
756 | |
757 | unsigned NumObjects : 32 - 1 - NumExprBits; |
758 | }; |
759 | |
760 | class CXXUnresolvedConstructExprBitfields { |
761 | friend class ASTStmtReader; |
762 | friend class CXXUnresolvedConstructExpr; |
763 | |
764 | unsigned : NumExprBits; |
765 | |
766 | |
767 | unsigned NumArgs; |
768 | }; |
769 | |
770 | class CXXDependentScopeMemberExprBitfields { |
771 | friend class ASTStmtReader; |
772 | friend class CXXDependentScopeMemberExpr; |
773 | |
774 | unsigned : NumExprBits; |
775 | |
776 | |
777 | |
778 | unsigned IsArrow : 1; |
779 | |
780 | |
781 | |
782 | unsigned HasTemplateKWAndArgsInfo : 1; |
783 | |
784 | |
785 | |
786 | unsigned HasFirstQualifierFoundInScope : 1; |
787 | |
788 | |
789 | SourceLocation OperatorLoc; |
790 | }; |
791 | |
792 | class OverloadExprBitfields { |
793 | friend class ASTStmtReader; |
794 | friend class OverloadExpr; |
795 | |
796 | unsigned : NumExprBits; |
797 | |
798 | |
799 | |
800 | unsigned HasTemplateKWAndArgsInfo : 1; |
801 | |
802 | |
803 | |
804 | |
805 | unsigned : 32 - NumExprBits - 1; |
806 | |
807 | |
808 | unsigned NumResults; |
809 | }; |
810 | enum { NumOverloadExprBits = NumExprBits + 1 }; |
811 | |
812 | class UnresolvedLookupExprBitfields { |
813 | friend class ASTStmtReader; |
814 | friend class UnresolvedLookupExpr; |
815 | |
816 | unsigned : NumOverloadExprBits; |
817 | |
818 | |
819 | |
820 | unsigned RequiresADL : 1; |
821 | |
822 | |
823 | |
824 | unsigned Overloaded : 1; |
825 | }; |
826 | static_assert(sizeof(UnresolvedLookupExprBitfields) <= 4, |
827 | "UnresolvedLookupExprBitfields must be <= than 4 bytes to" |
828 | "avoid trashing OverloadExprBitfields::NumResults!"); |
829 | |
830 | class UnresolvedMemberExprBitfields { |
831 | friend class ASTStmtReader; |
832 | friend class UnresolvedMemberExpr; |
833 | |
834 | unsigned : NumOverloadExprBits; |
835 | |
836 | |
837 | |
838 | unsigned IsArrow : 1; |
839 | |
840 | |
841 | unsigned HasUnresolvedUsing : 1; |
842 | }; |
843 | static_assert(sizeof(UnresolvedMemberExprBitfields) <= 4, |
844 | "UnresolvedMemberExprBitfields must be <= than 4 bytes to" |
845 | "avoid trashing OverloadExprBitfields::NumResults!"); |
846 | |
847 | class CXXNoexceptExprBitfields { |
848 | friend class ASTStmtReader; |
849 | friend class CXXNoexceptExpr; |
850 | |
851 | unsigned : NumExprBits; |
852 | |
853 | unsigned Value : 1; |
854 | }; |
855 | |
856 | class SubstNonTypeTemplateParmExprBitfields { |
857 | friend class ASTStmtReader; |
858 | friend class SubstNonTypeTemplateParmExpr; |
859 | |
860 | unsigned : NumExprBits; |
861 | |
862 | |
863 | SourceLocation NameLoc; |
864 | }; |
865 | |
866 | |
867 | |
868 | class CoawaitExprBitfields { |
869 | friend class CoawaitExpr; |
870 | |
871 | unsigned : NumExprBits; |
872 | |
873 | unsigned IsImplicit : 1; |
874 | }; |
875 | |
876 | |
877 | |
878 | class ObjCIndirectCopyRestoreExprBitfields { |
879 | friend class ObjCIndirectCopyRestoreExpr; |
880 | |
881 | unsigned : NumExprBits; |
882 | |
883 | unsigned ShouldCopy : 1; |
884 | }; |
885 | |
886 | |
887 | |
888 | class OpaqueValueExprBitfields { |
889 | friend class ASTStmtReader; |
890 | friend class OpaqueValueExpr; |
891 | |
892 | unsigned : NumExprBits; |
893 | |
894 | |
895 | |
896 | unsigned IsUnique : 1; |
897 | |
898 | SourceLocation Loc; |
899 | }; |
900 | |
901 | union { |
902 | |
903 | |
904 | StmtBitfields StmtBits; |
905 | NullStmtBitfields NullStmtBits; |
906 | CompoundStmtBitfields CompoundStmtBits; |
907 | LabelStmtBitfields LabelStmtBits; |
908 | AttributedStmtBitfields AttributedStmtBits; |
909 | IfStmtBitfields IfStmtBits; |
910 | SwitchStmtBitfields SwitchStmtBits; |
911 | WhileStmtBitfields WhileStmtBits; |
912 | DoStmtBitfields DoStmtBits; |
913 | ForStmtBitfields ForStmtBits; |
914 | GotoStmtBitfields GotoStmtBits; |
915 | ContinueStmtBitfields ContinueStmtBits; |
916 | BreakStmtBitfields BreakStmtBits; |
917 | ReturnStmtBitfields ReturnStmtBits; |
918 | SwitchCaseBitfields SwitchCaseBits; |
919 | |
920 | |
921 | ExprBitfields ExprBits; |
922 | PredefinedExprBitfields PredefinedExprBits; |
923 | DeclRefExprBitfields DeclRefExprBits; |
924 | FloatingLiteralBitfields FloatingLiteralBits; |
925 | StringLiteralBitfields StringLiteralBits; |
926 | CharacterLiteralBitfields CharacterLiteralBits; |
927 | UnaryOperatorBitfields UnaryOperatorBits; |
928 | UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits; |
929 | ArraySubscriptExprBitfields ArraySubscriptExprBits; |
930 | CallExprBitfields CallExprBits; |
931 | MemberExprBitfields MemberExprBits; |
932 | CastExprBitfields CastExprBits; |
933 | BinaryOperatorBitfields BinaryOperatorBits; |
934 | InitListExprBitfields InitListExprBits; |
935 | ParenListExprBitfields ParenListExprBits; |
936 | GenericSelectionExprBitfields GenericSelectionExprBits; |
937 | PseudoObjectExprBitfields PseudoObjectExprBits; |
938 | |
939 | |
940 | CXXOperatorCallExprBitfields CXXOperatorCallExprBits; |
941 | CXXBoolLiteralExprBitfields CXXBoolLiteralExprBits; |
942 | CXXNullPtrLiteralExprBitfields CXXNullPtrLiteralExprBits; |
943 | CXXThisExprBitfields CXXThisExprBits; |
944 | CXXThrowExprBitfields CXXThrowExprBits; |
945 | CXXDefaultArgExprBitfields CXXDefaultArgExprBits; |
946 | CXXDefaultInitExprBitfields CXXDefaultInitExprBits; |
947 | CXXScalarValueInitExprBitfields CXXScalarValueInitExprBits; |
948 | CXXNewExprBitfields CXXNewExprBits; |
949 | CXXDeleteExprBitfields CXXDeleteExprBits; |
950 | TypeTraitExprBitfields TypeTraitExprBits; |
951 | DependentScopeDeclRefExprBitfields DependentScopeDeclRefExprBits; |
952 | CXXConstructExprBitfields CXXConstructExprBits; |
953 | ExprWithCleanupsBitfields ExprWithCleanupsBits; |
954 | CXXUnresolvedConstructExprBitfields CXXUnresolvedConstructExprBits; |
955 | CXXDependentScopeMemberExprBitfields CXXDependentScopeMemberExprBits; |
956 | OverloadExprBitfields OverloadExprBits; |
957 | UnresolvedLookupExprBitfields UnresolvedLookupExprBits; |
958 | UnresolvedMemberExprBitfields UnresolvedMemberExprBits; |
959 | CXXNoexceptExprBitfields CXXNoexceptExprBits; |
960 | SubstNonTypeTemplateParmExprBitfields SubstNonTypeTemplateParmExprBits; |
961 | |
962 | |
963 | CoawaitExprBitfields CoawaitBits; |
964 | |
965 | |
966 | ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits; |
967 | |
968 | |
969 | OpaqueValueExprBitfields OpaqueValueExprBits; |
970 | }; |
971 | |
972 | public: |
973 | |
974 | |
975 | void* operator new(size_t bytes, const ASTContext& C, |
976 | unsigned alignment = 8); |
977 | |
978 | void* operator new(size_t bytes, const ASTContext* C, |
979 | unsigned alignment = 8) { |
980 | return operator new(bytes, *C, alignment); |
981 | } |
982 | |
983 | void *operator new(size_t bytes, void *mem) noexcept { return mem; } |
984 | |
985 | void operator delete(void *, const ASTContext &, unsigned) noexcept {} |
986 | void operator delete(void *, const ASTContext *, unsigned) noexcept {} |
987 | void operator delete(void *, size_t) noexcept {} |
988 | void operator delete(void *, void *) noexcept {} |
989 | |
990 | public: |
991 | |
992 | |
993 | |
994 | struct EmptyShell {}; |
995 | |
996 | protected: |
997 | |
998 | |
999 | |
1000 | |
1001 | template<typename T, typename TPtr = T *, typename StmtPtr = Stmt *> |
1002 | struct CastIterator |
1003 | : llvm::iterator_adaptor_base<CastIterator<T, TPtr, StmtPtr>, StmtPtr *, |
1004 | std::random_access_iterator_tag, TPtr> { |
1005 | using Base = typename CastIterator::iterator_adaptor_base; |
1006 | |
1007 | CastIterator() : Base(nullptr) {} |
1008 | CastIterator(StmtPtr *I) : Base(I) {} |
1009 | |
1010 | typename Base::value_type operator*() const { |
1011 | return cast<T>(*this->I); |
1012 | } |
1013 | }; |
1014 | |
1015 | |
1016 | template <typename T> |
1017 | using ConstCastIterator = CastIterator<T, const T *const, const Stmt *const>; |
1018 | |
1019 | using ExprIterator = CastIterator<Expr>; |
1020 | using ConstExprIterator = ConstCastIterator<Expr>; |
1021 | |
1022 | private: |
1023 | |
1024 | static bool StatisticsEnabled; |
1025 | |
1026 | protected: |
1027 | |
1028 | explicit Stmt(StmtClass SC, EmptyShell) : Stmt(SC) {} |
1029 | |
1030 | public: |
1031 | Stmt(StmtClass SC) { |
1032 | static_assert(sizeof(*this) <= 8, |
1033 | "changing bitfields changed sizeof(Stmt)"); |
1034 | static_assert(sizeof(*this) % alignof(void *) == 0, |
1035 | "Insufficient alignment!"); |
1036 | StmtBits.sClass = SC; |
1037 | StmtBits.IsOMPStructuredBlock = false; |
1038 | if (StatisticsEnabled) Stmt::addStmtClass(SC); |
1039 | } |
1040 | |
1041 | StmtClass getStmtClass() const { |
1042 | return static_cast<StmtClass>(StmtBits.sClass); |
1043 | } |
1044 | |
1045 | const char *getStmtClassName() const; |
1046 | |
1047 | bool isOMPStructuredBlock() const { return StmtBits.IsOMPStructuredBlock; } |
1048 | void setIsOMPStructuredBlock(bool IsOMPStructuredBlock) { |
1049 | StmtBits.IsOMPStructuredBlock = IsOMPStructuredBlock; |
1050 | } |
1051 | |
1052 | |
1053 | |
1054 | |
1055 | SourceRange getSourceRange() const LLVM_READONLY; |
1056 | SourceLocation getBeginLoc() const LLVM_READONLY; |
1057 | SourceLocation getEndLoc() const LLVM_READONLY; |
1058 | |
1059 | |
1060 | static void addStmtClass(const StmtClass s); |
1061 | static void EnableStatistics(); |
1062 | static void PrintStats(); |
1063 | |
1064 | |
1065 | |
1066 | void dump() const; |
1067 | void dump(SourceManager &SM) const; |
1068 | void dump(raw_ostream &OS, SourceManager &SM) const; |
1069 | void dump(raw_ostream &OS) const; |
1070 | |
1071 | |
1072 | int64_t getID(const ASTContext &Context) const; |
1073 | |
1074 | |
1075 | void dumpColor() const; |
1076 | |
1077 | |
1078 | |
1079 | void dumpPretty(const ASTContext &Context) const; |
1080 | void printPretty(raw_ostream &OS, PrinterHelper *Helper, |
1081 | const PrintingPolicy &Policy, unsigned Indentation = 0, |
1082 | StringRef NewlineSymbol = "\n", |
1083 | const ASTContext *Context = nullptr) const; |
1084 | |
1085 | |
1086 | |
1087 | void viewAST() const; |
1088 | |
1089 | |
1090 | |
1091 | Stmt *IgnoreContainers(bool IgnoreCaptured = false); |
1092 | const Stmt *IgnoreContainers(bool IgnoreCaptured = false) const { |
1093 | return const_cast<Stmt *>(this)->IgnoreContainers(IgnoreCaptured); |
1094 | } |
1095 | |
1096 | const Stmt *stripLabelLikeStatements() const; |
1097 | Stmt *stripLabelLikeStatements() { |
1098 | return const_cast<Stmt*>( |
1099 | const_cast<const Stmt*>(this)->stripLabelLikeStatements()); |
1100 | } |
1101 | |
1102 | |
1103 | |
1104 | |
1105 | using child_iterator = StmtIterator; |
1106 | using const_child_iterator = ConstStmtIterator; |
1107 | |
1108 | using child_range = llvm::iterator_range<child_iterator>; |
1109 | using const_child_range = llvm::iterator_range<const_child_iterator>; |
1110 | |
1111 | child_range children(); |
1112 | |
1113 | const_child_range children() const { |
1114 | auto Children = const_cast<Stmt *>(this)->children(); |
1115 | return const_child_range(Children.begin(), Children.end()); |
1116 | } |
1117 | |
1118 | child_iterator child_begin() { return children().begin(); } |
1119 | child_iterator child_end() { return children().end(); } |
1120 | |
1121 | const_child_iterator child_begin() const { return children().begin(); } |
1122 | const_child_iterator child_end() const { return children().end(); } |
1123 | |
1124 | |
1125 | |
1126 | |
1127 | |
1128 | |
1129 | |
1130 | |
1131 | |
1132 | |
1133 | |
1134 | |
1135 | |
1136 | void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, |
1137 | bool Canonical) const; |
1138 | |
1139 | |
1140 | |
1141 | |
1142 | |
1143 | |
1144 | |
1145 | |
1146 | void ProcessODRHash(llvm::FoldingSetNodeID &ID, ODRHash& Hash) const; |
1147 | }; |
1148 | |
1149 | |
1150 | |
1151 | |
1152 | |
1153 | class DeclStmt : public Stmt { |
1154 | DeclGroupRef DG; |
1155 | SourceLocation StartLoc, EndLoc; |
1156 | |
1157 | public: |
1158 | DeclStmt(DeclGroupRef dg, SourceLocation startLoc, SourceLocation endLoc) |
1159 | : Stmt(DeclStmtClass), DG(dg), StartLoc(startLoc), EndLoc(endLoc) {} |
1160 | |
1161 | |
1162 | explicit DeclStmt(EmptyShell Empty) : Stmt(DeclStmtClass, Empty) {} |
1163 | |
1164 | |
1165 | |
1166 | bool isSingleDecl() const { return DG.isSingleDecl(); } |
1167 | |
1168 | const Decl *getSingleDecl() const { return DG.getSingleDecl(); } |
1169 | Decl *getSingleDecl() { return DG.getSingleDecl(); } |
1170 | |
1171 | const DeclGroupRef getDeclGroup() const { return DG; } |
1172 | DeclGroupRef getDeclGroup() { return DG; } |
1173 | void setDeclGroup(DeclGroupRef DGR) { DG = DGR; } |
1174 | |
1175 | void setStartLoc(SourceLocation L) { StartLoc = L; } |
1176 | SourceLocation getEndLoc() const { return EndLoc; } |
1177 | void setEndLoc(SourceLocation L) { EndLoc = L; } |
1178 | |
1179 | SourceLocation getBeginLoc() const LLVM_READONLY { return StartLoc; } |
1180 | |
1181 | static bool classof(const Stmt *T) { |
1182 | return T->getStmtClass() == DeclStmtClass; |
1183 | } |
1184 | |
1185 | |
1186 | child_range children() { |
1187 | return child_range(child_iterator(DG.begin(), DG.end()), |
1188 | child_iterator(DG.end(), DG.end())); |
1189 | } |
1190 | |
1191 | using decl_iterator = DeclGroupRef::iterator; |
1192 | using const_decl_iterator = DeclGroupRef::const_iterator; |
1193 | using decl_range = llvm::iterator_range<decl_iterator>; |
1194 | using decl_const_range = llvm::iterator_range<const_decl_iterator>; |
1195 | |
1196 | decl_range decls() { return decl_range(decl_begin(), decl_end()); } |
1197 | |
1198 | decl_const_range decls() const { |
1199 | return decl_const_range(decl_begin(), decl_end()); |
1200 | } |
1201 | |
1202 | decl_iterator decl_begin() { return DG.begin(); } |
1203 | decl_iterator decl_end() { return DG.end(); } |
1204 | const_decl_iterator decl_begin() const { return DG.begin(); } |
1205 | const_decl_iterator decl_end() const { return DG.end(); } |
1206 | |
1207 | using reverse_decl_iterator = std::reverse_iterator<decl_iterator>; |
1208 | |
1209 | reverse_decl_iterator decl_rbegin() { |
1210 | return reverse_decl_iterator(decl_end()); |
1211 | } |
1212 | |
1213 | reverse_decl_iterator decl_rend() { |
1214 | return reverse_decl_iterator(decl_begin()); |
1215 | } |
1216 | }; |
1217 | |
1218 | |
1219 | |
1220 | class NullStmt : public Stmt { |
1221 | public: |
1222 | NullStmt(SourceLocation L, bool hasLeadingEmptyMacro = false) |
1223 | : Stmt(NullStmtClass) { |
1224 | NullStmtBits.HasLeadingEmptyMacro = hasLeadingEmptyMacro; |
1225 | setSemiLoc(L); |
1226 | } |
1227 | |
1228 | |
1229 | explicit NullStmt(EmptyShell Empty) : Stmt(NullStmtClass, Empty) {} |
1230 | |
1231 | SourceLocation getSemiLoc() const { return NullStmtBits.SemiLoc; } |
1232 | void setSemiLoc(SourceLocation L) { NullStmtBits.SemiLoc = L; } |
1233 | |
1234 | bool hasLeadingEmptyMacro() const { |
1235 | return NullStmtBits.HasLeadingEmptyMacro; |
1236 | } |
1237 | |
1238 | SourceLocation getBeginLoc() const { return getSemiLoc(); } |
1239 | SourceLocation getEndLoc() const { return getSemiLoc(); } |
1240 | |
1241 | static bool classof(const Stmt *T) { |
1242 | return T->getStmtClass() == NullStmtClass; |
1243 | } |
1244 | |
1245 | child_range children() { |
1246 | return child_range(child_iterator(), child_iterator()); |
1247 | } |
1248 | }; |
1249 | |
1250 | |
1251 | class CompoundStmt final : public Stmt, |
1252 | private llvm::TrailingObjects<CompoundStmt, Stmt *> { |
1253 | friend class ASTStmtReader; |
1254 | friend TrailingObjects; |
1255 | |
1256 | |
1257 | SourceLocation RBraceLoc; |
1258 | |
1259 | CompoundStmt(ArrayRef<Stmt *> Stmts, SourceLocation LB, SourceLocation RB); |
1260 | explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {} |
1261 | |
1262 | void setStmts(ArrayRef<Stmt *> Stmts); |
1263 | |
1264 | public: |
1265 | static CompoundStmt *Create(const ASTContext &C, ArrayRef<Stmt *> Stmts, |
1266 | SourceLocation LB, SourceLocation RB); |
1267 | |
1268 | |
1269 | explicit CompoundStmt(SourceLocation Loc) |
1270 | : Stmt(CompoundStmtClass), RBraceLoc(Loc) { |
1271 | CompoundStmtBits.NumStmts = 0; |
1272 | CompoundStmtBits.LBraceLoc = Loc; |
1273 | } |
1274 | |
1275 | |
1276 | static CompoundStmt *CreateEmpty(const ASTContext &C, unsigned NumStmts); |
1277 | |
1278 | bool body_empty() const { return CompoundStmtBits.NumStmts == 0; } |
1279 | unsigned size() const { return CompoundStmtBits.NumStmts; } |
1280 | |
1281 | using body_iterator = Stmt **; |
1282 | using body_range = llvm::iterator_range<body_iterator>; |
1283 | |
1284 | body_range body() { return body_range(body_begin(), body_end()); } |
1285 | body_iterator body_begin() { return getTrailingObjects<Stmt *>(); } |
1286 | body_iterator body_end() { return body_begin() + size(); } |
1287 | Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; } |
1288 | |
1289 | Stmt *body_back() { |
1290 | return !body_empty() ? body_begin()[size() - 1] : nullptr; |
1291 | } |
1292 | |
1293 | void setLastStmt(Stmt *S) { |
1294 | (0) . __assert_fail ("!body_empty() && \"setLastStmt\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1294, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!body_empty() && "setLastStmt"); |
1295 | body_begin()[size() - 1] = S; |
1296 | } |
1297 | |
1298 | using const_body_iterator = Stmt *const *; |
1299 | using body_const_range = llvm::iterator_range<const_body_iterator>; |
1300 | |
1301 | body_const_range body() const { |
1302 | return body_const_range(body_begin(), body_end()); |
1303 | } |
1304 | |
1305 | const_body_iterator body_begin() const { |
1306 | return getTrailingObjects<Stmt *>(); |
1307 | } |
1308 | |
1309 | const_body_iterator body_end() const { return body_begin() + size(); } |
1310 | |
1311 | const Stmt *body_front() const { |
1312 | return !body_empty() ? body_begin()[0] : nullptr; |
1313 | } |
1314 | |
1315 | const Stmt *body_back() const { |
1316 | return !body_empty() ? body_begin()[size() - 1] : nullptr; |
1317 | } |
1318 | |
1319 | using reverse_body_iterator = std::reverse_iterator<body_iterator>; |
1320 | |
1321 | reverse_body_iterator body_rbegin() { |
1322 | return reverse_body_iterator(body_end()); |
1323 | } |
1324 | |
1325 | reverse_body_iterator body_rend() { |
1326 | return reverse_body_iterator(body_begin()); |
1327 | } |
1328 | |
1329 | using const_reverse_body_iterator = |
1330 | std::reverse_iterator<const_body_iterator>; |
1331 | |
1332 | const_reverse_body_iterator body_rbegin() const { |
1333 | return const_reverse_body_iterator(body_end()); |
1334 | } |
1335 | |
1336 | const_reverse_body_iterator body_rend() const { |
1337 | return const_reverse_body_iterator(body_begin()); |
1338 | } |
1339 | |
1340 | SourceLocation getBeginLoc() const { return CompoundStmtBits.LBraceLoc; } |
1341 | SourceLocation getEndLoc() const { return RBraceLoc; } |
1342 | |
1343 | SourceLocation getLBracLoc() const { return CompoundStmtBits.LBraceLoc; } |
1344 | SourceLocation getRBracLoc() const { return RBraceLoc; } |
1345 | |
1346 | static bool classof(const Stmt *T) { |
1347 | return T->getStmtClass() == CompoundStmtClass; |
1348 | } |
1349 | |
1350 | |
1351 | child_range children() { return child_range(body_begin(), body_end()); } |
1352 | |
1353 | const_child_range children() const { |
1354 | return const_child_range(body_begin(), body_end()); |
1355 | } |
1356 | }; |
1357 | |
1358 | |
1359 | class SwitchCase : public Stmt { |
1360 | protected: |
1361 | |
1362 | SourceLocation ColonLoc; |
1363 | |
1364 | |
1365 | |
1366 | |
1367 | |
1368 | |
1369 | SwitchCase *NextSwitchCase = nullptr; |
1370 | |
1371 | SwitchCase(StmtClass SC, SourceLocation KWLoc, SourceLocation ColonLoc) |
1372 | : Stmt(SC), ColonLoc(ColonLoc) { |
1373 | setKeywordLoc(KWLoc); |
1374 | } |
1375 | |
1376 | SwitchCase(StmtClass SC, EmptyShell) : Stmt(SC) {} |
1377 | |
1378 | public: |
1379 | const SwitchCase *getNextSwitchCase() const { return NextSwitchCase; } |
1380 | SwitchCase *getNextSwitchCase() { return NextSwitchCase; } |
1381 | void setNextSwitchCase(SwitchCase *SC) { NextSwitchCase = SC; } |
1382 | |
1383 | SourceLocation getKeywordLoc() const { return SwitchCaseBits.KeywordLoc; } |
1384 | void setKeywordLoc(SourceLocation L) { SwitchCaseBits.KeywordLoc = L; } |
1385 | SourceLocation getColonLoc() const { return ColonLoc; } |
1386 | void setColonLoc(SourceLocation L) { ColonLoc = L; } |
1387 | |
1388 | inline Stmt *getSubStmt(); |
1389 | const Stmt *getSubStmt() const { |
1390 | return const_cast<SwitchCase *>(this)->getSubStmt(); |
1391 | } |
1392 | |
1393 | SourceLocation getBeginLoc() const { return getKeywordLoc(); } |
1394 | inline SourceLocation getEndLoc() const LLVM_READONLY; |
1395 | |
1396 | static bool classof(const Stmt *T) { |
1397 | return T->getStmtClass() == CaseStmtClass || |
1398 | T->getStmtClass() == DefaultStmtClass; |
1399 | } |
1400 | }; |
1401 | |
1402 | |
1403 | |
1404 | class CaseStmt final |
1405 | : public SwitchCase, |
1406 | private llvm::TrailingObjects<CaseStmt, Stmt *, SourceLocation> { |
1407 | friend TrailingObjects; |
1408 | |
1409 | |
1410 | |
1411 | |
1412 | |
1413 | |
1414 | |
1415 | |
1416 | |
1417 | |
1418 | |
1419 | |
1420 | |
1421 | |
1422 | |
1423 | |
1424 | enum { LhsOffset = 0, SubStmtOffsetFromRhs = 1 }; |
1425 | enum { NumMandatoryStmtPtr = 2 }; |
1426 | |
1427 | unsigned numTrailingObjects(OverloadToken<Stmt *>) const { |
1428 | return NumMandatoryStmtPtr + caseStmtIsGNURange(); |
1429 | } |
1430 | |
1431 | unsigned numTrailingObjects(OverloadToken<SourceLocation>) const { |
1432 | return caseStmtIsGNURange(); |
1433 | } |
1434 | |
1435 | unsigned lhsOffset() const { return LhsOffset; } |
1436 | unsigned rhsOffset() const { return LhsOffset + caseStmtIsGNURange(); } |
1437 | unsigned subStmtOffset() const { return rhsOffset() + SubStmtOffsetFromRhs; } |
1438 | |
1439 | |
1440 | |
1441 | CaseStmt(Expr *lhs, Expr *rhs, SourceLocation caseLoc, |
1442 | SourceLocation ellipsisLoc, SourceLocation colonLoc) |
1443 | : SwitchCase(CaseStmtClass, caseLoc, colonLoc) { |
1444 | |
1445 | bool IsGNURange = rhs != nullptr; |
1446 | SwitchCaseBits.CaseStmtIsGNURange = IsGNURange; |
1447 | setLHS(lhs); |
1448 | setSubStmt(nullptr); |
1449 | if (IsGNURange) { |
1450 | setRHS(rhs); |
1451 | setEllipsisLoc(ellipsisLoc); |
1452 | } |
1453 | } |
1454 | |
1455 | |
1456 | explicit CaseStmt(EmptyShell Empty, bool CaseStmtIsGNURange) |
1457 | : SwitchCase(CaseStmtClass, Empty) { |
1458 | SwitchCaseBits.CaseStmtIsGNURange = CaseStmtIsGNURange; |
1459 | } |
1460 | |
1461 | public: |
1462 | |
1463 | static CaseStmt *Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, |
1464 | SourceLocation caseLoc, SourceLocation ellipsisLoc, |
1465 | SourceLocation colonLoc); |
1466 | |
1467 | |
1468 | static CaseStmt *CreateEmpty(const ASTContext &Ctx, bool CaseStmtIsGNURange); |
1469 | |
1470 | |
1471 | |
1472 | |
1473 | bool caseStmtIsGNURange() const { return SwitchCaseBits.CaseStmtIsGNURange; } |
1474 | |
1475 | SourceLocation getCaseLoc() const { return getKeywordLoc(); } |
1476 | void setCaseLoc(SourceLocation L) { setKeywordLoc(L); } |
1477 | |
1478 | |
1479 | SourceLocation getEllipsisLoc() const { |
1480 | return caseStmtIsGNURange() ? *getTrailingObjects<SourceLocation>() |
1481 | : SourceLocation(); |
1482 | } |
1483 | |
1484 | |
1485 | |
1486 | void setEllipsisLoc(SourceLocation L) { |
1487 | (0) . __assert_fail ("caseStmtIsGNURange() && \"setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1489, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert( |
1488 | (0) . __assert_fail ("caseStmtIsGNURange() && \"setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1489, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> caseStmtIsGNURange() && |
1489 | (0) . __assert_fail ("caseStmtIsGNURange() && \"setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1489, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "setEllipsisLoc but this is not a case stmt of the form LHS ... RHS!"); |
1490 | *getTrailingObjects<SourceLocation>() = L; |
1491 | } |
1492 | |
1493 | Expr *getLHS() { |
1494 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]); |
1495 | } |
1496 | |
1497 | const Expr *getLHS() const { |
1498 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[lhsOffset()]); |
1499 | } |
1500 | |
1501 | void setLHS(Expr *Val) { |
1502 | getTrailingObjects<Stmt *>()[lhsOffset()] = reinterpret_cast<Stmt *>(Val); |
1503 | } |
1504 | |
1505 | Expr *getRHS() { |
1506 | return caseStmtIsGNURange() ? reinterpret_cast<Expr *>( |
1507 | getTrailingObjects<Stmt *>()[rhsOffset()]) |
1508 | : nullptr; |
1509 | } |
1510 | |
1511 | const Expr *getRHS() const { |
1512 | return caseStmtIsGNURange() ? reinterpret_cast<Expr *>( |
1513 | getTrailingObjects<Stmt *>()[rhsOffset()]) |
1514 | : nullptr; |
1515 | } |
1516 | |
1517 | void setRHS(Expr *Val) { |
1518 | (0) . __assert_fail ("caseStmtIsGNURange() && \"setRHS but this is not a case stmt of the form LHS ... RHS!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1519, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(caseStmtIsGNURange() && |
1519 | (0) . __assert_fail ("caseStmtIsGNURange() && \"setRHS but this is not a case stmt of the form LHS ... RHS!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1519, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "setRHS but this is not a case stmt of the form LHS ... RHS!"); |
1520 | getTrailingObjects<Stmt *>()[rhsOffset()] = reinterpret_cast<Stmt *>(Val); |
1521 | } |
1522 | |
1523 | Stmt *getSubStmt() { return getTrailingObjects<Stmt *>()[subStmtOffset()]; } |
1524 | const Stmt *getSubStmt() const { |
1525 | return getTrailingObjects<Stmt *>()[subStmtOffset()]; |
1526 | } |
1527 | |
1528 | void setSubStmt(Stmt *S) { |
1529 | getTrailingObjects<Stmt *>()[subStmtOffset()] = S; |
1530 | } |
1531 | |
1532 | SourceLocation getBeginLoc() const { return getKeywordLoc(); } |
1533 | SourceLocation getEndLoc() const LLVM_READONLY { |
1534 | |
1535 | const CaseStmt *CS = this; |
1536 | while (const auto *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt())) |
1537 | CS = CS2; |
1538 | |
1539 | return CS->getSubStmt()->getEndLoc(); |
1540 | } |
1541 | |
1542 | static bool classof(const Stmt *T) { |
1543 | return T->getStmtClass() == CaseStmtClass; |
1544 | } |
1545 | |
1546 | |
1547 | child_range children() { |
1548 | return child_range(getTrailingObjects<Stmt *>(), |
1549 | getTrailingObjects<Stmt *>() + |
1550 | numTrailingObjects(OverloadToken<Stmt *>())); |
1551 | } |
1552 | }; |
1553 | |
1554 | class DefaultStmt : public SwitchCase { |
1555 | Stmt *SubStmt; |
1556 | |
1557 | public: |
1558 | DefaultStmt(SourceLocation DL, SourceLocation CL, Stmt *substmt) |
1559 | : SwitchCase(DefaultStmtClass, DL, CL), SubStmt(substmt) {} |
1560 | |
1561 | |
1562 | explicit DefaultStmt(EmptyShell Empty) |
1563 | : SwitchCase(DefaultStmtClass, Empty) {} |
1564 | |
1565 | Stmt *getSubStmt() { return SubStmt; } |
1566 | const Stmt *getSubStmt() const { return SubStmt; } |
1567 | void setSubStmt(Stmt *S) { SubStmt = S; } |
1568 | |
1569 | SourceLocation getDefaultLoc() const { return getKeywordLoc(); } |
1570 | void setDefaultLoc(SourceLocation L) { setKeywordLoc(L); } |
1571 | |
1572 | SourceLocation getBeginLoc() const { return getKeywordLoc(); } |
1573 | SourceLocation getEndLoc() const LLVM_READONLY { |
1574 | return SubStmt->getEndLoc(); |
1575 | } |
1576 | |
1577 | static bool classof(const Stmt *T) { |
1578 | return T->getStmtClass() == DefaultStmtClass; |
1579 | } |
1580 | |
1581 | |
1582 | child_range children() { return child_range(&SubStmt, &SubStmt + 1); } |
1583 | }; |
1584 | |
1585 | SourceLocation SwitchCase::getEndLoc() const { |
1586 | if (const auto *CS = dyn_cast<CaseStmt>(this)) |
1587 | return CS->getEndLoc(); |
1588 | else if (const auto *DS = dyn_cast<DefaultStmt>(this)) |
1589 | return DS->getEndLoc(); |
1590 | llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!"); |
1591 | } |
1592 | |
1593 | Stmt *SwitchCase::getSubStmt() { |
1594 | if (auto *CS = dyn_cast<CaseStmt>(this)) |
1595 | return CS->getSubStmt(); |
1596 | else if (auto *DS = dyn_cast<DefaultStmt>(this)) |
1597 | return DS->getSubStmt(); |
1598 | llvm_unreachable("SwitchCase is neither a CaseStmt nor a DefaultStmt!"); |
1599 | } |
1600 | |
1601 | |
1602 | |
1603 | |
1604 | |
1605 | |
1606 | |
1607 | class ValueStmt : public Stmt { |
1608 | protected: |
1609 | using Stmt::Stmt; |
1610 | |
1611 | public: |
1612 | const Expr *getExprStmt() const; |
1613 | Expr *getExprStmt() { |
1614 | const ValueStmt *ConstThis = this; |
1615 | return const_cast<Expr*>(ConstThis->getExprStmt()); |
1616 | } |
1617 | |
1618 | static bool classof(const Stmt *T) { |
1619 | return T->getStmtClass() >= firstValueStmtConstant && |
1620 | T->getStmtClass() <= lastValueStmtConstant; |
1621 | } |
1622 | }; |
1623 | |
1624 | |
1625 | |
1626 | class LabelStmt : public ValueStmt { |
1627 | LabelDecl *TheDecl; |
1628 | Stmt *SubStmt; |
1629 | |
1630 | public: |
1631 | |
1632 | LabelStmt(SourceLocation IL, LabelDecl *D, Stmt *substmt) |
1633 | : ValueStmt(LabelStmtClass), TheDecl(D), SubStmt(substmt) { |
1634 | setIdentLoc(IL); |
1635 | } |
1636 | |
1637 | |
1638 | explicit LabelStmt(EmptyShell Empty) : ValueStmt(LabelStmtClass, Empty) {} |
1639 | |
1640 | SourceLocation getIdentLoc() const { return LabelStmtBits.IdentLoc; } |
1641 | void setIdentLoc(SourceLocation L) { LabelStmtBits.IdentLoc = L; } |
1642 | |
1643 | LabelDecl *getDecl() const { return TheDecl; } |
1644 | void setDecl(LabelDecl *D) { TheDecl = D; } |
1645 | |
1646 | const char *getName() const; |
1647 | Stmt *getSubStmt() { return SubStmt; } |
1648 | |
1649 | const Stmt *getSubStmt() const { return SubStmt; } |
1650 | void setSubStmt(Stmt *SS) { SubStmt = SS; } |
1651 | |
1652 | SourceLocation getBeginLoc() const { return getIdentLoc(); } |
1653 | SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();} |
1654 | |
1655 | child_range children() { return child_range(&SubStmt, &SubStmt + 1); } |
1656 | |
1657 | static bool classof(const Stmt *T) { |
1658 | return T->getStmtClass() == LabelStmtClass; |
1659 | } |
1660 | }; |
1661 | |
1662 | |
1663 | |
1664 | |
1665 | |
1666 | class AttributedStmt final |
1667 | : public ValueStmt, |
1668 | private llvm::TrailingObjects<AttributedStmt, const Attr *> { |
1669 | friend class ASTStmtReader; |
1670 | friend TrailingObjects; |
1671 | |
1672 | Stmt *SubStmt; |
1673 | |
1674 | AttributedStmt(SourceLocation Loc, ArrayRef<const Attr *> Attrs, |
1675 | Stmt *SubStmt) |
1676 | : ValueStmt(AttributedStmtClass), SubStmt(SubStmt) { |
1677 | AttributedStmtBits.NumAttrs = Attrs.size(); |
1678 | AttributedStmtBits.AttrLoc = Loc; |
1679 | std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr()); |
1680 | } |
1681 | |
1682 | explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs) |
1683 | : ValueStmt(AttributedStmtClass, Empty) { |
1684 | AttributedStmtBits.NumAttrs = NumAttrs; |
1685 | AttributedStmtBits.AttrLoc = SourceLocation{}; |
1686 | std::fill_n(getAttrArrayPtr(), NumAttrs, nullptr); |
1687 | } |
1688 | |
1689 | const Attr *const *getAttrArrayPtr() const { |
1690 | return getTrailingObjects<const Attr *>(); |
1691 | } |
1692 | const Attr **getAttrArrayPtr() { return getTrailingObjects<const Attr *>(); } |
1693 | |
1694 | public: |
1695 | static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc, |
1696 | ArrayRef<const Attr *> Attrs, Stmt *SubStmt); |
1697 | |
1698 | |
1699 | static AttributedStmt *CreateEmpty(const ASTContext &C, unsigned NumAttrs); |
1700 | |
1701 | SourceLocation getAttrLoc() const { return AttributedStmtBits.AttrLoc; } |
1702 | ArrayRef<const Attr *> getAttrs() const { |
1703 | return llvm::makeArrayRef(getAttrArrayPtr(), AttributedStmtBits.NumAttrs); |
1704 | } |
1705 | |
1706 | Stmt *getSubStmt() { return SubStmt; } |
1707 | const Stmt *getSubStmt() const { return SubStmt; } |
1708 | |
1709 | SourceLocation getBeginLoc() const { return getAttrLoc(); } |
1710 | SourceLocation getEndLoc() const LLVM_READONLY { return SubStmt->getEndLoc();} |
1711 | |
1712 | child_range children() { return child_range(&SubStmt, &SubStmt + 1); } |
1713 | |
1714 | static bool classof(const Stmt *T) { |
1715 | return T->getStmtClass() == AttributedStmtClass; |
1716 | } |
1717 | }; |
1718 | |
1719 | |
1720 | class IfStmt final |
1721 | : public Stmt, |
1722 | private llvm::TrailingObjects<IfStmt, Stmt *, SourceLocation> { |
1723 | friend TrailingObjects; |
1724 | |
1725 | |
1726 | |
1727 | |
1728 | |
1729 | |
1730 | |
1731 | |
1732 | |
1733 | |
1734 | |
1735 | |
1736 | |
1737 | |
1738 | |
1739 | |
1740 | |
1741 | |
1742 | |
1743 | |
1744 | |
1745 | |
1746 | |
1747 | enum { InitOffset = 0, ThenOffsetFromCond = 1, ElseOffsetFromCond = 2 }; |
1748 | enum { NumMandatoryStmtPtr = 2 }; |
1749 | |
1750 | unsigned numTrailingObjects(OverloadToken<Stmt *>) const { |
1751 | return NumMandatoryStmtPtr + hasElseStorage() + hasVarStorage() + |
1752 | hasInitStorage(); |
1753 | } |
1754 | |
1755 | unsigned numTrailingObjects(OverloadToken<SourceLocation>) const { |
1756 | return hasElseStorage(); |
1757 | } |
1758 | |
1759 | unsigned initOffset() const { return InitOffset; } |
1760 | unsigned varOffset() const { return InitOffset + hasInitStorage(); } |
1761 | unsigned condOffset() const { |
1762 | return InitOffset + hasInitStorage() + hasVarStorage(); |
1763 | } |
1764 | unsigned thenOffset() const { return condOffset() + ThenOffsetFromCond; } |
1765 | unsigned elseOffset() const { return condOffset() + ElseOffsetFromCond; } |
1766 | |
1767 | |
1768 | IfStmt(const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init, |
1769 | VarDecl *Var, Expr *Cond, Stmt *Then, SourceLocation EL, Stmt *Else); |
1770 | |
1771 | |
1772 | explicit IfStmt(EmptyShell Empty, bool HasElse, bool HasVar, bool HasInit); |
1773 | |
1774 | public: |
1775 | |
1776 | static IfStmt *Create(const ASTContext &Ctx, SourceLocation IL, |
1777 | bool IsConstexpr, Stmt *Init, VarDecl *Var, Expr *Cond, |
1778 | Stmt *Then, SourceLocation EL = SourceLocation(), |
1779 | Stmt *Else = nullptr); |
1780 | |
1781 | |
1782 | |
1783 | static IfStmt *CreateEmpty(const ASTContext &Ctx, bool HasElse, bool HasVar, |
1784 | bool HasInit); |
1785 | |
1786 | |
1787 | bool hasInitStorage() const { return IfStmtBits.HasInit; } |
1788 | |
1789 | |
1790 | bool hasVarStorage() const { return IfStmtBits.HasVar; } |
1791 | |
1792 | |
1793 | bool hasElseStorage() const { return IfStmtBits.HasElse; } |
1794 | |
1795 | Expr *getCond() { |
1796 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]); |
1797 | } |
1798 | |
1799 | const Expr *getCond() const { |
1800 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]); |
1801 | } |
1802 | |
1803 | void setCond(Expr *Cond) { |
1804 | getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond); |
1805 | } |
1806 | |
1807 | Stmt *getThen() { return getTrailingObjects<Stmt *>()[thenOffset()]; } |
1808 | const Stmt *getThen() const { |
1809 | return getTrailingObjects<Stmt *>()[thenOffset()]; |
1810 | } |
1811 | |
1812 | void setThen(Stmt *Then) { |
1813 | getTrailingObjects<Stmt *>()[thenOffset()] = Then; |
1814 | } |
1815 | |
1816 | Stmt *getElse() { |
1817 | return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()] |
1818 | : nullptr; |
1819 | } |
1820 | |
1821 | const Stmt *getElse() const { |
1822 | return hasElseStorage() ? getTrailingObjects<Stmt *>()[elseOffset()] |
1823 | : nullptr; |
1824 | } |
1825 | |
1826 | void setElse(Stmt *Else) { |
1827 | (0) . __assert_fail ("hasElseStorage() && \"This if statement has no storage for an else statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1828, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasElseStorage() && |
1828 | (0) . __assert_fail ("hasElseStorage() && \"This if statement has no storage for an else statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1828, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "This if statement has no storage for an else statement!"); |
1829 | getTrailingObjects<Stmt *>()[elseOffset()] = Else; |
1830 | } |
1831 | |
1832 | |
1833 | |
1834 | |
1835 | |
1836 | |
1837 | |
1838 | |
1839 | |
1840 | VarDecl *getConditionVariable(); |
1841 | const VarDecl *getConditionVariable() const { |
1842 | return const_cast<IfStmt *>(this)->getConditionVariable(); |
1843 | } |
1844 | |
1845 | |
1846 | |
1847 | void setConditionVariable(const ASTContext &Ctx, VarDecl *V); |
1848 | |
1849 | |
1850 | |
1851 | DeclStmt *getConditionVariableDeclStmt() { |
1852 | return hasVarStorage() ? static_cast<DeclStmt *>( |
1853 | getTrailingObjects<Stmt *>()[varOffset()]) |
1854 | : nullptr; |
1855 | } |
1856 | |
1857 | const DeclStmt *getConditionVariableDeclStmt() const { |
1858 | return hasVarStorage() ? static_cast<DeclStmt *>( |
1859 | getTrailingObjects<Stmt *>()[varOffset()]) |
1860 | : nullptr; |
1861 | } |
1862 | |
1863 | Stmt *getInit() { |
1864 | return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()] |
1865 | : nullptr; |
1866 | } |
1867 | |
1868 | const Stmt *getInit() const { |
1869 | return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()] |
1870 | : nullptr; |
1871 | } |
1872 | |
1873 | void setInit(Stmt *Init) { |
1874 | (0) . __assert_fail ("hasInitStorage() && \"This if statement has no storage for an init statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1875, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasInitStorage() && |
1875 | (0) . __assert_fail ("hasInitStorage() && \"This if statement has no storage for an init statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1875, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "This if statement has no storage for an init statement!"); |
1876 | getTrailingObjects<Stmt *>()[initOffset()] = Init; |
1877 | } |
1878 | |
1879 | SourceLocation getIfLoc() const { return IfStmtBits.IfLoc; } |
1880 | void setIfLoc(SourceLocation IfLoc) { IfStmtBits.IfLoc = IfLoc; } |
1881 | |
1882 | SourceLocation getElseLoc() const { |
1883 | return hasElseStorage() ? *getTrailingObjects<SourceLocation>() |
1884 | : SourceLocation(); |
1885 | } |
1886 | |
1887 | void setElseLoc(SourceLocation ElseLoc) { |
1888 | (0) . __assert_fail ("hasElseStorage() && \"This if statement has no storage for an else statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1889, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasElseStorage() && |
1889 | (0) . __assert_fail ("hasElseStorage() && \"This if statement has no storage for an else statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 1889, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "This if statement has no storage for an else statement!"); |
1890 | *getTrailingObjects<SourceLocation>() = ElseLoc; |
1891 | } |
1892 | |
1893 | bool isConstexpr() const { return IfStmtBits.IsConstexpr; } |
1894 | void setConstexpr(bool C) { IfStmtBits.IsConstexpr = C; } |
1895 | |
1896 | bool isObjCAvailabilityCheck() const; |
1897 | |
1898 | SourceLocation getBeginLoc() const { return getIfLoc(); } |
1899 | SourceLocation getEndLoc() const LLVM_READONLY { |
1900 | if (getElse()) |
1901 | return getElse()->getEndLoc(); |
1902 | return getThen()->getEndLoc(); |
1903 | } |
1904 | |
1905 | |
1906 | |
1907 | child_range children() { |
1908 | return child_range(getTrailingObjects<Stmt *>(), |
1909 | getTrailingObjects<Stmt *>() + |
1910 | numTrailingObjects(OverloadToken<Stmt *>())); |
1911 | } |
1912 | |
1913 | static bool classof(const Stmt *T) { |
1914 | return T->getStmtClass() == IfStmtClass; |
1915 | } |
1916 | }; |
1917 | |
1918 | |
1919 | class SwitchStmt final : public Stmt, |
1920 | private llvm::TrailingObjects<SwitchStmt, Stmt *> { |
1921 | friend TrailingObjects; |
1922 | |
1923 | |
1924 | SwitchCase *FirstCase; |
1925 | |
1926 | |
1927 | |
1928 | |
1929 | |
1930 | |
1931 | |
1932 | |
1933 | |
1934 | |
1935 | |
1936 | |
1937 | |
1938 | |
1939 | |
1940 | |
1941 | |
1942 | |
1943 | enum { InitOffset = 0, BodyOffsetFromCond = 1 }; |
1944 | enum { NumMandatoryStmtPtr = 2 }; |
1945 | |
1946 | unsigned numTrailingObjects(OverloadToken<Stmt *>) const { |
1947 | return NumMandatoryStmtPtr + hasInitStorage() + hasVarStorage(); |
1948 | } |
1949 | |
1950 | unsigned initOffset() const { return InitOffset; } |
1951 | unsigned varOffset() const { return InitOffset + hasInitStorage(); } |
1952 | unsigned condOffset() const { |
1953 | return InitOffset + hasInitStorage() + hasVarStorage(); |
1954 | } |
1955 | unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; } |
1956 | |
1957 | |
1958 | SwitchStmt(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond); |
1959 | |
1960 | |
1961 | explicit SwitchStmt(EmptyShell Empty, bool HasInit, bool HasVar); |
1962 | |
1963 | public: |
1964 | |
1965 | static SwitchStmt *Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, |
1966 | Expr *Cond); |
1967 | |
1968 | |
1969 | |
1970 | static SwitchStmt *CreateEmpty(const ASTContext &Ctx, bool HasInit, |
1971 | bool HasVar); |
1972 | |
1973 | |
1974 | bool hasInitStorage() const { return SwitchStmtBits.HasInit; } |
1975 | |
1976 | |
1977 | bool hasVarStorage() const { return SwitchStmtBits.HasVar; } |
1978 | |
1979 | Expr *getCond() { |
1980 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]); |
1981 | } |
1982 | |
1983 | const Expr *getCond() const { |
1984 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]); |
1985 | } |
1986 | |
1987 | void setCond(Expr *Cond) { |
1988 | getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond); |
1989 | } |
1990 | |
1991 | Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; } |
1992 | const Stmt *getBody() const { |
1993 | return getTrailingObjects<Stmt *>()[bodyOffset()]; |
1994 | } |
1995 | |
1996 | void setBody(Stmt *Body) { |
1997 | getTrailingObjects<Stmt *>()[bodyOffset()] = Body; |
1998 | } |
1999 | |
2000 | Stmt *getInit() { |
2001 | return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()] |
2002 | : nullptr; |
2003 | } |
2004 | |
2005 | const Stmt *getInit() const { |
2006 | return hasInitStorage() ? getTrailingObjects<Stmt *>()[initOffset()] |
2007 | : nullptr; |
2008 | } |
2009 | |
2010 | void setInit(Stmt *Init) { |
2011 | (0) . __assert_fail ("hasInitStorage() && \"This switch statement has no storage for an init statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2012, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasInitStorage() && |
2012 | (0) . __assert_fail ("hasInitStorage() && \"This switch statement has no storage for an init statement!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2012, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "This switch statement has no storage for an init statement!"); |
2013 | getTrailingObjects<Stmt *>()[initOffset()] = Init; |
2014 | } |
2015 | |
2016 | |
2017 | |
2018 | |
2019 | |
2020 | |
2021 | |
2022 | |
2023 | |
2024 | |
2025 | VarDecl *getConditionVariable(); |
2026 | const VarDecl *getConditionVariable() const { |
2027 | return const_cast<SwitchStmt *>(this)->getConditionVariable(); |
2028 | } |
2029 | |
2030 | |
2031 | |
2032 | void setConditionVariable(const ASTContext &Ctx, VarDecl *VD); |
2033 | |
2034 | |
2035 | |
2036 | DeclStmt *getConditionVariableDeclStmt() { |
2037 | return hasVarStorage() ? static_cast<DeclStmt *>( |
2038 | getTrailingObjects<Stmt *>()[varOffset()]) |
2039 | : nullptr; |
2040 | } |
2041 | |
2042 | const DeclStmt *getConditionVariableDeclStmt() const { |
2043 | return hasVarStorage() ? static_cast<DeclStmt *>( |
2044 | getTrailingObjects<Stmt *>()[varOffset()]) |
2045 | : nullptr; |
2046 | } |
2047 | |
2048 | SwitchCase *getSwitchCaseList() { return FirstCase; } |
2049 | const SwitchCase *getSwitchCaseList() const { return FirstCase; } |
2050 | void setSwitchCaseList(SwitchCase *SC) { FirstCase = SC; } |
2051 | |
2052 | SourceLocation getSwitchLoc() const { return SwitchStmtBits.SwitchLoc; } |
2053 | void setSwitchLoc(SourceLocation L) { SwitchStmtBits.SwitchLoc = L; } |
2054 | |
2055 | void setBody(Stmt *S, SourceLocation SL) { |
2056 | setBody(S); |
2057 | setSwitchLoc(SL); |
2058 | } |
2059 | |
2060 | void addSwitchCase(SwitchCase *SC) { |
2061 | (0) . __assert_fail ("!SC->getNextSwitchCase() && \"case/default already added to a switch\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2062, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!SC->getNextSwitchCase() && |
2062 | (0) . __assert_fail ("!SC->getNextSwitchCase() && \"case/default already added to a switch\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2062, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "case/default already added to a switch"); |
2063 | SC->setNextSwitchCase(FirstCase); |
2064 | FirstCase = SC; |
2065 | } |
2066 | |
2067 | |
2068 | |
2069 | void setAllEnumCasesCovered() { SwitchStmtBits.AllEnumCasesCovered = true; } |
2070 | |
2071 | |
2072 | |
2073 | bool isAllEnumCasesCovered() const { |
2074 | return SwitchStmtBits.AllEnumCasesCovered; |
2075 | } |
2076 | |
2077 | SourceLocation getBeginLoc() const { return getSwitchLoc(); } |
2078 | SourceLocation getEndLoc() const LLVM_READONLY { |
2079 | return getBody() ? getBody()->getEndLoc() |
2080 | : reinterpret_cast<const Stmt *>(getCond())->getEndLoc(); |
2081 | } |
2082 | |
2083 | |
2084 | child_range children() { |
2085 | return child_range(getTrailingObjects<Stmt *>(), |
2086 | getTrailingObjects<Stmt *>() + |
2087 | numTrailingObjects(OverloadToken<Stmt *>())); |
2088 | } |
2089 | |
2090 | static bool classof(const Stmt *T) { |
2091 | return T->getStmtClass() == SwitchStmtClass; |
2092 | } |
2093 | }; |
2094 | |
2095 | |
2096 | class WhileStmt final : public Stmt, |
2097 | private llvm::TrailingObjects<WhileStmt, Stmt *> { |
2098 | friend TrailingObjects; |
2099 | |
2100 | |
2101 | |
2102 | |
2103 | |
2104 | |
2105 | |
2106 | |
2107 | |
2108 | |
2109 | |
2110 | |
2111 | |
2112 | |
2113 | |
2114 | |
2115 | enum { VarOffset = 0, BodyOffsetFromCond = 1 }; |
2116 | enum { NumMandatoryStmtPtr = 2 }; |
2117 | |
2118 | unsigned varOffset() const { return VarOffset; } |
2119 | unsigned condOffset() const { return VarOffset + hasVarStorage(); } |
2120 | unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; } |
2121 | |
2122 | unsigned numTrailingObjects(OverloadToken<Stmt *>) const { |
2123 | return NumMandatoryStmtPtr + hasVarStorage(); |
2124 | } |
2125 | |
2126 | |
2127 | WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, |
2128 | SourceLocation WL); |
2129 | |
2130 | |
2131 | explicit WhileStmt(EmptyShell Empty, bool HasVar); |
2132 | |
2133 | public: |
2134 | |
2135 | static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, |
2136 | Stmt *Body, SourceLocation WL); |
2137 | |
2138 | |
2139 | |
2140 | static WhileStmt *CreateEmpty(const ASTContext &Ctx, bool HasVar); |
2141 | |
2142 | |
2143 | bool hasVarStorage() const { return WhileStmtBits.HasVar; } |
2144 | |
2145 | Expr *getCond() { |
2146 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]); |
2147 | } |
2148 | |
2149 | const Expr *getCond() const { |
2150 | return reinterpret_cast<Expr *>(getTrailingObjects<Stmt *>()[condOffset()]); |
2151 | } |
2152 | |
2153 | void setCond(Expr *Cond) { |
2154 | getTrailingObjects<Stmt *>()[condOffset()] = reinterpret_cast<Stmt *>(Cond); |
2155 | } |
2156 | |
2157 | Stmt *getBody() { return getTrailingObjects<Stmt *>()[bodyOffset()]; } |
2158 | const Stmt *getBody() const { |
2159 | return getTrailingObjects<Stmt *>()[bodyOffset()]; |
2160 | } |
2161 | |
2162 | void setBody(Stmt *Body) { |
2163 | getTrailingObjects<Stmt *>()[bodyOffset()] = Body; |
2164 | } |
2165 | |
2166 | |
2167 | |
2168 | |
2169 | |
2170 | |
2171 | |
2172 | |
2173 | |
2174 | VarDecl *getConditionVariable(); |
2175 | const VarDecl *getConditionVariable() const { |
2176 | return const_cast<WhileStmt *>(this)->getConditionVariable(); |
2177 | } |
2178 | |
2179 | |
2180 | |
2181 | void setConditionVariable(const ASTContext &Ctx, VarDecl *V); |
2182 | |
2183 | |
2184 | |
2185 | DeclStmt *getConditionVariableDeclStmt() { |
2186 | return hasVarStorage() ? static_cast<DeclStmt *>( |
2187 | getTrailingObjects<Stmt *>()[varOffset()]) |
2188 | : nullptr; |
2189 | } |
2190 | |
2191 | const DeclStmt *getConditionVariableDeclStmt() const { |
2192 | return hasVarStorage() ? static_cast<DeclStmt *>( |
2193 | getTrailingObjects<Stmt *>()[varOffset()]) |
2194 | : nullptr; |
2195 | } |
2196 | |
2197 | SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; } |
2198 | void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; } |
2199 | |
2200 | SourceLocation getBeginLoc() const { return getWhileLoc(); } |
2201 | SourceLocation getEndLoc() const LLVM_READONLY { |
2202 | return getBody()->getEndLoc(); |
2203 | } |
2204 | |
2205 | static bool classof(const Stmt *T) { |
2206 | return T->getStmtClass() == WhileStmtClass; |
2207 | } |
2208 | |
2209 | |
2210 | child_range children() { |
2211 | return child_range(getTrailingObjects<Stmt *>(), |
2212 | getTrailingObjects<Stmt *>() + |
2213 | numTrailingObjects(OverloadToken<Stmt *>())); |
2214 | } |
2215 | }; |
2216 | |
2217 | |
2218 | class DoStmt : public Stmt { |
2219 | enum { BODY, COND, END_EXPR }; |
2220 | Stmt *SubExprs[END_EXPR]; |
2221 | SourceLocation WhileLoc; |
2222 | SourceLocation RParenLoc; |
2223 | |
2224 | public: |
2225 | DoStmt(Stmt *Body, Expr *Cond, SourceLocation DL, SourceLocation WL, |
2226 | SourceLocation RP) |
2227 | : Stmt(DoStmtClass), WhileLoc(WL), RParenLoc(RP) { |
2228 | setCond(Cond); |
2229 | setBody(Body); |
2230 | setDoLoc(DL); |
2231 | } |
2232 | |
2233 | |
2234 | explicit DoStmt(EmptyShell Empty) : Stmt(DoStmtClass, Empty) {} |
2235 | |
2236 | Expr *getCond() { return reinterpret_cast<Expr *>(SubExprs[COND]); } |
2237 | const Expr *getCond() const { |
2238 | return reinterpret_cast<Expr *>(SubExprs[COND]); |
2239 | } |
2240 | |
2241 | void setCond(Expr *Cond) { SubExprs[COND] = reinterpret_cast<Stmt *>(Cond); } |
2242 | |
2243 | Stmt *getBody() { return SubExprs[BODY]; } |
2244 | const Stmt *getBody() const { return SubExprs[BODY]; } |
2245 | void setBody(Stmt *Body) { SubExprs[BODY] = Body; } |
2246 | |
2247 | SourceLocation getDoLoc() const { return DoStmtBits.DoLoc; } |
2248 | void setDoLoc(SourceLocation L) { DoStmtBits.DoLoc = L; } |
2249 | SourceLocation getWhileLoc() const { return WhileLoc; } |
2250 | void setWhileLoc(SourceLocation L) { WhileLoc = L; } |
2251 | SourceLocation getRParenLoc() const { return RParenLoc; } |
2252 | void setRParenLoc(SourceLocation L) { RParenLoc = L; } |
2253 | |
2254 | SourceLocation getBeginLoc() const { return getDoLoc(); } |
2255 | SourceLocation getEndLoc() const { return getRParenLoc(); } |
2256 | |
2257 | static bool classof(const Stmt *T) { |
2258 | return T->getStmtClass() == DoStmtClass; |
2259 | } |
2260 | |
2261 | |
2262 | child_range children() { |
2263 | return child_range(&SubExprs[0], &SubExprs[0] + END_EXPR); |
2264 | } |
2265 | }; |
2266 | |
2267 | |
2268 | |
2269 | |
2270 | class ForStmt : public Stmt { |
2271 | enum { INIT, CONDVAR, COND, INC, BODY, END_EXPR }; |
2272 | Stmt* SubExprs[END_EXPR]; |
2273 | SourceLocation LParenLoc, RParenLoc; |
2274 | |
2275 | public: |
2276 | ForStmt(const ASTContext &C, Stmt *Init, Expr *Cond, VarDecl *condVar, |
2277 | Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP, |
2278 | SourceLocation RP); |
2279 | |
2280 | |
2281 | explicit ForStmt(EmptyShell Empty) : Stmt(ForStmtClass, Empty) {} |
2282 | |
2283 | Stmt *getInit() { return SubExprs[INIT]; } |
2284 | |
2285 | |
2286 | |
2287 | |
2288 | |
2289 | |
2290 | |
2291 | |
2292 | |
2293 | VarDecl *getConditionVariable() const; |
2294 | void setConditionVariable(const ASTContext &C, VarDecl *V); |
2295 | |
2296 | |
2297 | |
2298 | const DeclStmt *getConditionVariableDeclStmt() const { |
2299 | return reinterpret_cast<DeclStmt*>(SubExprs[CONDVAR]); |
2300 | } |
2301 | |
2302 | Expr *getCond() { return reinterpret_cast<Expr*>(SubExprs[COND]); } |
2303 | Expr *getInc() { return reinterpret_cast<Expr*>(SubExprs[INC]); } |
2304 | Stmt *getBody() { return SubExprs[BODY]; } |
2305 | |
2306 | const Stmt *getInit() const { return SubExprs[INIT]; } |
2307 | const Expr *getCond() const { return reinterpret_cast<Expr*>(SubExprs[COND]);} |
2308 | const Expr *getInc() const { return reinterpret_cast<Expr*>(SubExprs[INC]); } |
2309 | const Stmt *getBody() const { return SubExprs[BODY]; } |
2310 | |
2311 | void setInit(Stmt *S) { SubExprs[INIT] = S; } |
2312 | void setCond(Expr *E) { SubExprs[COND] = reinterpret_cast<Stmt*>(E); } |
2313 | void setInc(Expr *E) { SubExprs[INC] = reinterpret_cast<Stmt*>(E); } |
2314 | void setBody(Stmt *S) { SubExprs[BODY] = S; } |
2315 | |
2316 | SourceLocation getForLoc() const { return ForStmtBits.ForLoc; } |
2317 | void setForLoc(SourceLocation L) { ForStmtBits.ForLoc = L; } |
2318 | SourceLocation getLParenLoc() const { return LParenLoc; } |
2319 | void setLParenLoc(SourceLocation L) { LParenLoc = L; } |
2320 | SourceLocation getRParenLoc() const { return RParenLoc; } |
2321 | void setRParenLoc(SourceLocation L) { RParenLoc = L; } |
2322 | |
2323 | SourceLocation getBeginLoc() const { return getForLoc(); } |
2324 | SourceLocation getEndLoc() const { return getBody()->getEndLoc(); } |
2325 | |
2326 | static bool classof(const Stmt *T) { |
2327 | return T->getStmtClass() == ForStmtClass; |
2328 | } |
2329 | |
2330 | |
2331 | child_range children() { |
2332 | return child_range(&SubExprs[0], &SubExprs[0]+END_EXPR); |
2333 | } |
2334 | }; |
2335 | |
2336 | |
2337 | class GotoStmt : public Stmt { |
2338 | LabelDecl *Label; |
2339 | SourceLocation LabelLoc; |
2340 | |
2341 | public: |
2342 | GotoStmt(LabelDecl *label, SourceLocation GL, SourceLocation LL) |
2343 | : Stmt(GotoStmtClass), Label(label), LabelLoc(LL) { |
2344 | setGotoLoc(GL); |
2345 | } |
2346 | |
2347 | |
2348 | explicit GotoStmt(EmptyShell Empty) : Stmt(GotoStmtClass, Empty) {} |
2349 | |
2350 | LabelDecl *getLabel() const { return Label; } |
2351 | void setLabel(LabelDecl *D) { Label = D; } |
2352 | |
2353 | SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; } |
2354 | void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; } |
2355 | SourceLocation getLabelLoc() const { return LabelLoc; } |
2356 | void setLabelLoc(SourceLocation L) { LabelLoc = L; } |
2357 | |
2358 | SourceLocation getBeginLoc() const { return getGotoLoc(); } |
2359 | SourceLocation getEndLoc() const { return getLabelLoc(); } |
2360 | |
2361 | static bool classof(const Stmt *T) { |
2362 | return T->getStmtClass() == GotoStmtClass; |
2363 | } |
2364 | |
2365 | |
2366 | child_range children() { |
2367 | return child_range(child_iterator(), child_iterator()); |
2368 | } |
2369 | }; |
2370 | |
2371 | |
2372 | class IndirectGotoStmt : public Stmt { |
2373 | SourceLocation StarLoc; |
2374 | Stmt *Target; |
2375 | |
2376 | public: |
2377 | IndirectGotoStmt(SourceLocation gotoLoc, SourceLocation starLoc, Expr *target) |
2378 | : Stmt(IndirectGotoStmtClass), StarLoc(starLoc) { |
2379 | setTarget(target); |
2380 | setGotoLoc(gotoLoc); |
2381 | } |
2382 | |
2383 | |
2384 | explicit IndirectGotoStmt(EmptyShell Empty) |
2385 | : Stmt(IndirectGotoStmtClass, Empty) {} |
2386 | |
2387 | void setGotoLoc(SourceLocation L) { GotoStmtBits.GotoLoc = L; } |
2388 | SourceLocation getGotoLoc() const { return GotoStmtBits.GotoLoc; } |
2389 | void setStarLoc(SourceLocation L) { StarLoc = L; } |
2390 | SourceLocation getStarLoc() const { return StarLoc; } |
2391 | |
2392 | Expr *getTarget() { return reinterpret_cast<Expr *>(Target); } |
2393 | const Expr *getTarget() const { |
2394 | return reinterpret_cast<const Expr *>(Target); |
2395 | } |
2396 | void setTarget(Expr *E) { Target = reinterpret_cast<Stmt *>(E); } |
2397 | |
2398 | |
2399 | |
2400 | LabelDecl *getConstantTarget(); |
2401 | const LabelDecl *getConstantTarget() const { |
2402 | return const_cast<IndirectGotoStmt *>(this)->getConstantTarget(); |
2403 | } |
2404 | |
2405 | SourceLocation getBeginLoc() const { return getGotoLoc(); } |
2406 | SourceLocation getEndLoc() const LLVM_READONLY { return Target->getEndLoc(); } |
2407 | |
2408 | static bool classof(const Stmt *T) { |
2409 | return T->getStmtClass() == IndirectGotoStmtClass; |
2410 | } |
2411 | |
2412 | |
2413 | child_range children() { return child_range(&Target, &Target + 1); } |
2414 | }; |
2415 | |
2416 | |
2417 | class ContinueStmt : public Stmt { |
2418 | public: |
2419 | ContinueStmt(SourceLocation CL) : Stmt(ContinueStmtClass) { |
2420 | setContinueLoc(CL); |
2421 | } |
2422 | |
2423 | |
2424 | explicit ContinueStmt(EmptyShell Empty) : Stmt(ContinueStmtClass, Empty) {} |
2425 | |
2426 | SourceLocation getContinueLoc() const { return ContinueStmtBits.ContinueLoc; } |
2427 | void setContinueLoc(SourceLocation L) { ContinueStmtBits.ContinueLoc = L; } |
2428 | |
2429 | SourceLocation getBeginLoc() const { return getContinueLoc(); } |
2430 | SourceLocation getEndLoc() const { return getContinueLoc(); } |
2431 | |
2432 | static bool classof(const Stmt *T) { |
2433 | return T->getStmtClass() == ContinueStmtClass; |
2434 | } |
2435 | |
2436 | |
2437 | child_range children() { |
2438 | return child_range(child_iterator(), child_iterator()); |
2439 | } |
2440 | }; |
2441 | |
2442 | |
2443 | class BreakStmt : public Stmt { |
2444 | public: |
2445 | BreakStmt(SourceLocation BL) : Stmt(BreakStmtClass) { |
2446 | setBreakLoc(BL); |
2447 | } |
2448 | |
2449 | |
2450 | explicit BreakStmt(EmptyShell Empty) : Stmt(BreakStmtClass, Empty) {} |
2451 | |
2452 | SourceLocation getBreakLoc() const { return BreakStmtBits.BreakLoc; } |
2453 | void setBreakLoc(SourceLocation L) { BreakStmtBits.BreakLoc = L; } |
2454 | |
2455 | SourceLocation getBeginLoc() const { return getBreakLoc(); } |
2456 | SourceLocation getEndLoc() const { return getBreakLoc(); } |
2457 | |
2458 | static bool classof(const Stmt *T) { |
2459 | return T->getStmtClass() == BreakStmtClass; |
2460 | } |
2461 | |
2462 | |
2463 | child_range children() { |
2464 | return child_range(child_iterator(), child_iterator()); |
2465 | } |
2466 | }; |
2467 | |
2468 | |
2469 | |
2470 | |
2471 | |
2472 | |
2473 | |
2474 | |
2475 | |
2476 | class ReturnStmt final |
2477 | : public Stmt, |
2478 | private llvm::TrailingObjects<ReturnStmt, const VarDecl *> { |
2479 | friend TrailingObjects; |
2480 | |
2481 | |
2482 | Stmt *RetExpr; |
2483 | |
2484 | |
2485 | |
2486 | |
2487 | |
2488 | bool hasNRVOCandidate() const { return ReturnStmtBits.HasNRVOCandidate; } |
2489 | |
2490 | unsigned numTrailingObjects(OverloadToken<const VarDecl *>) const { |
2491 | return hasNRVOCandidate(); |
2492 | } |
2493 | |
2494 | |
2495 | ReturnStmt(SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate); |
2496 | |
2497 | |
2498 | explicit ReturnStmt(EmptyShell Empty, bool HasNRVOCandidate); |
2499 | |
2500 | public: |
2501 | |
2502 | static ReturnStmt *Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, |
2503 | const VarDecl *NRVOCandidate); |
2504 | |
2505 | |
2506 | |
2507 | static ReturnStmt *CreateEmpty(const ASTContext &Ctx, bool HasNRVOCandidate); |
2508 | |
2509 | Expr *getRetValue() { return reinterpret_cast<Expr *>(RetExpr); } |
2510 | const Expr *getRetValue() const { return reinterpret_cast<Expr *>(RetExpr); } |
2511 | void setRetValue(Expr *E) { RetExpr = reinterpret_cast<Stmt *>(E); } |
2512 | |
2513 | |
2514 | |
2515 | |
2516 | |
2517 | |
2518 | const VarDecl *getNRVOCandidate() const { |
2519 | return hasNRVOCandidate() ? *getTrailingObjects<const VarDecl *>() |
2520 | : nullptr; |
2521 | } |
2522 | |
2523 | |
2524 | |
2525 | |
2526 | void setNRVOCandidate(const VarDecl *Var) { |
2527 | (0) . __assert_fail ("hasNRVOCandidate() && \"This return statement has no storage for an NRVO candidate!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2528, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasNRVOCandidate() && |
2528 | (0) . __assert_fail ("hasNRVOCandidate() && \"This return statement has no storage for an NRVO candidate!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2528, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "This return statement has no storage for an NRVO candidate!"); |
2529 | *getTrailingObjects<const VarDecl *>() = Var; |
2530 | } |
2531 | |
2532 | SourceLocation getReturnLoc() const { return ReturnStmtBits.RetLoc; } |
2533 | void setReturnLoc(SourceLocation L) { ReturnStmtBits.RetLoc = L; } |
2534 | |
2535 | SourceLocation getBeginLoc() const { return getReturnLoc(); } |
2536 | SourceLocation getEndLoc() const LLVM_READONLY { |
2537 | return RetExpr ? RetExpr->getEndLoc() : getReturnLoc(); |
2538 | } |
2539 | |
2540 | static bool classof(const Stmt *T) { |
2541 | return T->getStmtClass() == ReturnStmtClass; |
2542 | } |
2543 | |
2544 | |
2545 | child_range children() { |
2546 | if (RetExpr) |
2547 | return child_range(&RetExpr, &RetExpr + 1); |
2548 | return child_range(child_iterator(), child_iterator()); |
2549 | } |
2550 | }; |
2551 | |
2552 | |
2553 | class AsmStmt : public Stmt { |
2554 | protected: |
2555 | friend class ASTStmtReader; |
2556 | |
2557 | SourceLocation AsmLoc; |
2558 | |
2559 | |
2560 | |
2561 | bool IsSimple; |
2562 | |
2563 | |
2564 | |
2565 | bool IsVolatile; |
2566 | |
2567 | unsigned NumOutputs; |
2568 | unsigned NumInputs; |
2569 | unsigned NumClobbers; |
2570 | |
2571 | Stmt **Exprs = nullptr; |
2572 | |
2573 | AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile, |
2574 | unsigned numoutputs, unsigned numinputs, unsigned numclobbers) |
2575 | : Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile), |
2576 | NumOutputs(numoutputs), NumInputs(numinputs), |
2577 | NumClobbers(numclobbers) {} |
2578 | |
2579 | public: |
2580 | |
2581 | explicit AsmStmt(StmtClass SC, EmptyShell Empty) : Stmt(SC, Empty) {} |
2582 | |
2583 | SourceLocation getAsmLoc() const { return AsmLoc; } |
2584 | void setAsmLoc(SourceLocation L) { AsmLoc = L; } |
2585 | |
2586 | bool isSimple() const { return IsSimple; } |
2587 | void setSimple(bool V) { IsSimple = V; } |
2588 | |
2589 | bool isVolatile() const { return IsVolatile; } |
2590 | void setVolatile(bool V) { IsVolatile = V; } |
2591 | |
2592 | SourceLocation getBeginLoc() const LLVM_READONLY { return {}; } |
2593 | SourceLocation getEndLoc() const LLVM_READONLY { return {}; } |
2594 | |
2595 | |
2596 | |
2597 | |
2598 | std::string generateAsmString(const ASTContext &C) const; |
2599 | |
2600 | |
2601 | |
2602 | unsigned getNumOutputs() const { return NumOutputs; } |
2603 | |
2604 | |
2605 | |
2606 | |
2607 | StringRef getOutputConstraint(unsigned i) const; |
2608 | |
2609 | |
2610 | |
2611 | |
2612 | bool isOutputPlusConstraint(unsigned i) const { |
2613 | return getOutputConstraint(i)[0] == '+'; |
2614 | } |
2615 | |
2616 | const Expr *getOutputExpr(unsigned i) const; |
2617 | |
2618 | |
2619 | |
2620 | unsigned getNumPlusOperands() const; |
2621 | |
2622 | |
2623 | |
2624 | unsigned getNumInputs() const { return NumInputs; } |
2625 | |
2626 | |
2627 | |
2628 | StringRef getInputConstraint(unsigned i) const; |
2629 | |
2630 | const Expr *getInputExpr(unsigned i) const; |
2631 | |
2632 | |
2633 | |
2634 | unsigned getNumClobbers() const { return NumClobbers; } |
2635 | StringRef getClobber(unsigned i) const; |
2636 | |
2637 | static bool classof(const Stmt *T) { |
2638 | return T->getStmtClass() == GCCAsmStmtClass || |
2639 | T->getStmtClass() == MSAsmStmtClass; |
2640 | } |
2641 | |
2642 | |
2643 | |
2644 | using inputs_iterator = ExprIterator; |
2645 | using const_inputs_iterator = ConstExprIterator; |
2646 | using inputs_range = llvm::iterator_range<inputs_iterator>; |
2647 | using inputs_const_range = llvm::iterator_range<const_inputs_iterator>; |
2648 | |
2649 | inputs_iterator begin_inputs() { |
2650 | return &Exprs[0] + NumOutputs; |
2651 | } |
2652 | |
2653 | inputs_iterator end_inputs() { |
2654 | return &Exprs[0] + NumOutputs + NumInputs; |
2655 | } |
2656 | |
2657 | inputs_range inputs() { return inputs_range(begin_inputs(), end_inputs()); } |
2658 | |
2659 | const_inputs_iterator begin_inputs() const { |
2660 | return &Exprs[0] + NumOutputs; |
2661 | } |
2662 | |
2663 | const_inputs_iterator end_inputs() const { |
2664 | return &Exprs[0] + NumOutputs + NumInputs; |
2665 | } |
2666 | |
2667 | inputs_const_range inputs() const { |
2668 | return inputs_const_range(begin_inputs(), end_inputs()); |
2669 | } |
2670 | |
2671 | |
2672 | |
2673 | using outputs_iterator = ExprIterator; |
2674 | using const_outputs_iterator = ConstExprIterator; |
2675 | using outputs_range = llvm::iterator_range<outputs_iterator>; |
2676 | using outputs_const_range = llvm::iterator_range<const_outputs_iterator>; |
2677 | |
2678 | outputs_iterator begin_outputs() { |
2679 | return &Exprs[0]; |
2680 | } |
2681 | |
2682 | outputs_iterator end_outputs() { |
2683 | return &Exprs[0] + NumOutputs; |
2684 | } |
2685 | |
2686 | outputs_range outputs() { |
2687 | return outputs_range(begin_outputs(), end_outputs()); |
2688 | } |
2689 | |
2690 | const_outputs_iterator begin_outputs() const { |
2691 | return &Exprs[0]; |
2692 | } |
2693 | |
2694 | const_outputs_iterator end_outputs() const { |
2695 | return &Exprs[0] + NumOutputs; |
2696 | } |
2697 | |
2698 | outputs_const_range outputs() const { |
2699 | return outputs_const_range(begin_outputs(), end_outputs()); |
2700 | } |
2701 | |
2702 | child_range children() { |
2703 | return child_range(&Exprs[0], &Exprs[0] + NumOutputs + NumInputs); |
2704 | } |
2705 | }; |
2706 | |
2707 | |
2708 | class GCCAsmStmt : public AsmStmt { |
2709 | friend class ASTStmtReader; |
2710 | |
2711 | SourceLocation RParenLoc; |
2712 | StringLiteral *AsmStr; |
2713 | |
2714 | |
2715 | StringLiteral **Constraints = nullptr; |
2716 | StringLiteral **Clobbers = nullptr; |
2717 | IdentifierInfo **Names = nullptr; |
2718 | |
2719 | public: |
2720 | GCCAsmStmt(const ASTContext &C, SourceLocation asmloc, bool issimple, |
2721 | bool isvolatile, unsigned numoutputs, unsigned numinputs, |
2722 | IdentifierInfo **names, StringLiteral **constraints, Expr **exprs, |
2723 | StringLiteral *asmstr, unsigned numclobbers, |
2724 | StringLiteral **clobbers, SourceLocation rparenloc); |
2725 | |
2726 | |
2727 | explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty) {} |
2728 | |
2729 | SourceLocation getRParenLoc() const { return RParenLoc; } |
2730 | void setRParenLoc(SourceLocation L) { RParenLoc = L; } |
2731 | |
2732 | |
2733 | |
2734 | const StringLiteral *getAsmString() const { return AsmStr; } |
2735 | StringLiteral *getAsmString() { return AsmStr; } |
2736 | void setAsmString(StringLiteral *E) { AsmStr = E; } |
2737 | |
2738 | |
2739 | |
2740 | |
2741 | class AsmStringPiece { |
2742 | public: |
2743 | enum Kind { |
2744 | String, |
2745 | Operand |
2746 | }; |
2747 | |
2748 | private: |
2749 | Kind MyKind; |
2750 | std::string Str; |
2751 | unsigned OperandNo; |
2752 | |
2753 | |
2754 | CharSourceRange Range; |
2755 | |
2756 | public: |
2757 | AsmStringPiece(const std::string &S) : MyKind(String), Str(S) {} |
2758 | AsmStringPiece(unsigned OpNo, const std::string &S, SourceLocation Begin, |
2759 | SourceLocation End) |
2760 | : MyKind(Operand), Str(S), OperandNo(OpNo), |
2761 | Range(CharSourceRange::getCharRange(Begin, End)) {} |
2762 | |
2763 | bool isString() const { return MyKind == String; } |
2764 | bool isOperand() const { return MyKind == Operand; } |
2765 | |
2766 | const std::string &getString() const { return Str; } |
2767 | |
2768 | unsigned getOperandNo() const { |
2769 | assert(isOperand()); |
2770 | return OperandNo; |
2771 | } |
2772 | |
2773 | CharSourceRange getRange() const { |
2774 | (0) . __assert_fail ("isOperand() && \"Range is currently used only for Operands.\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 2774, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isOperand() && "Range is currently used only for Operands."); |
2775 | return Range; |
2776 | } |
2777 | |
2778 | |
2779 | |
2780 | char getModifier() const; |
2781 | }; |
2782 | |
2783 | |
2784 | |
2785 | |
2786 | |
2787 | |
2788 | unsigned AnalyzeAsmString(SmallVectorImpl<AsmStringPiece> &Pieces, |
2789 | const ASTContext &C, unsigned &DiagOffs) const; |
2790 | |
2791 | |
2792 | std::string generateAsmString(const ASTContext &C) const; |
2793 | |
2794 | |
2795 | |
2796 | IdentifierInfo *getOutputIdentifier(unsigned i) const { return Names[i]; } |
2797 | |
2798 | StringRef getOutputName(unsigned i) const { |
2799 | if (IdentifierInfo *II = getOutputIdentifier(i)) |
2800 | return II->getName(); |
2801 | |
2802 | return {}; |
2803 | } |
2804 | |
2805 | StringRef getOutputConstraint(unsigned i) const; |
2806 | |
2807 | const StringLiteral *getOutputConstraintLiteral(unsigned i) const { |
2808 | return Constraints[i]; |
2809 | } |
2810 | StringLiteral *getOutputConstraintLiteral(unsigned i) { |
2811 | return Constraints[i]; |
2812 | } |
2813 | |
2814 | Expr *getOutputExpr(unsigned i); |
2815 | |
2816 | const Expr *getOutputExpr(unsigned i) const { |
2817 | return const_cast<GCCAsmStmt*>(this)->getOutputExpr(i); |
2818 | } |
2819 | |
2820 | |
2821 | |
2822 | IdentifierInfo *getInputIdentifier(unsigned i) const { |
2823 | return Names[i + NumOutputs]; |
2824 | } |
2825 | |
2826 | StringRef getInputName(unsigned i) const { |
2827 | if (IdentifierInfo *II = getInputIdentifier(i)) |
2828 | return II->getName(); |
2829 | |
2830 | return {}; |
2831 | } |
2832 | |
2833 | StringRef getInputConstraint(unsigned i) const; |
2834 | |
2835 | const StringLiteral *getInputConstraintLiteral(unsigned i) const { |
2836 | return Constraints[i + NumOutputs]; |
2837 | } |
2838 | StringLiteral *getInputConstraintLiteral(unsigned i) { |
2839 | return Constraints[i + NumOutputs]; |
2840 | } |
2841 | |
2842 | Expr *getInputExpr(unsigned i); |
2843 | void setInputExpr(unsigned i, Expr *E); |
2844 | |
2845 | const Expr *getInputExpr(unsigned i) const { |
2846 | return const_cast<GCCAsmStmt*>(this)->getInputExpr(i); |
2847 | } |
2848 | |
2849 | private: |
2850 | void setOutputsAndInputsAndClobbers(const ASTContext &C, |
2851 | IdentifierInfo **Names, |
2852 | StringLiteral **Constraints, |
2853 | Stmt **Exprs, |
2854 | unsigned NumOutputs, |
2855 | unsigned NumInputs, |
2856 | StringLiteral **Clobbers, |
2857 | unsigned NumClobbers); |
2858 | |
2859 | public: |
2860 | |
2861 | |
2862 | |
2863 | |
2864 | |
2865 | int getNamedOperand(StringRef SymbolicName) const; |
2866 | |
2867 | StringRef getClobber(unsigned i) const; |
2868 | |
2869 | StringLiteral *getClobberStringLiteral(unsigned i) { return Clobbers[i]; } |
2870 | const StringLiteral *getClobberStringLiteral(unsigned i) const { |
2871 | return Clobbers[i]; |
2872 | } |
2873 | |
2874 | SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; } |
2875 | SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; } |
2876 | |
2877 | static bool classof(const Stmt *T) { |
2878 | return T->getStmtClass() == GCCAsmStmtClass; |
2879 | } |
2880 | }; |
2881 | |
2882 | |
2883 | class MSAsmStmt : public AsmStmt { |
2884 | friend class ASTStmtReader; |
2885 | |
2886 | SourceLocation LBraceLoc, EndLoc; |
2887 | StringRef AsmStr; |
2888 | |
2889 | unsigned NumAsmToks = 0; |
2890 | |
2891 | Token *AsmToks = nullptr; |
2892 | StringRef *Constraints = nullptr; |
2893 | StringRef *Clobbers = nullptr; |
2894 | |
2895 | public: |
2896 | MSAsmStmt(const ASTContext &C, SourceLocation asmloc, |
2897 | SourceLocation lbraceloc, bool issimple, bool isvolatile, |
2898 | ArrayRef<Token> asmtoks, unsigned numoutputs, unsigned numinputs, |
2899 | ArrayRef<StringRef> constraints, |
2900 | ArrayRef<Expr*> exprs, StringRef asmstr, |
2901 | ArrayRef<StringRef> clobbers, SourceLocation endloc); |
2902 | |
2903 | |
2904 | explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty) {} |
2905 | |
2906 | SourceLocation getLBraceLoc() const { return LBraceLoc; } |
2907 | void setLBraceLoc(SourceLocation L) { LBraceLoc = L; } |
2908 | SourceLocation getEndLoc() const { return EndLoc; } |
2909 | void setEndLoc(SourceLocation L) { EndLoc = L; } |
2910 | |
2911 | bool hasBraces() const { return LBraceLoc.isValid(); } |
2912 | |
2913 | unsigned getNumAsmToks() { return NumAsmToks; } |
2914 | Token *getAsmToks() { return AsmToks; } |
2915 | |
2916 | |
2917 | StringRef getAsmString() const { return AsmStr; } |
2918 | |
2919 | |
2920 | std::string generateAsmString(const ASTContext &C) const; |
2921 | |
2922 | |
2923 | |
2924 | StringRef getOutputConstraint(unsigned i) const { |
2925 | assert(i < NumOutputs); |
2926 | return Constraints[i]; |
2927 | } |
2928 | |
2929 | Expr *getOutputExpr(unsigned i); |
2930 | |
2931 | const Expr *getOutputExpr(unsigned i) const { |
2932 | return const_cast<MSAsmStmt*>(this)->getOutputExpr(i); |
2933 | } |
2934 | |
2935 | |
2936 | |
2937 | StringRef getInputConstraint(unsigned i) const { |
2938 | assert(i < NumInputs); |
2939 | return Constraints[i + NumOutputs]; |
2940 | } |
2941 | |
2942 | Expr *getInputExpr(unsigned i); |
2943 | void setInputExpr(unsigned i, Expr *E); |
2944 | |
2945 | const Expr *getInputExpr(unsigned i) const { |
2946 | return const_cast<MSAsmStmt*>(this)->getInputExpr(i); |
2947 | } |
2948 | |
2949 | |
2950 | |
2951 | ArrayRef<StringRef> getAllConstraints() const { |
2952 | return llvm::makeArrayRef(Constraints, NumInputs + NumOutputs); |
2953 | } |
2954 | |
2955 | ArrayRef<StringRef> getClobbers() const { |
2956 | return llvm::makeArrayRef(Clobbers, NumClobbers); |
2957 | } |
2958 | |
2959 | ArrayRef<Expr*> getAllExprs() const { |
2960 | return llvm::makeArrayRef(reinterpret_cast<Expr**>(Exprs), |
2961 | NumInputs + NumOutputs); |
2962 | } |
2963 | |
2964 | StringRef getClobber(unsigned i) const { return getClobbers()[i]; } |
2965 | |
2966 | private: |
2967 | void initialize(const ASTContext &C, StringRef AsmString, |
2968 | ArrayRef<Token> AsmToks, ArrayRef<StringRef> Constraints, |
2969 | ArrayRef<Expr*> Exprs, ArrayRef<StringRef> Clobbers); |
2970 | |
2971 | public: |
2972 | SourceLocation getBeginLoc() const LLVM_READONLY { return AsmLoc; } |
2973 | |
2974 | static bool classof(const Stmt *T) { |
2975 | return T->getStmtClass() == MSAsmStmtClass; |
2976 | } |
2977 | |
2978 | child_range children() { |
2979 | return child_range(&Exprs[0], &Exprs[NumInputs + NumOutputs]); |
2980 | } |
2981 | }; |
2982 | |
2983 | class SEHExceptStmt : public Stmt { |
2984 | friend class ASTReader; |
2985 | friend class ASTStmtReader; |
2986 | |
2987 | SourceLocation Loc; |
2988 | Stmt *Children[2]; |
2989 | |
2990 | enum { FILTER_EXPR, BLOCK }; |
2991 | |
2992 | SEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block); |
2993 | explicit SEHExceptStmt(EmptyShell E) : Stmt(SEHExceptStmtClass, E) {} |
2994 | |
2995 | public: |
2996 | static SEHExceptStmt* Create(const ASTContext &C, |
2997 | SourceLocation ExceptLoc, |
2998 | Expr *FilterExpr, |
2999 | Stmt *Block); |
3000 | |
3001 | SourceLocation getBeginLoc() const LLVM_READONLY { return getExceptLoc(); } |
3002 | |
3003 | SourceLocation getExceptLoc() const { return Loc; } |
3004 | SourceLocation getEndLoc() const { return getBlock()->getEndLoc(); } |
3005 | |
3006 | Expr *getFilterExpr() const { |
3007 | return reinterpret_cast<Expr*>(Children[FILTER_EXPR]); |
3008 | } |
3009 | |
3010 | CompoundStmt *getBlock() const { |
3011 | return cast<CompoundStmt>(Children[BLOCK]); |
3012 | } |
3013 | |
3014 | child_range children() { |
3015 | return child_range(Children, Children+2); |
3016 | } |
3017 | |
3018 | static bool classof(const Stmt *T) { |
3019 | return T->getStmtClass() == SEHExceptStmtClass; |
3020 | } |
3021 | }; |
3022 | |
3023 | class SEHFinallyStmt : public Stmt { |
3024 | friend class ASTReader; |
3025 | friend class ASTStmtReader; |
3026 | |
3027 | SourceLocation Loc; |
3028 | Stmt *Block; |
3029 | |
3030 | SEHFinallyStmt(SourceLocation Loc, Stmt *Block); |
3031 | explicit SEHFinallyStmt(EmptyShell E) : Stmt(SEHFinallyStmtClass, E) {} |
3032 | |
3033 | public: |
3034 | static SEHFinallyStmt* Create(const ASTContext &C, |
3035 | SourceLocation FinallyLoc, |
3036 | Stmt *Block); |
3037 | |
3038 | SourceLocation getBeginLoc() const LLVM_READONLY { return getFinallyLoc(); } |
3039 | |
3040 | SourceLocation getFinallyLoc() const { return Loc; } |
3041 | SourceLocation getEndLoc() const { return Block->getEndLoc(); } |
3042 | |
3043 | CompoundStmt *getBlock() const { return cast<CompoundStmt>(Block); } |
3044 | |
3045 | child_range children() { |
3046 | return child_range(&Block,&Block+1); |
3047 | } |
3048 | |
3049 | static bool classof(const Stmt *T) { |
3050 | return T->getStmtClass() == SEHFinallyStmtClass; |
3051 | } |
3052 | }; |
3053 | |
3054 | class SEHTryStmt : public Stmt { |
3055 | friend class ASTReader; |
3056 | friend class ASTStmtReader; |
3057 | |
3058 | bool IsCXXTry; |
3059 | SourceLocation TryLoc; |
3060 | Stmt *Children[2]; |
3061 | |
3062 | enum { TRY = 0, HANDLER = 1 }; |
3063 | |
3064 | SEHTryStmt(bool isCXXTry, |
3065 | SourceLocation TryLoc, |
3066 | Stmt *TryBlock, |
3067 | Stmt *Handler); |
3068 | |
3069 | explicit SEHTryStmt(EmptyShell E) : Stmt(SEHTryStmtClass, E) {} |
3070 | |
3071 | public: |
3072 | static SEHTryStmt* Create(const ASTContext &C, bool isCXXTry, |
3073 | SourceLocation TryLoc, Stmt *TryBlock, |
3074 | Stmt *Handler); |
3075 | |
3076 | SourceLocation getBeginLoc() const LLVM_READONLY { return getTryLoc(); } |
3077 | |
3078 | SourceLocation getTryLoc() const { return TryLoc; } |
3079 | SourceLocation getEndLoc() const { return Children[HANDLER]->getEndLoc(); } |
3080 | |
3081 | bool getIsCXXTry() const { return IsCXXTry; } |
3082 | |
3083 | CompoundStmt* getTryBlock() const { |
3084 | return cast<CompoundStmt>(Children[TRY]); |
3085 | } |
3086 | |
3087 | Stmt *getHandler() const { return Children[HANDLER]; } |
3088 | |
3089 | |
3090 | SEHExceptStmt *getExceptHandler() const; |
3091 | SEHFinallyStmt *getFinallyHandler() const; |
3092 | |
3093 | child_range children() { |
3094 | return child_range(Children, Children+2); |
3095 | } |
3096 | |
3097 | static bool classof(const Stmt *T) { |
3098 | return T->getStmtClass() == SEHTryStmtClass; |
3099 | } |
3100 | }; |
3101 | |
3102 | |
3103 | class SEHLeaveStmt : public Stmt { |
3104 | SourceLocation LeaveLoc; |
3105 | |
3106 | public: |
3107 | explicit SEHLeaveStmt(SourceLocation LL) |
3108 | : Stmt(SEHLeaveStmtClass), LeaveLoc(LL) {} |
3109 | |
3110 | |
3111 | explicit SEHLeaveStmt(EmptyShell Empty) : Stmt(SEHLeaveStmtClass, Empty) {} |
3112 | |
3113 | SourceLocation getLeaveLoc() const { return LeaveLoc; } |
3114 | void setLeaveLoc(SourceLocation L) { LeaveLoc = L; } |
3115 | |
3116 | SourceLocation getBeginLoc() const LLVM_READONLY { return LeaveLoc; } |
3117 | SourceLocation getEndLoc() const LLVM_READONLY { return LeaveLoc; } |
3118 | |
3119 | static bool classof(const Stmt *T) { |
3120 | return T->getStmtClass() == SEHLeaveStmtClass; |
3121 | } |
3122 | |
3123 | |
3124 | child_range children() { |
3125 | return child_range(child_iterator(), child_iterator()); |
3126 | } |
3127 | }; |
3128 | |
3129 | |
3130 | |
3131 | |
3132 | |
3133 | |
3134 | |
3135 | |
3136 | |
3137 | |
3138 | class CapturedStmt : public Stmt { |
3139 | public: |
3140 | |
3141 | |
3142 | enum VariableCaptureKind { |
3143 | VCK_This, |
3144 | VCK_ByRef, |
3145 | VCK_ByCopy, |
3146 | VCK_VLAType, |
3147 | }; |
3148 | |
3149 | |
3150 | |
3151 | class Capture { |
3152 | llvm::PointerIntPair<VarDecl *, 2, VariableCaptureKind> VarAndKind; |
3153 | SourceLocation Loc; |
3154 | |
3155 | public: |
3156 | friend class ASTStmtReader; |
3157 | |
3158 | |
3159 | |
3160 | |
3161 | |
3162 | |
3163 | |
3164 | |
3165 | Capture(SourceLocation Loc, VariableCaptureKind Kind, |
3166 | VarDecl *Var = nullptr); |
3167 | |
3168 | |
3169 | VariableCaptureKind getCaptureKind() const; |
3170 | |
3171 | |
3172 | |
3173 | SourceLocation getLocation() const { return Loc; } |
3174 | |
3175 | |
3176 | bool capturesThis() const { return getCaptureKind() == VCK_This; } |
3177 | |
3178 | |
3179 | bool capturesVariable() const { return getCaptureKind() == VCK_ByRef; } |
3180 | |
3181 | |
3182 | bool capturesVariableByCopy() const { |
3183 | return getCaptureKind() == VCK_ByCopy; |
3184 | } |
3185 | |
3186 | |
3187 | |
3188 | bool capturesVariableArrayType() const { |
3189 | return getCaptureKind() == VCK_VLAType; |
3190 | } |
3191 | |
3192 | |
3193 | |
3194 | |
3195 | VarDecl *getCapturedVar() const; |
3196 | }; |
3197 | |
3198 | private: |
3199 | |
3200 | unsigned NumCaptures; |
3201 | |
3202 | |
3203 | |
3204 | llvm::PointerIntPair<CapturedDecl *, 2, CapturedRegionKind> CapDeclAndKind; |
3205 | |
3206 | |
3207 | RecordDecl *TheRecordDecl = nullptr; |
3208 | |
3209 | |
3210 | CapturedStmt(Stmt *S, CapturedRegionKind Kind, ArrayRef<Capture> Captures, |
3211 | ArrayRef<Expr *> CaptureInits, CapturedDecl *CD, RecordDecl *RD); |
3212 | |
3213 | |
3214 | CapturedStmt(EmptyShell Empty, unsigned NumCaptures); |
3215 | |
3216 | Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); } |
3217 | |
3218 | Stmt *const *getStoredStmts() const { |
3219 | return reinterpret_cast<Stmt *const *>(this + 1); |
3220 | } |
3221 | |
3222 | Capture *getStoredCaptures() const; |
3223 | |
3224 | void setCapturedStmt(Stmt *S) { getStoredStmts()[NumCaptures] = S; } |
3225 | |
3226 | public: |
3227 | friend class ASTStmtReader; |
3228 | |
3229 | static CapturedStmt *Create(const ASTContext &Context, Stmt *S, |
3230 | CapturedRegionKind Kind, |
3231 | ArrayRef<Capture> Captures, |
3232 | ArrayRef<Expr *> CaptureInits, |
3233 | CapturedDecl *CD, RecordDecl *RD); |
3234 | |
3235 | static CapturedStmt *CreateDeserialized(const ASTContext &Context, |
3236 | unsigned NumCaptures); |
3237 | |
3238 | |
3239 | Stmt *getCapturedStmt() { return getStoredStmts()[NumCaptures]; } |
3240 | const Stmt *getCapturedStmt() const { return getStoredStmts()[NumCaptures]; } |
3241 | |
3242 | |
3243 | CapturedDecl *getCapturedDecl(); |
3244 | const CapturedDecl *getCapturedDecl() const; |
3245 | |
3246 | |
3247 | void setCapturedDecl(CapturedDecl *D); |
3248 | |
3249 | |
3250 | CapturedRegionKind getCapturedRegionKind() const; |
3251 | |
3252 | |
3253 | void setCapturedRegionKind(CapturedRegionKind Kind); |
3254 | |
3255 | |
3256 | const RecordDecl *getCapturedRecordDecl() const { return TheRecordDecl; } |
3257 | |
3258 | |
3259 | void setCapturedRecordDecl(RecordDecl *D) { |
3260 | (0) . __assert_fail ("D && \"null RecordDecl\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/Stmt.h", 3260, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(D && "null RecordDecl"); |
3261 | TheRecordDecl = D; |
3262 | } |
3263 | |
3264 | |
3265 | bool capturesVariable(const VarDecl *Var) const; |
3266 | |
3267 | |
3268 | using capture_iterator = Capture *; |
3269 | using const_capture_iterator = const Capture *; |
3270 | using capture_range = llvm::iterator_range<capture_iterator>; |
3271 | using capture_const_range = llvm::iterator_range<const_capture_iterator>; |
3272 | |
3273 | capture_range captures() { |
3274 | return capture_range(capture_begin(), capture_end()); |
3275 | } |
3276 | capture_const_range captures() const { |
3277 | return capture_const_range(capture_begin(), capture_end()); |
3278 | } |
3279 | |
3280 | |
3281 | capture_iterator capture_begin() { return getStoredCaptures(); } |
3282 | const_capture_iterator capture_begin() const { return getStoredCaptures(); } |
3283 | |
3284 | |
3285 | |
3286 | capture_iterator capture_end() const { |
3287 | return getStoredCaptures() + NumCaptures; |
3288 | } |
3289 | |
3290 | |
3291 | unsigned capture_size() const { return NumCaptures; } |
3292 | |
3293 | |
3294 | using capture_init_iterator = Expr **; |
3295 | using capture_init_range = llvm::iterator_range<capture_init_iterator>; |
3296 | |
3297 | |
3298 | |
3299 | using const_capture_init_iterator = Expr *const *; |
3300 | using const_capture_init_range = |
3301 | llvm::iterator_range<const_capture_init_iterator>; |
3302 | |
3303 | capture_init_range capture_inits() { |
3304 | return capture_init_range(capture_init_begin(), capture_init_end()); |
3305 | } |
3306 | |
3307 | const_capture_init_range capture_inits() const { |
3308 | return const_capture_init_range(capture_init_begin(), capture_init_end()); |
3309 | } |
3310 | |
3311 | |
3312 | capture_init_iterator capture_init_begin() { |
3313 | return reinterpret_cast<Expr **>(getStoredStmts()); |
3314 | } |
3315 | |
3316 | const_capture_init_iterator capture_init_begin() const { |
3317 | return reinterpret_cast<Expr *const *>(getStoredStmts()); |
3318 | } |
3319 | |
3320 | |
3321 | |
3322 | capture_init_iterator capture_init_end() { |
3323 | return capture_init_begin() + NumCaptures; |
3324 | } |
3325 | |
3326 | const_capture_init_iterator capture_init_end() const { |
3327 | return capture_init_begin() + NumCaptures; |
3328 | } |
3329 | |
3330 | SourceLocation getBeginLoc() const LLVM_READONLY { |
3331 | return getCapturedStmt()->getBeginLoc(); |
3332 | } |
3333 | |
3334 | SourceLocation getEndLoc() const LLVM_READONLY { |
3335 | return getCapturedStmt()->getEndLoc(); |
3336 | } |
3337 | |
3338 | SourceRange getSourceRange() const LLVM_READONLY { |
3339 | return getCapturedStmt()->getSourceRange(); |
3340 | } |
3341 | |
3342 | static bool classof(const Stmt *T) { |
3343 | return T->getStmtClass() == CapturedStmtClass; |
3344 | } |
3345 | |
3346 | child_range children(); |
3347 | }; |
3348 | |
3349 | } |
3350 | |
3351 | #endif |
3352 | |