1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H |
14 | #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H |
15 | |
16 | #include "CoroutineStmtBuilder.h" |
17 | #include "TypeLocBuilder.h" |
18 | #include "clang/AST/Decl.h" |
19 | #include "clang/AST/DeclObjC.h" |
20 | #include "clang/AST/DeclTemplate.h" |
21 | #include "clang/AST/Expr.h" |
22 | #include "clang/AST/ExprCXX.h" |
23 | #include "clang/AST/ExprObjC.h" |
24 | #include "clang/AST/ExprOpenMP.h" |
25 | #include "clang/AST/Stmt.h" |
26 | #include "clang/AST/StmtCXX.h" |
27 | #include "clang/AST/StmtObjC.h" |
28 | #include "clang/AST/StmtOpenMP.h" |
29 | #include "clang/Sema/Designator.h" |
30 | #include "clang/Sema/Lookup.h" |
31 | #include "clang/Sema/Ownership.h" |
32 | #include "clang/Sema/ParsedTemplate.h" |
33 | #include "clang/Sema/ScopeInfo.h" |
34 | #include "clang/Sema/SemaDiagnostic.h" |
35 | #include "clang/Sema/SemaInternal.h" |
36 | #include "llvm/ADT/ArrayRef.h" |
37 | #include "llvm/Support/ErrorHandling.h" |
38 | #include <algorithm> |
39 | |
40 | namespace clang { |
41 | using namespace sema; |
42 | |
43 | |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | template<typename Derived> |
95 | class TreeTransform { |
96 | |
97 | |
98 | |
99 | class ForgetPartiallySubstitutedPackRAII { |
100 | Derived &Self; |
101 | TemplateArgument Old; |
102 | |
103 | public: |
104 | ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) { |
105 | Old = Self.ForgetPartiallySubstitutedPack(); |
106 | } |
107 | |
108 | ~ForgetPartiallySubstitutedPackRAII() { |
109 | Self.RememberPartiallySubstitutedPack(Old); |
110 | } |
111 | }; |
112 | |
113 | protected: |
114 | Sema &SemaRef; |
115 | |
116 | |
117 | |
118 | |
119 | llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls; |
120 | |
121 | public: |
122 | |
123 | TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { } |
124 | |
125 | |
126 | Derived &getDerived() { return static_cast<Derived&>(*this); } |
127 | |
128 | |
129 | const Derived &getDerived() const { |
130 | return static_cast<const Derived&>(*this); |
131 | } |
132 | |
133 | static inline ExprResult Owned(Expr *E) { return E; } |
134 | static inline StmtResult Owned(Stmt *S) { return S; } |
135 | |
136 | |
137 | |
138 | Sema &getSema() const { return SemaRef; } |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | bool AlwaysRebuild() { return SemaRef.ArgumentPackSubstitutionIndex != -1; } |
150 | |
151 | |
152 | |
153 | |
154 | |
155 | |
156 | |
157 | SourceLocation getBaseLocation() { return SourceLocation(); } |
158 | |
159 | |
160 | |
161 | |
162 | |
163 | |
164 | DeclarationName getBaseEntity() { return DeclarationName(); } |
165 | |
166 | |
167 | |
168 | |
169 | |
170 | |
171 | void setBase(SourceLocation Loc, DeclarationName Entity) { } |
172 | |
173 | |
174 | |
175 | class TemporaryBase { |
176 | TreeTransform &Self; |
177 | SourceLocation OldLocation; |
178 | DeclarationName OldEntity; |
179 | |
180 | public: |
181 | TemporaryBase(TreeTransform &Self, SourceLocation Location, |
182 | DeclarationName Entity) : Self(Self) { |
183 | OldLocation = Self.getDerived().getBaseLocation(); |
184 | OldEntity = Self.getDerived().getBaseEntity(); |
185 | |
186 | if (Location.isValid()) |
187 | Self.getDerived().setBase(Location, Entity); |
188 | } |
189 | |
190 | ~TemporaryBase() { |
191 | Self.getDerived().setBase(OldLocation, OldEntity); |
192 | } |
193 | }; |
194 | |
195 | |
196 | |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | bool AlreadyTransformed(QualType T) { |
203 | return T.isNull(); |
204 | } |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | bool DropCallArgument(Expr *E) { |
213 | return E->isDefaultArgument(); |
214 | } |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | |
231 | |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | |
243 | |
244 | |
245 | |
246 | |
247 | |
248 | |
249 | |
250 | |
251 | |
252 | |
253 | bool TryExpandParameterPacks(SourceLocation EllipsisLoc, |
254 | SourceRange PatternRange, |
255 | ArrayRef<UnexpandedParameterPack> Unexpanded, |
256 | bool &ShouldExpand, |
257 | bool &RetainExpansion, |
258 | Optional<unsigned> &NumExpansions) { |
259 | ShouldExpand = false; |
260 | return false; |
261 | } |
262 | |
263 | |
264 | |
265 | |
266 | |
267 | |
268 | TemplateArgument ForgetPartiallySubstitutedPack() { |
269 | return TemplateArgument(); |
270 | } |
271 | |
272 | |
273 | |
274 | |
275 | |
276 | |
277 | void RememberPartiallySubstitutedPack(TemplateArgument Arg) { } |
278 | |
279 | |
280 | |
281 | void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { } |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | |
289 | |
290 | |
291 | |
292 | QualType TransformType(QualType T); |
293 | |
294 | |
295 | |
296 | |
297 | |
298 | |
299 | |
300 | |
301 | |
302 | TypeSourceInfo *TransformType(TypeSourceInfo *DI); |
303 | |
304 | |
305 | |
306 | |
307 | |
308 | QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL); |
309 | |
310 | |
311 | |
312 | |
313 | |
314 | |
315 | |
316 | |
317 | QualType TransformTypeWithDeducedTST(QualType T); |
318 | TypeSourceInfo *TransformTypeWithDeducedTST(TypeSourceInfo *DI); |
319 | |
320 | |
321 | |
322 | enum StmtDiscardKind { |
323 | SDK_Discarded, |
324 | SDK_NotDiscarded, |
325 | SDK_StmtExprResult, |
326 | }; |
327 | |
328 | |
329 | |
330 | |
331 | |
332 | |
333 | |
334 | |
335 | |
336 | |
337 | StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK = SDK_Discarded); |
338 | |
339 | |
340 | |
341 | |
342 | |
343 | |
344 | |
345 | |
346 | |
347 | OMPClause *TransformOMPClause(OMPClause *S); |
348 | |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | |
355 | |
356 | |
357 | const Attr *TransformAttr(const Attr *S); |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | |
364 | |
365 | #define ATTR(X) |
366 | #define PRAGMA_SPELLING_ATTR(X) \ |
367 | const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; } |
368 | #include "clang/Basic/AttrList.inc" |
369 | |
370 | |
371 | |
372 | |
373 | |
374 | |
375 | |
376 | |
377 | |
378 | ExprResult TransformExpr(Expr *E); |
379 | |
380 | |
381 | |
382 | |
383 | |
384 | |
385 | |
386 | |
387 | ExprResult TransformInitializer(Expr *Init, bool NotCopyInit); |
388 | |
389 | |
390 | |
391 | |
392 | |
393 | |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | |
400 | |
401 | |
402 | |
403 | |
404 | |
405 | |
406 | |
407 | |
408 | |
409 | |
410 | |
411 | |
412 | bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, |
413 | SmallVectorImpl<Expr *> &Outputs, |
414 | bool *ArgChanged = nullptr); |
415 | |
416 | |
417 | |
418 | |
419 | |
420 | |
421 | |
422 | Decl *TransformDecl(SourceLocation Loc, Decl *D) { |
423 | llvm::DenseMap<Decl *, Decl *>::iterator Known |
424 | = TransformedLocalDecls.find(D); |
425 | if (Known != TransformedLocalDecls.end()) |
426 | return Known->second; |
427 | |
428 | return D; |
429 | } |
430 | |
431 | |
432 | |
433 | |
434 | |
435 | Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, |
436 | Expr *Expr, |
437 | Sema::ConditionKind Kind); |
438 | |
439 | |
440 | |
441 | |
442 | |
443 | |
444 | void transformAttrs(Decl *Old, Decl *New) { } |
445 | |
446 | |
447 | |
448 | |
449 | |
450 | |
451 | |
452 | |
453 | void transformedLocalDecl(Decl *Old, Decl *New) { |
454 | TransformedLocalDecls[Old] = New; |
455 | } |
456 | |
457 | |
458 | |
459 | |
460 | |
461 | Decl *TransformDefinition(SourceLocation Loc, Decl *D) { |
462 | return getDerived().TransformDecl(Loc, D); |
463 | } |
464 | |
465 | |
466 | |
467 | |
468 | |
469 | |
470 | |
471 | |
472 | |
473 | |
474 | NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { |
475 | return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D)); |
476 | } |
477 | |
478 | |
479 | bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, |
480 | LookupResult &R); |
481 | |
482 | |
483 | |
484 | |
485 | |
486 | |
487 | |
488 | NestedNameSpecifierLoc |
489 | TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, |
490 | QualType ObjectType = QualType(), |
491 | NamedDecl *FirstQualifierInScope = nullptr); |
492 | |
493 | |
494 | |
495 | |
496 | |
497 | |
498 | |
499 | DeclarationNameInfo |
500 | TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo); |
501 | |
502 | |
503 | |
504 | |
505 | |
506 | |
507 | |
508 | |
509 | |
510 | |
511 | |
512 | |
513 | |
514 | |
515 | |
516 | |
517 | |
518 | |
519 | |
520 | |
521 | |
522 | TemplateName |
523 | TransformTemplateName(CXXScopeSpec &SS, TemplateName Name, |
524 | SourceLocation NameLoc, |
525 | QualType ObjectType = QualType(), |
526 | NamedDecl *FirstQualifierInScope = nullptr, |
527 | bool AllowInjectedClassName = false); |
528 | |
529 | |
530 | |
531 | |
532 | |
533 | |
534 | |
535 | |
536 | |
537 | bool TransformTemplateArgument(const TemplateArgumentLoc &Input, |
538 | TemplateArgumentLoc &Output, |
539 | bool Uneval = false); |
540 | |
541 | |
542 | |
543 | |
544 | |
545 | |
546 | |
547 | |
548 | |
549 | |
550 | |
551 | |
552 | |
553 | |
554 | |
555 | |
556 | |
557 | |
558 | |
559 | bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, |
560 | unsigned NumInputs, |
561 | TemplateArgumentListInfo &Outputs, |
562 | bool Uneval = false) { |
563 | return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs, |
564 | Uneval); |
565 | } |
566 | |
567 | |
568 | |
569 | |
570 | |
571 | |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | |
580 | |
581 | template<typename InputIterator> |
582 | bool TransformTemplateArguments(InputIterator First, |
583 | InputIterator Last, |
584 | TemplateArgumentListInfo &Outputs, |
585 | bool Uneval = false); |
586 | |
587 | |
588 | void InventTemplateArgumentLoc(const TemplateArgument &Arg, |
589 | TemplateArgumentLoc &ArgLoc); |
590 | |
591 | |
592 | TypeSourceInfo *InventTypeSourceInfo(QualType T) { |
593 | return SemaRef.Context.getTrivialTypeSourceInfo(T, |
594 | getDerived().getBaseLocation()); |
595 | } |
596 | |
597 | #define ABSTRACT_TYPELOC(CLASS, PARENT) |
598 | #define TYPELOC(CLASS, PARENT) \ |
599 | QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T); |
600 | #include "clang/AST/TypeLocNodes.def" |
601 | |
602 | template<typename Fn> |
603 | QualType TransformFunctionProtoType(TypeLocBuilder &TLB, |
604 | FunctionProtoTypeLoc TL, |
605 | CXXRecordDecl *ThisContext, |
606 | Qualifiers ThisTypeQuals, |
607 | Fn TransformExceptionSpec); |
608 | |
609 | bool TransformExceptionSpec(SourceLocation Loc, |
610 | FunctionProtoType::ExceptionSpecInfo &ESI, |
611 | SmallVectorImpl<QualType> &Exceptions, |
612 | bool &Changed); |
613 | |
614 | StmtResult TransformSEHHandler(Stmt *Handler); |
615 | |
616 | QualType |
617 | TransformTemplateSpecializationType(TypeLocBuilder &TLB, |
618 | TemplateSpecializationTypeLoc TL, |
619 | TemplateName Template); |
620 | |
621 | QualType |
622 | TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, |
623 | DependentTemplateSpecializationTypeLoc TL, |
624 | TemplateName Template, |
625 | CXXScopeSpec &SS); |
626 | |
627 | QualType TransformDependentTemplateSpecializationType( |
628 | TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, |
629 | NestedNameSpecifierLoc QualifierLoc); |
630 | |
631 | |
632 | |
633 | |
634 | |
635 | |
636 | |
637 | |
638 | bool TransformFunctionTypeParams( |
639 | SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, |
640 | const QualType *ParamTypes, |
641 | const FunctionProtoType::ExtParameterInfo *ParamInfos, |
642 | SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars, |
643 | Sema::ExtParameterInfoBuilder &PInfos); |
644 | |
645 | |
646 | |
647 | |
648 | |
649 | |
650 | ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm, |
651 | int indexAdjustment, |
652 | Optional<unsigned> NumExpansions, |
653 | bool ExpectParameterPack); |
654 | |
655 | QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL); |
656 | |
657 | StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr); |
658 | ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E); |
659 | |
660 | TemplateParameterList *TransformTemplateParameterList( |
661 | TemplateParameterList *TPL) { |
662 | return TPL; |
663 | } |
664 | |
665 | ExprResult TransformAddressOfOperand(Expr *E); |
666 | |
667 | ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, |
668 | bool IsAddressOfOperand, |
669 | TypeSourceInfo **RecoveryTSI); |
670 | |
671 | ExprResult TransformParenDependentScopeDeclRefExpr( |
672 | ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, |
673 | TypeSourceInfo **RecoveryTSI); |
674 | |
675 | StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S); |
676 | |
677 | |
678 | |
679 | #define STMT(Node, Parent) \ |
680 | LLVM_ATTRIBUTE_NOINLINE \ |
681 | StmtResult Transform##Node(Node *S); |
682 | #define VALUESTMT(Node, Parent) \ |
683 | LLVM_ATTRIBUTE_NOINLINE \ |
684 | StmtResult Transform##Node(Node *S, StmtDiscardKind SDK); |
685 | #define EXPR(Node, Parent) \ |
686 | LLVM_ATTRIBUTE_NOINLINE \ |
687 | ExprResult Transform##Node(Node *E); |
688 | #define ABSTRACT_STMT(Stmt) |
689 | #include "clang/AST/StmtNodes.inc" |
690 | |
691 | #define OPENMP_CLAUSE(Name, Class) \ |
692 | LLVM_ATTRIBUTE_NOINLINE \ |
693 | OMPClause *Transform ## Class(Class *S); |
694 | #include "clang/Basic/OpenMPKinds.def" |
695 | |
696 | |
697 | |
698 | |
699 | |
700 | |
701 | |
702 | QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL); |
703 | |
704 | |
705 | |
706 | |
707 | |
708 | QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil); |
709 | |
710 | |
711 | |
712 | |
713 | |
714 | QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil); |
715 | |
716 | |
717 | |
718 | |
719 | |
720 | |
721 | |
722 | |
723 | |
724 | QualType RebuildReferenceType(QualType ReferentType, |
725 | bool LValue, |
726 | SourceLocation Sigil); |
727 | |
728 | |
729 | |
730 | |
731 | |
732 | |
733 | QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType, |
734 | SourceLocation Sigil); |
735 | |
736 | QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, |
737 | SourceLocation ProtocolLAngleLoc, |
738 | ArrayRef<ObjCProtocolDecl *> Protocols, |
739 | ArrayRef<SourceLocation> ProtocolLocs, |
740 | SourceLocation ProtocolRAngleLoc); |
741 | |
742 | |
743 | |
744 | |
745 | |
746 | QualType RebuildObjCObjectType(QualType BaseType, |
747 | SourceLocation Loc, |
748 | SourceLocation TypeArgsLAngleLoc, |
749 | ArrayRef<TypeSourceInfo *> TypeArgs, |
750 | SourceLocation TypeArgsRAngleLoc, |
751 | SourceLocation ProtocolLAngleLoc, |
752 | ArrayRef<ObjCProtocolDecl *> Protocols, |
753 | ArrayRef<SourceLocation> ProtocolLocs, |
754 | SourceLocation ProtocolRAngleLoc); |
755 | |
756 | |
757 | |
758 | |
759 | |
760 | QualType RebuildObjCObjectPointerType(QualType PointeeType, |
761 | SourceLocation Star); |
762 | |
763 | |
764 | |
765 | |
766 | |
767 | |
768 | |
769 | |
770 | QualType RebuildArrayType(QualType ElementType, |
771 | ArrayType::ArraySizeModifier SizeMod, |
772 | const llvm::APInt *Size, |
773 | Expr *SizeExpr, |
774 | unsigned IndexTypeQuals, |
775 | SourceRange BracketsRange); |
776 | |
777 | |
778 | |
779 | |
780 | |
781 | |
782 | QualType RebuildConstantArrayType(QualType ElementType, |
783 | ArrayType::ArraySizeModifier SizeMod, |
784 | const llvm::APInt &Size, |
785 | unsigned IndexTypeQuals, |
786 | SourceRange BracketsRange); |
787 | |
788 | |
789 | |
790 | |
791 | |
792 | |
793 | QualType RebuildIncompleteArrayType(QualType ElementType, |
794 | ArrayType::ArraySizeModifier SizeMod, |
795 | unsigned IndexTypeQuals, |
796 | SourceRange BracketsRange); |
797 | |
798 | |
799 | |
800 | |
801 | |
802 | |
803 | QualType RebuildVariableArrayType(QualType ElementType, |
804 | ArrayType::ArraySizeModifier SizeMod, |
805 | Expr *SizeExpr, |
806 | unsigned IndexTypeQuals, |
807 | SourceRange BracketsRange); |
808 | |
809 | |
810 | |
811 | |
812 | |
813 | |
814 | QualType RebuildDependentSizedArrayType(QualType ElementType, |
815 | ArrayType::ArraySizeModifier SizeMod, |
816 | Expr *SizeExpr, |
817 | unsigned IndexTypeQuals, |
818 | SourceRange BracketsRange); |
819 | |
820 | |
821 | |
822 | |
823 | |
824 | |
825 | QualType RebuildVectorType(QualType ElementType, unsigned NumElements, |
826 | VectorType::VectorKind VecKind); |
827 | |
828 | |
829 | |
830 | |
831 | |
832 | |
833 | QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, |
834 | SourceLocation AttributeLoc, |
835 | VectorType::VectorKind); |
836 | |
837 | |
838 | |
839 | |
840 | |
841 | |
842 | QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, |
843 | SourceLocation AttributeLoc); |
844 | |
845 | |
846 | |
847 | |
848 | |
849 | |
850 | QualType RebuildDependentSizedExtVectorType(QualType ElementType, |
851 | Expr *SizeExpr, |
852 | SourceLocation AttributeLoc); |
853 | |
854 | |
855 | |
856 | |
857 | |
858 | |
859 | |
860 | |
861 | |
862 | QualType RebuildDependentAddressSpaceType(QualType PointeeType, |
863 | Expr *AddrSpaceExpr, |
864 | SourceLocation AttributeLoc); |
865 | |
866 | |
867 | |
868 | |
869 | |
870 | QualType RebuildFunctionProtoType(QualType T, |
871 | MutableArrayRef<QualType> ParamTypes, |
872 | const FunctionProtoType::ExtProtoInfo &EPI); |
873 | |
874 | |
875 | QualType RebuildFunctionNoProtoType(QualType ResultType); |
876 | |
877 | |
878 | |
879 | QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D); |
880 | |
881 | |
882 | QualType RebuildTypedefType(TypedefNameDecl *Typedef) { |
883 | return SemaRef.Context.getTypeDeclType(Typedef); |
884 | } |
885 | |
886 | |
887 | QualType RebuildRecordType(RecordDecl *Record) { |
888 | return SemaRef.Context.getTypeDeclType(Record); |
889 | } |
890 | |
891 | |
892 | QualType RebuildEnumType(EnumDecl *Enum) { |
893 | return SemaRef.Context.getTypeDeclType(Enum); |
894 | } |
895 | |
896 | |
897 | |
898 | |
899 | |
900 | QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc); |
901 | |
902 | |
903 | |
904 | |
905 | QualType RebuildTypeOfType(QualType Underlying); |
906 | |
907 | |
908 | QualType RebuildUnaryTransformType(QualType BaseType, |
909 | UnaryTransformType::UTTKind UKind, |
910 | SourceLocation Loc); |
911 | |
912 | |
913 | |
914 | |
915 | |
916 | QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc); |
917 | |
918 | |
919 | |
920 | |
921 | QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword) { |
922 | |
923 | |
924 | |
925 | return SemaRef.Context.getAutoType(Deduced, Keyword, |
926 | false); |
927 | } |
928 | |
929 | |
930 | |
931 | QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, |
932 | QualType Deduced) { |
933 | return SemaRef.Context.getDeducedTemplateSpecializationType( |
934 | Template, Deduced, false); |
935 | } |
936 | |
937 | |
938 | |
939 | |
940 | |
941 | |
942 | QualType RebuildTemplateSpecializationType(TemplateName Template, |
943 | SourceLocation TemplateLoc, |
944 | TemplateArgumentListInfo &Args); |
945 | |
946 | |
947 | |
948 | |
949 | |
950 | QualType RebuildParenType(QualType InnerType) { |
951 | return SemaRef.BuildParenType(InnerType); |
952 | } |
953 | |
954 | |
955 | |
956 | |
957 | |
958 | |
959 | QualType RebuildElaboratedType(SourceLocation KeywordLoc, |
960 | ElaboratedTypeKeyword Keyword, |
961 | NestedNameSpecifierLoc QualifierLoc, |
962 | QualType Named) { |
963 | return SemaRef.Context.getElaboratedType(Keyword, |
964 | QualifierLoc.getNestedNameSpecifier(), |
965 | Named); |
966 | } |
967 | |
968 | |
969 | |
970 | |
971 | |
972 | |
973 | QualType RebuildDependentTemplateSpecializationType( |
974 | ElaboratedTypeKeyword Keyword, |
975 | NestedNameSpecifierLoc QualifierLoc, |
976 | SourceLocation TemplateKWLoc, |
977 | const IdentifierInfo *Name, |
978 | SourceLocation NameLoc, |
979 | TemplateArgumentListInfo &Args, |
980 | bool AllowInjectedClassName) { |
981 | |
982 | |
983 | CXXScopeSpec SS; |
984 | SS.Adopt(QualifierLoc); |
985 | TemplateName InstName = getDerived().RebuildTemplateName( |
986 | SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr, |
987 | AllowInjectedClassName); |
988 | |
989 | if (InstName.isNull()) |
990 | return QualType(); |
991 | |
992 | |
993 | if (InstName.getAsDependentTemplateName()) |
994 | return SemaRef.Context.getDependentTemplateSpecializationType(Keyword, |
995 | QualifierLoc.getNestedNameSpecifier(), |
996 | Name, |
997 | Args); |
998 | |
999 | |
1000 | |
1001 | QualType T = |
1002 | getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); |
1003 | if (T.isNull()) return QualType(); |
1004 | |
1005 | if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr) |
1006 | return T; |
1007 | |
1008 | return SemaRef.Context.getElaboratedType(Keyword, |
1009 | QualifierLoc.getNestedNameSpecifier(), |
1010 | T); |
1011 | } |
1012 | |
1013 | |
1014 | |
1015 | |
1016 | |
1017 | |
1018 | QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, |
1019 | SourceLocation KeywordLoc, |
1020 | NestedNameSpecifierLoc QualifierLoc, |
1021 | const IdentifierInfo *Id, |
1022 | SourceLocation IdLoc, |
1023 | bool DeducedTSTContext) { |
1024 | CXXScopeSpec SS; |
1025 | SS.Adopt(QualifierLoc); |
1026 | |
1027 | if (QualifierLoc.getNestedNameSpecifier()->isDependent()) { |
1028 | |
1029 | if (!SemaRef.computeDeclContext(SS)) |
1030 | return SemaRef.Context.getDependentNameType(Keyword, |
1031 | QualifierLoc.getNestedNameSpecifier(), |
1032 | Id); |
1033 | } |
1034 | |
1035 | if (Keyword == ETK_None || Keyword == ETK_Typename) { |
1036 | QualType T = SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc, |
1037 | *Id, IdLoc); |
1038 | |
1039 | |
1040 | if (!DeducedTSTContext) { |
1041 | if (auto *Deduced = dyn_cast_or_null<DeducedTemplateSpecializationType>( |
1042 | T.isNull() ? nullptr : T->getContainedDeducedType())) { |
1043 | SemaRef.Diag(IdLoc, diag::err_dependent_deduced_tst) |
1044 | << (int)SemaRef.getTemplateNameKindForDiagnostics( |
1045 | Deduced->getTemplateName()) |
1046 | << QualType(QualifierLoc.getNestedNameSpecifier()->getAsType(), 0); |
1047 | if (auto *TD = Deduced->getTemplateName().getAsTemplateDecl()) |
1048 | SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here); |
1049 | return QualType(); |
1050 | } |
1051 | } |
1052 | return T; |
1053 | } |
1054 | |
1055 | TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForKeyword(Keyword); |
1056 | |
1057 | |
1058 | |
1059 | |
1060 | LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName); |
1061 | DeclContext *DC = SemaRef.computeDeclContext(SS, false); |
1062 | if (!DC) |
1063 | return QualType(); |
1064 | |
1065 | if (SemaRef.RequireCompleteDeclContext(SS, DC)) |
1066 | return QualType(); |
1067 | |
1068 | TagDecl *Tag = nullptr; |
1069 | SemaRef.LookupQualifiedName(Result, DC); |
1070 | switch (Result.getResultKind()) { |
1071 | case LookupResult::NotFound: |
1072 | case LookupResult::NotFoundInCurrentInstantiation: |
1073 | break; |
1074 | |
1075 | case LookupResult::Found: |
1076 | Tag = Result.getAsSingle<TagDecl>(); |
1077 | break; |
1078 | |
1079 | case LookupResult::FoundOverloaded: |
1080 | case LookupResult::FoundUnresolvedValue: |
1081 | llvm_unreachable("Tag lookup cannot find non-tags"); |
1082 | |
1083 | case LookupResult::Ambiguous: |
1084 | |
1085 | return QualType(); |
1086 | } |
1087 | |
1088 | if (!Tag) { |
1089 | |
1090 | |
1091 | LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName); |
1092 | SemaRef.LookupQualifiedName(Result, DC); |
1093 | switch (Result.getResultKind()) { |
1094 | case LookupResult::Found: |
1095 | case LookupResult::FoundOverloaded: |
1096 | case LookupResult::FoundUnresolvedValue: { |
1097 | NamedDecl *SomeDecl = Result.getRepresentativeDecl(); |
1098 | Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind); |
1099 | SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl |
1100 | << NTK << Kind; |
1101 | SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at); |
1102 | break; |
1103 | } |
1104 | default: |
1105 | SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope) |
1106 | << Kind << Id << DC << QualifierLoc.getSourceRange(); |
1107 | break; |
1108 | } |
1109 | return QualType(); |
1110 | } |
1111 | |
1112 | if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, , |
1113 | IdLoc, Id)) { |
1114 | SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id; |
1115 | SemaRef.Diag(Tag->getLocation(), diag::note_previous_use); |
1116 | return QualType(); |
1117 | } |
1118 | |
1119 | |
1120 | QualType T = SemaRef.Context.getTypeDeclType(Tag); |
1121 | return SemaRef.Context.getElaboratedType(Keyword, |
1122 | QualifierLoc.getNestedNameSpecifier(), |
1123 | T); |
1124 | } |
1125 | |
1126 | |
1127 | |
1128 | |
1129 | |
1130 | QualType RebuildPackExpansionType(QualType Pattern, |
1131 | SourceRange PatternRange, |
1132 | SourceLocation EllipsisLoc, |
1133 | Optional<unsigned> NumExpansions) { |
1134 | return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc, |
1135 | NumExpansions); |
1136 | } |
1137 | |
1138 | |
1139 | |
1140 | |
1141 | |
1142 | QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc); |
1143 | |
1144 | |
1145 | QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, |
1146 | bool isReadPipe); |
1147 | |
1148 | |
1149 | |
1150 | |
1151 | |
1152 | |
1153 | |
1154 | TemplateName RebuildTemplateName(CXXScopeSpec &SS, |
1155 | bool TemplateKW, |
1156 | TemplateDecl *Template); |
1157 | |
1158 | |
1159 | |
1160 | |
1161 | |
1162 | |
1163 | |
1164 | |
1165 | TemplateName RebuildTemplateName(CXXScopeSpec &SS, |
1166 | SourceLocation TemplateKWLoc, |
1167 | const IdentifierInfo &Name, |
1168 | SourceLocation NameLoc, QualType ObjectType, |
1169 | NamedDecl *FirstQualifierInScope, |
1170 | bool AllowInjectedClassName); |
1171 | |
1172 | |
1173 | |
1174 | |
1175 | |
1176 | |
1177 | |
1178 | |
1179 | TemplateName RebuildTemplateName(CXXScopeSpec &SS, |
1180 | SourceLocation TemplateKWLoc, |
1181 | OverloadedOperatorKind Operator, |
1182 | SourceLocation NameLoc, QualType ObjectType, |
1183 | bool AllowInjectedClassName); |
1184 | |
1185 | |
1186 | |
1187 | |
1188 | |
1189 | |
1190 | |
1191 | |
1192 | TemplateName RebuildTemplateName(TemplateTemplateParmDecl *Param, |
1193 | const TemplateArgument &ArgPack) { |
1194 | return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack); |
1195 | } |
1196 | |
1197 | |
1198 | |
1199 | |
1200 | |
1201 | StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, |
1202 | MultiStmtArg Statements, |
1203 | SourceLocation RBraceLoc, |
1204 | bool IsStmtExpr) { |
1205 | return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements, |
1206 | IsStmtExpr); |
1207 | } |
1208 | |
1209 | |
1210 | |
1211 | |
1212 | |
1213 | StmtResult RebuildCaseStmt(SourceLocation CaseLoc, |
1214 | Expr *LHS, |
1215 | SourceLocation EllipsisLoc, |
1216 | Expr *RHS, |
1217 | SourceLocation ColonLoc) { |
1218 | return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS, |
1219 | ColonLoc); |
1220 | } |
1221 | |
1222 | |
1223 | |
1224 | |
1225 | |
1226 | StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body) { |
1227 | getSema().ActOnCaseStmtBody(S, Body); |
1228 | return S; |
1229 | } |
1230 | |
1231 | |
1232 | |
1233 | |
1234 | |
1235 | StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, |
1236 | SourceLocation ColonLoc, |
1237 | Stmt *SubStmt) { |
1238 | return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt, |
1239 | ); |
1240 | } |
1241 | |
1242 | |
1243 | |
1244 | |
1245 | |
1246 | StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, |
1247 | SourceLocation ColonLoc, Stmt *SubStmt) { |
1248 | return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt); |
1249 | } |
1250 | |
1251 | |
1252 | |
1253 | |
1254 | |
1255 | StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, |
1256 | ArrayRef<const Attr*> Attrs, |
1257 | Stmt *SubStmt) { |
1258 | return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt); |
1259 | } |
1260 | |
1261 | |
1262 | |
1263 | |
1264 | |
1265 | StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr, |
1266 | Sema::ConditionResult Cond, Stmt *Init, Stmt *Then, |
1267 | SourceLocation ElseLoc, Stmt *Else) { |
1268 | return getSema().ActOnIfStmt(IfLoc, IsConstexpr, Init, Cond, Then, |
1269 | ElseLoc, Else); |
1270 | } |
1271 | |
1272 | |
1273 | |
1274 | |
1275 | |
1276 | StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, Stmt *Init, |
1277 | Sema::ConditionResult Cond) { |
1278 | return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Init, Cond); |
1279 | } |
1280 | |
1281 | |
1282 | |
1283 | |
1284 | |
1285 | StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, |
1286 | Stmt *Switch, Stmt *Body) { |
1287 | return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body); |
1288 | } |
1289 | |
1290 | |
1291 | |
1292 | |
1293 | |
1294 | StmtResult RebuildWhileStmt(SourceLocation WhileLoc, |
1295 | Sema::ConditionResult Cond, Stmt *Body) { |
1296 | return getSema().ActOnWhileStmt(WhileLoc, Cond, Body); |
1297 | } |
1298 | |
1299 | |
1300 | |
1301 | |
1302 | |
1303 | StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, |
1304 | SourceLocation WhileLoc, SourceLocation LParenLoc, |
1305 | Expr *Cond, SourceLocation RParenLoc) { |
1306 | return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc, |
1307 | Cond, RParenLoc); |
1308 | } |
1309 | |
1310 | |
1311 | |
1312 | |
1313 | |
1314 | StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, |
1315 | Stmt *Init, Sema::ConditionResult Cond, |
1316 | Sema::FullExprArg Inc, SourceLocation RParenLoc, |
1317 | Stmt *Body) { |
1318 | return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond, |
1319 | Inc, RParenLoc, Body); |
1320 | } |
1321 | |
1322 | |
1323 | |
1324 | |
1325 | |
1326 | StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, |
1327 | LabelDecl *Label) { |
1328 | return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label); |
1329 | } |
1330 | |
1331 | |
1332 | |
1333 | |
1334 | |
1335 | StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, |
1336 | SourceLocation StarLoc, |
1337 | Expr *Target) { |
1338 | return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target); |
1339 | } |
1340 | |
1341 | |
1342 | |
1343 | |
1344 | |
1345 | StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result) { |
1346 | return getSema().BuildReturnStmt(ReturnLoc, Result); |
1347 | } |
1348 | |
1349 | |
1350 | |
1351 | |
1352 | |
1353 | StmtResult RebuildDeclStmt(MutableArrayRef<Decl *> Decls, |
1354 | SourceLocation StartLoc, SourceLocation EndLoc) { |
1355 | Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls); |
1356 | return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc); |
1357 | } |
1358 | |
1359 | |
1360 | |
1361 | |
1362 | |
1363 | StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, |
1364 | bool IsVolatile, unsigned NumOutputs, |
1365 | unsigned NumInputs, IdentifierInfo **Names, |
1366 | MultiExprArg Constraints, MultiExprArg Exprs, |
1367 | Expr *AsmString, MultiExprArg Clobbers, |
1368 | SourceLocation RParenLoc) { |
1369 | return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, |
1370 | NumInputs, Names, Constraints, Exprs, |
1371 | AsmString, Clobbers, RParenLoc); |
1372 | } |
1373 | |
1374 | |
1375 | |
1376 | |
1377 | |
1378 | StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, |
1379 | ArrayRef<Token> AsmToks, |
1380 | StringRef AsmString, |
1381 | unsigned NumOutputs, unsigned NumInputs, |
1382 | ArrayRef<StringRef> Constraints, |
1383 | ArrayRef<StringRef> Clobbers, |
1384 | ArrayRef<Expr*> Exprs, |
1385 | SourceLocation EndLoc) { |
1386 | return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString, |
1387 | NumOutputs, NumInputs, |
1388 | Constraints, Clobbers, Exprs, EndLoc); |
1389 | } |
1390 | |
1391 | |
1392 | |
1393 | |
1394 | |
1395 | StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, |
1396 | bool IsImplicit) { |
1397 | return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit); |
1398 | } |
1399 | |
1400 | |
1401 | |
1402 | |
1403 | |
1404 | ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, |
1405 | bool IsImplicit) { |
1406 | return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Result, IsImplicit); |
1407 | } |
1408 | |
1409 | |
1410 | |
1411 | |
1412 | |
1413 | ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, |
1414 | Expr *Result, |
1415 | UnresolvedLookupExpr *Lookup) { |
1416 | return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup); |
1417 | } |
1418 | |
1419 | |
1420 | |
1421 | |
1422 | |
1423 | ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result) { |
1424 | return getSema().BuildCoyieldExpr(CoyieldLoc, Result); |
1425 | } |
1426 | |
1427 | StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args) { |
1428 | return getSema().BuildCoroutineBodyStmt(Args); |
1429 | } |
1430 | |
1431 | |
1432 | |
1433 | |
1434 | |
1435 | StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, |
1436 | Stmt *TryBody, |
1437 | MultiStmtArg CatchStmts, |
1438 | Stmt *Finally) { |
1439 | return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts, |
1440 | Finally); |
1441 | } |
1442 | |
1443 | |
1444 | |
1445 | |
1446 | |
1447 | VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, |
1448 | TypeSourceInfo *TInfo, QualType T) { |
1449 | return getSema().BuildObjCExceptionDecl(TInfo, T, |
1450 | ExceptionDecl->getInnerLocStart(), |
1451 | ExceptionDecl->getLocation(), |
1452 | ExceptionDecl->getIdentifier()); |
1453 | } |
1454 | |
1455 | |
1456 | |
1457 | |
1458 | |
1459 | StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, |
1460 | SourceLocation RParenLoc, |
1461 | VarDecl *Var, |
1462 | Stmt *Body) { |
1463 | return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, |
1464 | Var, Body); |
1465 | } |
1466 | |
1467 | |
1468 | |
1469 | |
1470 | |
1471 | StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, |
1472 | Stmt *Body) { |
1473 | return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body); |
1474 | } |
1475 | |
1476 | |
1477 | |
1478 | |
1479 | |
1480 | StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, |
1481 | Expr *Operand) { |
1482 | return getSema().BuildObjCAtThrowStmt(AtLoc, Operand); |
1483 | } |
1484 | |
1485 | |
1486 | |
1487 | |
1488 | |
1489 | StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, |
1490 | DeclarationNameInfo DirName, |
1491 | OpenMPDirectiveKind CancelRegion, |
1492 | ArrayRef<OMPClause *> Clauses, |
1493 | Stmt *AStmt, SourceLocation StartLoc, |
1494 | SourceLocation EndLoc) { |
1495 | return getSema().ActOnOpenMPExecutableDirective( |
1496 | Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc); |
1497 | } |
1498 | |
1499 | |
1500 | |
1501 | |
1502 | |
1503 | OMPClause *RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, |
1504 | Expr *Condition, SourceLocation StartLoc, |
1505 | SourceLocation LParenLoc, |
1506 | SourceLocation NameModifierLoc, |
1507 | SourceLocation ColonLoc, |
1508 | SourceLocation EndLoc) { |
1509 | return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc, |
1510 | LParenLoc, NameModifierLoc, ColonLoc, |
1511 | EndLoc); |
1512 | } |
1513 | |
1514 | |
1515 | |
1516 | |
1517 | |
1518 | OMPClause *RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, |
1519 | SourceLocation LParenLoc, |
1520 | SourceLocation EndLoc) { |
1521 | return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc, |
1522 | EndLoc); |
1523 | } |
1524 | |
1525 | |
1526 | |
1527 | |
1528 | |
1529 | OMPClause *RebuildOMPNumThreadsClause(Expr *NumThreads, |
1530 | SourceLocation StartLoc, |
1531 | SourceLocation LParenLoc, |
1532 | SourceLocation EndLoc) { |
1533 | return getSema().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc, |
1534 | LParenLoc, EndLoc); |
1535 | } |
1536 | |
1537 | |
1538 | |
1539 | |
1540 | |
1541 | OMPClause *RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, |
1542 | SourceLocation LParenLoc, |
1543 | SourceLocation EndLoc) { |
1544 | return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc); |
1545 | } |
1546 | |
1547 | |
1548 | |
1549 | |
1550 | |
1551 | OMPClause *RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, |
1552 | SourceLocation LParenLoc, |
1553 | SourceLocation EndLoc) { |
1554 | return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc); |
1555 | } |
1556 | |
1557 | |
1558 | |
1559 | |
1560 | |
1561 | OMPClause *RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, |
1562 | SourceLocation LParenLoc, |
1563 | SourceLocation EndLoc) { |
1564 | return getSema().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc, EndLoc); |
1565 | } |
1566 | |
1567 | |
1568 | |
1569 | |
1570 | |
1571 | OMPClause *RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, |
1572 | SourceLocation LParenLoc, |
1573 | SourceLocation EndLoc) { |
1574 | return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc, |
1575 | EndLoc); |
1576 | } |
1577 | |
1578 | |
1579 | |
1580 | |
1581 | |
1582 | OMPClause *RebuildOMPDefaultClause(OpenMPDefaultClauseKind Kind, |
1583 | SourceLocation KindKwLoc, |
1584 | SourceLocation StartLoc, |
1585 | SourceLocation LParenLoc, |
1586 | SourceLocation EndLoc) { |
1587 | return getSema().ActOnOpenMPDefaultClause(Kind, KindKwLoc, |
1588 | StartLoc, LParenLoc, EndLoc); |
1589 | } |
1590 | |
1591 | |
1592 | |
1593 | |
1594 | |
1595 | OMPClause *RebuildOMPProcBindClause(OpenMPProcBindClauseKind Kind, |
1596 | SourceLocation KindKwLoc, |
1597 | SourceLocation StartLoc, |
1598 | SourceLocation LParenLoc, |
1599 | SourceLocation EndLoc) { |
1600 | return getSema().ActOnOpenMPProcBindClause(Kind, KindKwLoc, |
1601 | StartLoc, LParenLoc, EndLoc); |
1602 | } |
1603 | |
1604 | |
1605 | |
1606 | |
1607 | |
1608 | OMPClause *RebuildOMPScheduleClause( |
1609 | OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, |
1610 | OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, |
1611 | SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, |
1612 | SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) { |
1613 | return getSema().ActOnOpenMPScheduleClause( |
1614 | M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc, |
1615 | CommaLoc, EndLoc); |
1616 | } |
1617 | |
1618 | |
1619 | |
1620 | |
1621 | |
1622 | OMPClause *RebuildOMPOrderedClause(SourceLocation StartLoc, |
1623 | SourceLocation EndLoc, |
1624 | SourceLocation LParenLoc, Expr *Num) { |
1625 | return getSema().ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Num); |
1626 | } |
1627 | |
1628 | |
1629 | |
1630 | |
1631 | |
1632 | OMPClause *RebuildOMPPrivateClause(ArrayRef<Expr *> VarList, |
1633 | SourceLocation StartLoc, |
1634 | SourceLocation LParenLoc, |
1635 | SourceLocation EndLoc) { |
1636 | return getSema().ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc, |
1637 | EndLoc); |
1638 | } |
1639 | |
1640 | |
1641 | |
1642 | |
1643 | |
1644 | OMPClause *RebuildOMPFirstprivateClause(ArrayRef<Expr *> VarList, |
1645 | SourceLocation StartLoc, |
1646 | SourceLocation LParenLoc, |
1647 | SourceLocation EndLoc) { |
1648 | return getSema().ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc, |
1649 | EndLoc); |
1650 | } |
1651 | |
1652 | |
1653 | |
1654 | |
1655 | |
1656 | OMPClause *RebuildOMPLastprivateClause(ArrayRef<Expr *> VarList, |
1657 | SourceLocation StartLoc, |
1658 | SourceLocation LParenLoc, |
1659 | SourceLocation EndLoc) { |
1660 | return getSema().ActOnOpenMPLastprivateClause(VarList, StartLoc, LParenLoc, |
1661 | EndLoc); |
1662 | } |
1663 | |
1664 | |
1665 | |
1666 | |
1667 | |
1668 | OMPClause *RebuildOMPSharedClause(ArrayRef<Expr *> VarList, |
1669 | SourceLocation StartLoc, |
1670 | SourceLocation LParenLoc, |
1671 | SourceLocation EndLoc) { |
1672 | return getSema().ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc, |
1673 | EndLoc); |
1674 | } |
1675 | |
1676 | |
1677 | |
1678 | |
1679 | |
1680 | OMPClause *RebuildOMPReductionClause(ArrayRef<Expr *> VarList, |
1681 | SourceLocation StartLoc, |
1682 | SourceLocation LParenLoc, |
1683 | SourceLocation ColonLoc, |
1684 | SourceLocation EndLoc, |
1685 | CXXScopeSpec &ReductionIdScopeSpec, |
1686 | const DeclarationNameInfo &ReductionId, |
1687 | ArrayRef<Expr *> UnresolvedReductions) { |
1688 | return getSema().ActOnOpenMPReductionClause( |
1689 | VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, |
1690 | ReductionId, UnresolvedReductions); |
1691 | } |
1692 | |
1693 | |
1694 | |
1695 | |
1696 | |
1697 | OMPClause *RebuildOMPTaskReductionClause( |
1698 | ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
1699 | SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, |
1700 | CXXScopeSpec &ReductionIdScopeSpec, |
1701 | const DeclarationNameInfo &ReductionId, |
1702 | ArrayRef<Expr *> UnresolvedReductions) { |
1703 | return getSema().ActOnOpenMPTaskReductionClause( |
1704 | VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, |
1705 | ReductionId, UnresolvedReductions); |
1706 | } |
1707 | |
1708 | |
1709 | |
1710 | |
1711 | |
1712 | OMPClause * |
1713 | RebuildOMPInReductionClause(ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
1714 | SourceLocation LParenLoc, SourceLocation ColonLoc, |
1715 | SourceLocation EndLoc, |
1716 | CXXScopeSpec &ReductionIdScopeSpec, |
1717 | const DeclarationNameInfo &ReductionId, |
1718 | ArrayRef<Expr *> UnresolvedReductions) { |
1719 | return getSema().ActOnOpenMPInReductionClause( |
1720 | VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, |
1721 | ReductionId, UnresolvedReductions); |
1722 | } |
1723 | |
1724 | |
1725 | |
1726 | |
1727 | |
1728 | OMPClause *RebuildOMPLinearClause(ArrayRef<Expr *> VarList, Expr *Step, |
1729 | SourceLocation StartLoc, |
1730 | SourceLocation LParenLoc, |
1731 | OpenMPLinearClauseKind Modifier, |
1732 | SourceLocation ModifierLoc, |
1733 | SourceLocation ColonLoc, |
1734 | SourceLocation EndLoc) { |
1735 | return getSema().ActOnOpenMPLinearClause(VarList, Step, StartLoc, LParenLoc, |
1736 | Modifier, ModifierLoc, ColonLoc, |
1737 | EndLoc); |
1738 | } |
1739 | |
1740 | |
1741 | |
1742 | |
1743 | |
1744 | OMPClause *RebuildOMPAlignedClause(ArrayRef<Expr *> VarList, Expr *Alignment, |
1745 | SourceLocation StartLoc, |
1746 | SourceLocation LParenLoc, |
1747 | SourceLocation ColonLoc, |
1748 | SourceLocation EndLoc) { |
1749 | return getSema().ActOnOpenMPAlignedClause(VarList, Alignment, StartLoc, |
1750 | LParenLoc, ColonLoc, EndLoc); |
1751 | } |
1752 | |
1753 | |
1754 | |
1755 | |
1756 | |
1757 | OMPClause *RebuildOMPCopyinClause(ArrayRef<Expr *> VarList, |
1758 | SourceLocation StartLoc, |
1759 | SourceLocation LParenLoc, |
1760 | SourceLocation EndLoc) { |
1761 | return getSema().ActOnOpenMPCopyinClause(VarList, StartLoc, LParenLoc, |
1762 | EndLoc); |
1763 | } |
1764 | |
1765 | |
1766 | |
1767 | |
1768 | |
1769 | OMPClause *RebuildOMPCopyprivateClause(ArrayRef<Expr *> VarList, |
1770 | SourceLocation StartLoc, |
1771 | SourceLocation LParenLoc, |
1772 | SourceLocation EndLoc) { |
1773 | return getSema().ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc, |
1774 | EndLoc); |
1775 | } |
1776 | |
1777 | |
1778 | |
1779 | |
1780 | |
1781 | OMPClause *RebuildOMPFlushClause(ArrayRef<Expr *> VarList, |
1782 | SourceLocation StartLoc, |
1783 | SourceLocation LParenLoc, |
1784 | SourceLocation EndLoc) { |
1785 | return getSema().ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc, |
1786 | EndLoc); |
1787 | } |
1788 | |
1789 | |
1790 | |
1791 | |
1792 | |
1793 | OMPClause * |
1794 | RebuildOMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc, |
1795 | SourceLocation ColonLoc, ArrayRef<Expr *> VarList, |
1796 | SourceLocation StartLoc, SourceLocation LParenLoc, |
1797 | SourceLocation EndLoc) { |
1798 | return getSema().ActOnOpenMPDependClause(DepKind, DepLoc, ColonLoc, VarList, |
1799 | StartLoc, LParenLoc, EndLoc); |
1800 | } |
1801 | |
1802 | |
1803 | |
1804 | |
1805 | |
1806 | OMPClause *RebuildOMPDeviceClause(Expr *Device, SourceLocation StartLoc, |
1807 | SourceLocation LParenLoc, |
1808 | SourceLocation EndLoc) { |
1809 | return getSema().ActOnOpenMPDeviceClause(Device, StartLoc, LParenLoc, |
1810 | EndLoc); |
1811 | } |
1812 | |
1813 | |
1814 | |
1815 | |
1816 | |
1817 | OMPClause *RebuildOMPMapClause( |
1818 | ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, |
1819 | ArrayRef<SourceLocation> MapTypeModifiersLoc, |
1820 | CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId, |
1821 | OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, |
1822 | SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, |
1823 | const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) { |
1824 | return getSema().ActOnOpenMPMapClause(MapTypeModifiers, MapTypeModifiersLoc, |
1825 | MapperIdScopeSpec, MapperId, MapType, |
1826 | IsMapTypeImplicit, MapLoc, ColonLoc, |
1827 | VarList, Locs, UnresolvedMappers); |
1828 | } |
1829 | |
1830 | |
1831 | |
1832 | |
1833 | |
1834 | OMPClause *RebuildOMPAllocateClause(Expr *Allocate, ArrayRef<Expr *> VarList, |
1835 | SourceLocation StartLoc, |
1836 | SourceLocation LParenLoc, |
1837 | SourceLocation ColonLoc, |
1838 | SourceLocation EndLoc) { |
1839 | return getSema().ActOnOpenMPAllocateClause(Allocate, VarList, StartLoc, |
1840 | LParenLoc, ColonLoc, EndLoc); |
1841 | } |
1842 | |
1843 | |
1844 | |
1845 | |
1846 | |
1847 | OMPClause *RebuildOMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, |
1848 | SourceLocation LParenLoc, |
1849 | SourceLocation EndLoc) { |
1850 | return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc, |
1851 | EndLoc); |
1852 | } |
1853 | |
1854 | |
1855 | |
1856 | |
1857 | |
1858 | OMPClause *RebuildOMPThreadLimitClause(Expr *ThreadLimit, |
1859 | SourceLocation StartLoc, |
1860 | SourceLocation LParenLoc, |
1861 | SourceLocation EndLoc) { |
1862 | return getSema().ActOnOpenMPThreadLimitClause(ThreadLimit, StartLoc, |
1863 | LParenLoc, EndLoc); |
1864 | } |
1865 | |
1866 | |
1867 | |
1868 | |
1869 | |
1870 | OMPClause *RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, |
1871 | SourceLocation LParenLoc, |
1872 | SourceLocation EndLoc) { |
1873 | return getSema().ActOnOpenMPPriorityClause(Priority, StartLoc, LParenLoc, |
1874 | EndLoc); |
1875 | } |
1876 | |
1877 | |
1878 | |
1879 | |
1880 | |
1881 | OMPClause *RebuildOMPGrainsizeClause(Expr *Grainsize, SourceLocation StartLoc, |
1882 | SourceLocation LParenLoc, |
1883 | SourceLocation EndLoc) { |
1884 | return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc, |
1885 | EndLoc); |
1886 | } |
1887 | |
1888 | |
1889 | |
1890 | |
1891 | |
1892 | OMPClause *RebuildOMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc, |
1893 | SourceLocation LParenLoc, |
1894 | SourceLocation EndLoc) { |
1895 | return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc, |
1896 | EndLoc); |
1897 | } |
1898 | |
1899 | |
1900 | |
1901 | |
1902 | |
1903 | OMPClause *RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, |
1904 | SourceLocation LParenLoc, |
1905 | SourceLocation EndLoc) { |
1906 | return getSema().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc, EndLoc); |
1907 | } |
1908 | |
1909 | |
1910 | |
1911 | |
1912 | |
1913 | OMPClause * |
1914 | RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, |
1915 | Expr *ChunkSize, SourceLocation StartLoc, |
1916 | SourceLocation LParenLoc, SourceLocation KindLoc, |
1917 | SourceLocation CommaLoc, SourceLocation EndLoc) { |
1918 | return getSema().ActOnOpenMPDistScheduleClause( |
1919 | Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc); |
1920 | } |
1921 | |
1922 | |
1923 | |
1924 | |
1925 | |
1926 | OMPClause *RebuildOMPToClause(ArrayRef<Expr *> VarList, |
1927 | CXXScopeSpec &MapperIdScopeSpec, |
1928 | DeclarationNameInfo &MapperId, |
1929 | const OMPVarListLocTy &Locs, |
1930 | ArrayRef<Expr *> UnresolvedMappers) { |
1931 | return getSema().ActOnOpenMPToClause(VarList, MapperIdScopeSpec, MapperId, |
1932 | Locs, UnresolvedMappers); |
1933 | } |
1934 | |
1935 | |
1936 | |
1937 | |
1938 | |
1939 | OMPClause *RebuildOMPFromClause(ArrayRef<Expr *> VarList, |
1940 | CXXScopeSpec &MapperIdScopeSpec, |
1941 | DeclarationNameInfo &MapperId, |
1942 | const OMPVarListLocTy &Locs, |
1943 | ArrayRef<Expr *> UnresolvedMappers) { |
1944 | return getSema().ActOnOpenMPFromClause(VarList, MapperIdScopeSpec, MapperId, |
1945 | Locs, UnresolvedMappers); |
1946 | } |
1947 | |
1948 | |
1949 | |
1950 | |
1951 | |
1952 | OMPClause *RebuildOMPUseDevicePtrClause(ArrayRef<Expr *> VarList, |
1953 | const OMPVarListLocTy &Locs) { |
1954 | return getSema().ActOnOpenMPUseDevicePtrClause(VarList, Locs); |
1955 | } |
1956 | |
1957 | |
1958 | |
1959 | |
1960 | |
1961 | OMPClause *RebuildOMPIsDevicePtrClause(ArrayRef<Expr *> VarList, |
1962 | const OMPVarListLocTy &Locs) { |
1963 | return getSema().ActOnOpenMPIsDevicePtrClause(VarList, Locs); |
1964 | } |
1965 | |
1966 | |
1967 | |
1968 | |
1969 | |
1970 | ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, |
1971 | Expr *object) { |
1972 | return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object); |
1973 | } |
1974 | |
1975 | |
1976 | |
1977 | |
1978 | |
1979 | StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, |
1980 | Expr *Object, Stmt *Body) { |
1981 | return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body); |
1982 | } |
1983 | |
1984 | |
1985 | |
1986 | |
1987 | |
1988 | StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, |
1989 | Stmt *Body) { |
1990 | return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body); |
1991 | } |
1992 | |
1993 | |
1994 | |
1995 | |
1996 | |
1997 | StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, |
1998 | Stmt *Element, |
1999 | Expr *Collection, |
2000 | SourceLocation RParenLoc, |
2001 | Stmt *Body) { |
2002 | StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc, |
2003 | Element, |
2004 | Collection, |
2005 | RParenLoc); |
2006 | if (ForEachStmt.isInvalid()) |
2007 | return StmtError(); |
2008 | |
2009 | return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body); |
2010 | } |
2011 | |
2012 | |
2013 | |
2014 | |
2015 | |
2016 | VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, |
2017 | TypeSourceInfo *Declarator, |
2018 | SourceLocation StartLoc, |
2019 | SourceLocation IdLoc, |
2020 | IdentifierInfo *Id) { |
2021 | VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator, |
2022 | StartLoc, IdLoc, Id); |
2023 | if (Var) |
2024 | getSema().CurContext->addDecl(Var); |
2025 | return Var; |
2026 | } |
2027 | |
2028 | |
2029 | |
2030 | |
2031 | |
2032 | StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, |
2033 | VarDecl *ExceptionDecl, |
2034 | Stmt *Handler) { |
2035 | return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl, |
2036 | Handler)); |
2037 | } |
2038 | |
2039 | |
2040 | |
2041 | |
2042 | |
2043 | StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, |
2044 | ArrayRef<Stmt *> Handlers) { |
2045 | return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers); |
2046 | } |
2047 | |
2048 | |
2049 | |
2050 | |
2051 | |
2052 | StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, |
2053 | SourceLocation CoawaitLoc, Stmt *Init, |
2054 | SourceLocation ColonLoc, Stmt *Range, |
2055 | Stmt *Begin, Stmt *End, Expr *Cond, |
2056 | Expr *Inc, Stmt *LoopVar, |
2057 | SourceLocation RParenLoc) { |
2058 | |
2059 | |
2060 | if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) { |
2061 | if (RangeStmt->isSingleDecl()) { |
2062 | if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) { |
2063 | if (RangeVar->isInvalidDecl()) |
2064 | return StmtError(); |
2065 | |
2066 | Expr *RangeExpr = RangeVar->getInit(); |
2067 | if (!RangeExpr->isTypeDependent() && |
2068 | RangeExpr->getType()->isObjCObjectPointerType()) { |
2069 | |
2070 | |
2071 | if (Init) { |
2072 | return SemaRef.Diag(Init->getBeginLoc(), |
2073 | diag::err_objc_for_range_init_stmt) |
2074 | << Init->getSourceRange(); |
2075 | } |
2076 | return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar, |
2077 | RangeExpr, RParenLoc); |
2078 | } |
2079 | } |
2080 | } |
2081 | } |
2082 | |
2083 | return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, Init, ColonLoc, |
2084 | Range, Begin, End, Cond, Inc, LoopVar, |
2085 | RParenLoc, Sema::BFRK_Rebuild); |
2086 | } |
2087 | |
2088 | |
2089 | |
2090 | |
2091 | |
2092 | StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, |
2093 | bool IsIfExists, |
2094 | NestedNameSpecifierLoc QualifierLoc, |
2095 | DeclarationNameInfo NameInfo, |
2096 | Stmt *Nested) { |
2097 | return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists, |
2098 | QualifierLoc, NameInfo, Nested); |
2099 | } |
2100 | |
2101 | |
2102 | |
2103 | |
2104 | |
2105 | StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body) { |
2106 | return getSema().FinishCXXForRangeStmt(ForRange, Body); |
2107 | } |
2108 | |
2109 | StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, |
2110 | Stmt *TryBlock, Stmt *Handler) { |
2111 | return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler); |
2112 | } |
2113 | |
2114 | StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, |
2115 | Stmt *Block) { |
2116 | return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block); |
2117 | } |
2118 | |
2119 | StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block) { |
2120 | return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block); |
2121 | } |
2122 | |
2123 | |
2124 | |
2125 | |
2126 | |
2127 | ExprResult RebuildPredefinedExpr(SourceLocation Loc, |
2128 | PredefinedExpr::IdentKind IK) { |
2129 | return getSema().BuildPredefinedExpr(Loc, IK); |
2130 | } |
2131 | |
2132 | |
2133 | |
2134 | |
2135 | |
2136 | ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, |
2137 | LookupResult &R, |
2138 | bool RequiresADL) { |
2139 | return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL); |
2140 | } |
2141 | |
2142 | |
2143 | |
2144 | |
2145 | |
2146 | |
2147 | ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, |
2148 | ValueDecl *VD, |
2149 | const DeclarationNameInfo &NameInfo, |
2150 | TemplateArgumentListInfo *TemplateArgs) { |
2151 | CXXScopeSpec SS; |
2152 | SS.Adopt(QualifierLoc); |
2153 | |
2154 | |
2155 | |
2156 | return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD); |
2157 | } |
2158 | |
2159 | |
2160 | |
2161 | |
2162 | |
2163 | ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, |
2164 | SourceLocation RParen) { |
2165 | return getSema().ActOnParenExpr(LParen, RParen, SubExpr); |
2166 | } |
2167 | |
2168 | |
2169 | |
2170 | |
2171 | |
2172 | ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, |
2173 | SourceLocation OperatorLoc, |
2174 | bool isArrow, |
2175 | CXXScopeSpec &SS, |
2176 | TypeSourceInfo *ScopeType, |
2177 | SourceLocation CCLoc, |
2178 | SourceLocation TildeLoc, |
2179 | PseudoDestructorTypeStorage Destroyed); |
2180 | |
2181 | |
2182 | |
2183 | |
2184 | |
2185 | ExprResult RebuildUnaryOperator(SourceLocation OpLoc, |
2186 | UnaryOperatorKind Opc, |
2187 | Expr *SubExpr) { |
2188 | return getSema().BuildUnaryOp(, OpLoc, Opc, SubExpr); |
2189 | } |
2190 | |
2191 | |
2192 | |
2193 | |
2194 | |
2195 | ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, |
2196 | TypeSourceInfo *Type, |
2197 | ArrayRef<Sema::OffsetOfComponent> Components, |
2198 | SourceLocation RParenLoc) { |
2199 | return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components, |
2200 | RParenLoc); |
2201 | } |
2202 | |
2203 | |
2204 | |
2205 | |
2206 | |
2207 | |
2208 | ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, |
2209 | SourceLocation OpLoc, |
2210 | UnaryExprOrTypeTrait ExprKind, |
2211 | SourceRange R) { |
2212 | return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R); |
2213 | } |
2214 | |
2215 | |
2216 | |
2217 | |
2218 | |
2219 | |
2220 | ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, |
2221 | UnaryExprOrTypeTrait ExprKind, |
2222 | SourceRange R) { |
2223 | ExprResult Result |
2224 | = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind); |
2225 | if (Result.isInvalid()) |
2226 | return ExprError(); |
2227 | |
2228 | return Result; |
2229 | } |
2230 | |
2231 | |
2232 | |
2233 | |
2234 | |
2235 | ExprResult RebuildArraySubscriptExpr(Expr *LHS, |
2236 | SourceLocation LBracketLoc, |
2237 | Expr *RHS, |
2238 | SourceLocation RBracketLoc) { |
2239 | return getSema().ActOnArraySubscriptExpr(, LHS, |
2240 | LBracketLoc, RHS, |
2241 | RBracketLoc); |
2242 | } |
2243 | |
2244 | |
2245 | |
2246 | |
2247 | |
2248 | ExprResult RebuildOMPArraySectionExpr(Expr *Base, SourceLocation LBracketLoc, |
2249 | Expr *LowerBound, |
2250 | SourceLocation ColonLoc, Expr *Length, |
2251 | SourceLocation RBracketLoc) { |
2252 | return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound, |
2253 | ColonLoc, Length, RBracketLoc); |
2254 | } |
2255 | |
2256 | |
2257 | |
2258 | |
2259 | |
2260 | ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, |
2261 | MultiExprArg Args, |
2262 | SourceLocation RParenLoc, |
2263 | Expr *ExecConfig = nullptr) { |
2264 | return getSema().ActOnCallExpr(, Callee, LParenLoc, |
2265 | Args, RParenLoc, ExecConfig); |
2266 | } |
2267 | |
2268 | |
2269 | |
2270 | |
2271 | |
2272 | ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, |
2273 | bool isArrow, |
2274 | NestedNameSpecifierLoc QualifierLoc, |
2275 | SourceLocation TemplateKWLoc, |
2276 | const DeclarationNameInfo &MemberNameInfo, |
2277 | ValueDecl *Member, |
2278 | NamedDecl *FoundDecl, |
2279 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
2280 | NamedDecl *FirstQualifierInScope) { |
2281 | ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base, |
2282 | isArrow); |
2283 | if (!Member->getDeclName()) { |
2284 | |
2285 | |
2286 | |
2287 | (0) . __assert_fail ("Member->getType()->isRecordType() && \"unnamed member not of record type?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 2288, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Member->getType()->isRecordType() && |
2288 | (0) . __assert_fail ("Member->getType()->isRecordType() && \"unnamed member not of record type?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 2288, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "unnamed member not of record type?"); |
2289 | |
2290 | BaseResult = |
2291 | getSema().PerformObjectMemberConversion(BaseResult.get(), |
2292 | QualifierLoc.getNestedNameSpecifier(), |
2293 | FoundDecl, Member); |
2294 | if (BaseResult.isInvalid()) |
2295 | return ExprError(); |
2296 | Base = BaseResult.get(); |
2297 | |
2298 | CXXScopeSpec EmptySS; |
2299 | return getSema().BuildFieldReferenceExpr( |
2300 | Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member), |
2301 | DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo); |
2302 | } |
2303 | |
2304 | CXXScopeSpec SS; |
2305 | SS.Adopt(QualifierLoc); |
2306 | |
2307 | Base = BaseResult.get(); |
2308 | QualType BaseType = Base->getType(); |
2309 | |
2310 | if (isArrow && !BaseType->isPointerType()) |
2311 | return ExprError(); |
2312 | |
2313 | |
2314 | |
2315 | LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName); |
2316 | R.addDecl(FoundDecl); |
2317 | R.resolveKind(); |
2318 | |
2319 | return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow, |
2320 | SS, TemplateKWLoc, |
2321 | FirstQualifierInScope, |
2322 | R, ExplicitTemplateArgs, |
2323 | ); |
2324 | } |
2325 | |
2326 | |
2327 | |
2328 | |
2329 | |
2330 | ExprResult RebuildBinaryOperator(SourceLocation OpLoc, |
2331 | BinaryOperatorKind Opc, |
2332 | Expr *LHS, Expr *RHS) { |
2333 | return getSema().BuildBinOp(, OpLoc, Opc, LHS, RHS); |
2334 | } |
2335 | |
2336 | |
2337 | |
2338 | |
2339 | |
2340 | ExprResult RebuildConditionalOperator(Expr *Cond, |
2341 | SourceLocation QuestionLoc, |
2342 | Expr *LHS, |
2343 | SourceLocation ColonLoc, |
2344 | Expr *RHS) { |
2345 | return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond, |
2346 | LHS, RHS); |
2347 | } |
2348 | |
2349 | |
2350 | |
2351 | |
2352 | |
2353 | ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, |
2354 | TypeSourceInfo *TInfo, |
2355 | SourceLocation RParenLoc, |
2356 | Expr *SubExpr) { |
2357 | return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, |
2358 | SubExpr); |
2359 | } |
2360 | |
2361 | |
2362 | |
2363 | |
2364 | |
2365 | ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, |
2366 | TypeSourceInfo *TInfo, |
2367 | SourceLocation RParenLoc, |
2368 | Expr *Init) { |
2369 | return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, |
2370 | Init); |
2371 | } |
2372 | |
2373 | |
2374 | |
2375 | |
2376 | |
2377 | ExprResult RebuildExtVectorElementExpr(Expr *Base, |
2378 | SourceLocation OpLoc, |
2379 | SourceLocation AccessorLoc, |
2380 | IdentifierInfo &Accessor) { |
2381 | |
2382 | CXXScopeSpec SS; |
2383 | DeclarationNameInfo NameInfo(&Accessor, AccessorLoc); |
2384 | return getSema().BuildMemberReferenceExpr(Base, Base->getType(), |
2385 | OpLoc, false, |
2386 | SS, SourceLocation(), |
2387 | nullptr, |
2388 | NameInfo, |
2389 | nullptr, |
2390 | nullptr); |
2391 | } |
2392 | |
2393 | |
2394 | |
2395 | |
2396 | |
2397 | ExprResult RebuildInitList(SourceLocation LBraceLoc, |
2398 | MultiExprArg Inits, |
2399 | SourceLocation RBraceLoc) { |
2400 | return SemaRef.ActOnInitList(LBraceLoc, Inits, RBraceLoc); |
2401 | } |
2402 | |
2403 | |
2404 | |
2405 | |
2406 | |
2407 | ExprResult RebuildDesignatedInitExpr(Designation &Desig, |
2408 | MultiExprArg ArrayExprs, |
2409 | SourceLocation EqualOrColonLoc, |
2410 | bool GNUSyntax, |
2411 | Expr *Init) { |
2412 | ExprResult Result |
2413 | = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax, |
2414 | Init); |
2415 | if (Result.isInvalid()) |
2416 | return ExprError(); |
2417 | |
2418 | return Result; |
2419 | } |
2420 | |
2421 | |
2422 | |
2423 | |
2424 | |
2425 | |
2426 | ExprResult RebuildImplicitValueInitExpr(QualType T) { |
2427 | return new (SemaRef.Context) ImplicitValueInitExpr(T); |
2428 | } |
2429 | |
2430 | |
2431 | |
2432 | |
2433 | |
2434 | ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, |
2435 | Expr *SubExpr, TypeSourceInfo *TInfo, |
2436 | SourceLocation RParenLoc) { |
2437 | return getSema().BuildVAArgExpr(BuiltinLoc, |
2438 | SubExpr, TInfo, |
2439 | RParenLoc); |
2440 | } |
2441 | |
2442 | |
2443 | |
2444 | |
2445 | |
2446 | ExprResult RebuildParenListExpr(SourceLocation LParenLoc, |
2447 | MultiExprArg SubExprs, |
2448 | SourceLocation RParenLoc) { |
2449 | return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs); |
2450 | } |
2451 | |
2452 | |
2453 | |
2454 | |
2455 | |
2456 | |
2457 | ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, |
2458 | SourceLocation LabelLoc, LabelDecl *Label) { |
2459 | return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label); |
2460 | } |
2461 | |
2462 | |
2463 | |
2464 | |
2465 | |
2466 | ExprResult RebuildStmtExpr(SourceLocation LParenLoc, |
2467 | Stmt *SubStmt, |
2468 | SourceLocation RParenLoc) { |
2469 | return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc); |
2470 | } |
2471 | |
2472 | |
2473 | |
2474 | |
2475 | |
2476 | ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, |
2477 | Expr *Cond, Expr *LHS, Expr *RHS, |
2478 | SourceLocation RParenLoc) { |
2479 | return SemaRef.ActOnChooseExpr(BuiltinLoc, |
2480 | Cond, LHS, RHS, |
2481 | RParenLoc); |
2482 | } |
2483 | |
2484 | |
2485 | |
2486 | |
2487 | |
2488 | ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, |
2489 | SourceLocation DefaultLoc, |
2490 | SourceLocation RParenLoc, |
2491 | Expr *ControllingExpr, |
2492 | ArrayRef<TypeSourceInfo *> Types, |
2493 | ArrayRef<Expr *> Exprs) { |
2494 | return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, |
2495 | ControllingExpr, Types, Exprs); |
2496 | } |
2497 | |
2498 | |
2499 | |
2500 | |
2501 | |
2502 | |
2503 | |
2504 | |
2505 | |
2506 | ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, |
2507 | SourceLocation OpLoc, |
2508 | Expr *Callee, |
2509 | Expr *First, |
2510 | Expr *Second); |
2511 | |
2512 | |
2513 | |
2514 | |
2515 | |
2516 | |
2517 | |
2518 | ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, |
2519 | Stmt::StmtClass Class, |
2520 | SourceLocation LAngleLoc, |
2521 | TypeSourceInfo *TInfo, |
2522 | SourceLocation RAngleLoc, |
2523 | SourceLocation LParenLoc, |
2524 | Expr *SubExpr, |
2525 | SourceLocation RParenLoc) { |
2526 | switch (Class) { |
2527 | case Stmt::CXXStaticCastExprClass: |
2528 | return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo, |
2529 | RAngleLoc, LParenLoc, |
2530 | SubExpr, RParenLoc); |
2531 | |
2532 | case Stmt::CXXDynamicCastExprClass: |
2533 | return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo, |
2534 | RAngleLoc, LParenLoc, |
2535 | SubExpr, RParenLoc); |
2536 | |
2537 | case Stmt::CXXReinterpretCastExprClass: |
2538 | return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo, |
2539 | RAngleLoc, LParenLoc, |
2540 | SubExpr, |
2541 | RParenLoc); |
2542 | |
2543 | case Stmt::CXXConstCastExprClass: |
2544 | return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo, |
2545 | RAngleLoc, LParenLoc, |
2546 | SubExpr, RParenLoc); |
2547 | |
2548 | default: |
2549 | llvm_unreachable("Invalid C++ named cast"); |
2550 | } |
2551 | } |
2552 | |
2553 | |
2554 | |
2555 | |
2556 | |
2557 | ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, |
2558 | SourceLocation LAngleLoc, |
2559 | TypeSourceInfo *TInfo, |
2560 | SourceLocation RAngleLoc, |
2561 | SourceLocation LParenLoc, |
2562 | Expr *SubExpr, |
2563 | SourceLocation RParenLoc) { |
2564 | return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast, |
2565 | TInfo, SubExpr, |
2566 | SourceRange(LAngleLoc, RAngleLoc), |
2567 | SourceRange(LParenLoc, RParenLoc)); |
2568 | } |
2569 | |
2570 | |
2571 | |
2572 | |
2573 | |
2574 | ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, |
2575 | SourceLocation LAngleLoc, |
2576 | TypeSourceInfo *TInfo, |
2577 | SourceLocation RAngleLoc, |
2578 | SourceLocation LParenLoc, |
2579 | Expr *SubExpr, |
2580 | SourceLocation RParenLoc) { |
2581 | return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast, |
2582 | TInfo, SubExpr, |
2583 | SourceRange(LAngleLoc, RAngleLoc), |
2584 | SourceRange(LParenLoc, RParenLoc)); |
2585 | } |
2586 | |
2587 | |
2588 | |
2589 | |
2590 | |
2591 | ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, |
2592 | SourceLocation LAngleLoc, |
2593 | TypeSourceInfo *TInfo, |
2594 | SourceLocation RAngleLoc, |
2595 | SourceLocation LParenLoc, |
2596 | Expr *SubExpr, |
2597 | SourceLocation RParenLoc) { |
2598 | return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast, |
2599 | TInfo, SubExpr, |
2600 | SourceRange(LAngleLoc, RAngleLoc), |
2601 | SourceRange(LParenLoc, RParenLoc)); |
2602 | } |
2603 | |
2604 | |
2605 | |
2606 | |
2607 | |
2608 | ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, |
2609 | SourceLocation LAngleLoc, |
2610 | TypeSourceInfo *TInfo, |
2611 | SourceLocation RAngleLoc, |
2612 | SourceLocation LParenLoc, |
2613 | Expr *SubExpr, |
2614 | SourceLocation RParenLoc) { |
2615 | return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast, |
2616 | TInfo, SubExpr, |
2617 | SourceRange(LAngleLoc, RAngleLoc), |
2618 | SourceRange(LParenLoc, RParenLoc)); |
2619 | } |
2620 | |
2621 | |
2622 | |
2623 | |
2624 | |
2625 | ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, |
2626 | SourceLocation LParenLoc, |
2627 | Expr *Sub, |
2628 | SourceLocation RParenLoc, |
2629 | bool ListInitialization) { |
2630 | return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc, |
2631 | MultiExprArg(&Sub, 1), RParenLoc, |
2632 | ListInitialization); |
2633 | } |
2634 | |
2635 | |
2636 | |
2637 | |
2638 | |
2639 | ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, |
2640 | SourceLocation TypeidLoc, |
2641 | TypeSourceInfo *Operand, |
2642 | SourceLocation RParenLoc) { |
2643 | return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, |
2644 | RParenLoc); |
2645 | } |
2646 | |
2647 | |
2648 | |
2649 | |
2650 | |
2651 | |
2652 | ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, |
2653 | SourceLocation TypeidLoc, |
2654 | Expr *Operand, |
2655 | SourceLocation RParenLoc) { |
2656 | return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, |
2657 | RParenLoc); |
2658 | } |
2659 | |
2660 | |
2661 | |
2662 | |
2663 | |
2664 | ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, |
2665 | SourceLocation TypeidLoc, |
2666 | TypeSourceInfo *Operand, |
2667 | SourceLocation RParenLoc) { |
2668 | return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand, |
2669 | RParenLoc); |
2670 | } |
2671 | |
2672 | |
2673 | |
2674 | |
2675 | |
2676 | ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, |
2677 | SourceLocation TypeidLoc, |
2678 | Expr *Operand, |
2679 | SourceLocation RParenLoc) { |
2680 | return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand, |
2681 | RParenLoc); |
2682 | } |
2683 | |
2684 | |
2685 | |
2686 | |
2687 | |
2688 | |
2689 | ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, |
2690 | QualType ThisType, |
2691 | bool isImplicit) { |
2692 | getSema().CheckCXXThisCapture(ThisLoc); |
2693 | return new (getSema().Context) CXXThisExpr(ThisLoc, ThisType, isImplicit); |
2694 | } |
2695 | |
2696 | |
2697 | |
2698 | |
2699 | |
2700 | ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, |
2701 | bool IsThrownVariableInScope) { |
2702 | return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope); |
2703 | } |
2704 | |
2705 | |
2706 | |
2707 | |
2708 | |
2709 | |
2710 | ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, |
2711 | ParmVarDecl *Param) { |
2712 | return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param); |
2713 | } |
2714 | |
2715 | |
2716 | |
2717 | |
2718 | |
2719 | |
2720 | ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, |
2721 | FieldDecl *Field) { |
2722 | return CXXDefaultInitExpr::Create(getSema().Context, Loc, Field); |
2723 | } |
2724 | |
2725 | |
2726 | |
2727 | |
2728 | |
2729 | ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, |
2730 | SourceLocation LParenLoc, |
2731 | SourceLocation RParenLoc) { |
2732 | return getSema().BuildCXXTypeConstructExpr( |
2733 | TSInfo, LParenLoc, None, RParenLoc, ); |
2734 | } |
2735 | |
2736 | |
2737 | |
2738 | |
2739 | |
2740 | ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, |
2741 | bool UseGlobal, |
2742 | SourceLocation PlacementLParen, |
2743 | MultiExprArg PlacementArgs, |
2744 | SourceLocation PlacementRParen, |
2745 | SourceRange TypeIdParens, |
2746 | QualType AllocatedType, |
2747 | TypeSourceInfo *AllocatedTypeInfo, |
2748 | Expr *ArraySize, |
2749 | SourceRange DirectInitRange, |
2750 | Expr *Initializer) { |
2751 | return getSema().BuildCXXNew(StartLoc, UseGlobal, |
2752 | PlacementLParen, |
2753 | PlacementArgs, |
2754 | PlacementRParen, |
2755 | TypeIdParens, |
2756 | AllocatedType, |
2757 | AllocatedTypeInfo, |
2758 | ArraySize, |
2759 | DirectInitRange, |
2760 | Initializer); |
2761 | } |
2762 | |
2763 | |
2764 | |
2765 | |
2766 | |
2767 | ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, |
2768 | bool IsGlobalDelete, |
2769 | bool IsArrayForm, |
2770 | Expr *Operand) { |
2771 | return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm, |
2772 | Operand); |
2773 | } |
2774 | |
2775 | |
2776 | |
2777 | |
2778 | |
2779 | ExprResult RebuildTypeTrait(TypeTrait Trait, |
2780 | SourceLocation StartLoc, |
2781 | ArrayRef<TypeSourceInfo *> Args, |
2782 | SourceLocation RParenLoc) { |
2783 | return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc); |
2784 | } |
2785 | |
2786 | |
2787 | |
2788 | |
2789 | |
2790 | ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, |
2791 | SourceLocation StartLoc, |
2792 | TypeSourceInfo *TSInfo, |
2793 | Expr *DimExpr, |
2794 | SourceLocation RParenLoc) { |
2795 | return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc); |
2796 | } |
2797 | |
2798 | |
2799 | |
2800 | |
2801 | |
2802 | ExprResult RebuildExpressionTrait(ExpressionTrait Trait, |
2803 | SourceLocation StartLoc, |
2804 | Expr *Queried, |
2805 | SourceLocation RParenLoc) { |
2806 | return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc); |
2807 | } |
2808 | |
2809 | |
2810 | |
2811 | |
2812 | |
2813 | |
2814 | ExprResult RebuildDependentScopeDeclRefExpr( |
2815 | NestedNameSpecifierLoc QualifierLoc, |
2816 | SourceLocation TemplateKWLoc, |
2817 | const DeclarationNameInfo &NameInfo, |
2818 | const TemplateArgumentListInfo *TemplateArgs, |
2819 | bool IsAddressOfOperand, |
2820 | TypeSourceInfo **RecoveryTSI) { |
2821 | CXXScopeSpec SS; |
2822 | SS.Adopt(QualifierLoc); |
2823 | |
2824 | if (TemplateArgs || TemplateKWLoc.isValid()) |
2825 | return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc, NameInfo, |
2826 | TemplateArgs); |
2827 | |
2828 | return getSema().BuildQualifiedDeclarationNameExpr( |
2829 | SS, NameInfo, IsAddressOfOperand, , RecoveryTSI); |
2830 | } |
2831 | |
2832 | |
2833 | |
2834 | |
2835 | |
2836 | ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, |
2837 | SourceLocation TemplateKWLoc, |
2838 | LookupResult &R, |
2839 | bool RequiresADL, |
2840 | const TemplateArgumentListInfo *TemplateArgs) { |
2841 | return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL, |
2842 | TemplateArgs); |
2843 | } |
2844 | |
2845 | |
2846 | |
2847 | |
2848 | |
2849 | ExprResult RebuildCXXConstructExpr(QualType T, |
2850 | SourceLocation Loc, |
2851 | CXXConstructorDecl *Constructor, |
2852 | bool IsElidable, |
2853 | MultiExprArg Args, |
2854 | bool HadMultipleCandidates, |
2855 | bool ListInitialization, |
2856 | bool StdInitListInitialization, |
2857 | bool RequiresZeroInit, |
2858 | CXXConstructExpr::ConstructionKind ConstructKind, |
2859 | SourceRange ParenRange) { |
2860 | SmallVector<Expr*, 8> ConvertedArgs; |
2861 | if (getSema().CompleteConstructorCall(Constructor, Args, Loc, |
2862 | ConvertedArgs)) |
2863 | return ExprError(); |
2864 | |
2865 | return getSema().BuildCXXConstructExpr(Loc, T, Constructor, |
2866 | IsElidable, |
2867 | ConvertedArgs, |
2868 | HadMultipleCandidates, |
2869 | ListInitialization, |
2870 | StdInitListInitialization, |
2871 | RequiresZeroInit, ConstructKind, |
2872 | ParenRange); |
2873 | } |
2874 | |
2875 | |
2876 | |
2877 | ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, |
2878 | CXXConstructorDecl *Constructor, |
2879 | bool ConstructsVBase, |
2880 | bool InheritedFromVBase) { |
2881 | return new (getSema().Context) CXXInheritedCtorInitExpr( |
2882 | Loc, T, Constructor, ConstructsVBase, InheritedFromVBase); |
2883 | } |
2884 | |
2885 | |
2886 | |
2887 | |
2888 | |
2889 | ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, |
2890 | SourceLocation LParenOrBraceLoc, |
2891 | MultiExprArg Args, |
2892 | SourceLocation RParenOrBraceLoc, |
2893 | bool ListInitialization) { |
2894 | return getSema().BuildCXXTypeConstructExpr( |
2895 | TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization); |
2896 | } |
2897 | |
2898 | |
2899 | |
2900 | |
2901 | |
2902 | ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, |
2903 | SourceLocation LParenLoc, |
2904 | MultiExprArg Args, |
2905 | SourceLocation RParenLoc, |
2906 | bool ListInitialization) { |
2907 | return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args, |
2908 | RParenLoc, ListInitialization); |
2909 | } |
2910 | |
2911 | |
2912 | |
2913 | |
2914 | |
2915 | ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, |
2916 | QualType BaseType, |
2917 | bool IsArrow, |
2918 | SourceLocation OperatorLoc, |
2919 | NestedNameSpecifierLoc QualifierLoc, |
2920 | SourceLocation TemplateKWLoc, |
2921 | NamedDecl *FirstQualifierInScope, |
2922 | const DeclarationNameInfo &MemberNameInfo, |
2923 | const TemplateArgumentListInfo *TemplateArgs) { |
2924 | CXXScopeSpec SS; |
2925 | SS.Adopt(QualifierLoc); |
2926 | |
2927 | return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType, |
2928 | OperatorLoc, IsArrow, |
2929 | SS, TemplateKWLoc, |
2930 | FirstQualifierInScope, |
2931 | MemberNameInfo, |
2932 | TemplateArgs, ); |
2933 | } |
2934 | |
2935 | |
2936 | |
2937 | |
2938 | |
2939 | ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, |
2940 | SourceLocation OperatorLoc, |
2941 | bool IsArrow, |
2942 | NestedNameSpecifierLoc QualifierLoc, |
2943 | SourceLocation TemplateKWLoc, |
2944 | NamedDecl *FirstQualifierInScope, |
2945 | LookupResult &R, |
2946 | const TemplateArgumentListInfo *TemplateArgs) { |
2947 | CXXScopeSpec SS; |
2948 | SS.Adopt(QualifierLoc); |
2949 | |
2950 | return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType, |
2951 | OperatorLoc, IsArrow, |
2952 | SS, TemplateKWLoc, |
2953 | FirstQualifierInScope, |
2954 | R, TemplateArgs, ); |
2955 | } |
2956 | |
2957 | |
2958 | |
2959 | |
2960 | |
2961 | ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg) { |
2962 | return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd()); |
2963 | } |
2964 | |
2965 | |
2966 | ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, |
2967 | NamedDecl *Pack, |
2968 | SourceLocation PackLoc, |
2969 | SourceLocation RParenLoc, |
2970 | Optional<unsigned> Length, |
2971 | ArrayRef<TemplateArgument> PartialArgs) { |
2972 | return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc, |
2973 | RParenLoc, Length, PartialArgs); |
2974 | } |
2975 | |
2976 | |
2977 | |
2978 | |
2979 | |
2980 | ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { |
2981 | return getSema().BuildObjCBoxedExpr(SR, ValueExpr); |
2982 | } |
2983 | |
2984 | |
2985 | |
2986 | |
2987 | |
2988 | ExprResult RebuildObjCArrayLiteral(SourceRange Range, |
2989 | Expr **Elements, unsigned NumElements) { |
2990 | return getSema().BuildObjCArrayLiteral(Range, |
2991 | MultiExprArg(Elements, NumElements)); |
2992 | } |
2993 | |
2994 | ExprResult RebuildObjCSubscriptRefExpr(SourceLocation RB, |
2995 | Expr *Base, Expr *Key, |
2996 | ObjCMethodDecl *getterMethod, |
2997 | ObjCMethodDecl *setterMethod) { |
2998 | return getSema().BuildObjCSubscriptExpression(RB, Base, Key, |
2999 | getterMethod, setterMethod); |
3000 | } |
3001 | |
3002 | |
3003 | |
3004 | |
3005 | |
3006 | ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, |
3007 | MutableArrayRef<ObjCDictionaryElement> Elements) { |
3008 | return getSema().BuildObjCDictionaryLiteral(Range, Elements); |
3009 | } |
3010 | |
3011 | |
3012 | |
3013 | |
3014 | |
3015 | ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, |
3016 | TypeSourceInfo *EncodeTypeInfo, |
3017 | SourceLocation RParenLoc) { |
3018 | return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc); |
3019 | } |
3020 | |
3021 | |
3022 | ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, |
3023 | Selector Sel, |
3024 | ArrayRef<SourceLocation> SelectorLocs, |
3025 | ObjCMethodDecl *Method, |
3026 | SourceLocation LBracLoc, |
3027 | MultiExprArg Args, |
3028 | SourceLocation RBracLoc) { |
3029 | return SemaRef.BuildClassMessage(ReceiverTypeInfo, |
3030 | ReceiverTypeInfo->getType(), |
3031 | SourceLocation(), |
3032 | Sel, Method, LBracLoc, SelectorLocs, |
3033 | RBracLoc, Args); |
3034 | } |
3035 | |
3036 | |
3037 | ExprResult RebuildObjCMessageExpr(Expr *Receiver, |
3038 | Selector Sel, |
3039 | ArrayRef<SourceLocation> SelectorLocs, |
3040 | ObjCMethodDecl *Method, |
3041 | SourceLocation LBracLoc, |
3042 | MultiExprArg Args, |
3043 | SourceLocation RBracLoc) { |
3044 | return SemaRef.BuildInstanceMessage(Receiver, |
3045 | Receiver->getType(), |
3046 | SourceLocation(), |
3047 | Sel, Method, LBracLoc, SelectorLocs, |
3048 | RBracLoc, Args); |
3049 | } |
3050 | |
3051 | |
3052 | ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, |
3053 | Selector Sel, |
3054 | ArrayRef<SourceLocation> SelectorLocs, |
3055 | QualType SuperType, |
3056 | ObjCMethodDecl *Method, |
3057 | SourceLocation LBracLoc, |
3058 | MultiExprArg Args, |
3059 | SourceLocation RBracLoc) { |
3060 | return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr, |
3061 | SuperType, |
3062 | SuperLoc, |
3063 | Sel, Method, LBracLoc, SelectorLocs, |
3064 | RBracLoc, Args) |
3065 | : SemaRef.BuildClassMessage(nullptr, |
3066 | SuperType, |
3067 | SuperLoc, |
3068 | Sel, Method, LBracLoc, SelectorLocs, |
3069 | RBracLoc, Args); |
3070 | |
3071 | |
3072 | } |
3073 | |
3074 | |
3075 | |
3076 | |
3077 | |
3078 | ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, |
3079 | SourceLocation IvarLoc, |
3080 | bool IsArrow, bool IsFreeIvar) { |
3081 | CXXScopeSpec SS; |
3082 | DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc); |
3083 | ExprResult Result = getSema().BuildMemberReferenceExpr( |
3084 | BaseArg, BaseArg->getType(), |
3085 | IvarLoc, IsArrow, SS, SourceLocation(), |
3086 | , NameInfo, |
3087 | , |
3088 | ); |
3089 | if (IsFreeIvar && Result.isUsable()) |
3090 | cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar); |
3091 | return Result; |
3092 | } |
3093 | |
3094 | |
3095 | |
3096 | |
3097 | |
3098 | ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, |
3099 | ObjCPropertyDecl *Property, |
3100 | SourceLocation PropertyLoc) { |
3101 | CXXScopeSpec SS; |
3102 | DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc); |
3103 | return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(), |
3104 | , |
3105 | , |
3106 | SS, SourceLocation(), |
3107 | , |
3108 | NameInfo, |
3109 | , |
3110 | ); |
3111 | } |
3112 | |
3113 | |
3114 | |
3115 | |
3116 | |
3117 | ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, |
3118 | ObjCMethodDecl *Getter, |
3119 | ObjCMethodDecl *Setter, |
3120 | SourceLocation PropertyLoc) { |
3121 | |
3122 | |
3123 | return Owned( |
3124 | new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T, |
3125 | VK_LValue, OK_ObjCProperty, |
3126 | PropertyLoc, Base)); |
3127 | } |
3128 | |
3129 | |
3130 | |
3131 | |
3132 | |
3133 | ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, |
3134 | SourceLocation OpLoc, bool IsArrow) { |
3135 | CXXScopeSpec SS; |
3136 | DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc); |
3137 | return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(), |
3138 | OpLoc, IsArrow, |
3139 | SS, SourceLocation(), |
3140 | , |
3141 | NameInfo, |
3142 | , |
3143 | ); |
3144 | } |
3145 | |
3146 | |
3147 | |
3148 | |
3149 | |
3150 | ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, |
3151 | MultiExprArg SubExprs, |
3152 | SourceLocation RParenLoc) { |
3153 | |
3154 | const IdentifierInfo &Name |
3155 | = SemaRef.Context.Idents.get("__builtin_shufflevector"); |
3156 | TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl(); |
3157 | DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name)); |
3158 | (0) . __assert_fail ("!Lookup.empty() && \"No __builtin_shufflevector?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3158, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Lookup.empty() && "No __builtin_shufflevector?"); |
3159 | |
3160 | |
3161 | FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front()); |
3162 | Expr *Callee = new (SemaRef.Context) |
3163 | DeclRefExpr(SemaRef.Context, Builtin, false, |
3164 | SemaRef.Context.BuiltinFnTy, VK_RValue, BuiltinLoc); |
3165 | QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType()); |
3166 | Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy, |
3167 | CK_BuiltinFnToFnPtr).get(); |
3168 | |
3169 | |
3170 | ExprResult TheCall = CallExpr::Create( |
3171 | SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(), |
3172 | Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc); |
3173 | |
3174 | |
3175 | return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.get())); |
3176 | } |
3177 | |
3178 | |
3179 | ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, |
3180 | Expr *SrcExpr, TypeSourceInfo *DstTInfo, |
3181 | SourceLocation RParenLoc) { |
3182 | return SemaRef.SemaConvertVectorExpr(SrcExpr, DstTInfo, |
3183 | BuiltinLoc, RParenLoc); |
3184 | } |
3185 | |
3186 | |
3187 | |
3188 | |
3189 | |
3190 | |
3191 | TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, |
3192 | SourceLocation EllipsisLoc, |
3193 | Optional<unsigned> NumExpansions) { |
3194 | switch (Pattern.getArgument().getKind()) { |
3195 | case TemplateArgument::Expression: { |
3196 | ExprResult Result |
3197 | = getSema().CheckPackExpansion(Pattern.getSourceExpression(), |
3198 | EllipsisLoc, NumExpansions); |
3199 | if (Result.isInvalid()) |
3200 | return TemplateArgumentLoc(); |
3201 | |
3202 | return TemplateArgumentLoc(Result.get(), Result.get()); |
3203 | } |
3204 | |
3205 | case TemplateArgument::Template: |
3206 | return TemplateArgumentLoc(TemplateArgument( |
3207 | Pattern.getArgument().getAsTemplate(), |
3208 | NumExpansions), |
3209 | Pattern.getTemplateQualifierLoc(), |
3210 | Pattern.getTemplateNameLoc(), |
3211 | EllipsisLoc); |
3212 | |
3213 | case TemplateArgument::Null: |
3214 | case TemplateArgument::Integral: |
3215 | case TemplateArgument::Declaration: |
3216 | case TemplateArgument::Pack: |
3217 | case TemplateArgument::TemplateExpansion: |
3218 | case TemplateArgument::NullPtr: |
3219 | llvm_unreachable("Pack expansion pattern has no parameter packs"); |
3220 | |
3221 | case TemplateArgument::Type: |
3222 | if (TypeSourceInfo *Expansion |
3223 | = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(), |
3224 | EllipsisLoc, |
3225 | NumExpansions)) |
3226 | return TemplateArgumentLoc(TemplateArgument(Expansion->getType()), |
3227 | Expansion); |
3228 | break; |
3229 | } |
3230 | |
3231 | return TemplateArgumentLoc(); |
3232 | } |
3233 | |
3234 | |
3235 | |
3236 | |
3237 | |
3238 | |
3239 | ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, |
3240 | Optional<unsigned> NumExpansions) { |
3241 | return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions); |
3242 | } |
3243 | |
3244 | |
3245 | |
3246 | |
3247 | |
3248 | ExprResult RebuildCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS, |
3249 | BinaryOperatorKind Operator, |
3250 | SourceLocation EllipsisLoc, Expr *RHS, |
3251 | SourceLocation RParenLoc) { |
3252 | return getSema().BuildCXXFoldExpr(LParenLoc, LHS, Operator, EllipsisLoc, |
3253 | RHS, RParenLoc); |
3254 | } |
3255 | |
3256 | |
3257 | |
3258 | |
3259 | |
3260 | ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, |
3261 | BinaryOperatorKind Operator) { |
3262 | return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator); |
3263 | } |
3264 | |
3265 | |
3266 | |
3267 | |
3268 | |
3269 | ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, |
3270 | MultiExprArg SubExprs, |
3271 | QualType RetTy, |
3272 | AtomicExpr::AtomicOp Op, |
3273 | SourceLocation RParenLoc) { |
3274 | |
3275 | |
3276 | |
3277 | return new (SemaRef.Context) AtomicExpr(BuiltinLoc, SubExprs, RetTy, Op, |
3278 | RParenLoc); |
3279 | } |
3280 | |
3281 | private: |
3282 | TypeLoc TransformTypeInObjectScope(TypeLoc TL, |
3283 | QualType ObjectType, |
3284 | NamedDecl *FirstQualifierInScope, |
3285 | CXXScopeSpec &SS); |
3286 | |
3287 | TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo, |
3288 | QualType ObjectType, |
3289 | NamedDecl *FirstQualifierInScope, |
3290 | CXXScopeSpec &SS); |
3291 | |
3292 | TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType, |
3293 | NamedDecl *FirstQualifierInScope, |
3294 | CXXScopeSpec &SS); |
3295 | |
3296 | QualType TransformDependentNameType(TypeLocBuilder &TLB, |
3297 | DependentNameTypeLoc TL, |
3298 | bool DeducibleTSTContext); |
3299 | }; |
3300 | |
3301 | template <typename Derived> |
3302 | StmtResult TreeTransform<Derived>::TransformStmt(Stmt *S, StmtDiscardKind SDK) { |
3303 | if (!S) |
3304 | return S; |
3305 | |
3306 | switch (S->getStmtClass()) { |
3307 | case Stmt::NoStmtClass: break; |
3308 | |
3309 | |
3310 | |
3311 | #define STMT(Node, Parent) \ |
3312 | case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S)); |
3313 | #define VALUESTMT(Node, Parent) \ |
3314 | case Stmt::Node##Class: \ |
3315 | return getDerived().Transform##Node(cast<Node>(S), SDK); |
3316 | #define ABSTRACT_STMT(Node) |
3317 | #define EXPR(Node, Parent) |
3318 | #include "clang/AST/StmtNodes.inc" |
3319 | |
3320 | |
3321 | #define STMT(Node, Parent) |
3322 | #define ABSTRACT_STMT(Stmt) |
3323 | #define EXPR(Node, Parent) case Stmt::Node##Class: |
3324 | #include "clang/AST/StmtNodes.inc" |
3325 | { |
3326 | ExprResult E = getDerived().TransformExpr(cast<Expr>(S)); |
3327 | |
3328 | if (SDK == SDK_StmtExprResult) |
3329 | E = getSema().ActOnStmtExprResult(E); |
3330 | return getSema().ActOnExprStmt(E, SDK == SDK_Discarded); |
3331 | } |
3332 | } |
3333 | |
3334 | return S; |
3335 | } |
3336 | |
3337 | template<typename Derived> |
3338 | OMPClause *TreeTransform<Derived>::TransformOMPClause(OMPClause *S) { |
3339 | if (!S) |
3340 | return S; |
3341 | |
3342 | switch (S->getClauseKind()) { |
3343 | default: break; |
3344 | |
3345 | #define OPENMP_CLAUSE(Name, Class) \ |
3346 | case OMPC_ ## Name : \ |
3347 | return getDerived().Transform ## Class(cast<Class>(S)); |
3348 | #include "clang/Basic/OpenMPKinds.def" |
3349 | } |
3350 | |
3351 | return S; |
3352 | } |
3353 | |
3354 | |
3355 | template<typename Derived> |
3356 | ExprResult TreeTransform<Derived>::TransformExpr(Expr *E) { |
3357 | if (!E) |
3358 | return E; |
3359 | |
3360 | switch (E->getStmtClass()) { |
3361 | case Stmt::NoStmtClass: break; |
3362 | #define STMT(Node, Parent) case Stmt::Node##Class: break; |
3363 | #define ABSTRACT_STMT(Stmt) |
3364 | #define EXPR(Node, Parent) \ |
3365 | case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E)); |
3366 | #include "clang/AST/StmtNodes.inc" |
3367 | } |
3368 | |
3369 | return E; |
3370 | } |
3371 | |
3372 | template<typename Derived> |
3373 | ExprResult TreeTransform<Derived>::TransformInitializer(Expr *Init, |
3374 | bool NotCopyInit) { |
3375 | |
3376 | |
3377 | if (!Init) |
3378 | return Init; |
3379 | |
3380 | if (auto *FE = dyn_cast<FullExpr>(Init)) |
3381 | Init = FE->getSubExpr(); |
3382 | |
3383 | if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) |
3384 | Init = AIL->getCommonExpr(); |
3385 | |
3386 | if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init)) |
3387 | Init = MTE->GetTemporaryExpr(); |
3388 | |
3389 | while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init)) |
3390 | Init = Binder->getSubExpr(); |
3391 | |
3392 | if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init)) |
3393 | Init = ICE->getSubExprAsWritten(); |
3394 | |
3395 | if (CXXStdInitializerListExpr *ILE = |
3396 | dyn_cast<CXXStdInitializerListExpr>(Init)) |
3397 | return TransformInitializer(ILE->getSubExpr(), NotCopyInit); |
3398 | |
3399 | |
3400 | |
3401 | |
3402 | CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init); |
3403 | if (!NotCopyInit && !(Construct && Construct->isListInitialization())) |
3404 | return getDerived().TransformExpr(Init); |
3405 | |
3406 | |
3407 | if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) { |
3408 | SourceRange Parens = VIE->getSourceRange(); |
3409 | return getDerived().RebuildParenListExpr(Parens.getBegin(), None, |
3410 | Parens.getEnd()); |
3411 | } |
3412 | |
3413 | |
3414 | if (isa<ImplicitValueInitExpr>(Init)) |
3415 | return getDerived().RebuildParenListExpr(SourceLocation(), None, |
3416 | SourceLocation()); |
3417 | |
3418 | |
3419 | |
3420 | if (!Construct || isa<CXXTemporaryObjectExpr>(Construct)) |
3421 | return getDerived().TransformExpr(Init); |
3422 | |
3423 | |
3424 | |
3425 | if (Construct && Construct->isStdInitListInitialization()) |
3426 | return TransformInitializer(Construct->getArg(0), NotCopyInit); |
3427 | |
3428 | |
3429 | EnterExpressionEvaluationContext Context( |
3430 | getSema(), EnterExpressionEvaluationContext::InitList, |
3431 | Construct->isListInitialization()); |
3432 | |
3433 | SmallVector<Expr*, 8> NewArgs; |
3434 | bool ArgChanged = false; |
3435 | if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(), |
3436 | , NewArgs, &ArgChanged)) |
3437 | return ExprError(); |
3438 | |
3439 | |
3440 | if (Construct->isListInitialization()) |
3441 | return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs, |
3442 | Construct->getEndLoc()); |
3443 | |
3444 | |
3445 | SourceRange Parens = Construct->getParenOrBraceRange(); |
3446 | if (Parens.isInvalid()) { |
3447 | |
3448 | |
3449 | (0) . __assert_fail ("NewArgs.empty() && \"no parens or braces but have direct init with arguments?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3450, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(NewArgs.empty() && |
3450 | (0) . __assert_fail ("NewArgs.empty() && \"no parens or braces but have direct init with arguments?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3450, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "no parens or braces but have direct init with arguments?"); |
3451 | return ExprEmpty(); |
3452 | } |
3453 | return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs, |
3454 | Parens.getEnd()); |
3455 | } |
3456 | |
3457 | template<typename Derived> |
3458 | bool TreeTransform<Derived>::TransformExprs(Expr *const *Inputs, |
3459 | unsigned NumInputs, |
3460 | bool IsCall, |
3461 | SmallVectorImpl<Expr *> &Outputs, |
3462 | bool *ArgChanged) { |
3463 | for (unsigned I = 0; I != NumInputs; ++I) { |
3464 | |
3465 | if (IsCall && getDerived().DropCallArgument(Inputs[I])) { |
3466 | if (ArgChanged) |
3467 | *ArgChanged = true; |
3468 | |
3469 | break; |
3470 | } |
3471 | |
3472 | if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) { |
3473 | Expr *Pattern = Expansion->getPattern(); |
3474 | |
3475 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
3476 | getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); |
3477 | (0) . __assert_fail ("!Unexpanded.empty() && \"Pack expansion without parameter packs?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3477, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); |
3478 | |
3479 | |
3480 | |
3481 | bool Expand = true; |
3482 | bool RetainExpansion = false; |
3483 | Optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions(); |
3484 | Optional<unsigned> NumExpansions = OrigNumExpansions; |
3485 | if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(), |
3486 | Pattern->getSourceRange(), |
3487 | Unexpanded, |
3488 | Expand, RetainExpansion, |
3489 | NumExpansions)) |
3490 | return true; |
3491 | |
3492 | if (!Expand) { |
3493 | |
3494 | |
3495 | |
3496 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
3497 | ExprResult OutPattern = getDerived().TransformExpr(Pattern); |
3498 | if (OutPattern.isInvalid()) |
3499 | return true; |
3500 | |
3501 | ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(), |
3502 | Expansion->getEllipsisLoc(), |
3503 | NumExpansions); |
3504 | if (Out.isInvalid()) |
3505 | return true; |
3506 | |
3507 | if (ArgChanged) |
3508 | *ArgChanged = true; |
3509 | Outputs.push_back(Out.get()); |
3510 | continue; |
3511 | } |
3512 | |
3513 | |
3514 | |
3515 | if (ArgChanged) *ArgChanged = true; |
3516 | |
3517 | |
3518 | |
3519 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
3520 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); |
3521 | ExprResult Out = getDerived().TransformExpr(Pattern); |
3522 | if (Out.isInvalid()) |
3523 | return true; |
3524 | |
3525 | if (Out.get()->containsUnexpandedParameterPack()) { |
3526 | Out = getDerived().RebuildPackExpansion( |
3527 | Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions); |
3528 | if (Out.isInvalid()) |
3529 | return true; |
3530 | } |
3531 | |
3532 | Outputs.push_back(Out.get()); |
3533 | } |
3534 | |
3535 | |
3536 | |
3537 | if (RetainExpansion) { |
3538 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
3539 | |
3540 | ExprResult Out = getDerived().TransformExpr(Pattern); |
3541 | if (Out.isInvalid()) |
3542 | return true; |
3543 | |
3544 | Out = getDerived().RebuildPackExpansion( |
3545 | Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions); |
3546 | if (Out.isInvalid()) |
3547 | return true; |
3548 | |
3549 | Outputs.push_back(Out.get()); |
3550 | } |
3551 | |
3552 | continue; |
3553 | } |
3554 | |
3555 | ExprResult Result = |
3556 | IsCall ? getDerived().TransformInitializer(Inputs[I], ) |
3557 | : getDerived().TransformExpr(Inputs[I]); |
3558 | if (Result.isInvalid()) |
3559 | return true; |
3560 | |
3561 | if (Result.get() != Inputs[I] && ArgChanged) |
3562 | *ArgChanged = true; |
3563 | |
3564 | Outputs.push_back(Result.get()); |
3565 | } |
3566 | |
3567 | return false; |
3568 | } |
3569 | |
3570 | template <typename Derived> |
3571 | Sema::ConditionResult TreeTransform<Derived>::TransformCondition( |
3572 | SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind) { |
3573 | if (Var) { |
3574 | VarDecl *ConditionVar = cast_or_null<VarDecl>( |
3575 | getDerived().TransformDefinition(Var->getLocation(), Var)); |
3576 | |
3577 | if (!ConditionVar) |
3578 | return Sema::ConditionError(); |
3579 | |
3580 | return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind); |
3581 | } |
3582 | |
3583 | if (Expr) { |
3584 | ExprResult CondExpr = getDerived().TransformExpr(Expr); |
3585 | |
3586 | if (CondExpr.isInvalid()) |
3587 | return Sema::ConditionError(); |
3588 | |
3589 | return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind); |
3590 | } |
3591 | |
3592 | return Sema::ConditionResult(); |
3593 | } |
3594 | |
3595 | template<typename Derived> |
3596 | NestedNameSpecifierLoc |
3597 | TreeTransform<Derived>::TransformNestedNameSpecifierLoc( |
3598 | NestedNameSpecifierLoc NNS, |
3599 | QualType ObjectType, |
3600 | NamedDecl *FirstQualifierInScope) { |
3601 | SmallVector<NestedNameSpecifierLoc, 4> Qualifiers; |
3602 | for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier; |
3603 | Qualifier = Qualifier.getPrefix()) |
3604 | Qualifiers.push_back(Qualifier); |
3605 | |
3606 | CXXScopeSpec SS; |
3607 | while (!Qualifiers.empty()) { |
3608 | NestedNameSpecifierLoc Q = Qualifiers.pop_back_val(); |
3609 | NestedNameSpecifier *QNNS = Q.getNestedNameSpecifier(); |
3610 | |
3611 | switch (QNNS->getKind()) { |
3612 | case NestedNameSpecifier::Identifier: { |
3613 | Sema::NestedNameSpecInfo IdInfo(QNNS->getAsIdentifier(), |
3614 | Q.getLocalBeginLoc(), Q.getLocalEndLoc(), ObjectType); |
3615 | if (SemaRef.BuildCXXNestedNameSpecifier(, IdInfo, false, |
3616 | SS, FirstQualifierInScope, false)) |
3617 | return NestedNameSpecifierLoc(); |
3618 | } |
3619 | break; |
3620 | |
3621 | case NestedNameSpecifier::Namespace: { |
3622 | NamespaceDecl *NS |
3623 | = cast_or_null<NamespaceDecl>( |
3624 | getDerived().TransformDecl( |
3625 | Q.getLocalBeginLoc(), |
3626 | QNNS->getAsNamespace())); |
3627 | SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc()); |
3628 | break; |
3629 | } |
3630 | |
3631 | case NestedNameSpecifier::NamespaceAlias: { |
3632 | NamespaceAliasDecl *Alias |
3633 | = cast_or_null<NamespaceAliasDecl>( |
3634 | getDerived().TransformDecl(Q.getLocalBeginLoc(), |
3635 | QNNS->getAsNamespaceAlias())); |
3636 | SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(), |
3637 | Q.getLocalEndLoc()); |
3638 | break; |
3639 | } |
3640 | |
3641 | case NestedNameSpecifier::Global: |
3642 | |
3643 | |
3644 | SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc()); |
3645 | break; |
3646 | |
3647 | case NestedNameSpecifier::Super: { |
3648 | CXXRecordDecl *RD = |
3649 | cast_or_null<CXXRecordDecl>(getDerived().TransformDecl( |
3650 | SourceLocation(), QNNS->getAsRecordDecl())); |
3651 | SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc()); |
3652 | break; |
3653 | } |
3654 | |
3655 | case NestedNameSpecifier::TypeSpecWithTemplate: |
3656 | case NestedNameSpecifier::TypeSpec: { |
3657 | TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType, |
3658 | FirstQualifierInScope, SS); |
3659 | |
3660 | if (!TL) |
3661 | return NestedNameSpecifierLoc(); |
3662 | |
3663 | if (TL.getType()->isDependentType() || TL.getType()->isRecordType() || |
3664 | (SemaRef.getLangOpts().CPlusPlus11 && |
3665 | TL.getType()->isEnumeralType())) { |
3666 | (0) . __assert_fail ("!TL.getType().hasLocalQualifiers() && \"Can't get cv-qualifiers here\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3667, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!TL.getType().hasLocalQualifiers() && |
3667 | (0) . __assert_fail ("!TL.getType().hasLocalQualifiers() && \"Can't get cv-qualifiers here\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3667, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Can't get cv-qualifiers here"); |
3668 | if (TL.getType()->isEnumeralType()) |
3669 | SemaRef.Diag(TL.getBeginLoc(), |
3670 | diag::warn_cxx98_compat_enum_nested_name_spec); |
3671 | SS.Extend(SemaRef.Context, SourceLocation(), TL, |
3672 | Q.getLocalEndLoc()); |
3673 | break; |
3674 | } |
3675 | |
3676 | |
3677 | TypedefTypeLoc TTL = TL.getAs<TypedefTypeLoc>(); |
3678 | if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) { |
3679 | SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag) |
3680 | << TL.getType() << SS.getRange(); |
3681 | } |
3682 | return NestedNameSpecifierLoc(); |
3683 | } |
3684 | } |
3685 | |
3686 | |
3687 | FirstQualifierInScope = nullptr; |
3688 | ObjectType = QualType(); |
3689 | } |
3690 | |
3691 | |
3692 | if (SS.getScopeRep() == NNS.getNestedNameSpecifier() && |
3693 | !getDerived().AlwaysRebuild()) |
3694 | return NNS; |
3695 | |
3696 | |
3697 | |
3698 | if (SS.location_size() == NNS.getDataLength() && |
3699 | memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0) |
3700 | return NestedNameSpecifierLoc(SS.getScopeRep(), NNS.getOpaqueData()); |
3701 | |
3702 | |
3703 | return SS.getWithLocInContext(SemaRef.Context); |
3704 | } |
3705 | |
3706 | template<typename Derived> |
3707 | DeclarationNameInfo |
3708 | TreeTransform<Derived> |
3709 | ::TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo) { |
3710 | DeclarationName Name = NameInfo.getName(); |
3711 | if (!Name) |
3712 | return DeclarationNameInfo(); |
3713 | |
3714 | switch (Name.getNameKind()) { |
3715 | case DeclarationName::Identifier: |
3716 | case DeclarationName::ObjCZeroArgSelector: |
3717 | case DeclarationName::ObjCOneArgSelector: |
3718 | case DeclarationName::ObjCMultiArgSelector: |
3719 | case DeclarationName::CXXOperatorName: |
3720 | case DeclarationName::CXXLiteralOperatorName: |
3721 | case DeclarationName::CXXUsingDirective: |
3722 | return NameInfo; |
3723 | |
3724 | case DeclarationName::CXXDeductionGuideName: { |
3725 | TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate(); |
3726 | TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>( |
3727 | getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate)); |
3728 | if (!NewTemplate) |
3729 | return DeclarationNameInfo(); |
3730 | |
3731 | DeclarationNameInfo NewNameInfo(NameInfo); |
3732 | NewNameInfo.setName( |
3733 | SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate)); |
3734 | return NewNameInfo; |
3735 | } |
3736 | |
3737 | case DeclarationName::CXXConstructorName: |
3738 | case DeclarationName::CXXDestructorName: |
3739 | case DeclarationName::CXXConversionFunctionName: { |
3740 | TypeSourceInfo *NewTInfo; |
3741 | CanQualType NewCanTy; |
3742 | if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) { |
3743 | NewTInfo = getDerived().TransformType(OldTInfo); |
3744 | if (!NewTInfo) |
3745 | return DeclarationNameInfo(); |
3746 | NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType()); |
3747 | } |
3748 | else { |
3749 | NewTInfo = nullptr; |
3750 | TemporaryBase Rebase(*this, NameInfo.getLoc(), Name); |
3751 | QualType NewT = getDerived().TransformType(Name.getCXXNameType()); |
3752 | if (NewT.isNull()) |
3753 | return DeclarationNameInfo(); |
3754 | NewCanTy = SemaRef.Context.getCanonicalType(NewT); |
3755 | } |
3756 | |
3757 | DeclarationName NewName |
3758 | = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(), |
3759 | NewCanTy); |
3760 | DeclarationNameInfo NewNameInfo(NameInfo); |
3761 | NewNameInfo.setName(NewName); |
3762 | NewNameInfo.setNamedTypeInfo(NewTInfo); |
3763 | return NewNameInfo; |
3764 | } |
3765 | } |
3766 | |
3767 | llvm_unreachable("Unknown name kind."); |
3768 | } |
3769 | |
3770 | template<typename Derived> |
3771 | TemplateName |
3772 | TreeTransform<Derived>::TransformTemplateName(CXXScopeSpec &SS, |
3773 | TemplateName Name, |
3774 | SourceLocation NameLoc, |
3775 | QualType ObjectType, |
3776 | NamedDecl *FirstQualifierInScope, |
3777 | bool AllowInjectedClassName) { |
3778 | if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) { |
3779 | TemplateDecl *Template = QTN->getTemplateDecl(); |
3780 | (0) . __assert_fail ("Template && \"qualified template name must refer to a template\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 3780, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Template && "qualified template name must refer to a template"); |
3781 | |
3782 | TemplateDecl *TransTemplate |
3783 | = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc, |
3784 | Template)); |
3785 | if (!TransTemplate) |
3786 | return TemplateName(); |
3787 | |
3788 | if (!getDerived().AlwaysRebuild() && |
3789 | SS.getScopeRep() == QTN->getQualifier() && |
3790 | TransTemplate == Template) |
3791 | return Name; |
3792 | |
3793 | return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(), |
3794 | TransTemplate); |
3795 | } |
3796 | |
3797 | if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) { |
3798 | if (SS.getScopeRep()) { |
3799 | |
3800 | ObjectType = QualType(); |
3801 | FirstQualifierInScope = nullptr; |
3802 | } |
3803 | |
3804 | if (!getDerived().AlwaysRebuild() && |
3805 | SS.getScopeRep() == DTN->getQualifier() && |
3806 | ObjectType.isNull()) |
3807 | return Name; |
3808 | |
3809 | |
3810 | SourceLocation TemplateKWLoc = NameLoc; |
3811 | |
3812 | if (DTN->isIdentifier()) { |
3813 | return getDerived().RebuildTemplateName(SS, |
3814 | TemplateKWLoc, |
3815 | *DTN->getIdentifier(), |
3816 | NameLoc, |
3817 | ObjectType, |
3818 | FirstQualifierInScope, |
3819 | AllowInjectedClassName); |
3820 | } |
3821 | |
3822 | return getDerived().RebuildTemplateName(SS, TemplateKWLoc, |
3823 | DTN->getOperator(), NameLoc, |
3824 | ObjectType, AllowInjectedClassName); |
3825 | } |
3826 | |
3827 | if (TemplateDecl *Template = Name.getAsTemplateDecl()) { |
3828 | TemplateDecl *TransTemplate |
3829 | = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc, |
3830 | Template)); |
3831 | if (!TransTemplate) |
3832 | return TemplateName(); |
3833 | |
3834 | if (!getDerived().AlwaysRebuild() && |
3835 | TransTemplate == Template) |
3836 | return Name; |
3837 | |
3838 | return TemplateName(TransTemplate); |
3839 | } |
3840 | |
3841 | if (SubstTemplateTemplateParmPackStorage *SubstPack |
3842 | = Name.getAsSubstTemplateTemplateParmPack()) { |
3843 | TemplateTemplateParmDecl *TransParam |
3844 | = cast_or_null<TemplateTemplateParmDecl>( |
3845 | getDerived().TransformDecl(NameLoc, SubstPack->getParameterPack())); |
3846 | if (!TransParam) |
3847 | return TemplateName(); |
3848 | |
3849 | if (!getDerived().AlwaysRebuild() && |
3850 | TransParam == SubstPack->getParameterPack()) |
3851 | return Name; |
3852 | |
3853 | return getDerived().RebuildTemplateName(TransParam, |
3854 | SubstPack->getArgumentPack()); |
3855 | } |
3856 | |
3857 | |
3858 | llvm_unreachable("overloaded function decl survived to here"); |
3859 | } |
3860 | |
3861 | template<typename Derived> |
3862 | void TreeTransform<Derived>::InventTemplateArgumentLoc( |
3863 | const TemplateArgument &Arg, |
3864 | TemplateArgumentLoc &Output) { |
3865 | SourceLocation Loc = getDerived().getBaseLocation(); |
3866 | switch (Arg.getKind()) { |
3867 | case TemplateArgument::Null: |
3868 | llvm_unreachable("null template argument in TreeTransform"); |
3869 | break; |
3870 | |
3871 | case TemplateArgument::Type: |
3872 | Output = TemplateArgumentLoc(Arg, |
3873 | SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc)); |
3874 | |
3875 | break; |
3876 | |
3877 | case TemplateArgument::Template: |
3878 | case TemplateArgument::TemplateExpansion: { |
3879 | NestedNameSpecifierLocBuilder Builder; |
3880 | TemplateName Template = Arg.getAsTemplateOrTemplatePattern(); |
3881 | if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) |
3882 | Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc); |
3883 | else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName()) |
3884 | Builder.MakeTrivial(SemaRef.Context, QTN->getQualifier(), Loc); |
3885 | |
3886 | if (Arg.getKind() == TemplateArgument::Template) |
3887 | Output = TemplateArgumentLoc(Arg, |
3888 | Builder.getWithLocInContext(SemaRef.Context), |
3889 | Loc); |
3890 | else |
3891 | Output = TemplateArgumentLoc(Arg, |
3892 | Builder.getWithLocInContext(SemaRef.Context), |
3893 | Loc, Loc); |
3894 | |
3895 | break; |
3896 | } |
3897 | |
3898 | case TemplateArgument::Expression: |
3899 | Output = TemplateArgumentLoc(Arg, Arg.getAsExpr()); |
3900 | break; |
3901 | |
3902 | case TemplateArgument::Declaration: |
3903 | case TemplateArgument::Integral: |
3904 | case TemplateArgument::Pack: |
3905 | case TemplateArgument::NullPtr: |
3906 | Output = TemplateArgumentLoc(Arg, TemplateArgumentLocInfo()); |
3907 | break; |
3908 | } |
3909 | } |
3910 | |
3911 | template<typename Derived> |
3912 | bool TreeTransform<Derived>::TransformTemplateArgument( |
3913 | const TemplateArgumentLoc &Input, |
3914 | TemplateArgumentLoc &Output, bool Uneval) { |
3915 | EnterExpressionEvaluationContext EEEC( |
3916 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated, |
3917 | , |
3918 | Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument); |
3919 | const TemplateArgument &Arg = Input.getArgument(); |
3920 | switch (Arg.getKind()) { |
3921 | case TemplateArgument::Null: |
3922 | case TemplateArgument::Integral: |
3923 | case TemplateArgument::Pack: |
3924 | case TemplateArgument::Declaration: |
3925 | case TemplateArgument::NullPtr: |
3926 | llvm_unreachable("Unexpected TemplateArgument"); |
3927 | |
3928 | case TemplateArgument::Type: { |
3929 | TypeSourceInfo *DI = Input.getTypeSourceInfo(); |
3930 | if (!DI) |
3931 | DI = InventTypeSourceInfo(Input.getArgument().getAsType()); |
3932 | |
3933 | DI = getDerived().TransformType(DI); |
3934 | if (!DI) return true; |
3935 | |
3936 | Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI); |
3937 | return false; |
3938 | } |
3939 | |
3940 | case TemplateArgument::Template: { |
3941 | NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc(); |
3942 | if (QualifierLoc) { |
3943 | QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc); |
3944 | if (!QualifierLoc) |
3945 | return true; |
3946 | } |
3947 | |
3948 | CXXScopeSpec SS; |
3949 | SS.Adopt(QualifierLoc); |
3950 | TemplateName Template |
3951 | = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(), |
3952 | Input.getTemplateNameLoc()); |
3953 | if (Template.isNull()) |
3954 | return true; |
3955 | |
3956 | Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc, |
3957 | Input.getTemplateNameLoc()); |
3958 | return false; |
3959 | } |
3960 | |
3961 | case TemplateArgument::TemplateExpansion: |
3962 | llvm_unreachable("Caller should expand pack expansions"); |
3963 | |
3964 | case TemplateArgument::Expression: { |
3965 | |
3966 | EnterExpressionEvaluationContext Unevaluated( |
3967 | getSema(), Uneval |
3968 | ? Sema::ExpressionEvaluationContext::Unevaluated |
3969 | : Sema::ExpressionEvaluationContext::ConstantEvaluated); |
3970 | |
3971 | Expr *InputExpr = Input.getSourceExpression(); |
3972 | if (!InputExpr) InputExpr = Input.getArgument().getAsExpr(); |
3973 | |
3974 | ExprResult E = getDerived().TransformExpr(InputExpr); |
3975 | E = SemaRef.ActOnConstantExpression(E); |
3976 | if (E.isInvalid()) return true; |
3977 | Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get()); |
3978 | return false; |
3979 | } |
3980 | } |
3981 | |
3982 | |
3983 | return true; |
3984 | } |
3985 | |
3986 | |
3987 | |
3988 | template<typename Derived, typename InputIterator> |
3989 | class TemplateArgumentLocInventIterator { |
3990 | TreeTransform<Derived> &Self; |
3991 | InputIterator Iter; |
3992 | |
3993 | public: |
3994 | typedef TemplateArgumentLoc value_type; |
3995 | typedef TemplateArgumentLoc reference; |
3996 | typedef typename std::iterator_traits<InputIterator>::difference_type |
3997 | difference_type; |
3998 | typedef std::input_iterator_tag iterator_category; |
3999 | |
4000 | class pointer { |
4001 | TemplateArgumentLoc Arg; |
4002 | |
4003 | public: |
4004 | explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { } |
4005 | |
4006 | const TemplateArgumentLoc *operator->() const { return &Arg; } |
4007 | }; |
4008 | |
4009 | TemplateArgumentLocInventIterator() { } |
4010 | |
4011 | explicit TemplateArgumentLocInventIterator(TreeTransform<Derived> &Self, |
4012 | InputIterator Iter) |
4013 | : Self(Self), Iter(Iter) { } |
4014 | |
4015 | TemplateArgumentLocInventIterator &operator++() { |
4016 | ++Iter; |
4017 | return *this; |
4018 | } |
4019 | |
4020 | TemplateArgumentLocInventIterator operator++(int) { |
4021 | TemplateArgumentLocInventIterator Old(*this); |
4022 | ++(*this); |
4023 | return Old; |
4024 | } |
4025 | |
4026 | reference operator*() const { |
4027 | TemplateArgumentLoc Result; |
4028 | Self.InventTemplateArgumentLoc(*Iter, Result); |
4029 | return Result; |
4030 | } |
4031 | |
4032 | pointer operator->() const { return pointer(**this); } |
4033 | |
4034 | friend bool operator==(const TemplateArgumentLocInventIterator &X, |
4035 | const TemplateArgumentLocInventIterator &Y) { |
4036 | return X.Iter == Y.Iter; |
4037 | } |
4038 | |
4039 | friend bool operator!=(const TemplateArgumentLocInventIterator &X, |
4040 | const TemplateArgumentLocInventIterator &Y) { |
4041 | return X.Iter != Y.Iter; |
4042 | } |
4043 | }; |
4044 | |
4045 | template<typename Derived> |
4046 | template<typename InputIterator> |
4047 | bool TreeTransform<Derived>::TransformTemplateArguments( |
4048 | InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, |
4049 | bool Uneval) { |
4050 | for (; First != Last; ++First) { |
4051 | TemplateArgumentLoc Out; |
4052 | TemplateArgumentLoc In = *First; |
4053 | |
4054 | if (In.getArgument().getKind() == TemplateArgument::Pack) { |
4055 | |
4056 | |
4057 | |
4058 | |
4059 | |
4060 | typedef TemplateArgumentLocInventIterator<Derived, |
4061 | TemplateArgument::pack_iterator> |
4062 | PackLocIterator; |
4063 | if (TransformTemplateArguments(PackLocIterator(*this, |
4064 | In.getArgument().pack_begin()), |
4065 | PackLocIterator(*this, |
4066 | In.getArgument().pack_end()), |
4067 | Outputs, Uneval)) |
4068 | return true; |
4069 | |
4070 | continue; |
4071 | } |
4072 | |
4073 | if (In.getArgument().isPackExpansion()) { |
4074 | |
4075 | |
4076 | SourceLocation Ellipsis; |
4077 | Optional<unsigned> OrigNumExpansions; |
4078 | TemplateArgumentLoc Pattern |
4079 | = getSema().getTemplateArgumentPackExpansionPattern( |
4080 | In, Ellipsis, OrigNumExpansions); |
4081 | |
4082 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
4083 | getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); |
4084 | (0) . __assert_fail ("!Unexpanded.empty() && \"Pack expansion without parameter packs?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 4084, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); |
4085 | |
4086 | |
4087 | |
4088 | bool Expand = true; |
4089 | bool RetainExpansion = false; |
4090 | Optional<unsigned> NumExpansions = OrigNumExpansions; |
4091 | if (getDerived().TryExpandParameterPacks(Ellipsis, |
4092 | Pattern.getSourceRange(), |
4093 | Unexpanded, |
4094 | Expand, |
4095 | RetainExpansion, |
4096 | NumExpansions)) |
4097 | return true; |
4098 | |
4099 | if (!Expand) { |
4100 | |
4101 | |
4102 | |
4103 | TemplateArgumentLoc OutPattern; |
4104 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
4105 | if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval)) |
4106 | return true; |
4107 | |
4108 | Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis, |
4109 | NumExpansions); |
4110 | if (Out.getArgument().isNull()) |
4111 | return true; |
4112 | |
4113 | Outputs.addArgument(Out); |
4114 | continue; |
4115 | } |
4116 | |
4117 | |
4118 | |
4119 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
4120 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); |
4121 | |
4122 | if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval)) |
4123 | return true; |
4124 | |
4125 | if (Out.getArgument().containsUnexpandedParameterPack()) { |
4126 | Out = getDerived().RebuildPackExpansion(Out, Ellipsis, |
4127 | OrigNumExpansions); |
4128 | if (Out.getArgument().isNull()) |
4129 | return true; |
4130 | } |
4131 | |
4132 | Outputs.addArgument(Out); |
4133 | } |
4134 | |
4135 | |
4136 | |
4137 | if (RetainExpansion) { |
4138 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
4139 | |
4140 | if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval)) |
4141 | return true; |
4142 | |
4143 | Out = getDerived().RebuildPackExpansion(Out, Ellipsis, |
4144 | OrigNumExpansions); |
4145 | if (Out.getArgument().isNull()) |
4146 | return true; |
4147 | |
4148 | Outputs.addArgument(Out); |
4149 | } |
4150 | |
4151 | continue; |
4152 | } |
4153 | |
4154 | |
4155 | if (getDerived().TransformTemplateArgument(In, Out, Uneval)) |
4156 | return true; |
4157 | |
4158 | Outputs.addArgument(Out); |
4159 | } |
4160 | |
4161 | return false; |
4162 | |
4163 | } |
4164 | |
4165 | |
4166 | |
4167 | |
4168 | |
4169 | template<typename Derived> |
4170 | QualType TreeTransform<Derived>::TransformType(QualType T) { |
4171 | if (getDerived().AlreadyTransformed(T)) |
4172 | return T; |
4173 | |
4174 | |
4175 | |
4176 | TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T, |
4177 | getDerived().getBaseLocation()); |
4178 | |
4179 | TypeSourceInfo *NewDI = getDerived().TransformType(DI); |
4180 | |
4181 | if (!NewDI) |
4182 | return QualType(); |
4183 | |
4184 | return NewDI->getType(); |
4185 | } |
4186 | |
4187 | template<typename Derived> |
4188 | TypeSourceInfo *TreeTransform<Derived>::TransformType(TypeSourceInfo *DI) { |
4189 | |
4190 | TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(), |
4191 | getDerived().getBaseEntity()); |
4192 | if (getDerived().AlreadyTransformed(DI->getType())) |
4193 | return DI; |
4194 | |
4195 | TypeLocBuilder TLB; |
4196 | |
4197 | TypeLoc TL = DI->getTypeLoc(); |
4198 | TLB.reserve(TL.getFullDataSize()); |
4199 | |
4200 | QualType Result = getDerived().TransformType(TLB, TL); |
4201 | if (Result.isNull()) |
4202 | return nullptr; |
4203 | |
4204 | return TLB.getTypeSourceInfo(SemaRef.Context, Result); |
4205 | } |
4206 | |
4207 | template<typename Derived> |
4208 | QualType |
4209 | TreeTransform<Derived>::TransformType(TypeLocBuilder &TLB, TypeLoc T) { |
4210 | switch (T.getTypeLocClass()) { |
4211 | #define ABSTRACT_TYPELOC(CLASS, PARENT) |
4212 | #define TYPELOC(CLASS, PARENT) \ |
4213 | case TypeLoc::CLASS: \ |
4214 | return getDerived().Transform##CLASS##Type(TLB, \ |
4215 | T.castAs<CLASS##TypeLoc>()); |
4216 | #include "clang/AST/TypeLocNodes.def" |
4217 | } |
4218 | |
4219 | llvm_unreachable("unhandled type loc!"); |
4220 | } |
4221 | |
4222 | template<typename Derived> |
4223 | QualType TreeTransform<Derived>::TransformTypeWithDeducedTST(QualType T) { |
4224 | if (!isa<DependentNameType>(T)) |
4225 | return TransformType(T); |
4226 | |
4227 | if (getDerived().AlreadyTransformed(T)) |
4228 | return T; |
4229 | TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T, |
4230 | getDerived().getBaseLocation()); |
4231 | TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI); |
4232 | return NewDI ? NewDI->getType() : QualType(); |
4233 | } |
4234 | |
4235 | template<typename Derived> |
4236 | TypeSourceInfo * |
4237 | TreeTransform<Derived>::TransformTypeWithDeducedTST(TypeSourceInfo *DI) { |
4238 | if (!isa<DependentNameType>(DI->getType())) |
4239 | return TransformType(DI); |
4240 | |
4241 | |
4242 | TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(), |
4243 | getDerived().getBaseEntity()); |
4244 | if (getDerived().AlreadyTransformed(DI->getType())) |
4245 | return DI; |
4246 | |
4247 | TypeLocBuilder TLB; |
4248 | |
4249 | TypeLoc TL = DI->getTypeLoc(); |
4250 | TLB.reserve(TL.getFullDataSize()); |
4251 | |
4252 | auto QTL = TL.getAs<QualifiedTypeLoc>(); |
4253 | if (QTL) |
4254 | TL = QTL.getUnqualifiedLoc(); |
4255 | |
4256 | auto DNTL = TL.castAs<DependentNameTypeLoc>(); |
4257 | |
4258 | QualType Result = getDerived().TransformDependentNameType( |
4259 | TLB, DNTL, ); |
4260 | if (Result.isNull()) |
4261 | return nullptr; |
4262 | |
4263 | if (QTL) { |
4264 | Result = getDerived().RebuildQualifiedType(Result, QTL); |
4265 | if (Result.isNull()) |
4266 | return nullptr; |
4267 | TLB.TypeWasModifiedSafely(Result); |
4268 | } |
4269 | |
4270 | return TLB.getTypeSourceInfo(SemaRef.Context, Result); |
4271 | } |
4272 | |
4273 | template<typename Derived> |
4274 | QualType |
4275 | TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB, |
4276 | QualifiedTypeLoc T) { |
4277 | QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc()); |
4278 | if (Result.isNull()) |
4279 | return QualType(); |
4280 | |
4281 | Result = getDerived().RebuildQualifiedType(Result, T); |
4282 | |
4283 | if (Result.isNull()) |
4284 | return QualType(); |
4285 | |
4286 | |
4287 | |
4288 | |
4289 | TLB.TypeWasModifiedSafely(Result); |
4290 | |
4291 | return Result; |
4292 | } |
4293 | |
4294 | template <typename Derived> |
4295 | QualType TreeTransform<Derived>::RebuildQualifiedType(QualType T, |
4296 | QualifiedTypeLoc TL) { |
4297 | |
4298 | SourceLocation Loc = TL.getBeginLoc(); |
4299 | Qualifiers Quals = TL.getType().getLocalQualifiers(); |
4300 | |
4301 | if (((T.getAddressSpace() != LangAS::Default && |
4302 | Quals.getAddressSpace() != LangAS::Default)) && |
4303 | T.getAddressSpace() != Quals.getAddressSpace()) { |
4304 | SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst) |
4305 | << TL.getType() << T; |
4306 | return QualType(); |
4307 | } |
4308 | |
4309 | |
4310 | |
4311 | |
4312 | if (T->isFunctionType()) { |
4313 | T = SemaRef.getASTContext().getAddrSpaceQualType(T, |
4314 | Quals.getAddressSpace()); |
4315 | return T; |
4316 | } |
4317 | |
4318 | |
4319 | |
4320 | |
4321 | |
4322 | |
4323 | if (T->isReferenceType()) { |
4324 | |
4325 | if (!Quals.hasRestrict()) |
4326 | return T; |
4327 | Quals = Qualifiers::fromCVRMask(Qualifiers::Restrict); |
4328 | } |
4329 | |
4330 | |
4331 | |
4332 | if (Quals.hasObjCLifetime()) { |
4333 | if (!T->isObjCLifetimeType() && !T->isDependentType()) |
4334 | Quals.removeObjCLifetime(); |
4335 | else if (T.getObjCLifetime()) { |
4336 | |
4337 | |
4338 | |
4339 | const AutoType *AutoTy; |
4340 | if (const SubstTemplateTypeParmType *SubstTypeParam |
4341 | = dyn_cast<SubstTemplateTypeParmType>(T)) { |
4342 | QualType Replacement = SubstTypeParam->getReplacementType(); |
4343 | Qualifiers Qs = Replacement.getQualifiers(); |
4344 | Qs.removeObjCLifetime(); |
4345 | Replacement = SemaRef.Context.getQualifiedType( |
4346 | Replacement.getUnqualifiedType(), Qs); |
4347 | T = SemaRef.Context.getSubstTemplateTypeParmType( |
4348 | SubstTypeParam->getReplacedParameter(), Replacement); |
4349 | } else if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) { |
4350 | |
4351 | QualType Deduced = AutoTy->getDeducedType(); |
4352 | Qualifiers Qs = Deduced.getQualifiers(); |
4353 | Qs.removeObjCLifetime(); |
4354 | Deduced = |
4355 | SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs); |
4356 | T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(), |
4357 | AutoTy->isDependentType()); |
4358 | } else { |
4359 | |
4360 | |
4361 | |
4362 | SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T; |
4363 | Quals.removeObjCLifetime(); |
4364 | } |
4365 | } |
4366 | } |
4367 | |
4368 | return SemaRef.BuildQualifiedType(T, Loc, Quals); |
4369 | } |
4370 | |
4371 | template<typename Derived> |
4372 | TypeLoc |
4373 | TreeTransform<Derived>::TransformTypeInObjectScope(TypeLoc TL, |
4374 | QualType ObjectType, |
4375 | NamedDecl *UnqualLookup, |
4376 | CXXScopeSpec &SS) { |
4377 | if (getDerived().AlreadyTransformed(TL.getType())) |
4378 | return TL; |
4379 | |
4380 | TypeSourceInfo *TSI = |
4381 | TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS); |
4382 | if (TSI) |
4383 | return TSI->getTypeLoc(); |
4384 | return TypeLoc(); |
4385 | } |
4386 | |
4387 | template<typename Derived> |
4388 | TypeSourceInfo * |
4389 | TreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSInfo, |
4390 | QualType ObjectType, |
4391 | NamedDecl *UnqualLookup, |
4392 | CXXScopeSpec &SS) { |
4393 | if (getDerived().AlreadyTransformed(TSInfo->getType())) |
4394 | return TSInfo; |
4395 | |
4396 | return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType, |
4397 | UnqualLookup, SS); |
4398 | } |
4399 | |
4400 | template <typename Derived> |
4401 | TypeSourceInfo *TreeTransform<Derived>::TransformTSIInObjectScope( |
4402 | TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup, |
4403 | CXXScopeSpec &SS) { |
4404 | QualType T = TL.getType(); |
4405 | assert(!getDerived().AlreadyTransformed(T)); |
4406 | |
4407 | TypeLocBuilder TLB; |
4408 | QualType Result; |
4409 | |
4410 | if (isa<TemplateSpecializationType>(T)) { |
4411 | TemplateSpecializationTypeLoc SpecTL = |
4412 | TL.castAs<TemplateSpecializationTypeLoc>(); |
4413 | |
4414 | TemplateName Template = getDerived().TransformTemplateName( |
4415 | SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(), |
4416 | ObjectType, UnqualLookup, ); |
4417 | if (Template.isNull()) |
4418 | return nullptr; |
4419 | |
4420 | Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL, |
4421 | Template); |
4422 | } else if (isa<DependentTemplateSpecializationType>(T)) { |
4423 | DependentTemplateSpecializationTypeLoc SpecTL = |
4424 | TL.castAs<DependentTemplateSpecializationTypeLoc>(); |
4425 | |
4426 | TemplateName Template |
4427 | = getDerived().RebuildTemplateName(SS, |
4428 | SpecTL.getTemplateKeywordLoc(), |
4429 | *SpecTL.getTypePtr()->getIdentifier(), |
4430 | SpecTL.getTemplateNameLoc(), |
4431 | ObjectType, UnqualLookup, |
4432 | ); |
4433 | if (Template.isNull()) |
4434 | return nullptr; |
4435 | |
4436 | Result = getDerived().TransformDependentTemplateSpecializationType(TLB, |
4437 | SpecTL, |
4438 | Template, |
4439 | SS); |
4440 | } else { |
4441 | |
4442 | Result = getDerived().TransformType(TLB, TL); |
4443 | } |
4444 | |
4445 | if (Result.isNull()) |
4446 | return nullptr; |
4447 | |
4448 | return TLB.getTypeSourceInfo(SemaRef.Context, Result); |
4449 | } |
4450 | |
4451 | template <class TyLoc> static inline |
4452 | QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T) { |
4453 | TyLoc NewT = TLB.push<TyLoc>(T.getType()); |
4454 | NewT.setNameLoc(T.getNameLoc()); |
4455 | return T.getType(); |
4456 | } |
4457 | |
4458 | template<typename Derived> |
4459 | QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB, |
4460 | BuiltinTypeLoc T) { |
4461 | BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType()); |
4462 | NewT.setBuiltinLoc(T.getBuiltinLoc()); |
4463 | if (T.needsExtraLocalData()) |
4464 | NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs(); |
4465 | return T.getType(); |
4466 | } |
4467 | |
4468 | template<typename Derived> |
4469 | QualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB, |
4470 | ComplexTypeLoc T) { |
4471 | |
4472 | return TransformTypeSpecType(TLB, T); |
4473 | } |
4474 | |
4475 | template <typename Derived> |
4476 | QualType TreeTransform<Derived>::TransformAdjustedType(TypeLocBuilder &TLB, |
4477 | AdjustedTypeLoc TL) { |
4478 | |
4479 | return getDerived().TransformType(TLB, TL.getOriginalLoc()); |
4480 | } |
4481 | |
4482 | template<typename Derived> |
4483 | QualType TreeTransform<Derived>::TransformDecayedType(TypeLocBuilder &TLB, |
4484 | DecayedTypeLoc TL) { |
4485 | QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc()); |
4486 | if (OriginalType.isNull()) |
4487 | return QualType(); |
4488 | |
4489 | QualType Result = TL.getType(); |
4490 | if (getDerived().AlwaysRebuild() || |
4491 | OriginalType != TL.getOriginalLoc().getType()) |
4492 | Result = SemaRef.Context.getDecayedType(OriginalType); |
4493 | TLB.push<DecayedTypeLoc>(Result); |
4494 | |
4495 | return Result; |
4496 | } |
4497 | |
4498 | template<typename Derived> |
4499 | QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB, |
4500 | PointerTypeLoc TL) { |
4501 | QualType PointeeType |
4502 | = getDerived().TransformType(TLB, TL.getPointeeLoc()); |
4503 | if (PointeeType.isNull()) |
4504 | return QualType(); |
4505 | |
4506 | QualType Result = TL.getType(); |
4507 | if (PointeeType->getAs<ObjCObjectType>()) { |
4508 | |
4509 | |
4510 | |
4511 | |
4512 | Result = SemaRef.Context.getObjCObjectPointerType(PointeeType); |
4513 | |
4514 | ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result); |
4515 | NewT.setStarLoc(TL.getStarLoc()); |
4516 | return Result; |
4517 | } |
4518 | |
4519 | if (getDerived().AlwaysRebuild() || |
4520 | PointeeType != TL.getPointeeLoc().getType()) { |
4521 | Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc()); |
4522 | if (Result.isNull()) |
4523 | return QualType(); |
4524 | } |
4525 | |
4526 | |
4527 | |
4528 | TLB.TypeWasModifiedSafely(Result->getPointeeType()); |
4529 | |
4530 | PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result); |
4531 | NewT.setSigilLoc(TL.getSigilLoc()); |
4532 | return Result; |
4533 | } |
4534 | |
4535 | template<typename Derived> |
4536 | QualType |
4537 | TreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB, |
4538 | BlockPointerTypeLoc TL) { |
4539 | QualType PointeeType |
4540 | = getDerived().TransformType(TLB, TL.getPointeeLoc()); |
4541 | if (PointeeType.isNull()) |
4542 | return QualType(); |
4543 | |
4544 | QualType Result = TL.getType(); |
4545 | if (getDerived().AlwaysRebuild() || |
4546 | PointeeType != TL.getPointeeLoc().getType()) { |
4547 | Result = getDerived().RebuildBlockPointerType(PointeeType, |
4548 | TL.getSigilLoc()); |
4549 | if (Result.isNull()) |
4550 | return QualType(); |
4551 | } |
4552 | |
4553 | BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result); |
4554 | NewT.setSigilLoc(TL.getSigilLoc()); |
4555 | return Result; |
4556 | } |
4557 | |
4558 | |
4559 | |
4560 | |
4561 | |
4562 | template<typename Derived> |
4563 | QualType |
4564 | TreeTransform<Derived>::TransformReferenceType(TypeLocBuilder &TLB, |
4565 | ReferenceTypeLoc TL) { |
4566 | const ReferenceType *T = TL.getTypePtr(); |
4567 | |
4568 | |
4569 | QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc()); |
4570 | if (PointeeType.isNull()) |
4571 | return QualType(); |
4572 | |
4573 | QualType Result = TL.getType(); |
4574 | if (getDerived().AlwaysRebuild() || |
4575 | PointeeType != T->getPointeeTypeAsWritten()) { |
4576 | Result = getDerived().RebuildReferenceType(PointeeType, |
4577 | T->isSpelledAsLValue(), |
4578 | TL.getSigilLoc()); |
4579 | if (Result.isNull()) |
4580 | return QualType(); |
4581 | } |
4582 | |
4583 | |
4584 | |
4585 | TLB.TypeWasModifiedSafely( |
4586 | Result->getAs<ReferenceType>()->getPointeeTypeAsWritten()); |
4587 | |
4588 | |
4589 | ReferenceTypeLoc NewTL; |
4590 | if (isa<LValueReferenceType>(Result)) |
4591 | NewTL = TLB.push<LValueReferenceTypeLoc>(Result); |
4592 | else |
4593 | NewTL = TLB.push<RValueReferenceTypeLoc>(Result); |
4594 | NewTL.setSigilLoc(TL.getSigilLoc()); |
4595 | |
4596 | return Result; |
4597 | } |
4598 | |
4599 | template<typename Derived> |
4600 | QualType |
4601 | TreeTransform<Derived>::TransformLValueReferenceType(TypeLocBuilder &TLB, |
4602 | LValueReferenceTypeLoc TL) { |
4603 | return TransformReferenceType(TLB, TL); |
4604 | } |
4605 | |
4606 | template<typename Derived> |
4607 | QualType |
4608 | TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB, |
4609 | RValueReferenceTypeLoc TL) { |
4610 | return TransformReferenceType(TLB, TL); |
4611 | } |
4612 | |
4613 | template<typename Derived> |
4614 | QualType |
4615 | TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB, |
4616 | MemberPointerTypeLoc TL) { |
4617 | QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc()); |
4618 | if (PointeeType.isNull()) |
4619 | return QualType(); |
4620 | |
4621 | TypeSourceInfo* OldClsTInfo = TL.getClassTInfo(); |
4622 | TypeSourceInfo *NewClsTInfo = nullptr; |
4623 | if (OldClsTInfo) { |
4624 | NewClsTInfo = getDerived().TransformType(OldClsTInfo); |
4625 | if (!NewClsTInfo) |
4626 | return QualType(); |
4627 | } |
4628 | |
4629 | const MemberPointerType *T = TL.getTypePtr(); |
4630 | QualType OldClsType = QualType(T->getClass(), 0); |
4631 | QualType NewClsType; |
4632 | if (NewClsTInfo) |
4633 | NewClsType = NewClsTInfo->getType(); |
4634 | else { |
4635 | NewClsType = getDerived().TransformType(OldClsType); |
4636 | if (NewClsType.isNull()) |
4637 | return QualType(); |
4638 | } |
4639 | |
4640 | QualType Result = TL.getType(); |
4641 | if (getDerived().AlwaysRebuild() || |
4642 | PointeeType != T->getPointeeType() || |
4643 | NewClsType != OldClsType) { |
4644 | Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType, |
4645 | TL.getStarLoc()); |
4646 | if (Result.isNull()) |
4647 | return QualType(); |
4648 | } |
4649 | |
4650 | |
4651 | |
4652 | const MemberPointerType *MPT = Result->getAs<MemberPointerType>(); |
4653 | if (MPT && PointeeType != MPT->getPointeeType()) { |
4654 | (MPT->getPointeeType())", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 4654, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isa<AdjustedType>(MPT->getPointeeType())); |
4655 | TLB.push<AdjustedTypeLoc>(MPT->getPointeeType()); |
4656 | } |
4657 | |
4658 | MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result); |
4659 | NewTL.setSigilLoc(TL.getSigilLoc()); |
4660 | NewTL.setClassTInfo(NewClsTInfo); |
4661 | |
4662 | return Result; |
4663 | } |
4664 | |
4665 | template<typename Derived> |
4666 | QualType |
4667 | TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB, |
4668 | ConstantArrayTypeLoc TL) { |
4669 | const ConstantArrayType *T = TL.getTypePtr(); |
4670 | QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); |
4671 | if (ElementType.isNull()) |
4672 | return QualType(); |
4673 | |
4674 | QualType Result = TL.getType(); |
4675 | if (getDerived().AlwaysRebuild() || |
4676 | ElementType != T->getElementType()) { |
4677 | Result = getDerived().RebuildConstantArrayType(ElementType, |
4678 | T->getSizeModifier(), |
4679 | T->getSize(), |
4680 | T->getIndexTypeCVRQualifiers(), |
4681 | TL.getBracketsRange()); |
4682 | if (Result.isNull()) |
4683 | return QualType(); |
4684 | } |
4685 | |
4686 | |
4687 | |
4688 | |
4689 | |
4690 | ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result); |
4691 | NewTL.setLBracketLoc(TL.getLBracketLoc()); |
4692 | NewTL.setRBracketLoc(TL.getRBracketLoc()); |
4693 | |
4694 | Expr *Size = TL.getSizeExpr(); |
4695 | if (Size) { |
4696 | EnterExpressionEvaluationContext Unevaluated( |
4697 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); |
4698 | Size = getDerived().TransformExpr(Size).template getAs<Expr>(); |
4699 | Size = SemaRef.ActOnConstantExpression(Size).get(); |
4700 | } |
4701 | NewTL.setSizeExpr(Size); |
4702 | |
4703 | return Result; |
4704 | } |
4705 | |
4706 | template<typename Derived> |
4707 | QualType TreeTransform<Derived>::TransformIncompleteArrayType( |
4708 | TypeLocBuilder &TLB, |
4709 | IncompleteArrayTypeLoc TL) { |
4710 | const IncompleteArrayType *T = TL.getTypePtr(); |
4711 | QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); |
4712 | if (ElementType.isNull()) |
4713 | return QualType(); |
4714 | |
4715 | QualType Result = TL.getType(); |
4716 | if (getDerived().AlwaysRebuild() || |
4717 | ElementType != T->getElementType()) { |
4718 | Result = getDerived().RebuildIncompleteArrayType(ElementType, |
4719 | T->getSizeModifier(), |
4720 | T->getIndexTypeCVRQualifiers(), |
4721 | TL.getBracketsRange()); |
4722 | if (Result.isNull()) |
4723 | return QualType(); |
4724 | } |
4725 | |
4726 | IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result); |
4727 | NewTL.setLBracketLoc(TL.getLBracketLoc()); |
4728 | NewTL.setRBracketLoc(TL.getRBracketLoc()); |
4729 | NewTL.setSizeExpr(nullptr); |
4730 | |
4731 | return Result; |
4732 | } |
4733 | |
4734 | template<typename Derived> |
4735 | QualType |
4736 | TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB, |
4737 | VariableArrayTypeLoc TL) { |
4738 | const VariableArrayType *T = TL.getTypePtr(); |
4739 | QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); |
4740 | if (ElementType.isNull()) |
4741 | return QualType(); |
4742 | |
4743 | ExprResult SizeResult; |
4744 | { |
4745 | EnterExpressionEvaluationContext Context( |
4746 | SemaRef, Sema::ExpressionEvaluationContext::PotentiallyEvaluated); |
4747 | SizeResult = getDerived().TransformExpr(T->getSizeExpr()); |
4748 | } |
4749 | if (SizeResult.isInvalid()) |
4750 | return QualType(); |
4751 | SizeResult = |
4752 | SemaRef.ActOnFinishFullExpr(SizeResult.get(), false); |
4753 | if (SizeResult.isInvalid()) |
4754 | return QualType(); |
4755 | |
4756 | Expr *Size = SizeResult.get(); |
4757 | |
4758 | QualType Result = TL.getType(); |
4759 | if (getDerived().AlwaysRebuild() || |
4760 | ElementType != T->getElementType() || |
4761 | Size != T->getSizeExpr()) { |
4762 | Result = getDerived().RebuildVariableArrayType(ElementType, |
4763 | T->getSizeModifier(), |
4764 | Size, |
4765 | T->getIndexTypeCVRQualifiers(), |
4766 | TL.getBracketsRange()); |
4767 | if (Result.isNull()) |
4768 | return QualType(); |
4769 | } |
4770 | |
4771 | |
4772 | |
4773 | ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result); |
4774 | NewTL.setLBracketLoc(TL.getLBracketLoc()); |
4775 | NewTL.setRBracketLoc(TL.getRBracketLoc()); |
4776 | NewTL.setSizeExpr(Size); |
4777 | |
4778 | return Result; |
4779 | } |
4780 | |
4781 | template<typename Derived> |
4782 | QualType |
4783 | TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB, |
4784 | DependentSizedArrayTypeLoc TL) { |
4785 | const DependentSizedArrayType *T = TL.getTypePtr(); |
4786 | QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); |
4787 | if (ElementType.isNull()) |
4788 | return QualType(); |
4789 | |
4790 | |
4791 | EnterExpressionEvaluationContext Unevaluated( |
4792 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); |
4793 | |
4794 | |
4795 | Expr *origSize = TL.getSizeExpr(); |
4796 | if (!origSize) origSize = T->getSizeExpr(); |
4797 | |
4798 | ExprResult sizeResult |
4799 | = getDerived().TransformExpr(origSize); |
4800 | sizeResult = SemaRef.ActOnConstantExpression(sizeResult); |
4801 | if (sizeResult.isInvalid()) |
4802 | return QualType(); |
4803 | |
4804 | Expr *size = sizeResult.get(); |
4805 | |
4806 | QualType Result = TL.getType(); |
4807 | if (getDerived().AlwaysRebuild() || |
4808 | ElementType != T->getElementType() || |
4809 | size != origSize) { |
4810 | Result = getDerived().RebuildDependentSizedArrayType(ElementType, |
4811 | T->getSizeModifier(), |
4812 | size, |
4813 | T->getIndexTypeCVRQualifiers(), |
4814 | TL.getBracketsRange()); |
4815 | if (Result.isNull()) |
4816 | return QualType(); |
4817 | } |
4818 | |
4819 | |
4820 | |
4821 | ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result); |
4822 | NewTL.setLBracketLoc(TL.getLBracketLoc()); |
4823 | NewTL.setRBracketLoc(TL.getRBracketLoc()); |
4824 | NewTL.setSizeExpr(size); |
4825 | |
4826 | return Result; |
4827 | } |
4828 | |
4829 | template <typename Derived> |
4830 | QualType TreeTransform<Derived>::TransformDependentVectorType( |
4831 | TypeLocBuilder &TLB, DependentVectorTypeLoc TL) { |
4832 | const DependentVectorType *T = TL.getTypePtr(); |
4833 | QualType ElementType = getDerived().TransformType(T->getElementType()); |
4834 | if (ElementType.isNull()) |
4835 | return QualType(); |
4836 | |
4837 | EnterExpressionEvaluationContext Unevaluated( |
4838 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); |
4839 | |
4840 | ExprResult Size = getDerived().TransformExpr(T->getSizeExpr()); |
4841 | Size = SemaRef.ActOnConstantExpression(Size); |
4842 | if (Size.isInvalid()) |
4843 | return QualType(); |
4844 | |
4845 | QualType Result = TL.getType(); |
4846 | if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() || |
4847 | Size.get() != T->getSizeExpr()) { |
4848 | Result = getDerived().RebuildDependentVectorType( |
4849 | ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind()); |
4850 | if (Result.isNull()) |
4851 | return QualType(); |
4852 | } |
4853 | |
4854 | |
4855 | if (isa<DependentVectorType>(Result)) { |
4856 | DependentVectorTypeLoc NewTL = |
4857 | TLB.push<DependentVectorTypeLoc>(Result); |
4858 | NewTL.setNameLoc(TL.getNameLoc()); |
4859 | } else { |
4860 | VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result); |
4861 | NewTL.setNameLoc(TL.getNameLoc()); |
4862 | } |
4863 | |
4864 | return Result; |
4865 | } |
4866 | |
4867 | template<typename Derived> |
4868 | QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType( |
4869 | TypeLocBuilder &TLB, |
4870 | DependentSizedExtVectorTypeLoc TL) { |
4871 | const DependentSizedExtVectorType *T = TL.getTypePtr(); |
4872 | |
4873 | |
4874 | QualType ElementType = getDerived().TransformType(T->getElementType()); |
4875 | if (ElementType.isNull()) |
4876 | return QualType(); |
4877 | |
4878 | |
4879 | EnterExpressionEvaluationContext Unevaluated( |
4880 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); |
4881 | |
4882 | ExprResult Size = getDerived().TransformExpr(T->getSizeExpr()); |
4883 | Size = SemaRef.ActOnConstantExpression(Size); |
4884 | if (Size.isInvalid()) |
4885 | return QualType(); |
4886 | |
4887 | QualType Result = TL.getType(); |
4888 | if (getDerived().AlwaysRebuild() || |
4889 | ElementType != T->getElementType() || |
4890 | Size.get() != T->getSizeExpr()) { |
4891 | Result = getDerived().RebuildDependentSizedExtVectorType(ElementType, |
4892 | Size.get(), |
4893 | T->getAttributeLoc()); |
4894 | if (Result.isNull()) |
4895 | return QualType(); |
4896 | } |
4897 | |
4898 | |
4899 | if (isa<DependentSizedExtVectorType>(Result)) { |
4900 | DependentSizedExtVectorTypeLoc NewTL |
4901 | = TLB.push<DependentSizedExtVectorTypeLoc>(Result); |
4902 | NewTL.setNameLoc(TL.getNameLoc()); |
4903 | } else { |
4904 | ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result); |
4905 | NewTL.setNameLoc(TL.getNameLoc()); |
4906 | } |
4907 | |
4908 | return Result; |
4909 | } |
4910 | |
4911 | template <typename Derived> |
4912 | QualType TreeTransform<Derived>::TransformDependentAddressSpaceType( |
4913 | TypeLocBuilder &TLB, DependentAddressSpaceTypeLoc TL) { |
4914 | const DependentAddressSpaceType *T = TL.getTypePtr(); |
4915 | |
4916 | QualType pointeeType = getDerived().TransformType(T->getPointeeType()); |
4917 | |
4918 | if (pointeeType.isNull()) |
4919 | return QualType(); |
4920 | |
4921 | |
4922 | EnterExpressionEvaluationContext Unevaluated( |
4923 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); |
4924 | |
4925 | ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr()); |
4926 | AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace); |
4927 | if (AddrSpace.isInvalid()) |
4928 | return QualType(); |
4929 | |
4930 | QualType Result = TL.getType(); |
4931 | if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() || |
4932 | AddrSpace.get() != T->getAddrSpaceExpr()) { |
4933 | Result = getDerived().RebuildDependentAddressSpaceType( |
4934 | pointeeType, AddrSpace.get(), T->getAttributeLoc()); |
4935 | if (Result.isNull()) |
4936 | return QualType(); |
4937 | } |
4938 | |
4939 | |
4940 | if (isa<DependentAddressSpaceType>(Result)) { |
4941 | DependentAddressSpaceTypeLoc NewTL = |
4942 | TLB.push<DependentAddressSpaceTypeLoc>(Result); |
4943 | |
4944 | NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange()); |
4945 | NewTL.setAttrExprOperand(TL.getAttrExprOperand()); |
4946 | NewTL.setAttrNameLoc(TL.getAttrNameLoc()); |
4947 | |
4948 | } else { |
4949 | TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo( |
4950 | Result, getDerived().getBaseLocation()); |
4951 | TransformType(TLB, DI->getTypeLoc()); |
4952 | } |
4953 | |
4954 | return Result; |
4955 | } |
4956 | |
4957 | template <typename Derived> |
4958 | QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB, |
4959 | VectorTypeLoc TL) { |
4960 | const VectorType *T = TL.getTypePtr(); |
4961 | QualType ElementType = getDerived().TransformType(T->getElementType()); |
4962 | if (ElementType.isNull()) |
4963 | return QualType(); |
4964 | |
4965 | QualType Result = TL.getType(); |
4966 | if (getDerived().AlwaysRebuild() || |
4967 | ElementType != T->getElementType()) { |
4968 | Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(), |
4969 | T->getVectorKind()); |
4970 | if (Result.isNull()) |
4971 | return QualType(); |
4972 | } |
4973 | |
4974 | VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result); |
4975 | NewTL.setNameLoc(TL.getNameLoc()); |
4976 | |
4977 | return Result; |
4978 | } |
4979 | |
4980 | template<typename Derived> |
4981 | QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB, |
4982 | ExtVectorTypeLoc TL) { |
4983 | const VectorType *T = TL.getTypePtr(); |
4984 | QualType ElementType = getDerived().TransformType(T->getElementType()); |
4985 | if (ElementType.isNull()) |
4986 | return QualType(); |
4987 | |
4988 | QualType Result = TL.getType(); |
4989 | if (getDerived().AlwaysRebuild() || |
4990 | ElementType != T->getElementType()) { |
4991 | Result = getDerived().RebuildExtVectorType(ElementType, |
4992 | T->getNumElements(), |
4993 | SourceLocation()); |
4994 | if (Result.isNull()) |
4995 | return QualType(); |
4996 | } |
4997 | |
4998 | ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result); |
4999 | NewTL.setNameLoc(TL.getNameLoc()); |
5000 | |
5001 | return Result; |
5002 | } |
5003 | |
5004 | template <typename Derived> |
5005 | ParmVarDecl *TreeTransform<Derived>::TransformFunctionTypeParam( |
5006 | ParmVarDecl *OldParm, int indexAdjustment, Optional<unsigned> NumExpansions, |
5007 | bool ExpectParameterPack) { |
5008 | TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo(); |
5009 | TypeSourceInfo *NewDI = nullptr; |
5010 | |
5011 | if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) { |
5012 | |
5013 | |
5014 | TypeLoc OldTL = OldDI->getTypeLoc(); |
5015 | PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>(); |
5016 | |
5017 | TypeLocBuilder TLB; |
5018 | TypeLoc NewTL = OldDI->getTypeLoc(); |
5019 | TLB.reserve(NewTL.getFullDataSize()); |
5020 | |
5021 | QualType Result = getDerived().TransformType(TLB, |
5022 | OldExpansionTL.getPatternLoc()); |
5023 | if (Result.isNull()) |
5024 | return nullptr; |
5025 | |
5026 | Result = RebuildPackExpansionType(Result, |
5027 | OldExpansionTL.getPatternLoc().getSourceRange(), |
5028 | OldExpansionTL.getEllipsisLoc(), |
5029 | NumExpansions); |
5030 | if (Result.isNull()) |
5031 | return nullptr; |
5032 | |
5033 | PackExpansionTypeLoc NewExpansionTL |
5034 | = TLB.push<PackExpansionTypeLoc>(Result); |
5035 | NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc()); |
5036 | NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result); |
5037 | } else |
5038 | NewDI = getDerived().TransformType(OldDI); |
5039 | if (!NewDI) |
5040 | return nullptr; |
5041 | |
5042 | if (NewDI == OldDI && indexAdjustment == 0) |
5043 | return OldParm; |
5044 | |
5045 | ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context, |
5046 | OldParm->getDeclContext(), |
5047 | OldParm->getInnerLocStart(), |
5048 | OldParm->getLocation(), |
5049 | OldParm->getIdentifier(), |
5050 | NewDI->getType(), |
5051 | NewDI, |
5052 | OldParm->getStorageClass(), |
5053 | nullptr); |
5054 | newParm->setScopeInfo(OldParm->getFunctionScopeDepth(), |
5055 | OldParm->getFunctionScopeIndex() + indexAdjustment); |
5056 | return newParm; |
5057 | } |
5058 | |
5059 | template <typename Derived> |
5060 | bool TreeTransform<Derived>::TransformFunctionTypeParams( |
5061 | SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, |
5062 | const QualType *ParamTypes, |
5063 | const FunctionProtoType::ExtParameterInfo *ParamInfos, |
5064 | SmallVectorImpl<QualType> &OutParamTypes, |
5065 | SmallVectorImpl<ParmVarDecl *> *PVars, |
5066 | Sema::ExtParameterInfoBuilder &PInfos) { |
5067 | int indexAdjustment = 0; |
5068 | |
5069 | unsigned NumParams = Params.size(); |
5070 | for (unsigned i = 0; i != NumParams; ++i) { |
5071 | if (ParmVarDecl *OldParm = Params[i]) { |
5072 | getFunctionScopeIndex() == i", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 5072, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(OldParm->getFunctionScopeIndex() == i); |
5073 | |
5074 | Optional<unsigned> NumExpansions; |
5075 | ParmVarDecl *NewParm = nullptr; |
5076 | if (OldParm->isParameterPack()) { |
5077 | |
5078 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
5079 | |
5080 | |
5081 | TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc(); |
5082 | PackExpansionTypeLoc ExpansionTL = TL.castAs<PackExpansionTypeLoc>(); |
5083 | TypeLoc Pattern = ExpansionTL.getPatternLoc(); |
5084 | SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded); |
5085 | (0) . __assert_fail ("Unexpanded.size() > 0 && \"Could not find parameter packs!\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 5085, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Unexpanded.size() > 0 && "Could not find parameter packs!"); |
5086 | |
5087 | |
5088 | bool ShouldExpand = false; |
5089 | bool RetainExpansion = false; |
5090 | Optional<unsigned> OrigNumExpansions = |
5091 | ExpansionTL.getTypePtr()->getNumExpansions(); |
5092 | NumExpansions = OrigNumExpansions; |
5093 | if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(), |
5094 | Pattern.getSourceRange(), |
5095 | Unexpanded, |
5096 | ShouldExpand, |
5097 | RetainExpansion, |
5098 | NumExpansions)) { |
5099 | return true; |
5100 | } |
5101 | |
5102 | if (ShouldExpand) { |
5103 | |
5104 | |
5105 | getDerived().ExpandingFunctionParameterPack(OldParm); |
5106 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
5107 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); |
5108 | ParmVarDecl *NewParm |
5109 | = getDerived().TransformFunctionTypeParam(OldParm, |
5110 | indexAdjustment++, |
5111 | OrigNumExpansions, |
5112 | ); |
5113 | if (!NewParm) |
5114 | return true; |
5115 | |
5116 | if (ParamInfos) |
5117 | PInfos.set(OutParamTypes.size(), ParamInfos[i]); |
5118 | OutParamTypes.push_back(NewParm->getType()); |
5119 | if (PVars) |
5120 | PVars->push_back(NewParm); |
5121 | } |
5122 | |
5123 | |
5124 | |
5125 | if (RetainExpansion) { |
5126 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
5127 | ParmVarDecl *NewParm |
5128 | = getDerived().TransformFunctionTypeParam(OldParm, |
5129 | indexAdjustment++, |
5130 | OrigNumExpansions, |
5131 | ); |
5132 | if (!NewParm) |
5133 | return true; |
5134 | |
5135 | if (ParamInfos) |
5136 | PInfos.set(OutParamTypes.size(), ParamInfos[i]); |
5137 | OutParamTypes.push_back(NewParm->getType()); |
5138 | if (PVars) |
5139 | PVars->push_back(NewParm); |
5140 | } |
5141 | |
5142 | |
5143 | |
5144 | |
5145 | |
5146 | indexAdjustment--; |
5147 | |
5148 | |
5149 | continue; |
5150 | } |
5151 | |
5152 | |
5153 | |
5154 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
5155 | NewParm = getDerived().TransformFunctionTypeParam(OldParm, |
5156 | indexAdjustment, |
5157 | NumExpansions, |
5158 | ); |
5159 | } else { |
5160 | NewParm = getDerived().TransformFunctionTypeParam( |
5161 | OldParm, indexAdjustment, None, false); |
5162 | } |
5163 | |
5164 | if (!NewParm) |
5165 | return true; |
5166 | |
5167 | if (ParamInfos) |
5168 | PInfos.set(OutParamTypes.size(), ParamInfos[i]); |
5169 | OutParamTypes.push_back(NewParm->getType()); |
5170 | if (PVars) |
5171 | PVars->push_back(NewParm); |
5172 | continue; |
5173 | } |
5174 | |
5175 | |
5176 | |
5177 | QualType OldType = ParamTypes[i]; |
5178 | bool IsPackExpansion = false; |
5179 | Optional<unsigned> NumExpansions; |
5180 | QualType NewType; |
5181 | if (const PackExpansionType *Expansion |
5182 | = dyn_cast<PackExpansionType>(OldType)) { |
5183 | |
5184 | QualType Pattern = Expansion->getPattern(); |
5185 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
5186 | getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); |
5187 | |
5188 | |
5189 | bool ShouldExpand = false; |
5190 | bool RetainExpansion = false; |
5191 | if (getDerived().TryExpandParameterPacks(Loc, SourceRange(), |
5192 | Unexpanded, |
5193 | ShouldExpand, |
5194 | RetainExpansion, |
5195 | NumExpansions)) { |
5196 | return true; |
5197 | } |
5198 | |
5199 | if (ShouldExpand) { |
5200 | |
5201 | |
5202 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
5203 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); |
5204 | QualType NewType = getDerived().TransformType(Pattern); |
5205 | if (NewType.isNull()) |
5206 | return true; |
5207 | |
5208 | if (NewType->containsUnexpandedParameterPack()) { |
5209 | NewType = |
5210 | getSema().getASTContext().getPackExpansionType(NewType, None); |
5211 | |
5212 | if (NewType.isNull()) |
5213 | return true; |
5214 | } |
5215 | |
5216 | if (ParamInfos) |
5217 | PInfos.set(OutParamTypes.size(), ParamInfos[i]); |
5218 | OutParamTypes.push_back(NewType); |
5219 | if (PVars) |
5220 | PVars->push_back(nullptr); |
5221 | } |
5222 | |
5223 | |
5224 | continue; |
5225 | } |
5226 | |
5227 | |
5228 | |
5229 | if (RetainExpansion) { |
5230 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
5231 | QualType NewType = getDerived().TransformType(Pattern); |
5232 | if (NewType.isNull()) |
5233 | return true; |
5234 | |
5235 | if (ParamInfos) |
5236 | PInfos.set(OutParamTypes.size(), ParamInfos[i]); |
5237 | OutParamTypes.push_back(NewType); |
5238 | if (PVars) |
5239 | PVars->push_back(nullptr); |
5240 | } |
5241 | |
5242 | |
5243 | |
5244 | OldType = Expansion->getPattern(); |
5245 | IsPackExpansion = true; |
5246 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
5247 | NewType = getDerived().TransformType(OldType); |
5248 | } else { |
5249 | NewType = getDerived().TransformType(OldType); |
5250 | } |
5251 | |
5252 | if (NewType.isNull()) |
5253 | return true; |
5254 | |
5255 | if (IsPackExpansion) |
5256 | NewType = getSema().Context.getPackExpansionType(NewType, |
5257 | NumExpansions); |
5258 | |
5259 | if (ParamInfos) |
5260 | PInfos.set(OutParamTypes.size(), ParamInfos[i]); |
5261 | OutParamTypes.push_back(NewType); |
5262 | if (PVars) |
5263 | PVars->push_back(nullptr); |
5264 | } |
5265 | |
5266 | #ifndef NDEBUG |
5267 | if (PVars) { |
5268 | for (unsigned i = 0, e = PVars->size(); i != e; ++i) |
5269 | if (ParmVarDecl *parm = (*PVars)[i]) |
5270 | getFunctionScopeIndex() == i", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 5270, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(parm->getFunctionScopeIndex() == i); |
5271 | } |
5272 | #endif |
5273 | |
5274 | return false; |
5275 | } |
5276 | |
5277 | template<typename Derived> |
5278 | QualType |
5279 | TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB, |
5280 | FunctionProtoTypeLoc TL) { |
5281 | SmallVector<QualType, 4> ExceptionStorage; |
5282 | TreeTransform *This = this; |
5283 | return getDerived().TransformFunctionProtoType( |
5284 | TLB, TL, nullptr, Qualifiers(), |
5285 | [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) { |
5286 | return This->TransformExceptionSpec(TL.getBeginLoc(), ESI, |
5287 | ExceptionStorage, Changed); |
5288 | }); |
5289 | } |
5290 | |
5291 | template<typename Derived> template<typename Fn> |
5292 | QualType TreeTransform<Derived>::TransformFunctionProtoType( |
5293 | TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, |
5294 | Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) { |
5295 | |
5296 | |
5297 | |
5298 | |
5299 | |
5300 | |
5301 | |
5302 | |
5303 | SmallVector<QualType, 4> ParamTypes; |
5304 | SmallVector<ParmVarDecl*, 4> ParamDecls; |
5305 | Sema::ExtParameterInfoBuilder ExtParamInfos; |
5306 | const FunctionProtoType *T = TL.getTypePtr(); |
5307 | |
5308 | QualType ResultType; |
5309 | |
5310 | if (T->hasTrailingReturn()) { |
5311 | if (getDerived().TransformFunctionTypeParams( |
5312 | TL.getBeginLoc(), TL.getParams(), |
5313 | TL.getTypePtr()->param_type_begin(), |
5314 | T->getExtParameterInfosOrNull(), |
5315 | ParamTypes, &ParamDecls, ExtParamInfos)) |
5316 | return QualType(); |
5317 | |
5318 | { |
5319 | |
5320 | |
5321 | |
5322 | |
5323 | |
5324 | |
5325 | Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, ThisTypeQuals); |
5326 | |
5327 | ResultType = getDerived().TransformType(TLB, TL.getReturnLoc()); |
5328 | if (ResultType.isNull()) |
5329 | return QualType(); |
5330 | } |
5331 | } |
5332 | else { |
5333 | ResultType = getDerived().TransformType(TLB, TL.getReturnLoc()); |
5334 | if (ResultType.isNull()) |
5335 | return QualType(); |
5336 | |
5337 | |
5338 | if (ResultType.getAddressSpace() != LangAS::Default) { |
5339 | SemaRef.Diag(TL.getReturnLoc().getBeginLoc(), |
5340 | diag::err_attribute_address_function_type); |
5341 | return QualType(); |
5342 | } |
5343 | |
5344 | if (getDerived().TransformFunctionTypeParams( |
5345 | TL.getBeginLoc(), TL.getParams(), |
5346 | TL.getTypePtr()->param_type_begin(), |
5347 | T->getExtParameterInfosOrNull(), |
5348 | ParamTypes, &ParamDecls, ExtParamInfos)) |
5349 | return QualType(); |
5350 | } |
5351 | |
5352 | FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo(); |
5353 | |
5354 | bool EPIChanged = false; |
5355 | if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged)) |
5356 | return QualType(); |
5357 | |
5358 | |
5359 | if (auto NewExtParamInfos = |
5360 | ExtParamInfos.getPointerOrNull(ParamTypes.size())) { |
5361 | if (!EPI.ExtParameterInfos || |
5362 | llvm::makeArrayRef(EPI.ExtParameterInfos, TL.getNumParams()) |
5363 | != llvm::makeArrayRef(NewExtParamInfos, ParamTypes.size())) { |
5364 | EPIChanged = true; |
5365 | } |
5366 | EPI.ExtParameterInfos = NewExtParamInfos; |
5367 | } else if (EPI.ExtParameterInfos) { |
5368 | EPIChanged = true; |
5369 | EPI.ExtParameterInfos = nullptr; |
5370 | } |
5371 | |
5372 | QualType Result = TL.getType(); |
5373 | if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() || |
5374 | T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) { |
5375 | Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI); |
5376 | if (Result.isNull()) |
5377 | return QualType(); |
5378 | } |
5379 | |
5380 | FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result); |
5381 | NewTL.setLocalRangeBegin(TL.getLocalRangeBegin()); |
5382 | NewTL.setLParenLoc(TL.getLParenLoc()); |
5383 | NewTL.setRParenLoc(TL.getRParenLoc()); |
5384 | NewTL.setExceptionSpecRange(TL.getExceptionSpecRange()); |
5385 | NewTL.setLocalRangeEnd(TL.getLocalRangeEnd()); |
5386 | for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i) |
5387 | NewTL.setParam(i, ParamDecls[i]); |
5388 | |
5389 | return Result; |
5390 | } |
5391 | |
5392 | template<typename Derived> |
5393 | bool TreeTransform<Derived>::TransformExceptionSpec( |
5394 | SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, |
5395 | SmallVectorImpl<QualType> &Exceptions, bool &Changed) { |
5396 | assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated); |
5397 | |
5398 | |
5399 | if (isComputedNoexcept(ESI.Type)) { |
5400 | EnterExpressionEvaluationContext Unevaluated( |
5401 | getSema(), Sema::ExpressionEvaluationContext::ConstantEvaluated); |
5402 | ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr); |
5403 | if (NoexceptExpr.isInvalid()) |
5404 | return true; |
5405 | |
5406 | ExceptionSpecificationType EST = ESI.Type; |
5407 | NoexceptExpr = |
5408 | getSema().ActOnNoexceptSpec(Loc, NoexceptExpr.get(), EST); |
5409 | if (NoexceptExpr.isInvalid()) |
5410 | return true; |
5411 | |
5412 | if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type) |
5413 | Changed = true; |
5414 | ESI.NoexceptExpr = NoexceptExpr.get(); |
5415 | ESI.Type = EST; |
5416 | } |
5417 | |
5418 | if (ESI.Type != EST_Dynamic) |
5419 | return false; |
5420 | |
5421 | |
5422 | for (QualType T : ESI.Exceptions) { |
5423 | if (const PackExpansionType *PackExpansion = |
5424 | T->getAs<PackExpansionType>()) { |
5425 | Changed = true; |
5426 | |
5427 | |
5428 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
5429 | SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(), |
5430 | Unexpanded); |
5431 | (0) . __assert_fail ("!Unexpanded.empty() && \"Pack expansion without parameter packs?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 5431, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); |
5432 | |
5433 | |
5434 | |
5435 | |
5436 | bool Expand = false; |
5437 | bool RetainExpansion = false; |
5438 | Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions(); |
5439 | |
5440 | |
5441 | if (getDerived().TryExpandParameterPacks( |
5442 | Loc, SourceRange(), Unexpanded, Expand, |
5443 | RetainExpansion, NumExpansions)) |
5444 | return true; |
5445 | |
5446 | if (!Expand) { |
5447 | |
5448 | |
5449 | |
5450 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
5451 | QualType U = getDerived().TransformType(PackExpansion->getPattern()); |
5452 | if (U.isNull()) |
5453 | return true; |
5454 | |
5455 | U = SemaRef.Context.getPackExpansionType(U, NumExpansions); |
5456 | Exceptions.push_back(U); |
5457 | continue; |
5458 | } |
5459 | |
5460 | |
5461 | |
5462 | for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) { |
5463 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx); |
5464 | |
5465 | QualType U = getDerived().TransformType(PackExpansion->getPattern()); |
5466 | if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc)) |
5467 | return true; |
5468 | |
5469 | Exceptions.push_back(U); |
5470 | } |
5471 | } else { |
5472 | QualType U = getDerived().TransformType(T); |
5473 | if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc)) |
5474 | return true; |
5475 | if (T != U) |
5476 | Changed = true; |
5477 | |
5478 | Exceptions.push_back(U); |
5479 | } |
5480 | } |
5481 | |
5482 | ESI.Exceptions = Exceptions; |
5483 | if (ESI.Exceptions.empty()) |
5484 | ESI.Type = EST_DynamicNone; |
5485 | return false; |
5486 | } |
5487 | |
5488 | template<typename Derived> |
5489 | QualType TreeTransform<Derived>::TransformFunctionNoProtoType( |
5490 | TypeLocBuilder &TLB, |
5491 | FunctionNoProtoTypeLoc TL) { |
5492 | const FunctionNoProtoType *T = TL.getTypePtr(); |
5493 | QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc()); |
5494 | if (ResultType.isNull()) |
5495 | return QualType(); |
5496 | |
5497 | QualType Result = TL.getType(); |
5498 | if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType()) |
5499 | Result = getDerived().RebuildFunctionNoProtoType(ResultType); |
5500 | |
5501 | FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result); |
5502 | NewTL.setLocalRangeBegin(TL.getLocalRangeBegin()); |
5503 | NewTL.setLParenLoc(TL.getLParenLoc()); |
5504 | NewTL.setRParenLoc(TL.getRParenLoc()); |
5505 | NewTL.setLocalRangeEnd(TL.getLocalRangeEnd()); |
5506 | |
5507 | return Result; |
5508 | } |
5509 | |
5510 | template<typename Derived> QualType |
5511 | TreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB, |
5512 | UnresolvedUsingTypeLoc TL) { |
5513 | const UnresolvedUsingType *T = TL.getTypePtr(); |
5514 | Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()); |
5515 | if (!D) |
5516 | return QualType(); |
5517 | |
5518 | QualType Result = TL.getType(); |
5519 | if (getDerived().AlwaysRebuild() || D != T->getDecl()) { |
5520 | Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D); |
5521 | if (Result.isNull()) |
5522 | return QualType(); |
5523 | } |
5524 | |
5525 | |
5526 | |
5527 | TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result); |
5528 | NewTL.setNameLoc(TL.getNameLoc()); |
5529 | |
5530 | return Result; |
5531 | } |
5532 | |
5533 | template<typename Derived> |
5534 | QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB, |
5535 | TypedefTypeLoc TL) { |
5536 | const TypedefType *T = TL.getTypePtr(); |
5537 | TypedefNameDecl *Typedef |
5538 | = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(), |
5539 | T->getDecl())); |
5540 | if (!Typedef) |
5541 | return QualType(); |
5542 | |
5543 | QualType Result = TL.getType(); |
5544 | if (getDerived().AlwaysRebuild() || |
5545 | Typedef != T->getDecl()) { |
5546 | Result = getDerived().RebuildTypedefType(Typedef); |
5547 | if (Result.isNull()) |
5548 | return QualType(); |
5549 | } |
5550 | |
5551 | TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result); |
5552 | NewTL.setNameLoc(TL.getNameLoc()); |
5553 | |
5554 | return Result; |
5555 | } |
5556 | |
5557 | template<typename Derived> |
5558 | QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB, |
5559 | TypeOfExprTypeLoc TL) { |
5560 | |
5561 | EnterExpressionEvaluationContext Unevaluated( |
5562 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, |
5563 | Sema::ReuseLambdaContextDecl); |
5564 | |
5565 | ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr()); |
5566 | if (E.isInvalid()) |
5567 | return QualType(); |
5568 | |
5569 | E = SemaRef.HandleExprEvaluationContextForTypeof(E.get()); |
5570 | if (E.isInvalid()) |
5571 | return QualType(); |
5572 | |
5573 | QualType Result = TL.getType(); |
5574 | if (getDerived().AlwaysRebuild() || |
5575 | E.get() != TL.getUnderlyingExpr()) { |
5576 | Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc()); |
5577 | if (Result.isNull()) |
5578 | return QualType(); |
5579 | } |
5580 | else E.get(); |
5581 | |
5582 | TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result); |
5583 | NewTL.setTypeofLoc(TL.getTypeofLoc()); |
5584 | NewTL.setLParenLoc(TL.getLParenLoc()); |
5585 | NewTL.setRParenLoc(TL.getRParenLoc()); |
5586 | |
5587 | return Result; |
5588 | } |
5589 | |
5590 | template<typename Derived> |
5591 | QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB, |
5592 | TypeOfTypeLoc TL) { |
5593 | TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo(); |
5594 | TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI); |
5595 | if (!New_Under_TI) |
5596 | return QualType(); |
5597 | |
5598 | QualType Result = TL.getType(); |
5599 | if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) { |
5600 | Result = getDerived().RebuildTypeOfType(New_Under_TI->getType()); |
5601 | if (Result.isNull()) |
5602 | return QualType(); |
5603 | } |
5604 | |
5605 | TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result); |
5606 | NewTL.setTypeofLoc(TL.getTypeofLoc()); |
5607 | NewTL.setLParenLoc(TL.getLParenLoc()); |
5608 | NewTL.setRParenLoc(TL.getRParenLoc()); |
5609 | NewTL.setUnderlyingTInfo(New_Under_TI); |
5610 | |
5611 | return Result; |
5612 | } |
5613 | |
5614 | template<typename Derived> |
5615 | QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB, |
5616 | DecltypeTypeLoc TL) { |
5617 | const DecltypeType *T = TL.getTypePtr(); |
5618 | |
5619 | |
5620 | EnterExpressionEvaluationContext Unevaluated( |
5621 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, nullptr, |
5622 | Sema::ExpressionEvaluationContextRecord::EK_Decltype); |
5623 | |
5624 | ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr()); |
5625 | if (E.isInvalid()) |
5626 | return QualType(); |
5627 | |
5628 | E = getSema().ActOnDecltypeExpression(E.get()); |
5629 | if (E.isInvalid()) |
5630 | return QualType(); |
5631 | |
5632 | QualType Result = TL.getType(); |
5633 | if (getDerived().AlwaysRebuild() || |
5634 | E.get() != T->getUnderlyingExpr()) { |
5635 | Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc()); |
5636 | if (Result.isNull()) |
5637 | return QualType(); |
5638 | } |
5639 | else E.get(); |
5640 | |
5641 | DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result); |
5642 | NewTL.setNameLoc(TL.getNameLoc()); |
5643 | |
5644 | return Result; |
5645 | } |
5646 | |
5647 | template<typename Derived> |
5648 | QualType TreeTransform<Derived>::TransformUnaryTransformType( |
5649 | TypeLocBuilder &TLB, |
5650 | UnaryTransformTypeLoc TL) { |
5651 | QualType Result = TL.getType(); |
5652 | if (Result->isDependentType()) { |
5653 | const UnaryTransformType *T = TL.getTypePtr(); |
5654 | QualType NewBase = |
5655 | getDerived().TransformType(TL.getUnderlyingTInfo())->getType(); |
5656 | Result = getDerived().RebuildUnaryTransformType(NewBase, |
5657 | T->getUTTKind(), |
5658 | TL.getKWLoc()); |
5659 | if (Result.isNull()) |
5660 | return QualType(); |
5661 | } |
5662 | |
5663 | UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result); |
5664 | NewTL.setKWLoc(TL.getKWLoc()); |
5665 | NewTL.setParensRange(TL.getParensRange()); |
5666 | NewTL.setUnderlyingTInfo(TL.getUnderlyingTInfo()); |
5667 | return Result; |
5668 | } |
5669 | |
5670 | template<typename Derived> |
5671 | QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB, |
5672 | AutoTypeLoc TL) { |
5673 | const AutoType *T = TL.getTypePtr(); |
5674 | QualType OldDeduced = T->getDeducedType(); |
5675 | QualType NewDeduced; |
5676 | if (!OldDeduced.isNull()) { |
5677 | NewDeduced = getDerived().TransformType(OldDeduced); |
5678 | if (NewDeduced.isNull()) |
5679 | return QualType(); |
5680 | } |
5681 | |
5682 | QualType Result = TL.getType(); |
5683 | if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced || |
5684 | T->isDependentType()) { |
5685 | Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword()); |
5686 | if (Result.isNull()) |
5687 | return QualType(); |
5688 | } |
5689 | |
5690 | AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result); |
5691 | NewTL.setNameLoc(TL.getNameLoc()); |
5692 | |
5693 | return Result; |
5694 | } |
5695 | |
5696 | template<typename Derived> |
5697 | QualType TreeTransform<Derived>::TransformDeducedTemplateSpecializationType( |
5698 | TypeLocBuilder &TLB, DeducedTemplateSpecializationTypeLoc TL) { |
5699 | const DeducedTemplateSpecializationType *T = TL.getTypePtr(); |
5700 | |
5701 | CXXScopeSpec SS; |
5702 | TemplateName TemplateName = getDerived().TransformTemplateName( |
5703 | SS, T->getTemplateName(), TL.getTemplateNameLoc()); |
5704 | if (TemplateName.isNull()) |
5705 | return QualType(); |
5706 | |
5707 | QualType OldDeduced = T->getDeducedType(); |
5708 | QualType NewDeduced; |
5709 | if (!OldDeduced.isNull()) { |
5710 | NewDeduced = getDerived().TransformType(OldDeduced); |
5711 | if (NewDeduced.isNull()) |
5712 | return QualType(); |
5713 | } |
5714 | |
5715 | QualType Result = getDerived().RebuildDeducedTemplateSpecializationType( |
5716 | TemplateName, NewDeduced); |
5717 | if (Result.isNull()) |
5718 | return QualType(); |
5719 | |
5720 | DeducedTemplateSpecializationTypeLoc NewTL = |
5721 | TLB.push<DeducedTemplateSpecializationTypeLoc>(Result); |
5722 | NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
5723 | |
5724 | return Result; |
5725 | } |
5726 | |
5727 | template<typename Derived> |
5728 | QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB, |
5729 | RecordTypeLoc TL) { |
5730 | const RecordType *T = TL.getTypePtr(); |
5731 | RecordDecl *Record |
5732 | = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(), |
5733 | T->getDecl())); |
5734 | if (!Record) |
5735 | return QualType(); |
5736 | |
5737 | QualType Result = TL.getType(); |
5738 | if (getDerived().AlwaysRebuild() || |
5739 | Record != T->getDecl()) { |
5740 | Result = getDerived().RebuildRecordType(Record); |
5741 | if (Result.isNull()) |
5742 | return QualType(); |
5743 | } |
5744 | |
5745 | RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result); |
5746 | NewTL.setNameLoc(TL.getNameLoc()); |
5747 | |
5748 | return Result; |
5749 | } |
5750 | |
5751 | template<typename Derived> |
5752 | QualType TreeTransform<Derived>::(TypeLocBuilder &TLB, |
5753 | EnumTypeLoc TL) { |
5754 | const EnumType *T = TL.getTypePtr(); |
5755 | EnumDecl *Enum |
5756 | = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(), |
5757 | T->getDecl())); |
5758 | if (!Enum) |
5759 | return QualType(); |
5760 | |
5761 | QualType Result = TL.getType(); |
5762 | if (getDerived().AlwaysRebuild() || |
5763 | Enum != T->getDecl()) { |
5764 | Result = getDerived().RebuildEnumType(Enum); |
5765 | if (Result.isNull()) |
5766 | return QualType(); |
5767 | } |
5768 | |
5769 | EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result); |
5770 | NewTL.setNameLoc(TL.getNameLoc()); |
5771 | |
5772 | return Result; |
5773 | } |
5774 | |
5775 | template<typename Derived> |
5776 | QualType TreeTransform<Derived>::TransformInjectedClassNameType( |
5777 | TypeLocBuilder &TLB, |
5778 | InjectedClassNameTypeLoc TL) { |
5779 | Decl *D = getDerived().TransformDecl(TL.getNameLoc(), |
5780 | TL.getTypePtr()->getDecl()); |
5781 | if (!D) return QualType(); |
5782 | |
5783 | QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D)); |
5784 | TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc()); |
5785 | return T; |
5786 | } |
5787 | |
5788 | template<typename Derived> |
5789 | QualType TreeTransform<Derived>::TransformTemplateTypeParmType( |
5790 | TypeLocBuilder &TLB, |
5791 | TemplateTypeParmTypeLoc TL) { |
5792 | return TransformTypeSpecType(TLB, TL); |
5793 | } |
5794 | |
5795 | template<typename Derived> |
5796 | QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType( |
5797 | TypeLocBuilder &TLB, |
5798 | SubstTemplateTypeParmTypeLoc TL) { |
5799 | const SubstTemplateTypeParmType *T = TL.getTypePtr(); |
5800 | |
5801 | |
5802 | |
5803 | |
5804 | TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName()); |
5805 | QualType Replacement = getDerived().TransformType(T->getReplacementType()); |
5806 | if (Replacement.isNull()) |
5807 | return QualType(); |
5808 | |
5809 | |
5810 | Replacement = SemaRef.Context.getCanonicalType(Replacement); |
5811 | QualType Result |
5812 | = SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(), |
5813 | Replacement); |
5814 | |
5815 | |
5816 | SubstTemplateTypeParmTypeLoc NewTL |
5817 | = TLB.push<SubstTemplateTypeParmTypeLoc>(Result); |
5818 | NewTL.setNameLoc(TL.getNameLoc()); |
5819 | return Result; |
5820 | |
5821 | } |
5822 | |
5823 | template<typename Derived> |
5824 | QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmPackType( |
5825 | TypeLocBuilder &TLB, |
5826 | SubstTemplateTypeParmPackTypeLoc TL) { |
5827 | return TransformTypeSpecType(TLB, TL); |
5828 | } |
5829 | |
5830 | template<typename Derived> |
5831 | QualType TreeTransform<Derived>::TransformTemplateSpecializationType( |
5832 | TypeLocBuilder &TLB, |
5833 | TemplateSpecializationTypeLoc TL) { |
5834 | const TemplateSpecializationType *T = TL.getTypePtr(); |
5835 | |
5836 | |
5837 | |
5838 | CXXScopeSpec SS; |
5839 | TemplateName Template |
5840 | = getDerived().TransformTemplateName(SS, T->getTemplateName(), |
5841 | TL.getTemplateNameLoc()); |
5842 | if (Template.isNull()) |
5843 | return QualType(); |
5844 | |
5845 | return getDerived().TransformTemplateSpecializationType(TLB, TL, Template); |
5846 | } |
5847 | |
5848 | template<typename Derived> |
5849 | QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB, |
5850 | AtomicTypeLoc TL) { |
5851 | QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc()); |
5852 | if (ValueType.isNull()) |
5853 | return QualType(); |
5854 | |
5855 | QualType Result = TL.getType(); |
5856 | if (getDerived().AlwaysRebuild() || |
5857 | ValueType != TL.getValueLoc().getType()) { |
5858 | Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc()); |
5859 | if (Result.isNull()) |
5860 | return QualType(); |
5861 | } |
5862 | |
5863 | AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result); |
5864 | NewTL.setKWLoc(TL.getKWLoc()); |
5865 | NewTL.setLParenLoc(TL.getLParenLoc()); |
5866 | NewTL.setRParenLoc(TL.getRParenLoc()); |
5867 | |
5868 | return Result; |
5869 | } |
5870 | |
5871 | template <typename Derived> |
5872 | QualType TreeTransform<Derived>::TransformPipeType(TypeLocBuilder &TLB, |
5873 | PipeTypeLoc TL) { |
5874 | QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc()); |
5875 | if (ValueType.isNull()) |
5876 | return QualType(); |
5877 | |
5878 | QualType Result = TL.getType(); |
5879 | if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) { |
5880 | const PipeType *PT = Result->getAs<PipeType>(); |
5881 | bool isReadPipe = PT->isReadOnly(); |
5882 | Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe); |
5883 | if (Result.isNull()) |
5884 | return QualType(); |
5885 | } |
5886 | |
5887 | PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result); |
5888 | NewTL.setKWLoc(TL.getKWLoc()); |
5889 | |
5890 | return Result; |
5891 | } |
5892 | |
5893 | |
5894 | |
5895 | |
5896 | |
5897 | |
5898 | template<typename ArgLocContainer> |
5899 | class TemplateArgumentLocContainerIterator { |
5900 | ArgLocContainer *Container; |
5901 | unsigned Index; |
5902 | |
5903 | public: |
5904 | typedef TemplateArgumentLoc value_type; |
5905 | typedef TemplateArgumentLoc reference; |
5906 | typedef int difference_type; |
5907 | typedef std::input_iterator_tag iterator_category; |
5908 | |
5909 | class pointer { |
5910 | TemplateArgumentLoc Arg; |
5911 | |
5912 | public: |
5913 | explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { } |
5914 | |
5915 | const TemplateArgumentLoc *operator->() const { |
5916 | return &Arg; |
5917 | } |
5918 | }; |
5919 | |
5920 | |
5921 | TemplateArgumentLocContainerIterator() {} |
5922 | |
5923 | TemplateArgumentLocContainerIterator(ArgLocContainer &Container, |
5924 | unsigned Index) |
5925 | : Container(&Container), Index(Index) { } |
5926 | |
5927 | TemplateArgumentLocContainerIterator &operator++() { |
5928 | ++Index; |
5929 | return *this; |
5930 | } |
5931 | |
5932 | TemplateArgumentLocContainerIterator operator++(int) { |
5933 | TemplateArgumentLocContainerIterator Old(*this); |
5934 | ++(*this); |
5935 | return Old; |
5936 | } |
5937 | |
5938 | TemplateArgumentLoc operator*() const { |
5939 | return Container->getArgLoc(Index); |
5940 | } |
5941 | |
5942 | pointer operator->() const { |
5943 | return pointer(Container->getArgLoc(Index)); |
5944 | } |
5945 | |
5946 | friend bool operator==(const TemplateArgumentLocContainerIterator &X, |
5947 | const TemplateArgumentLocContainerIterator &Y) { |
5948 | return X.Container == Y.Container && X.Index == Y.Index; |
5949 | } |
5950 | |
5951 | friend bool operator!=(const TemplateArgumentLocContainerIterator &X, |
5952 | const TemplateArgumentLocContainerIterator &Y) { |
5953 | return !(X == Y); |
5954 | } |
5955 | }; |
5956 | |
5957 | |
5958 | template <typename Derived> |
5959 | QualType TreeTransform<Derived>::TransformTemplateSpecializationType( |
5960 | TypeLocBuilder &TLB, |
5961 | TemplateSpecializationTypeLoc TL, |
5962 | TemplateName Template) { |
5963 | TemplateArgumentListInfo NewTemplateArgs; |
5964 | NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc()); |
5965 | NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc()); |
5966 | typedef TemplateArgumentLocContainerIterator<TemplateSpecializationTypeLoc> |
5967 | ArgIterator; |
5968 | if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0), |
5969 | ArgIterator(TL, TL.getNumArgs()), |
5970 | NewTemplateArgs)) |
5971 | return QualType(); |
5972 | |
5973 | |
5974 | |
5975 | QualType Result = |
5976 | getDerived().RebuildTemplateSpecializationType(Template, |
5977 | TL.getTemplateNameLoc(), |
5978 | NewTemplateArgs); |
5979 | |
5980 | if (!Result.isNull()) { |
5981 | |
5982 | |
5983 | |
5984 | |
5985 | if (isa<DependentTemplateSpecializationType>(Result)) { |
5986 | DependentTemplateSpecializationTypeLoc NewTL |
5987 | = TLB.push<DependentTemplateSpecializationTypeLoc>(Result); |
5988 | NewTL.setElaboratedKeywordLoc(SourceLocation()); |
5989 | NewTL.setQualifierLoc(NestedNameSpecifierLoc()); |
5990 | NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
5991 | NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
5992 | NewTL.setLAngleLoc(TL.getLAngleLoc()); |
5993 | NewTL.setRAngleLoc(TL.getRAngleLoc()); |
5994 | for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i) |
5995 | NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo()); |
5996 | return Result; |
5997 | } |
5998 | |
5999 | TemplateSpecializationTypeLoc NewTL |
6000 | = TLB.push<TemplateSpecializationTypeLoc>(Result); |
6001 | NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
6002 | NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
6003 | NewTL.setLAngleLoc(TL.getLAngleLoc()); |
6004 | NewTL.setRAngleLoc(TL.getRAngleLoc()); |
6005 | for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i) |
6006 | NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo()); |
6007 | } |
6008 | |
6009 | return Result; |
6010 | } |
6011 | |
6012 | template <typename Derived> |
6013 | QualType TreeTransform<Derived>::TransformDependentTemplateSpecializationType( |
6014 | TypeLocBuilder &TLB, |
6015 | DependentTemplateSpecializationTypeLoc TL, |
6016 | TemplateName Template, |
6017 | CXXScopeSpec &SS) { |
6018 | TemplateArgumentListInfo NewTemplateArgs; |
6019 | NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc()); |
6020 | NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc()); |
6021 | typedef TemplateArgumentLocContainerIterator< |
6022 | DependentTemplateSpecializationTypeLoc> ArgIterator; |
6023 | if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0), |
6024 | ArgIterator(TL, TL.getNumArgs()), |
6025 | NewTemplateArgs)) |
6026 | return QualType(); |
6027 | |
6028 | |
6029 | |
6030 | if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) { |
6031 | QualType Result |
6032 | = getSema().Context.getDependentTemplateSpecializationType( |
6033 | TL.getTypePtr()->getKeyword(), |
6034 | DTN->getQualifier(), |
6035 | DTN->getIdentifier(), |
6036 | NewTemplateArgs); |
6037 | |
6038 | DependentTemplateSpecializationTypeLoc NewTL |
6039 | = TLB.push<DependentTemplateSpecializationTypeLoc>(Result); |
6040 | NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); |
6041 | NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context)); |
6042 | NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
6043 | NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
6044 | NewTL.setLAngleLoc(TL.getLAngleLoc()); |
6045 | NewTL.setRAngleLoc(TL.getRAngleLoc()); |
6046 | for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i) |
6047 | NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo()); |
6048 | return Result; |
6049 | } |
6050 | |
6051 | QualType Result |
6052 | = getDerived().RebuildTemplateSpecializationType(Template, |
6053 | TL.getTemplateNameLoc(), |
6054 | NewTemplateArgs); |
6055 | |
6056 | if (!Result.isNull()) { |
6057 | |
6058 | TemplateSpecializationTypeLoc NewTL |
6059 | = TLB.push<TemplateSpecializationTypeLoc>(Result); |
6060 | NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
6061 | NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
6062 | NewTL.setLAngleLoc(TL.getLAngleLoc()); |
6063 | NewTL.setRAngleLoc(TL.getRAngleLoc()); |
6064 | for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i) |
6065 | NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo()); |
6066 | } |
6067 | |
6068 | return Result; |
6069 | } |
6070 | |
6071 | template<typename Derived> |
6072 | QualType |
6073 | TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB, |
6074 | ElaboratedTypeLoc TL) { |
6075 | const ElaboratedType *T = TL.getTypePtr(); |
6076 | |
6077 | NestedNameSpecifierLoc QualifierLoc; |
6078 | |
6079 | if (TL.getQualifierLoc()) { |
6080 | QualifierLoc |
6081 | = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc()); |
6082 | if (!QualifierLoc) |
6083 | return QualType(); |
6084 | } |
6085 | |
6086 | QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc()); |
6087 | if (NamedT.isNull()) |
6088 | return QualType(); |
6089 | |
6090 | |
6091 | |
6092 | |
6093 | |
6094 | if (T->getKeyword() != ETK_None && T->getKeyword() != ETK_Typename) { |
6095 | if (const TemplateSpecializationType *TST = |
6096 | NamedT->getAs<TemplateSpecializationType>()) { |
6097 | TemplateName Template = TST->getTemplateName(); |
6098 | if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>( |
6099 | Template.getAsTemplateDecl())) { |
6100 | SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(), |
6101 | diag::err_tag_reference_non_tag) |
6102 | << TAT << Sema::NTK_TypeAliasTemplate |
6103 | << ElaboratedType::getTagTypeKindForKeyword(T->getKeyword()); |
6104 | SemaRef.Diag(TAT->getLocation(), diag::note_declared_at); |
6105 | } |
6106 | } |
6107 | } |
6108 | |
6109 | QualType Result = TL.getType(); |
6110 | if (getDerived().AlwaysRebuild() || |
6111 | QualifierLoc != TL.getQualifierLoc() || |
6112 | NamedT != T->getNamedType()) { |
6113 | Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(), |
6114 | T->getKeyword(), |
6115 | QualifierLoc, NamedT); |
6116 | if (Result.isNull()) |
6117 | return QualType(); |
6118 | } |
6119 | |
6120 | ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result); |
6121 | NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); |
6122 | NewTL.setQualifierLoc(QualifierLoc); |
6123 | return Result; |
6124 | } |
6125 | |
6126 | template<typename Derived> |
6127 | QualType TreeTransform<Derived>::TransformAttributedType( |
6128 | TypeLocBuilder &TLB, |
6129 | AttributedTypeLoc TL) { |
6130 | const AttributedType *oldType = TL.getTypePtr(); |
6131 | QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc()); |
6132 | if (modifiedType.isNull()) |
6133 | return QualType(); |
6134 | |
6135 | |
6136 | const Attr *oldAttr = TL.getAttr(); |
6137 | const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr; |
6138 | if (oldAttr && !newAttr) |
6139 | return QualType(); |
6140 | |
6141 | QualType result = TL.getType(); |
6142 | |
6143 | |
6144 | if (getDerived().AlwaysRebuild() || |
6145 | modifiedType != oldType->getModifiedType()) { |
6146 | |
6147 | |
6148 | QualType equivalentType |
6149 | = getDerived().TransformType(oldType->getEquivalentType()); |
6150 | if (equivalentType.isNull()) |
6151 | return QualType(); |
6152 | |
6153 | |
6154 | |
6155 | if (auto nullability = oldType->getImmediateNullability()) { |
6156 | if (!modifiedType->canHaveNullability()) { |
6157 | SemaRef.Diag(TL.getAttr()->getLocation(), |
6158 | diag::err_nullability_nonpointer) |
6159 | << DiagNullabilityKind(*nullability, false) << modifiedType; |
6160 | return QualType(); |
6161 | } |
6162 | } |
6163 | |
6164 | result = SemaRef.Context.getAttributedType(TL.getAttrKind(), |
6165 | modifiedType, |
6166 | equivalentType); |
6167 | } |
6168 | |
6169 | AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result); |
6170 | newTL.setAttr(newAttr); |
6171 | return result; |
6172 | } |
6173 | |
6174 | template<typename Derived> |
6175 | QualType |
6176 | TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB, |
6177 | ParenTypeLoc TL) { |
6178 | QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc()); |
6179 | if (Inner.isNull()) |
6180 | return QualType(); |
6181 | |
6182 | QualType Result = TL.getType(); |
6183 | if (getDerived().AlwaysRebuild() || |
6184 | Inner != TL.getInnerLoc().getType()) { |
6185 | Result = getDerived().RebuildParenType(Inner); |
6186 | if (Result.isNull()) |
6187 | return QualType(); |
6188 | } |
6189 | |
6190 | ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result); |
6191 | NewTL.setLParenLoc(TL.getLParenLoc()); |
6192 | NewTL.setRParenLoc(TL.getRParenLoc()); |
6193 | return Result; |
6194 | } |
6195 | |
6196 | template<typename Derived> |
6197 | QualType TreeTransform<Derived>::TransformDependentNameType( |
6198 | TypeLocBuilder &TLB, DependentNameTypeLoc TL) { |
6199 | return TransformDependentNameType(TLB, TL, false); |
6200 | } |
6201 | |
6202 | template<typename Derived> |
6203 | QualType TreeTransform<Derived>::TransformDependentNameType( |
6204 | TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) { |
6205 | const DependentNameType *T = TL.getTypePtr(); |
6206 | |
6207 | NestedNameSpecifierLoc QualifierLoc |
6208 | = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc()); |
6209 | if (!QualifierLoc) |
6210 | return QualType(); |
6211 | |
6212 | QualType Result |
6213 | = getDerived().RebuildDependentNameType(T->getKeyword(), |
6214 | TL.getElaboratedKeywordLoc(), |
6215 | QualifierLoc, |
6216 | T->getIdentifier(), |
6217 | TL.getNameLoc(), |
6218 | DeducedTSTContext); |
6219 | if (Result.isNull()) |
6220 | return QualType(); |
6221 | |
6222 | if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) { |
6223 | QualType NamedT = ElabT->getNamedType(); |
6224 | TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc()); |
6225 | |
6226 | ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result); |
6227 | NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); |
6228 | NewTL.setQualifierLoc(QualifierLoc); |
6229 | } else { |
6230 | DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result); |
6231 | NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); |
6232 | NewTL.setQualifierLoc(QualifierLoc); |
6233 | NewTL.setNameLoc(TL.getNameLoc()); |
6234 | } |
6235 | return Result; |
6236 | } |
6237 | |
6238 | template<typename Derived> |
6239 | QualType TreeTransform<Derived>:: |
6240 | TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, |
6241 | DependentTemplateSpecializationTypeLoc TL) { |
6242 | NestedNameSpecifierLoc QualifierLoc; |
6243 | if (TL.getQualifierLoc()) { |
6244 | QualifierLoc |
6245 | = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc()); |
6246 | if (!QualifierLoc) |
6247 | return QualType(); |
6248 | } |
6249 | |
6250 | return getDerived() |
6251 | .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc); |
6252 | } |
6253 | |
6254 | template<typename Derived> |
6255 | QualType TreeTransform<Derived>:: |
6256 | TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, |
6257 | DependentTemplateSpecializationTypeLoc TL, |
6258 | NestedNameSpecifierLoc QualifierLoc) { |
6259 | const DependentTemplateSpecializationType *T = TL.getTypePtr(); |
6260 | |
6261 | TemplateArgumentListInfo NewTemplateArgs; |
6262 | NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc()); |
6263 | NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc()); |
6264 | |
6265 | typedef TemplateArgumentLocContainerIterator< |
6266 | DependentTemplateSpecializationTypeLoc> ArgIterator; |
6267 | if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0), |
6268 | ArgIterator(TL, TL.getNumArgs()), |
6269 | NewTemplateArgs)) |
6270 | return QualType(); |
6271 | |
6272 | QualType Result = getDerived().RebuildDependentTemplateSpecializationType( |
6273 | T->getKeyword(), QualifierLoc, TL.getTemplateKeywordLoc(), |
6274 | T->getIdentifier(), TL.getTemplateNameLoc(), NewTemplateArgs, |
6275 | false); |
6276 | if (Result.isNull()) |
6277 | return QualType(); |
6278 | |
6279 | if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) { |
6280 | QualType NamedT = ElabT->getNamedType(); |
6281 | |
6282 | |
6283 | TemplateSpecializationTypeLoc NamedTL |
6284 | = TLB.push<TemplateSpecializationTypeLoc>(NamedT); |
6285 | NamedTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
6286 | NamedTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
6287 | NamedTL.setLAngleLoc(TL.getLAngleLoc()); |
6288 | NamedTL.setRAngleLoc(TL.getRAngleLoc()); |
6289 | for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I) |
6290 | NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); |
6291 | |
6292 | |
6293 | ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result); |
6294 | NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); |
6295 | NewTL.setQualifierLoc(QualifierLoc); |
6296 | } else if (isa<DependentTemplateSpecializationType>(Result)) { |
6297 | DependentTemplateSpecializationTypeLoc SpecTL |
6298 | = TLB.push<DependentTemplateSpecializationTypeLoc>(Result); |
6299 | SpecTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc()); |
6300 | SpecTL.setQualifierLoc(QualifierLoc); |
6301 | SpecTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
6302 | SpecTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
6303 | SpecTL.setLAngleLoc(TL.getLAngleLoc()); |
6304 | SpecTL.setRAngleLoc(TL.getRAngleLoc()); |
6305 | for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I) |
6306 | SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); |
6307 | } else { |
6308 | TemplateSpecializationTypeLoc SpecTL |
6309 | = TLB.push<TemplateSpecializationTypeLoc>(Result); |
6310 | SpecTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc()); |
6311 | SpecTL.setTemplateNameLoc(TL.getTemplateNameLoc()); |
6312 | SpecTL.setLAngleLoc(TL.getLAngleLoc()); |
6313 | SpecTL.setRAngleLoc(TL.getRAngleLoc()); |
6314 | for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I) |
6315 | SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo()); |
6316 | } |
6317 | return Result; |
6318 | } |
6319 | |
6320 | template<typename Derived> |
6321 | QualType TreeTransform<Derived>::TransformPackExpansionType(TypeLocBuilder &TLB, |
6322 | PackExpansionTypeLoc TL) { |
6323 | QualType Pattern |
6324 | = getDerived().TransformType(TLB, TL.getPatternLoc()); |
6325 | if (Pattern.isNull()) |
6326 | return QualType(); |
6327 | |
6328 | QualType Result = TL.getType(); |
6329 | if (getDerived().AlwaysRebuild() || |
6330 | Pattern != TL.getPatternLoc().getType()) { |
6331 | Result = getDerived().RebuildPackExpansionType(Pattern, |
6332 | TL.getPatternLoc().getSourceRange(), |
6333 | TL.getEllipsisLoc(), |
6334 | TL.getTypePtr()->getNumExpansions()); |
6335 | if (Result.isNull()) |
6336 | return QualType(); |
6337 | } |
6338 | |
6339 | PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result); |
6340 | NewT.setEllipsisLoc(TL.getEllipsisLoc()); |
6341 | return Result; |
6342 | } |
6343 | |
6344 | template<typename Derived> |
6345 | QualType |
6346 | TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB, |
6347 | ObjCInterfaceTypeLoc TL) { |
6348 | |
6349 | TLB.pushFullCopy(TL); |
6350 | return TL.getType(); |
6351 | } |
6352 | |
6353 | template<typename Derived> |
6354 | QualType |
6355 | TreeTransform<Derived>::TransformObjCTypeParamType(TypeLocBuilder &TLB, |
6356 | ObjCTypeParamTypeLoc TL) { |
6357 | const ObjCTypeParamType *T = TL.getTypePtr(); |
6358 | ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>( |
6359 | getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl())); |
6360 | if (!OTP) |
6361 | return QualType(); |
6362 | |
6363 | QualType Result = TL.getType(); |
6364 | if (getDerived().AlwaysRebuild() || |
6365 | OTP != T->getDecl()) { |
6366 | Result = getDerived().RebuildObjCTypeParamType(OTP, |
6367 | TL.getProtocolLAngleLoc(), |
6368 | llvm::makeArrayRef(TL.getTypePtr()->qual_begin(), |
6369 | TL.getNumProtocols()), |
6370 | TL.getProtocolLocs(), |
6371 | TL.getProtocolRAngleLoc()); |
6372 | if (Result.isNull()) |
6373 | return QualType(); |
6374 | } |
6375 | |
6376 | ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result); |
6377 | if (TL.getNumProtocols()) { |
6378 | NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc()); |
6379 | for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i) |
6380 | NewTL.setProtocolLoc(i, TL.getProtocolLoc(i)); |
6381 | NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc()); |
6382 | } |
6383 | return Result; |
6384 | } |
6385 | |
6386 | template<typename Derived> |
6387 | QualType |
6388 | TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB, |
6389 | ObjCObjectTypeLoc TL) { |
6390 | |
6391 | QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc()); |
6392 | if (BaseType.isNull()) |
6393 | return QualType(); |
6394 | |
6395 | bool AnyChanged = BaseType != TL.getBaseLoc().getType(); |
6396 | |
6397 | |
6398 | SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos; |
6399 | for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) { |
6400 | TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i); |
6401 | TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc(); |
6402 | QualType TypeArg = TypeArgInfo->getType(); |
6403 | if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) { |
6404 | AnyChanged = true; |
6405 | |
6406 | |
6407 | const auto *PackExpansion = PackExpansionLoc.getType() |
6408 | ->castAs<PackExpansionType>(); |
6409 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
6410 | SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(), |
6411 | Unexpanded); |
6412 | (0) . __assert_fail ("!Unexpanded.empty() && \"Pack expansion without parameter packs?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 6412, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); |
6413 | |
6414 | |
6415 | |
6416 | TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc(); |
6417 | bool Expand = false; |
6418 | bool RetainExpansion = false; |
6419 | Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions(); |
6420 | if (getDerived().TryExpandParameterPacks( |
6421 | PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(), |
6422 | Unexpanded, Expand, RetainExpansion, NumExpansions)) |
6423 | return QualType(); |
6424 | |
6425 | if (!Expand) { |
6426 | |
6427 | |
6428 | |
6429 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
6430 | |
6431 | TypeLocBuilder TypeArgBuilder; |
6432 | TypeArgBuilder.reserve(PatternLoc.getFullDataSize()); |
6433 | QualType NewPatternType = getDerived().TransformType(TypeArgBuilder, |
6434 | PatternLoc); |
6435 | if (NewPatternType.isNull()) |
6436 | return QualType(); |
6437 | |
6438 | QualType NewExpansionType = SemaRef.Context.getPackExpansionType( |
6439 | NewPatternType, NumExpansions); |
6440 | auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType); |
6441 | NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc()); |
6442 | NewTypeArgInfos.push_back( |
6443 | TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType)); |
6444 | continue; |
6445 | } |
6446 | |
6447 | |
6448 | |
6449 | for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) { |
6450 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx); |
6451 | |
6452 | TypeLocBuilder TypeArgBuilder; |
6453 | TypeArgBuilder.reserve(PatternLoc.getFullDataSize()); |
6454 | |
6455 | QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder, |
6456 | PatternLoc); |
6457 | if (NewTypeArg.isNull()) |
6458 | return QualType(); |
6459 | |
6460 | NewTypeArgInfos.push_back( |
6461 | TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg)); |
6462 | } |
6463 | |
6464 | continue; |
6465 | } |
6466 | |
6467 | TypeLocBuilder TypeArgBuilder; |
6468 | TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize()); |
6469 | QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder, TypeArgLoc); |
6470 | if (NewTypeArg.isNull()) |
6471 | return QualType(); |
6472 | |
6473 | |
6474 | if (NewTypeArg == TypeArg) { |
6475 | NewTypeArgInfos.push_back(TypeArgInfo); |
6476 | continue; |
6477 | } |
6478 | |
6479 | NewTypeArgInfos.push_back( |
6480 | TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg)); |
6481 | AnyChanged = true; |
6482 | } |
6483 | |
6484 | QualType Result = TL.getType(); |
6485 | if (getDerived().AlwaysRebuild() || AnyChanged) { |
6486 | |
6487 | Result = getDerived().RebuildObjCObjectType( |
6488 | BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos, |
6489 | TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(), |
6490 | llvm::makeArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()), |
6491 | TL.getProtocolLocs(), TL.getProtocolRAngleLoc()); |
6492 | |
6493 | if (Result.isNull()) |
6494 | return QualType(); |
6495 | } |
6496 | |
6497 | ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result); |
6498 | NewT.setHasBaseTypeAsWritten(true); |
6499 | NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc()); |
6500 | for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) |
6501 | NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]); |
6502 | NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc()); |
6503 | NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc()); |
6504 | for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i) |
6505 | NewT.setProtocolLoc(i, TL.getProtocolLoc(i)); |
6506 | NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc()); |
6507 | return Result; |
6508 | } |
6509 | |
6510 | template<typename Derived> |
6511 | QualType |
6512 | TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB, |
6513 | ObjCObjectPointerTypeLoc TL) { |
6514 | QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc()); |
6515 | if (PointeeType.isNull()) |
6516 | return QualType(); |
6517 | |
6518 | QualType Result = TL.getType(); |
6519 | if (getDerived().AlwaysRebuild() || |
6520 | PointeeType != TL.getPointeeLoc().getType()) { |
6521 | Result = getDerived().RebuildObjCObjectPointerType(PointeeType, |
6522 | TL.getStarLoc()); |
6523 | if (Result.isNull()) |
6524 | return QualType(); |
6525 | } |
6526 | |
6527 | ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result); |
6528 | NewT.setStarLoc(TL.getStarLoc()); |
6529 | return Result; |
6530 | } |
6531 | |
6532 | |
6533 | |
6534 | |
6535 | template<typename Derived> |
6536 | StmtResult |
6537 | TreeTransform<Derived>::TransformNullStmt(NullStmt *S) { |
6538 | return S; |
6539 | } |
6540 | |
6541 | template<typename Derived> |
6542 | StmtResult |
6543 | TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S) { |
6544 | return getDerived().TransformCompoundStmt(S, false); |
6545 | } |
6546 | |
6547 | template<typename Derived> |
6548 | StmtResult |
6549 | TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S, |
6550 | bool IsStmtExpr) { |
6551 | Sema::CompoundScopeRAII CompoundScope(getSema()); |
6552 | |
6553 | bool SubStmtInvalid = false; |
6554 | bool SubStmtChanged = false; |
6555 | SmallVector<Stmt*, 8> Statements; |
6556 | for (auto *B : S->body()) { |
6557 | StmtResult Result = getDerived().TransformStmt( |
6558 | B, |
6559 | IsStmtExpr && B == S->body_back() ? SDK_StmtExprResult : SDK_Discarded); |
6560 | |
6561 | if (Result.isInvalid()) { |
6562 | |
6563 | |
6564 | if (isa<DeclStmt>(B)) |
6565 | return StmtError(); |
6566 | |
6567 | |
6568 | SubStmtInvalid = true; |
6569 | continue; |
6570 | } |
6571 | |
6572 | SubStmtChanged = SubStmtChanged || Result.get() != B; |
6573 | Statements.push_back(Result.getAs<Stmt>()); |
6574 | } |
6575 | |
6576 | if (SubStmtInvalid) |
6577 | return StmtError(); |
6578 | |
6579 | if (!getDerived().AlwaysRebuild() && |
6580 | !SubStmtChanged) |
6581 | return S; |
6582 | |
6583 | return getDerived().RebuildCompoundStmt(S->getLBracLoc(), |
6584 | Statements, |
6585 | S->getRBracLoc(), |
6586 | IsStmtExpr); |
6587 | } |
6588 | |
6589 | template<typename Derived> |
6590 | StmtResult |
6591 | TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) { |
6592 | ExprResult LHS, RHS; |
6593 | { |
6594 | EnterExpressionEvaluationContext Unevaluated( |
6595 | SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); |
6596 | |
6597 | |
6598 | LHS = getDerived().TransformExpr(S->getLHS()); |
6599 | LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS); |
6600 | if (LHS.isInvalid()) |
6601 | return StmtError(); |
6602 | |
6603 | |
6604 | RHS = getDerived().TransformExpr(S->getRHS()); |
6605 | RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS); |
6606 | if (RHS.isInvalid()) |
6607 | return StmtError(); |
6608 | } |
6609 | |
6610 | |
6611 | |
6612 | |
6613 | StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(), |
6614 | LHS.get(), |
6615 | S->getEllipsisLoc(), |
6616 | RHS.get(), |
6617 | S->getColonLoc()); |
6618 | if (Case.isInvalid()) |
6619 | return StmtError(); |
6620 | |
6621 | |
6622 | StmtResult SubStmt = |
6623 | getDerived().TransformStmt(S->getSubStmt()); |
6624 | if (SubStmt.isInvalid()) |
6625 | return StmtError(); |
6626 | |
6627 | |
6628 | return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get()); |
6629 | } |
6630 | |
6631 | template <typename Derived> |
6632 | StmtResult TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) { |
6633 | |
6634 | StmtResult SubStmt = |
6635 | getDerived().TransformStmt(S->getSubStmt()); |
6636 | if (SubStmt.isInvalid()) |
6637 | return StmtError(); |
6638 | |
6639 | |
6640 | return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(), |
6641 | SubStmt.get()); |
6642 | } |
6643 | |
6644 | template<typename Derived> |
6645 | StmtResult |
6646 | TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S, StmtDiscardKind SDK) { |
6647 | StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK); |
6648 | if (SubStmt.isInvalid()) |
6649 | return StmtError(); |
6650 | |
6651 | Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(), |
6652 | S->getDecl()); |
6653 | if (!LD) |
6654 | return StmtError(); |
6655 | |
6656 | |
6657 | |
6658 | |
6659 | if (LD == S->getDecl()) |
6660 | S->getDecl()->setStmt(nullptr); |
6661 | |
6662 | |
6663 | return getDerived().RebuildLabelStmt(S->getIdentLoc(), |
6664 | cast<LabelDecl>(LD), SourceLocation(), |
6665 | SubStmt.get()); |
6666 | } |
6667 | |
6668 | template <typename Derived> |
6669 | const Attr *TreeTransform<Derived>::TransformAttr(const Attr *R) { |
6670 | if (!R) |
6671 | return R; |
6672 | |
6673 | switch (R->getKind()) { |
6674 | |
6675 | #define ATTR(X) |
6676 | #define PRAGMA_SPELLING_ATTR(X) \ |
6677 | case attr::X: \ |
6678 | return getDerived().Transform##X##Attr(cast<X##Attr>(R)); |
6679 | #include "clang/Basic/AttrList.inc" |
6680 | default: |
6681 | return R; |
6682 | } |
6683 | } |
6684 | |
6685 | template <typename Derived> |
6686 | StmtResult |
6687 | TreeTransform<Derived>::TransformAttributedStmt(AttributedStmt *S, |
6688 | StmtDiscardKind SDK) { |
6689 | bool AttrsChanged = false; |
6690 | SmallVector<const Attr *, 1> Attrs; |
6691 | |
6692 | |
6693 | for (const auto *I : S->getAttrs()) { |
6694 | const Attr *R = getDerived().TransformAttr(I); |
6695 | AttrsChanged |= (I != R); |
6696 | Attrs.push_back(R); |
6697 | } |
6698 | |
6699 | StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK); |
6700 | if (SubStmt.isInvalid()) |
6701 | return StmtError(); |
6702 | |
6703 | if (SubStmt.get() == S->getSubStmt() && !AttrsChanged) |
6704 | return S; |
6705 | |
6706 | return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs, |
6707 | SubStmt.get()); |
6708 | } |
6709 | |
6710 | template<typename Derived> |
6711 | StmtResult |
6712 | TreeTransform<Derived>::TransformIfStmt(IfStmt *S) { |
6713 | |
6714 | StmtResult Init = getDerived().TransformStmt(S->getInit()); |
6715 | if (Init.isInvalid()) |
6716 | return StmtError(); |
6717 | |
6718 | |
6719 | Sema::ConditionResult Cond = getDerived().TransformCondition( |
6720 | S->getIfLoc(), S->getConditionVariable(), S->getCond(), |
6721 | S->isConstexpr() ? Sema::ConditionKind::ConstexprIf |
6722 | : Sema::ConditionKind::Boolean); |
6723 | if (Cond.isInvalid()) |
6724 | return StmtError(); |
6725 | |
6726 | |
6727 | llvm::Optional<bool> ConstexprConditionValue; |
6728 | if (S->isConstexpr()) |
6729 | ConstexprConditionValue = Cond.getKnownValue(); |
6730 | |
6731 | |
6732 | StmtResult Then; |
6733 | if (!ConstexprConditionValue || *ConstexprConditionValue) { |
6734 | Then = getDerived().TransformStmt(S->getThen()); |
6735 | if (Then.isInvalid()) |
6736 | return StmtError(); |
6737 | } else { |
6738 | Then = new (getSema().Context) NullStmt(S->getThen()->getBeginLoc()); |
6739 | } |
6740 | |
6741 | |
6742 | StmtResult Else; |
6743 | if (!ConstexprConditionValue || !*ConstexprConditionValue) { |
6744 | Else = getDerived().TransformStmt(S->getElse()); |
6745 | if (Else.isInvalid()) |
6746 | return StmtError(); |
6747 | } |
6748 | |
6749 | if (!getDerived().AlwaysRebuild() && |
6750 | Init.get() == S->getInit() && |
6751 | Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) && |
6752 | Then.get() == S->getThen() && |
6753 | Else.get() == S->getElse()) |
6754 | return S; |
6755 | |
6756 | return getDerived().RebuildIfStmt(S->getIfLoc(), S->isConstexpr(), Cond, |
6757 | Init.get(), Then.get(), S->getElseLoc(), |
6758 | Else.get()); |
6759 | } |
6760 | |
6761 | template<typename Derived> |
6762 | StmtResult |
6763 | TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) { |
6764 | |
6765 | StmtResult Init = getDerived().TransformStmt(S->getInit()); |
6766 | if (Init.isInvalid()) |
6767 | return StmtError(); |
6768 | |
6769 | |
6770 | Sema::ConditionResult Cond = getDerived().TransformCondition( |
6771 | S->getSwitchLoc(), S->getConditionVariable(), S->getCond(), |
6772 | Sema::ConditionKind::Switch); |
6773 | if (Cond.isInvalid()) |
6774 | return StmtError(); |
6775 | |
6776 | |
6777 | StmtResult Switch |
6778 | = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond); |
6779 | if (Switch.isInvalid()) |
6780 | return StmtError(); |
6781 | |
6782 | |
6783 | StmtResult Body = getDerived().TransformStmt(S->getBody()); |
6784 | if (Body.isInvalid()) |
6785 | return StmtError(); |
6786 | |
6787 | |
6788 | return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(), |
6789 | Body.get()); |
6790 | } |
6791 | |
6792 | template<typename Derived> |
6793 | StmtResult |
6794 | TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) { |
6795 | |
6796 | Sema::ConditionResult Cond = getDerived().TransformCondition( |
6797 | S->getWhileLoc(), S->getConditionVariable(), S->getCond(), |
6798 | Sema::ConditionKind::Boolean); |
6799 | if (Cond.isInvalid()) |
6800 | return StmtError(); |
6801 | |
6802 | |
6803 | StmtResult Body = getDerived().TransformStmt(S->getBody()); |
6804 | if (Body.isInvalid()) |
6805 | return StmtError(); |
6806 | |
6807 | if (!getDerived().AlwaysRebuild() && |
6808 | Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) && |
6809 | Body.get() == S->getBody()) |
6810 | return Owned(S); |
6811 | |
6812 | return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get()); |
6813 | } |
6814 | |
6815 | template<typename Derived> |
6816 | StmtResult |
6817 | TreeTransform<Derived>::TransformDoStmt(DoStmt *S) { |
6818 | |
6819 | StmtResult Body = getDerived().TransformStmt(S->getBody()); |
6820 | if (Body.isInvalid()) |
6821 | return StmtError(); |
6822 | |
6823 | |
6824 | ExprResult Cond = getDerived().TransformExpr(S->getCond()); |
6825 | if (Cond.isInvalid()) |
6826 | return StmtError(); |
6827 | |
6828 | if (!getDerived().AlwaysRebuild() && |
6829 | Cond.get() == S->getCond() && |
6830 | Body.get() == S->getBody()) |
6831 | return S; |
6832 | |
6833 | return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(), |
6834 | ->getWhileLoc(), Cond.get(), |
6835 | S->getRParenLoc()); |
6836 | } |
6837 | |
6838 | template<typename Derived> |
6839 | StmtResult |
6840 | TreeTransform<Derived>::TransformForStmt(ForStmt *S) { |
6841 | if (getSema().getLangOpts().OpenMP) |
6842 | getSema().startOpenMPLoop(); |
6843 | |
6844 | |
6845 | StmtResult Init = getDerived().TransformStmt(S->getInit()); |
6846 | if (Init.isInvalid()) |
6847 | return StmtError(); |
6848 | |
6849 | |
6850 | |
6851 | if (getSema().getLangOpts().OpenMP && Init.isUsable()) |
6852 | getSema().ActOnOpenMPLoopInitialization(S->getForLoc(), Init.get()); |
6853 | |
6854 | |
6855 | Sema::ConditionResult Cond = getDerived().TransformCondition( |
6856 | S->getForLoc(), S->getConditionVariable(), S->getCond(), |
6857 | Sema::ConditionKind::Boolean); |
6858 | if (Cond.isInvalid()) |
6859 | return StmtError(); |
6860 | |
6861 | |
6862 | ExprResult Inc = getDerived().TransformExpr(S->getInc()); |
6863 | if (Inc.isInvalid()) |
6864 | return StmtError(); |
6865 | |
6866 | Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get())); |
6867 | if (S->getInc() && !FullInc.get()) |
6868 | return StmtError(); |
6869 | |
6870 | |
6871 | StmtResult Body = getDerived().TransformStmt(S->getBody()); |
6872 | if (Body.isInvalid()) |
6873 | return StmtError(); |
6874 | |
6875 | if (!getDerived().AlwaysRebuild() && |
6876 | Init.get() == S->getInit() && |
6877 | Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) && |
6878 | Inc.get() == S->getInc() && |
6879 | Body.get() == S->getBody()) |
6880 | return S; |
6881 | |
6882 | return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(), |
6883 | Init.get(), Cond, FullInc, |
6884 | S->getRParenLoc(), Body.get()); |
6885 | } |
6886 | |
6887 | template<typename Derived> |
6888 | StmtResult |
6889 | TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) { |
6890 | Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(), |
6891 | S->getLabel()); |
6892 | if (!LD) |
6893 | return StmtError(); |
6894 | |
6895 | |
6896 | return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(), |
6897 | cast<LabelDecl>(LD)); |
6898 | } |
6899 | |
6900 | template<typename Derived> |
6901 | StmtResult |
6902 | TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) { |
6903 | ExprResult Target = getDerived().TransformExpr(S->getTarget()); |
6904 | if (Target.isInvalid()) |
6905 | return StmtError(); |
6906 | Target = SemaRef.MaybeCreateExprWithCleanups(Target.get()); |
6907 | |
6908 | if (!getDerived().AlwaysRebuild() && |
6909 | Target.get() == S->getTarget()) |
6910 | return S; |
6911 | |
6912 | return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(), |
6913 | Target.get()); |
6914 | } |
6915 | |
6916 | template<typename Derived> |
6917 | StmtResult |
6918 | TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) { |
6919 | return S; |
6920 | } |
6921 | |
6922 | template<typename Derived> |
6923 | StmtResult |
6924 | TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) { |
6925 | return S; |
6926 | } |
6927 | |
6928 | template<typename Derived> |
6929 | StmtResult |
6930 | TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) { |
6931 | ExprResult Result = getDerived().TransformInitializer(S->getRetValue(), |
6932 | ); |
6933 | if (Result.isInvalid()) |
6934 | return StmtError(); |
6935 | |
6936 | |
6937 | |
6938 | return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get()); |
6939 | } |
6940 | |
6941 | template<typename Derived> |
6942 | StmtResult |
6943 | TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) { |
6944 | bool DeclChanged = false; |
6945 | SmallVector<Decl *, 4> Decls; |
6946 | for (auto *D : S->decls()) { |
6947 | Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D); |
6948 | if (!Transformed) |
6949 | return StmtError(); |
6950 | |
6951 | if (Transformed != D) |
6952 | DeclChanged = true; |
6953 | |
6954 | Decls.push_back(Transformed); |
6955 | } |
6956 | |
6957 | if (!getDerived().AlwaysRebuild() && !DeclChanged) |
6958 | return S; |
6959 | |
6960 | return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc()); |
6961 | } |
6962 | |
6963 | template<typename Derived> |
6964 | StmtResult |
6965 | TreeTransform<Derived>::TransformGCCAsmStmt(GCCAsmStmt *S) { |
6966 | |
6967 | SmallVector<Expr*, 8> Constraints; |
6968 | SmallVector<Expr*, 8> Exprs; |
6969 | SmallVector<IdentifierInfo *, 4> Names; |
6970 | |
6971 | ExprResult AsmString; |
6972 | SmallVector<Expr*, 8> Clobbers; |
6973 | |
6974 | bool ExprsChanged = false; |
6975 | |
6976 | |
6977 | for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) { |
6978 | Names.push_back(S->getOutputIdentifier(I)); |
6979 | |
6980 | |
6981 | Constraints.push_back(S->getOutputConstraintLiteral(I)); |
6982 | |
6983 | |
6984 | Expr *OutputExpr = S->getOutputExpr(I); |
6985 | ExprResult Result = getDerived().TransformExpr(OutputExpr); |
6986 | if (Result.isInvalid()) |
6987 | return StmtError(); |
6988 | |
6989 | ExprsChanged |= Result.get() != OutputExpr; |
6990 | |
6991 | Exprs.push_back(Result.get()); |
6992 | } |
6993 | |
6994 | |
6995 | for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) { |
6996 | Names.push_back(S->getInputIdentifier(I)); |
6997 | |
6998 | |
6999 | Constraints.push_back(S->getInputConstraintLiteral(I)); |
7000 | |
7001 | |
7002 | Expr *InputExpr = S->getInputExpr(I); |
7003 | ExprResult Result = getDerived().TransformExpr(InputExpr); |
7004 | if (Result.isInvalid()) |
7005 | return StmtError(); |
7006 | |
7007 | ExprsChanged |= Result.get() != InputExpr; |
7008 | |
7009 | Exprs.push_back(Result.get()); |
7010 | } |
7011 | |
7012 | if (!getDerived().AlwaysRebuild() && !ExprsChanged) |
7013 | return S; |
7014 | |
7015 | |
7016 | for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) |
7017 | Clobbers.push_back(S->getClobberStringLiteral(I)); |
7018 | |
7019 | |
7020 | AsmString = S->getAsmString(); |
7021 | return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(), |
7022 | S->isVolatile(), S->getNumOutputs(), |
7023 | S->getNumInputs(), Names.data(), |
7024 | Constraints, Exprs, AsmString.get(), |
7025 | Clobbers, S->getRParenLoc()); |
7026 | } |
7027 | |
7028 | template<typename Derived> |
7029 | StmtResult |
7030 | TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) { |
7031 | ArrayRef<Token> AsmToks = |
7032 | llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks()); |
7033 | |
7034 | bool HadError = false, HadChange = false; |
7035 | |
7036 | ArrayRef<Expr*> SrcExprs = S->getAllExprs(); |
7037 | SmallVector<Expr*, 8> TransformedExprs; |
7038 | TransformedExprs.reserve(SrcExprs.size()); |
7039 | for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) { |
7040 | ExprResult Result = getDerived().TransformExpr(SrcExprs[i]); |
7041 | if (!Result.isUsable()) { |
7042 | HadError = true; |
7043 | } else { |
7044 | HadChange |= (Result.get() != SrcExprs[i]); |
7045 | TransformedExprs.push_back(Result.get()); |
7046 | } |
7047 | } |
7048 | |
7049 | if (HadError) return StmtError(); |
7050 | if (!HadChange && !getDerived().AlwaysRebuild()) |
7051 | return Owned(S); |
7052 | |
7053 | return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(), |
7054 | AsmToks, S->getAsmString(), |
7055 | S->getNumOutputs(), S->getNumInputs(), |
7056 | S->getAllConstraints(), S->getClobbers(), |
7057 | TransformedExprs, S->getEndLoc()); |
7058 | } |
7059 | |
7060 | |
7061 | |
7062 | template<typename Derived> |
7063 | StmtResult |
7064 | TreeTransform<Derived>::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) { |
7065 | auto *ScopeInfo = SemaRef.getCurFunction(); |
7066 | auto *FD = cast<FunctionDecl>(SemaRef.CurContext); |
7067 | (0) . __assert_fail ("FD && ScopeInfo && !ScopeInfo->CoroutinePromise && ScopeInfo->NeedsCoroutineSuspends && ScopeInfo->CoroutineSuspends.first == nullptr && ScopeInfo->CoroutineSuspends.second == nullptr && \"expected clean scope info\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7071, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise && |
7068 | (0) . __assert_fail ("FD && ScopeInfo && !ScopeInfo->CoroutinePromise && ScopeInfo->NeedsCoroutineSuspends && ScopeInfo->CoroutineSuspends.first == nullptr && ScopeInfo->CoroutineSuspends.second == nullptr && \"expected clean scope info\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7071, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> ScopeInfo->NeedsCoroutineSuspends && |
7069 | (0) . __assert_fail ("FD && ScopeInfo && !ScopeInfo->CoroutinePromise && ScopeInfo->NeedsCoroutineSuspends && ScopeInfo->CoroutineSuspends.first == nullptr && ScopeInfo->CoroutineSuspends.second == nullptr && \"expected clean scope info\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7071, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> ScopeInfo->CoroutineSuspends.first == nullptr && |
7070 | (0) . __assert_fail ("FD && ScopeInfo && !ScopeInfo->CoroutinePromise && ScopeInfo->NeedsCoroutineSuspends && ScopeInfo->CoroutineSuspends.first == nullptr && ScopeInfo->CoroutineSuspends.second == nullptr && \"expected clean scope info\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7071, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> ScopeInfo->CoroutineSuspends.second == nullptr && |
7071 | (0) . __assert_fail ("FD && ScopeInfo && !ScopeInfo->CoroutinePromise && ScopeInfo->NeedsCoroutineSuspends && ScopeInfo->CoroutineSuspends.first == nullptr && ScopeInfo->CoroutineSuspends.second == nullptr && \"expected clean scope info\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7071, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "expected clean scope info"); |
7072 | |
7073 | |
7074 | |
7075 | ScopeInfo->setNeedsCoroutineSuspends(false); |
7076 | |
7077 | |
7078 | |
7079 | if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation())) |
7080 | return StmtError(); |
7081 | auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation()); |
7082 | if (!Promise) |
7083 | return StmtError(); |
7084 | getDerived().transformedLocalDecl(S->getPromiseDecl(), Promise); |
7085 | ScopeInfo->CoroutinePromise = Promise; |
7086 | |
7087 | |
7088 | |
7089 | StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt()); |
7090 | if (InitSuspend.isInvalid()) |
7091 | return StmtError(); |
7092 | StmtResult FinalSuspend = |
7093 | getDerived().TransformStmt(S->getFinalSuspendStmt()); |
7094 | if (FinalSuspend.isInvalid()) |
7095 | return StmtError(); |
7096 | ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get()); |
7097 | (InitSuspend.get()) && isa(FinalSuspend.get())", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7097, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get())); |
7098 | |
7099 | StmtResult BodyRes = getDerived().TransformStmt(S->getBody()); |
7100 | if (BodyRes.isInvalid()) |
7101 | return StmtError(); |
7102 | |
7103 | CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get()); |
7104 | if (Builder.isInvalid()) |
7105 | return StmtError(); |
7106 | |
7107 | Expr *ReturnObject = S->getReturnValueInit(); |
7108 | (0) . __assert_fail ("ReturnObject && \"the return object is expected to be valid\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7108, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(ReturnObject && "the return object is expected to be valid"); |
7109 | ExprResult Res = getDerived().TransformInitializer(ReturnObject, |
7110 | false); |
7111 | if (Res.isInvalid()) |
7112 | return StmtError(); |
7113 | Builder.ReturnValue = Res.get(); |
7114 | |
7115 | if (S->hasDependentPromiseType()) { |
7116 | (0) . __assert_fail ("!Promise->getType()->isDependentType() && \"the promise type must no longer be dependent\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7117, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Promise->getType()->isDependentType() && |
7117 | (0) . __assert_fail ("!Promise->getType()->isDependentType() && \"the promise type must no longer be dependent\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7117, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "the promise type must no longer be dependent"); |
7118 | (0) . __assert_fail ("!S->getFallthroughHandler() && !S->getExceptionHandler() && !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && \"these nodes should not have been built yet\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7120, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!S->getFallthroughHandler() && !S->getExceptionHandler() && |
7119 | (0) . __assert_fail ("!S->getFallthroughHandler() && !S->getExceptionHandler() && !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && \"these nodes should not have been built yet\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7120, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && |
7120 | (0) . __assert_fail ("!S->getFallthroughHandler() && !S->getExceptionHandler() && !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() && \"these nodes should not have been built yet\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7120, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "these nodes should not have been built yet"); |
7121 | if (!Builder.buildDependentStatements()) |
7122 | return StmtError(); |
7123 | } else { |
7124 | if (auto *OnFallthrough = S->getFallthroughHandler()) { |
7125 | StmtResult Res = getDerived().TransformStmt(OnFallthrough); |
7126 | if (Res.isInvalid()) |
7127 | return StmtError(); |
7128 | Builder.OnFallthrough = Res.get(); |
7129 | } |
7130 | |
7131 | if (auto *OnException = S->getExceptionHandler()) { |
7132 | StmtResult Res = getDerived().TransformStmt(OnException); |
7133 | if (Res.isInvalid()) |
7134 | return StmtError(); |
7135 | Builder.OnException = Res.get(); |
7136 | } |
7137 | |
7138 | if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) { |
7139 | StmtResult Res = getDerived().TransformStmt(OnAllocFailure); |
7140 | if (Res.isInvalid()) |
7141 | return StmtError(); |
7142 | Builder.ReturnStmtOnAllocFailure = Res.get(); |
7143 | } |
7144 | |
7145 | |
7146 | (0) . __assert_fail ("S->getAllocate() && S->getDeallocate() && \"allocation and deallocation calls must already be built\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7147, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(S->getAllocate() && S->getDeallocate() && |
7147 | (0) . __assert_fail ("S->getAllocate() && S->getDeallocate() && \"allocation and deallocation calls must already be built\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7147, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "allocation and deallocation calls must already be built"); |
7148 | ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate()); |
7149 | if (AllocRes.isInvalid()) |
7150 | return StmtError(); |
7151 | Builder.Allocate = AllocRes.get(); |
7152 | |
7153 | ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate()); |
7154 | if (DeallocRes.isInvalid()) |
7155 | return StmtError(); |
7156 | Builder.Deallocate = DeallocRes.get(); |
7157 | |
7158 | (0) . __assert_fail ("S->getResultDecl() && \"ResultDecl must already be built\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 7158, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(S->getResultDecl() && "ResultDecl must already be built"); |
7159 | StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl()); |
7160 | if (ResultDecl.isInvalid()) |
7161 | return StmtError(); |
7162 | Builder.ResultDecl = ResultDecl.get(); |
7163 | |
7164 | if (auto *ReturnStmt = S->getReturnStmt()) { |
7165 | StmtResult Res = getDerived().TransformStmt(ReturnStmt); |
7166 | if (Res.isInvalid()) |
7167 | return StmtError(); |
7168 | Builder.ReturnStmt = Res.get(); |
7169 | } |
7170 | } |
7171 | |
7172 | return getDerived().RebuildCoroutineBodyStmt(Builder); |
7173 | } |
7174 | |
7175 | template<typename Derived> |
7176 | StmtResult |
7177 | TreeTransform<Derived>::TransformCoreturnStmt(CoreturnStmt *S) { |
7178 | ExprResult Result = getDerived().TransformInitializer(S->getOperand(), |
7179 | ); |
7180 | if (Result.isInvalid()) |
7181 | return StmtError(); |
7182 | |
7183 | |
7184 | |
7185 | return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(), |
7186 | S->isImplicit()); |
7187 | } |
7188 | |
7189 | template<typename Derived> |
7190 | ExprResult |
7191 | TreeTransform<Derived>::TransformCoawaitExpr(CoawaitExpr *E) { |
7192 | ExprResult Result = getDerived().TransformInitializer(E->getOperand(), |
7193 | ); |
7194 | if (Result.isInvalid()) |
7195 | return ExprError(); |
7196 | |
7197 | |
7198 | |
7199 | return getDerived().RebuildCoawaitExpr(E->getKeywordLoc(), Result.get(), |
7200 | E->isImplicit()); |
7201 | } |
7202 | |
7203 | template <typename Derived> |
7204 | ExprResult |
7205 | TreeTransform<Derived>::TransformDependentCoawaitExpr(DependentCoawaitExpr *E) { |
7206 | ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(), |
7207 | false); |
7208 | if (OperandResult.isInvalid()) |
7209 | return ExprError(); |
7210 | |
7211 | ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr( |
7212 | E->getOperatorCoawaitLookup()); |
7213 | |
7214 | if (LookupResult.isInvalid()) |
7215 | return ExprError(); |
7216 | |
7217 | |
7218 | |
7219 | return getDerived().RebuildDependentCoawaitExpr( |
7220 | E->getKeywordLoc(), OperandResult.get(), |
7221 | cast<UnresolvedLookupExpr>(LookupResult.get())); |
7222 | } |
7223 | |
7224 | template<typename Derived> |
7225 | ExprResult |
7226 | TreeTransform<Derived>::TransformCoyieldExpr(CoyieldExpr *E) { |
7227 | ExprResult Result = getDerived().TransformInitializer(E->getOperand(), |
7228 | ); |
7229 | if (Result.isInvalid()) |
7230 | return ExprError(); |
7231 | |
7232 | |
7233 | |
7234 | return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get()); |
7235 | } |
7236 | |
7237 | |
7238 | |
7239 | template<typename Derived> |
7240 | StmtResult |
7241 | TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { |
7242 | |
7243 | StmtResult TryBody = getDerived().TransformStmt(S->getTryBody()); |
7244 | if (TryBody.isInvalid()) |
7245 | return StmtError(); |
7246 | |
7247 | |
7248 | bool AnyCatchChanged = false; |
7249 | SmallVector<Stmt*, 8> CatchStmts; |
7250 | for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { |
7251 | StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I)); |
7252 | if (Catch.isInvalid()) |
7253 | return StmtError(); |
7254 | if (Catch.get() != S->getCatchStmt(I)) |
7255 | AnyCatchChanged = true; |
7256 | CatchStmts.push_back(Catch.get()); |
7257 | } |
7258 | |
7259 | |
7260 | StmtResult Finally; |
7261 | if (S->getFinallyStmt()) { |
7262 | Finally = getDerived().TransformStmt(S->getFinallyStmt()); |
7263 | if (Finally.isInvalid()) |
7264 | return StmtError(); |
7265 | } |
7266 | |
7267 | |
7268 | if (!getDerived().AlwaysRebuild() && |
7269 | TryBody.get() == S->getTryBody() && |
7270 | !AnyCatchChanged && |
7271 | Finally.get() == S->getFinallyStmt()) |
7272 | return S; |
7273 | |
7274 | |
7275 | return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(), |
7276 | CatchStmts, Finally.get()); |
7277 | } |
7278 | |
7279 | template<typename Derived> |
7280 | StmtResult |
7281 | TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) { |
7282 | |
7283 | VarDecl *Var = nullptr; |
7284 | if (VarDecl *FromVar = S->getCatchParamDecl()) { |
7285 | TypeSourceInfo *TSInfo = nullptr; |
7286 | if (FromVar->getTypeSourceInfo()) { |
7287 | TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo()); |
7288 | if (!TSInfo) |
7289 | return StmtError(); |
7290 | } |
7291 | |
7292 | QualType T; |
7293 | if (TSInfo) |
7294 | T = TSInfo->getType(); |
7295 | else { |
7296 | T = getDerived().TransformType(FromVar->getType()); |
7297 | if (T.isNull()) |
7298 | return StmtError(); |
7299 | } |
7300 | |
7301 | Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T); |
7302 | if (!Var) |
7303 | return StmtError(); |
7304 | } |
7305 | |
7306 | StmtResult Body = getDerived().TransformStmt(S->getCatchBody()); |
7307 | if (Body.isInvalid()) |
7308 | return StmtError(); |
7309 | |
7310 | return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(), |
7311 | S->getRParenLoc(), |
7312 | Var, Body.get()); |
7313 | } |
7314 | |
7315 | template<typename Derived> |
7316 | StmtResult |
7317 | TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { |
7318 | |
7319 | StmtResult Body = getDerived().TransformStmt(S->getFinallyBody()); |
7320 | if (Body.isInvalid()) |
7321 | return StmtError(); |
7322 | |
7323 | |
7324 | if (!getDerived().AlwaysRebuild() && |
7325 | Body.get() == S->getFinallyBody()) |
7326 | return S; |
7327 | |
7328 | |
7329 | return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(), |
7330 | Body.get()); |
7331 | } |
7332 | |
7333 | template<typename Derived> |
7334 | StmtResult |
7335 | TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) { |
7336 | ExprResult Operand; |
7337 | if (S->getThrowExpr()) { |
7338 | Operand = getDerived().TransformExpr(S->getThrowExpr()); |
7339 | if (Operand.isInvalid()) |
7340 | return StmtError(); |
7341 | } |
7342 | |
7343 | if (!getDerived().AlwaysRebuild() && |
7344 | Operand.get() == S->getThrowExpr()) |
7345 | return S; |
7346 | |
7347 | return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get()); |
7348 | } |
7349 | |
7350 | template<typename Derived> |
7351 | StmtResult |
7352 | TreeTransform<Derived>::TransformObjCAtSynchronizedStmt( |
7353 | ObjCAtSynchronizedStmt *S) { |
7354 | |
7355 | ExprResult Object = getDerived().TransformExpr(S->getSynchExpr()); |
7356 | if (Object.isInvalid()) |
7357 | return StmtError(); |
7358 | Object = |
7359 | getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(), |
7360 | Object.get()); |
7361 | if (Object.isInvalid()) |
7362 | return StmtError(); |
7363 | |
7364 | |
7365 | StmtResult Body = getDerived().TransformStmt(S->getSynchBody()); |
7366 | if (Body.isInvalid()) |
7367 | return StmtError(); |
7368 | |
7369 | |
7370 | if (!getDerived().AlwaysRebuild() && |
7371 | Object.get() == S->getSynchExpr() && |
7372 | Body.get() == S->getSynchBody()) |
7373 | return S; |
7374 | |
7375 | |
7376 | return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(), |
7377 | Object.get(), Body.get()); |
7378 | } |
7379 | |
7380 | template<typename Derived> |
7381 | StmtResult |
7382 | TreeTransform<Derived>::TransformObjCAutoreleasePoolStmt( |
7383 | ObjCAutoreleasePoolStmt *S) { |
7384 | |
7385 | StmtResult Body = getDerived().TransformStmt(S->getSubStmt()); |
7386 | if (Body.isInvalid()) |
7387 | return StmtError(); |
7388 | |
7389 | |
7390 | if (!getDerived().AlwaysRebuild() && |
7391 | Body.get() == S->getSubStmt()) |
7392 | return S; |
7393 | |
7394 | |
7395 | return getDerived().RebuildObjCAutoreleasePoolStmt( |
7396 | S->getAtLoc(), Body.get()); |
7397 | } |
7398 | |
7399 | template<typename Derived> |
7400 | StmtResult |
7401 | TreeTransform<Derived>::TransformObjCForCollectionStmt( |
7402 | ObjCForCollectionStmt *S) { |
7403 | |
7404 | StmtResult Element = |
7405 | getDerived().TransformStmt(S->getElement(), SDK_NotDiscarded); |
7406 | if (Element.isInvalid()) |
7407 | return StmtError(); |
7408 | |
7409 | |
7410 | ExprResult Collection = getDerived().TransformExpr(S->getCollection()); |
7411 | if (Collection.isInvalid()) |
7412 | return StmtError(); |
7413 | |
7414 | |
7415 | StmtResult Body = getDerived().TransformStmt(S->getBody()); |
7416 | if (Body.isInvalid()) |
7417 | return StmtError(); |
7418 | |
7419 | |
7420 | if (!getDerived().AlwaysRebuild() && |
7421 | Element.get() == S->getElement() && |
7422 | Collection.get() == S->getCollection() && |
7423 | Body.get() == S->getBody()) |
7424 | return S; |
7425 | |
7426 | |
7427 | return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(), |
7428 | Element.get(), |
7429 | Collection.get(), |
7430 | S->getRParenLoc(), |
7431 | Body.get()); |
7432 | } |
7433 | |
7434 | template <typename Derived> |
7435 | StmtResult TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) { |
7436 | |
7437 | VarDecl *Var = nullptr; |
7438 | if (VarDecl *ExceptionDecl = S->getExceptionDecl()) { |
7439 | TypeSourceInfo *T = |
7440 | getDerived().TransformType(ExceptionDecl->getTypeSourceInfo()); |
7441 | if (!T) |
7442 | return StmtError(); |
7443 | |
7444 | Var = getDerived().RebuildExceptionDecl( |
7445 | ExceptionDecl, T, ExceptionDecl->getInnerLocStart(), |
7446 | ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier()); |
7447 | if (!Var || Var->isInvalidDecl()) |
7448 | return StmtError(); |
7449 | } |
7450 | |
7451 | |
7452 | StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock()); |
7453 | if (Handler.isInvalid()) |
7454 | return StmtError(); |
7455 | |
7456 | if (!getDerived().AlwaysRebuild() && !Var && |
7457 | Handler.get() == S->getHandlerBlock()) |
7458 | return S; |
7459 | |
7460 | return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get()); |
7461 | } |
7462 | |
7463 | template <typename Derived> |
7464 | StmtResult TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) { |
7465 | |
7466 | StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock()); |
7467 | if (TryBlock.isInvalid()) |
7468 | return StmtError(); |
7469 | |
7470 | |
7471 | bool HandlerChanged = false; |
7472 | SmallVector<Stmt *, 8> Handlers; |
7473 | for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) { |
7474 | StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I)); |
7475 | if (Handler.isInvalid()) |
7476 | return StmtError(); |
7477 | |
7478 | HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I); |
7479 | Handlers.push_back(Handler.getAs<Stmt>()); |
7480 | } |
7481 | |
7482 | if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() && |
7483 | !HandlerChanged) |
7484 | return S; |
7485 | |
7486 | return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(), |
7487 | Handlers); |
7488 | } |
7489 | |
7490 | template<typename Derived> |
7491 | StmtResult |
7492 | TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) { |
7493 | StmtResult Init = |
7494 | S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult(); |
7495 | if (Init.isInvalid()) |
7496 | return StmtError(); |
7497 | |
7498 | StmtResult Range = getDerived().TransformStmt(S->getRangeStmt()); |
7499 | if (Range.isInvalid()) |
7500 | return StmtError(); |
7501 | |
7502 | StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt()); |
7503 | if (Begin.isInvalid()) |
7504 | return StmtError(); |
7505 | StmtResult End = getDerived().TransformStmt(S->getEndStmt()); |
7506 | if (End.isInvalid()) |
7507 | return StmtError(); |
7508 | |
7509 | ExprResult Cond = getDerived().TransformExpr(S->getCond()); |
7510 | if (Cond.isInvalid()) |
7511 | return StmtError(); |
7512 | if (Cond.get()) |
7513 | Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get()); |
7514 | if (Cond.isInvalid()) |
7515 | return StmtError(); |
7516 | if (Cond.get()) |
7517 | Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get()); |
7518 | |
7519 | ExprResult Inc = getDerived().TransformExpr(S->getInc()); |
7520 | if (Inc.isInvalid()) |
7521 | return StmtError(); |
7522 | if (Inc.get()) |
7523 | Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get()); |
7524 | |
7525 | StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt()); |
7526 | if (LoopVar.isInvalid()) |
7527 | return StmtError(); |
7528 | |
7529 | StmtResult NewStmt = S; |
7530 | if (getDerived().AlwaysRebuild() || |
7531 | Init.get() != S->getInit() || |
7532 | Range.get() != S->getRangeStmt() || |
7533 | Begin.get() != S->getBeginStmt() || |
7534 | End.get() != S->getEndStmt() || |
7535 | Cond.get() != S->getCond() || |
7536 | Inc.get() != S->getInc() || |
7537 | LoopVar.get() != S->getLoopVarStmt()) { |
7538 | NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(), |
7539 | S->getCoawaitLoc(), Init.get(), |
7540 | S->getColonLoc(), Range.get(), |
7541 | Begin.get(), End.get(), |
7542 | Cond.get(), |
7543 | Inc.get(), LoopVar.get(), |
7544 | S->getRParenLoc()); |
7545 | if (NewStmt.isInvalid()) |
7546 | return StmtError(); |
7547 | } |
7548 | |
7549 | StmtResult Body = getDerived().TransformStmt(S->getBody()); |
7550 | if (Body.isInvalid()) |
7551 | return StmtError(); |
7552 | |
7553 | |
7554 | |
7555 | if (Body.get() != S->getBody() && NewStmt.get() == S) { |
7556 | NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(), |
7557 | S->getCoawaitLoc(), Init.get(), |
7558 | S->getColonLoc(), Range.get(), |
7559 | Begin.get(), End.get(), |
7560 | Cond.get(), |
7561 | Inc.get(), LoopVar.get(), |
7562 | S->getRParenLoc()); |
7563 | if (NewStmt.isInvalid()) |
7564 | return StmtError(); |
7565 | } |
7566 | |
7567 | if (NewStmt.get() == S) |
7568 | return S; |
7569 | |
7570 | return FinishCXXForRangeStmt(NewStmt.get(), Body.get()); |
7571 | } |
7572 | |
7573 | template<typename Derived> |
7574 | StmtResult |
7575 | TreeTransform<Derived>::TransformMSDependentExistsStmt( |
7576 | MSDependentExistsStmt *S) { |
7577 | |
7578 | NestedNameSpecifierLoc QualifierLoc; |
7579 | if (S->getQualifierLoc()) { |
7580 | QualifierLoc |
7581 | = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc()); |
7582 | if (!QualifierLoc) |
7583 | return StmtError(); |
7584 | } |
7585 | |
7586 | |
7587 | DeclarationNameInfo NameInfo = S->getNameInfo(); |
7588 | if (NameInfo.getName()) { |
7589 | NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo); |
7590 | if (!NameInfo.getName()) |
7591 | return StmtError(); |
7592 | } |
7593 | |
7594 | |
7595 | if (!getDerived().AlwaysRebuild() && |
7596 | QualifierLoc == S->getQualifierLoc() && |
7597 | NameInfo.getName() == S->getNameInfo().getName()) |
7598 | return S; |
7599 | |
7600 | |
7601 | CXXScopeSpec SS; |
7602 | SS.Adopt(QualifierLoc); |
7603 | bool Dependent = false; |
7604 | switch (getSema().CheckMicrosoftIfExistsSymbol(, SS, NameInfo)) { |
7605 | case Sema::IER_Exists: |
7606 | if (S->isIfExists()) |
7607 | break; |
7608 | |
7609 | return new (getSema().Context) NullStmt(S->getKeywordLoc()); |
7610 | |
7611 | case Sema::IER_DoesNotExist: |
7612 | if (S->isIfNotExists()) |
7613 | break; |
7614 | |
7615 | return new (getSema().Context) NullStmt(S->getKeywordLoc()); |
7616 | |
7617 | case Sema::IER_Dependent: |
7618 | Dependent = true; |
7619 | break; |
7620 | |
7621 | case Sema::IER_Error: |
7622 | return StmtError(); |
7623 | } |
7624 | |
7625 | |
7626 | StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt()); |
7627 | if (SubStmt.isInvalid()) |
7628 | return StmtError(); |
7629 | |
7630 | |
7631 | if (!Dependent) |
7632 | return SubStmt; |
7633 | |
7634 | |
7635 | return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(), |
7636 | S->isIfExists(), |
7637 | QualifierLoc, |
7638 | NameInfo, |
7639 | SubStmt.get()); |
7640 | } |
7641 | |
7642 | template<typename Derived> |
7643 | ExprResult |
7644 | TreeTransform<Derived>::TransformMSPropertyRefExpr(MSPropertyRefExpr *E) { |
7645 | NestedNameSpecifierLoc QualifierLoc; |
7646 | if (E->getQualifierLoc()) { |
7647 | QualifierLoc |
7648 | = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc()); |
7649 | if (!QualifierLoc) |
7650 | return ExprError(); |
7651 | } |
7652 | |
7653 | MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>( |
7654 | getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl())); |
7655 | if (!PD) |
7656 | return ExprError(); |
7657 | |
7658 | ExprResult Base = getDerived().TransformExpr(E->getBaseExpr()); |
7659 | if (Base.isInvalid()) |
7660 | return ExprError(); |
7661 | |
7662 | return new (SemaRef.getASTContext()) |
7663 | MSPropertyRefExpr(Base.get(), PD, E->isArrow(), |
7664 | SemaRef.getASTContext().PseudoObjectTy, VK_LValue, |
7665 | QualifierLoc, E->getMemberLoc()); |
7666 | } |
7667 | |
7668 | template <typename Derived> |
7669 | ExprResult TreeTransform<Derived>::TransformMSPropertySubscriptExpr( |
7670 | MSPropertySubscriptExpr *E) { |
7671 | auto BaseRes = getDerived().TransformExpr(E->getBase()); |
7672 | if (BaseRes.isInvalid()) |
7673 | return ExprError(); |
7674 | auto IdxRes = getDerived().TransformExpr(E->getIdx()); |
7675 | if (IdxRes.isInvalid()) |
7676 | return ExprError(); |
7677 | |
7678 | if (!getDerived().AlwaysRebuild() && |
7679 | BaseRes.get() == E->getBase() && |
7680 | IdxRes.get() == E->getIdx()) |
7681 | return E; |
7682 | |
7683 | return getDerived().RebuildArraySubscriptExpr( |
7684 | BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc()); |
7685 | } |
7686 | |
7687 | template <typename Derived> |
7688 | StmtResult TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) { |
7689 | StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock()); |
7690 | if (TryBlock.isInvalid()) |
7691 | return StmtError(); |
7692 | |
7693 | StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler()); |
7694 | if (Handler.isInvalid()) |
7695 | return StmtError(); |
7696 | |
7697 | if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() && |
7698 | Handler.get() == S->getHandler()) |
7699 | return S; |
7700 | |
7701 | return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(), |
7702 | TryBlock.get(), Handler.get()); |
7703 | } |
7704 | |
7705 | template <typename Derived> |
7706 | StmtResult TreeTransform<Derived>::TransformSEHFinallyStmt(SEHFinallyStmt *S) { |
7707 | StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock()); |
7708 | if (Block.isInvalid()) |
7709 | return StmtError(); |
7710 | |
7711 | return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get()); |
7712 | } |
7713 | |
7714 | template <typename Derived> |
7715 | StmtResult TreeTransform<Derived>::TransformSEHExceptStmt(SEHExceptStmt *S) { |
7716 | ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr()); |
7717 | if (FilterExpr.isInvalid()) |
7718 | return StmtError(); |
7719 | |
7720 | StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock()); |
7721 | if (Block.isInvalid()) |
7722 | return StmtError(); |
7723 | |
7724 | return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(), |
7725 | Block.get()); |
7726 | } |
7727 | |
7728 | template <typename Derived> |
7729 | StmtResult TreeTransform<Derived>::TransformSEHHandler(Stmt *Handler) { |
7730 | if (isa<SEHFinallyStmt>(Handler)) |
7731 | return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler)); |
7732 | else |
7733 | return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler)); |
7734 | } |
7735 | |
7736 | template<typename Derived> |
7737 | StmtResult |
7738 | TreeTransform<Derived>::TransformSEHLeaveStmt(SEHLeaveStmt *S) { |
7739 | return S; |
7740 | } |
7741 | |
7742 | |
7743 | |
7744 | |
7745 | template <typename Derived> |
7746 | StmtResult TreeTransform<Derived>::TransformOMPExecutableDirective( |
7747 | OMPExecutableDirective *D) { |
7748 | |
7749 | |
7750 | llvm::SmallVector<OMPClause *, 16> TClauses; |
7751 | ArrayRef<OMPClause *> Clauses = D->clauses(); |
7752 | TClauses.reserve(Clauses.size()); |
7753 | for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); |
7754 | I != E; ++I) { |
7755 | if (*I) { |
7756 | getDerived().getSema().StartOpenMPClause((*I)->getClauseKind()); |
7757 | OMPClause *Clause = getDerived().TransformOMPClause(*I); |
7758 | getDerived().getSema().EndOpenMPClause(); |
7759 | if (Clause) |
7760 | TClauses.push_back(Clause); |
7761 | } else { |
7762 | TClauses.push_back(nullptr); |
7763 | } |
7764 | } |
7765 | StmtResult AssociatedStmt; |
7766 | if (D->hasAssociatedStmt() && D->getAssociatedStmt()) { |
7767 | getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(), |
7768 | ); |
7769 | StmtResult Body; |
7770 | { |
7771 | Sema::CompoundScopeRAII CompoundScope(getSema()); |
7772 | Stmt *CS = D->getInnermostCapturedStmt()->getCapturedStmt(); |
7773 | Body = getDerived().TransformStmt(CS); |
7774 | } |
7775 | AssociatedStmt = |
7776 | getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses); |
7777 | if (AssociatedStmt.isInvalid()) { |
7778 | return StmtError(); |
7779 | } |
7780 | } |
7781 | if (TClauses.size() != Clauses.size()) { |
7782 | return StmtError(); |
7783 | } |
7784 | |
7785 | |
7786 | DeclarationNameInfo DirName; |
7787 | if (D->getDirectiveKind() == OMPD_critical) { |
7788 | DirName = cast<OMPCriticalDirective>(D)->getDirectiveName(); |
7789 | DirName = getDerived().TransformDeclarationNameInfo(DirName); |
7790 | } |
7791 | OpenMPDirectiveKind CancelRegion = OMPD_unknown; |
7792 | if (D->getDirectiveKind() == OMPD_cancellation_point) { |
7793 | CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion(); |
7794 | } else if (D->getDirectiveKind() == OMPD_cancel) { |
7795 | CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion(); |
7796 | } |
7797 | |
7798 | return getDerived().RebuildOMPExecutableDirective( |
7799 | D->getDirectiveKind(), DirName, CancelRegion, TClauses, |
7800 | AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc()); |
7801 | } |
7802 | |
7803 | template <typename Derived> |
7804 | StmtResult |
7805 | TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) { |
7806 | DeclarationNameInfo DirName; |
7807 | getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, nullptr, |
7808 | D->getBeginLoc()); |
7809 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7810 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7811 | return Res; |
7812 | } |
7813 | |
7814 | template <typename Derived> |
7815 | StmtResult |
7816 | TreeTransform<Derived>::TransformOMPSimdDirective(OMPSimdDirective *D) { |
7817 | DeclarationNameInfo DirName; |
7818 | getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr, |
7819 | D->getBeginLoc()); |
7820 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7821 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7822 | return Res; |
7823 | } |
7824 | |
7825 | template <typename Derived> |
7826 | StmtResult |
7827 | TreeTransform<Derived>::TransformOMPForDirective(OMPForDirective *D) { |
7828 | DeclarationNameInfo DirName; |
7829 | getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr, |
7830 | D->getBeginLoc()); |
7831 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7832 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7833 | return Res; |
7834 | } |
7835 | |
7836 | template <typename Derived> |
7837 | StmtResult |
7838 | TreeTransform<Derived>::TransformOMPForSimdDirective(OMPForSimdDirective *D) { |
7839 | DeclarationNameInfo DirName; |
7840 | getDerived().getSema().StartOpenMPDSABlock(OMPD_for_simd, DirName, nullptr, |
7841 | D->getBeginLoc()); |
7842 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7843 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7844 | return Res; |
7845 | } |
7846 | |
7847 | template <typename Derived> |
7848 | StmtResult |
7849 | TreeTransform<Derived>::TransformOMPSectionsDirective(OMPSectionsDirective *D) { |
7850 | DeclarationNameInfo DirName; |
7851 | getDerived().getSema().StartOpenMPDSABlock(OMPD_sections, DirName, nullptr, |
7852 | D->getBeginLoc()); |
7853 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7854 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7855 | return Res; |
7856 | } |
7857 | |
7858 | template <typename Derived> |
7859 | StmtResult |
7860 | TreeTransform<Derived>::TransformOMPSectionDirective(OMPSectionDirective *D) { |
7861 | DeclarationNameInfo DirName; |
7862 | getDerived().getSema().StartOpenMPDSABlock(OMPD_section, DirName, nullptr, |
7863 | D->getBeginLoc()); |
7864 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7865 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7866 | return Res; |
7867 | } |
7868 | |
7869 | template <typename Derived> |
7870 | StmtResult |
7871 | TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective *D) { |
7872 | DeclarationNameInfo DirName; |
7873 | getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName, nullptr, |
7874 | D->getBeginLoc()); |
7875 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7876 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7877 | return Res; |
7878 | } |
7879 | |
7880 | template <typename Derived> |
7881 | StmtResult |
7882 | TreeTransform<Derived>::TransformOMPMasterDirective(OMPMasterDirective *D) { |
7883 | DeclarationNameInfo DirName; |
7884 | getDerived().getSema().StartOpenMPDSABlock(OMPD_master, DirName, nullptr, |
7885 | D->getBeginLoc()); |
7886 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7887 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7888 | return Res; |
7889 | } |
7890 | |
7891 | template <typename Derived> |
7892 | StmtResult |
7893 | TreeTransform<Derived>::TransformOMPCriticalDirective(OMPCriticalDirective *D) { |
7894 | getDerived().getSema().StartOpenMPDSABlock( |
7895 | OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc()); |
7896 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7897 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7898 | return Res; |
7899 | } |
7900 | |
7901 | template <typename Derived> |
7902 | StmtResult TreeTransform<Derived>::TransformOMPParallelForDirective( |
7903 | OMPParallelForDirective *D) { |
7904 | DeclarationNameInfo DirName; |
7905 | getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for, DirName, |
7906 | nullptr, D->getBeginLoc()); |
7907 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7908 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7909 | return Res; |
7910 | } |
7911 | |
7912 | template <typename Derived> |
7913 | StmtResult TreeTransform<Derived>::TransformOMPParallelForSimdDirective( |
7914 | OMPParallelForSimdDirective *D) { |
7915 | DeclarationNameInfo DirName; |
7916 | getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for_simd, DirName, |
7917 | nullptr, D->getBeginLoc()); |
7918 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7919 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7920 | return Res; |
7921 | } |
7922 | |
7923 | template <typename Derived> |
7924 | StmtResult TreeTransform<Derived>::TransformOMPParallelSectionsDirective( |
7925 | OMPParallelSectionsDirective *D) { |
7926 | DeclarationNameInfo DirName; |
7927 | getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_sections, DirName, |
7928 | nullptr, D->getBeginLoc()); |
7929 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7930 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7931 | return Res; |
7932 | } |
7933 | |
7934 | template <typename Derived> |
7935 | StmtResult |
7936 | TreeTransform<Derived>::TransformOMPTaskDirective(OMPTaskDirective *D) { |
7937 | DeclarationNameInfo DirName; |
7938 | getDerived().getSema().StartOpenMPDSABlock(OMPD_task, DirName, nullptr, |
7939 | D->getBeginLoc()); |
7940 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7941 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7942 | return Res; |
7943 | } |
7944 | |
7945 | template <typename Derived> |
7946 | StmtResult TreeTransform<Derived>::TransformOMPTaskyieldDirective( |
7947 | OMPTaskyieldDirective *D) { |
7948 | DeclarationNameInfo DirName; |
7949 | getDerived().getSema().StartOpenMPDSABlock(OMPD_taskyield, DirName, nullptr, |
7950 | D->getBeginLoc()); |
7951 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7952 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7953 | return Res; |
7954 | } |
7955 | |
7956 | template <typename Derived> |
7957 | StmtResult |
7958 | TreeTransform<Derived>::TransformOMPBarrierDirective(OMPBarrierDirective *D) { |
7959 | DeclarationNameInfo DirName; |
7960 | getDerived().getSema().StartOpenMPDSABlock(OMPD_barrier, DirName, nullptr, |
7961 | D->getBeginLoc()); |
7962 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7963 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7964 | return Res; |
7965 | } |
7966 | |
7967 | template <typename Derived> |
7968 | StmtResult |
7969 | TreeTransform<Derived>::TransformOMPTaskwaitDirective(OMPTaskwaitDirective *D) { |
7970 | DeclarationNameInfo DirName; |
7971 | getDerived().getSema().StartOpenMPDSABlock(OMPD_taskwait, DirName, nullptr, |
7972 | D->getBeginLoc()); |
7973 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7974 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7975 | return Res; |
7976 | } |
7977 | |
7978 | template <typename Derived> |
7979 | StmtResult TreeTransform<Derived>::TransformOMPTaskgroupDirective( |
7980 | OMPTaskgroupDirective *D) { |
7981 | DeclarationNameInfo DirName; |
7982 | getDerived().getSema().StartOpenMPDSABlock(OMPD_taskgroup, DirName, nullptr, |
7983 | D->getBeginLoc()); |
7984 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7985 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7986 | return Res; |
7987 | } |
7988 | |
7989 | template <typename Derived> |
7990 | StmtResult |
7991 | TreeTransform<Derived>::TransformOMPFlushDirective(OMPFlushDirective *D) { |
7992 | DeclarationNameInfo DirName; |
7993 | getDerived().getSema().StartOpenMPDSABlock(OMPD_flush, DirName, nullptr, |
7994 | D->getBeginLoc()); |
7995 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
7996 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
7997 | return Res; |
7998 | } |
7999 | |
8000 | template <typename Derived> |
8001 | StmtResult |
8002 | TreeTransform<Derived>::TransformOMPOrderedDirective(OMPOrderedDirective *D) { |
8003 | DeclarationNameInfo DirName; |
8004 | getDerived().getSema().StartOpenMPDSABlock(OMPD_ordered, DirName, nullptr, |
8005 | D->getBeginLoc()); |
8006 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8007 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8008 | return Res; |
8009 | } |
8010 | |
8011 | template <typename Derived> |
8012 | StmtResult |
8013 | TreeTransform<Derived>::TransformOMPAtomicDirective(OMPAtomicDirective *D) { |
8014 | DeclarationNameInfo DirName; |
8015 | getDerived().getSema().StartOpenMPDSABlock(OMPD_atomic, DirName, nullptr, |
8016 | D->getBeginLoc()); |
8017 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8018 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8019 | return Res; |
8020 | } |
8021 | |
8022 | template <typename Derived> |
8023 | StmtResult |
8024 | TreeTransform<Derived>::TransformOMPTargetDirective(OMPTargetDirective *D) { |
8025 | DeclarationNameInfo DirName; |
8026 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target, DirName, nullptr, |
8027 | D->getBeginLoc()); |
8028 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8029 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8030 | return Res; |
8031 | } |
8032 | |
8033 | template <typename Derived> |
8034 | StmtResult TreeTransform<Derived>::TransformOMPTargetDataDirective( |
8035 | OMPTargetDataDirective *D) { |
8036 | DeclarationNameInfo DirName; |
8037 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_data, DirName, nullptr, |
8038 | D->getBeginLoc()); |
8039 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8040 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8041 | return Res; |
8042 | } |
8043 | |
8044 | template <typename Derived> |
8045 | StmtResult TreeTransform<Derived>::TransformOMPTargetEnterDataDirective( |
8046 | OMPTargetEnterDataDirective *D) { |
8047 | DeclarationNameInfo DirName; |
8048 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_enter_data, DirName, |
8049 | nullptr, D->getBeginLoc()); |
8050 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8051 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8052 | return Res; |
8053 | } |
8054 | |
8055 | template <typename Derived> |
8056 | StmtResult TreeTransform<Derived>::TransformOMPTargetExitDataDirective( |
8057 | OMPTargetExitDataDirective *D) { |
8058 | DeclarationNameInfo DirName; |
8059 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_exit_data, DirName, |
8060 | nullptr, D->getBeginLoc()); |
8061 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8062 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8063 | return Res; |
8064 | } |
8065 | |
8066 | template <typename Derived> |
8067 | StmtResult TreeTransform<Derived>::TransformOMPTargetParallelDirective( |
8068 | OMPTargetParallelDirective *D) { |
8069 | DeclarationNameInfo DirName; |
8070 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, DirName, |
8071 | nullptr, D->getBeginLoc()); |
8072 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8073 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8074 | return Res; |
8075 | } |
8076 | |
8077 | template <typename Derived> |
8078 | StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForDirective( |
8079 | OMPTargetParallelForDirective *D) { |
8080 | DeclarationNameInfo DirName; |
8081 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel_for, DirName, |
8082 | nullptr, D->getBeginLoc()); |
8083 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8084 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8085 | return Res; |
8086 | } |
8087 | |
8088 | template <typename Derived> |
8089 | StmtResult TreeTransform<Derived>::TransformOMPTargetUpdateDirective( |
8090 | OMPTargetUpdateDirective *D) { |
8091 | DeclarationNameInfo DirName; |
8092 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_update, DirName, |
8093 | nullptr, D->getBeginLoc()); |
8094 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8095 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8096 | return Res; |
8097 | } |
8098 | |
8099 | template <typename Derived> |
8100 | StmtResult |
8101 | TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) { |
8102 | DeclarationNameInfo DirName; |
8103 | getDerived().getSema().StartOpenMPDSABlock(OMPD_teams, DirName, nullptr, |
8104 | D->getBeginLoc()); |
8105 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8106 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8107 | return Res; |
8108 | } |
8109 | |
8110 | template <typename Derived> |
8111 | StmtResult TreeTransform<Derived>::TransformOMPCancellationPointDirective( |
8112 | OMPCancellationPointDirective *D) { |
8113 | DeclarationNameInfo DirName; |
8114 | getDerived().getSema().StartOpenMPDSABlock(OMPD_cancellation_point, DirName, |
8115 | nullptr, D->getBeginLoc()); |
8116 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8117 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8118 | return Res; |
8119 | } |
8120 | |
8121 | template <typename Derived> |
8122 | StmtResult |
8123 | TreeTransform<Derived>::TransformOMPCancelDirective(OMPCancelDirective *D) { |
8124 | DeclarationNameInfo DirName; |
8125 | getDerived().getSema().StartOpenMPDSABlock(OMPD_cancel, DirName, nullptr, |
8126 | D->getBeginLoc()); |
8127 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8128 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8129 | return Res; |
8130 | } |
8131 | |
8132 | template <typename Derived> |
8133 | StmtResult |
8134 | TreeTransform<Derived>::TransformOMPTaskLoopDirective(OMPTaskLoopDirective *D) { |
8135 | DeclarationNameInfo DirName; |
8136 | getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop, DirName, nullptr, |
8137 | D->getBeginLoc()); |
8138 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8139 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8140 | return Res; |
8141 | } |
8142 | |
8143 | template <typename Derived> |
8144 | StmtResult TreeTransform<Derived>::TransformOMPTaskLoopSimdDirective( |
8145 | OMPTaskLoopSimdDirective *D) { |
8146 | DeclarationNameInfo DirName; |
8147 | getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop_simd, DirName, |
8148 | nullptr, D->getBeginLoc()); |
8149 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8150 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8151 | return Res; |
8152 | } |
8153 | |
8154 | template <typename Derived> |
8155 | StmtResult TreeTransform<Derived>::TransformOMPDistributeDirective( |
8156 | OMPDistributeDirective *D) { |
8157 | DeclarationNameInfo DirName; |
8158 | getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute, DirName, nullptr, |
8159 | D->getBeginLoc()); |
8160 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8161 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8162 | return Res; |
8163 | } |
8164 | |
8165 | template <typename Derived> |
8166 | StmtResult TreeTransform<Derived>::TransformOMPDistributeParallelForDirective( |
8167 | OMPDistributeParallelForDirective *D) { |
8168 | DeclarationNameInfo DirName; |
8169 | getDerived().getSema().StartOpenMPDSABlock( |
8170 | OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc()); |
8171 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8172 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8173 | return Res; |
8174 | } |
8175 | |
8176 | template <typename Derived> |
8177 | StmtResult |
8178 | TreeTransform<Derived>::TransformOMPDistributeParallelForSimdDirective( |
8179 | OMPDistributeParallelForSimdDirective *D) { |
8180 | DeclarationNameInfo DirName; |
8181 | getDerived().getSema().StartOpenMPDSABlock( |
8182 | OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc()); |
8183 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8184 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8185 | return Res; |
8186 | } |
8187 | |
8188 | template <typename Derived> |
8189 | StmtResult TreeTransform<Derived>::TransformOMPDistributeSimdDirective( |
8190 | OMPDistributeSimdDirective *D) { |
8191 | DeclarationNameInfo DirName; |
8192 | getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute_simd, DirName, |
8193 | nullptr, D->getBeginLoc()); |
8194 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8195 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8196 | return Res; |
8197 | } |
8198 | |
8199 | template <typename Derived> |
8200 | StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForSimdDirective( |
8201 | OMPTargetParallelForSimdDirective *D) { |
8202 | DeclarationNameInfo DirName; |
8203 | getDerived().getSema().StartOpenMPDSABlock( |
8204 | OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc()); |
8205 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8206 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8207 | return Res; |
8208 | } |
8209 | |
8210 | template <typename Derived> |
8211 | StmtResult TreeTransform<Derived>::TransformOMPTargetSimdDirective( |
8212 | OMPTargetSimdDirective *D) { |
8213 | DeclarationNameInfo DirName; |
8214 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_simd, DirName, nullptr, |
8215 | D->getBeginLoc()); |
8216 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8217 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8218 | return Res; |
8219 | } |
8220 | |
8221 | template <typename Derived> |
8222 | StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeDirective( |
8223 | OMPTeamsDistributeDirective *D) { |
8224 | DeclarationNameInfo DirName; |
8225 | getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute, DirName, |
8226 | nullptr, D->getBeginLoc()); |
8227 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8228 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8229 | return Res; |
8230 | } |
8231 | |
8232 | template <typename Derived> |
8233 | StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeSimdDirective( |
8234 | OMPTeamsDistributeSimdDirective *D) { |
8235 | DeclarationNameInfo DirName; |
8236 | getDerived().getSema().StartOpenMPDSABlock( |
8237 | OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc()); |
8238 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8239 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8240 | return Res; |
8241 | } |
8242 | |
8243 | template <typename Derived> |
8244 | StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForSimdDirective( |
8245 | OMPTeamsDistributeParallelForSimdDirective *D) { |
8246 | DeclarationNameInfo DirName; |
8247 | getDerived().getSema().StartOpenMPDSABlock( |
8248 | OMPD_teams_distribute_parallel_for_simd, DirName, nullptr, |
8249 | D->getBeginLoc()); |
8250 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8251 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8252 | return Res; |
8253 | } |
8254 | |
8255 | template <typename Derived> |
8256 | StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForDirective( |
8257 | OMPTeamsDistributeParallelForDirective *D) { |
8258 | DeclarationNameInfo DirName; |
8259 | getDerived().getSema().StartOpenMPDSABlock( |
8260 | OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc()); |
8261 | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); |
8262 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8263 | return Res; |
8264 | } |
8265 | |
8266 | template <typename Derived> |
8267 | StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDirective( |
8268 | OMPTargetTeamsDirective *D) { |
8269 | DeclarationNameInfo DirName; |
8270 | getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams, DirName, |
8271 | nullptr, D->getBeginLoc()); |
8272 | auto Res = getDerived().TransformOMPExecutableDirective(D); |
8273 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8274 | return Res; |
8275 | } |
8276 | |
8277 | template <typename Derived> |
8278 | StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDistributeDirective( |
8279 | OMPTargetTeamsDistributeDirective *D) { |
8280 | DeclarationNameInfo DirName; |
8281 | getDerived().getSema().StartOpenMPDSABlock( |
8282 | OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc()); |
8283 | auto Res = getDerived().TransformOMPExecutableDirective(D); |
8284 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8285 | return Res; |
8286 | } |
8287 | |
8288 | template <typename Derived> |
8289 | StmtResult |
8290 | TreeTransform<Derived>::TransformOMPTargetTeamsDistributeParallelForDirective( |
8291 | OMPTargetTeamsDistributeParallelForDirective *D) { |
8292 | DeclarationNameInfo DirName; |
8293 | getDerived().getSema().StartOpenMPDSABlock( |
8294 | OMPD_target_teams_distribute_parallel_for, DirName, nullptr, |
8295 | D->getBeginLoc()); |
8296 | auto Res = getDerived().TransformOMPExecutableDirective(D); |
8297 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8298 | return Res; |
8299 | } |
8300 | |
8301 | template <typename Derived> |
8302 | StmtResult TreeTransform<Derived>:: |
8303 | TransformOMPTargetTeamsDistributeParallelForSimdDirective( |
8304 | OMPTargetTeamsDistributeParallelForSimdDirective *D) { |
8305 | DeclarationNameInfo DirName; |
8306 | getDerived().getSema().StartOpenMPDSABlock( |
8307 | OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr, |
8308 | D->getBeginLoc()); |
8309 | auto Res = getDerived().TransformOMPExecutableDirective(D); |
8310 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8311 | return Res; |
8312 | } |
8313 | |
8314 | template <typename Derived> |
8315 | StmtResult |
8316 | TreeTransform<Derived>::TransformOMPTargetTeamsDistributeSimdDirective( |
8317 | OMPTargetTeamsDistributeSimdDirective *D) { |
8318 | DeclarationNameInfo DirName; |
8319 | getDerived().getSema().StartOpenMPDSABlock( |
8320 | OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc()); |
8321 | auto Res = getDerived().TransformOMPExecutableDirective(D); |
8322 | getDerived().getSema().EndOpenMPDSABlock(Res.get()); |
8323 | return Res; |
8324 | } |
8325 | |
8326 | |
8327 | |
8328 | |
8329 | |
8330 | template <typename Derived> |
8331 | OMPClause *TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *C) { |
8332 | ExprResult Cond = getDerived().TransformExpr(C->getCondition()); |
8333 | if (Cond.isInvalid()) |
8334 | return nullptr; |
8335 | return getDerived().RebuildOMPIfClause( |
8336 | C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(), |
8337 | C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc()); |
8338 | } |
8339 | |
8340 | template <typename Derived> |
8341 | OMPClause *TreeTransform<Derived>::TransformOMPFinalClause(OMPFinalClause *C) { |
8342 | ExprResult Cond = getDerived().TransformExpr(C->getCondition()); |
8343 | if (Cond.isInvalid()) |
8344 | return nullptr; |
8345 | return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(), |
8346 | C->getLParenLoc(), C->getEndLoc()); |
8347 | } |
8348 | |
8349 | template <typename Derived> |
8350 | OMPClause * |
8351 | TreeTransform<Derived>::TransformOMPNumThreadsClause(OMPNumThreadsClause *C) { |
8352 | ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads()); |
8353 | if (NumThreads.isInvalid()) |
8354 | return nullptr; |
8355 | return getDerived().RebuildOMPNumThreadsClause( |
8356 | NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8357 | } |
8358 | |
8359 | template <typename Derived> |
8360 | OMPClause * |
8361 | TreeTransform<Derived>::TransformOMPSafelenClause(OMPSafelenClause *C) { |
8362 | ExprResult E = getDerived().TransformExpr(C->getSafelen()); |
8363 | if (E.isInvalid()) |
8364 | return nullptr; |
8365 | return getDerived().RebuildOMPSafelenClause( |
8366 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8367 | } |
8368 | |
8369 | template <typename Derived> |
8370 | OMPClause * |
8371 | TreeTransform<Derived>::TransformOMPAllocatorClause(OMPAllocatorClause *C) { |
8372 | ExprResult E = getDerived().TransformExpr(C->getAllocator()); |
8373 | if (E.isInvalid()) |
8374 | return nullptr; |
8375 | return getDerived().RebuildOMPAllocatorClause( |
8376 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8377 | } |
8378 | |
8379 | template <typename Derived> |
8380 | OMPClause * |
8381 | TreeTransform<Derived>::TransformOMPSimdlenClause(OMPSimdlenClause *C) { |
8382 | ExprResult E = getDerived().TransformExpr(C->getSimdlen()); |
8383 | if (E.isInvalid()) |
8384 | return nullptr; |
8385 | return getDerived().RebuildOMPSimdlenClause( |
8386 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8387 | } |
8388 | |
8389 | template <typename Derived> |
8390 | OMPClause * |
8391 | TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) { |
8392 | ExprResult E = getDerived().TransformExpr(C->getNumForLoops()); |
8393 | if (E.isInvalid()) |
8394 | return nullptr; |
8395 | return getDerived().RebuildOMPCollapseClause( |
8396 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8397 | } |
8398 | |
8399 | template <typename Derived> |
8400 | OMPClause * |
8401 | TreeTransform<Derived>::TransformOMPDefaultClause(OMPDefaultClause *C) { |
8402 | return getDerived().RebuildOMPDefaultClause( |
8403 | C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getBeginLoc(), |
8404 | C->getLParenLoc(), C->getEndLoc()); |
8405 | } |
8406 | |
8407 | template <typename Derived> |
8408 | OMPClause * |
8409 | TreeTransform<Derived>::TransformOMPProcBindClause(OMPProcBindClause *C) { |
8410 | return getDerived().RebuildOMPProcBindClause( |
8411 | C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(), |
8412 | C->getLParenLoc(), C->getEndLoc()); |
8413 | } |
8414 | |
8415 | template <typename Derived> |
8416 | OMPClause * |
8417 | TreeTransform<Derived>::TransformOMPScheduleClause(OMPScheduleClause *C) { |
8418 | ExprResult E = getDerived().TransformExpr(C->getChunkSize()); |
8419 | if (E.isInvalid()) |
8420 | return nullptr; |
8421 | return getDerived().RebuildOMPScheduleClause( |
8422 | C->getFirstScheduleModifier(), C->getSecondScheduleModifier(), |
8423 | C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(), |
8424 | C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(), |
8425 | C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc()); |
8426 | } |
8427 | |
8428 | template <typename Derived> |
8429 | OMPClause * |
8430 | TreeTransform<Derived>::TransformOMPOrderedClause(OMPOrderedClause *C) { |
8431 | ExprResult E; |
8432 | if (auto *Num = C->getNumForLoops()) { |
8433 | E = getDerived().TransformExpr(Num); |
8434 | if (E.isInvalid()) |
8435 | return nullptr; |
8436 | } |
8437 | return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(), |
8438 | C->getLParenLoc(), E.get()); |
8439 | } |
8440 | |
8441 | template <typename Derived> |
8442 | OMPClause * |
8443 | TreeTransform<Derived>::TransformOMPNowaitClause(OMPNowaitClause *C) { |
8444 | |
8445 | return C; |
8446 | } |
8447 | |
8448 | template <typename Derived> |
8449 | OMPClause * |
8450 | TreeTransform<Derived>::TransformOMPUntiedClause(OMPUntiedClause *C) { |
8451 | |
8452 | return C; |
8453 | } |
8454 | |
8455 | template <typename Derived> |
8456 | OMPClause * |
8457 | TreeTransform<Derived>::TransformOMPMergeableClause(OMPMergeableClause *C) { |
8458 | |
8459 | return C; |
8460 | } |
8461 | |
8462 | template <typename Derived> |
8463 | OMPClause *TreeTransform<Derived>::TransformOMPReadClause(OMPReadClause *C) { |
8464 | |
8465 | return C; |
8466 | } |
8467 | |
8468 | template <typename Derived> |
8469 | OMPClause *TreeTransform<Derived>::TransformOMPWriteClause(OMPWriteClause *C) { |
8470 | |
8471 | return C; |
8472 | } |
8473 | |
8474 | template <typename Derived> |
8475 | OMPClause * |
8476 | TreeTransform<Derived>::TransformOMPUpdateClause(OMPUpdateClause *C) { |
8477 | |
8478 | return C; |
8479 | } |
8480 | |
8481 | template <typename Derived> |
8482 | OMPClause * |
8483 | TreeTransform<Derived>::TransformOMPCaptureClause(OMPCaptureClause *C) { |
8484 | |
8485 | return C; |
8486 | } |
8487 | |
8488 | template <typename Derived> |
8489 | OMPClause * |
8490 | TreeTransform<Derived>::TransformOMPSeqCstClause(OMPSeqCstClause *C) { |
8491 | |
8492 | return C; |
8493 | } |
8494 | |
8495 | template <typename Derived> |
8496 | OMPClause * |
8497 | TreeTransform<Derived>::TransformOMPThreadsClause(OMPThreadsClause *C) { |
8498 | |
8499 | return C; |
8500 | } |
8501 | |
8502 | template <typename Derived> |
8503 | OMPClause *TreeTransform<Derived>::TransformOMPSIMDClause(OMPSIMDClause *C) { |
8504 | |
8505 | return C; |
8506 | } |
8507 | |
8508 | template <typename Derived> |
8509 | OMPClause * |
8510 | TreeTransform<Derived>::TransformOMPNogroupClause(OMPNogroupClause *C) { |
8511 | |
8512 | return C; |
8513 | } |
8514 | |
8515 | template <typename Derived> |
8516 | OMPClause *TreeTransform<Derived>::TransformOMPUnifiedAddressClause( |
8517 | OMPUnifiedAddressClause *C) { |
8518 | llvm_unreachable("unified_address clause cannot appear in dependent context"); |
8519 | } |
8520 | |
8521 | template <typename Derived> |
8522 | OMPClause *TreeTransform<Derived>::TransformOMPUnifiedSharedMemoryClause( |
8523 | OMPUnifiedSharedMemoryClause *C) { |
8524 | llvm_unreachable( |
8525 | "unified_shared_memory clause cannot appear in dependent context"); |
8526 | } |
8527 | |
8528 | template <typename Derived> |
8529 | OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause( |
8530 | OMPReverseOffloadClause *C) { |
8531 | llvm_unreachable("reverse_offload clause cannot appear in dependent context"); |
8532 | } |
8533 | |
8534 | template <typename Derived> |
8535 | OMPClause *TreeTransform<Derived>::TransformOMPDynamicAllocatorsClause( |
8536 | OMPDynamicAllocatorsClause *C) { |
8537 | llvm_unreachable( |
8538 | "dynamic_allocators clause cannot appear in dependent context"); |
8539 | } |
8540 | |
8541 | template <typename Derived> |
8542 | OMPClause *TreeTransform<Derived>::TransformOMPAtomicDefaultMemOrderClause( |
8543 | OMPAtomicDefaultMemOrderClause *C) { |
8544 | llvm_unreachable( |
8545 | "atomic_default_mem_order clause cannot appear in dependent context"); |
8546 | } |
8547 | |
8548 | template <typename Derived> |
8549 | OMPClause * |
8550 | TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) { |
8551 | llvm::SmallVector<Expr *, 16> Vars; |
8552 | Vars.reserve(C->varlist_size()); |
8553 | for (auto *VE : C->varlists()) { |
8554 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8555 | if (EVar.isInvalid()) |
8556 | return nullptr; |
8557 | Vars.push_back(EVar.get()); |
8558 | } |
8559 | return getDerived().RebuildOMPPrivateClause( |
8560 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8561 | } |
8562 | |
8563 | template <typename Derived> |
8564 | OMPClause *TreeTransform<Derived>::TransformOMPFirstprivateClause( |
8565 | OMPFirstprivateClause *C) { |
8566 | llvm::SmallVector<Expr *, 16> Vars; |
8567 | Vars.reserve(C->varlist_size()); |
8568 | for (auto *VE : C->varlists()) { |
8569 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8570 | if (EVar.isInvalid()) |
8571 | return nullptr; |
8572 | Vars.push_back(EVar.get()); |
8573 | } |
8574 | return getDerived().RebuildOMPFirstprivateClause( |
8575 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8576 | } |
8577 | |
8578 | template <typename Derived> |
8579 | OMPClause * |
8580 | TreeTransform<Derived>::TransformOMPLastprivateClause(OMPLastprivateClause *C) { |
8581 | llvm::SmallVector<Expr *, 16> Vars; |
8582 | Vars.reserve(C->varlist_size()); |
8583 | for (auto *VE : C->varlists()) { |
8584 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8585 | if (EVar.isInvalid()) |
8586 | return nullptr; |
8587 | Vars.push_back(EVar.get()); |
8588 | } |
8589 | return getDerived().RebuildOMPLastprivateClause( |
8590 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8591 | } |
8592 | |
8593 | template <typename Derived> |
8594 | OMPClause * |
8595 | TreeTransform<Derived>::TransformOMPSharedClause(OMPSharedClause *C) { |
8596 | llvm::SmallVector<Expr *, 16> Vars; |
8597 | Vars.reserve(C->varlist_size()); |
8598 | for (auto *VE : C->varlists()) { |
8599 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8600 | if (EVar.isInvalid()) |
8601 | return nullptr; |
8602 | Vars.push_back(EVar.get()); |
8603 | } |
8604 | return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(), |
8605 | C->getLParenLoc(), C->getEndLoc()); |
8606 | } |
8607 | |
8608 | template <typename Derived> |
8609 | OMPClause * |
8610 | TreeTransform<Derived>::TransformOMPReductionClause(OMPReductionClause *C) { |
8611 | llvm::SmallVector<Expr *, 16> Vars; |
8612 | Vars.reserve(C->varlist_size()); |
8613 | for (auto *VE : C->varlists()) { |
8614 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8615 | if (EVar.isInvalid()) |
8616 | return nullptr; |
8617 | Vars.push_back(EVar.get()); |
8618 | } |
8619 | CXXScopeSpec ReductionIdScopeSpec; |
8620 | ReductionIdScopeSpec.Adopt(C->getQualifierLoc()); |
8621 | |
8622 | DeclarationNameInfo NameInfo = C->getNameInfo(); |
8623 | if (NameInfo.getName()) { |
8624 | NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo); |
8625 | if (!NameInfo.getName()) |
8626 | return nullptr; |
8627 | } |
8628 | |
8629 | |
8630 | llvm::SmallVector<Expr *, 16> UnresolvedReductions; |
8631 | for (auto *E : C->reduction_ops()) { |
8632 | |
8633 | if (E) { |
8634 | auto *ULE = cast<UnresolvedLookupExpr>(E); |
8635 | UnresolvedSet<8> Decls; |
8636 | for (auto *D : ULE->decls()) { |
8637 | NamedDecl *InstD = |
8638 | cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D)); |
8639 | Decls.addDecl(InstD, InstD->getAccess()); |
8640 | } |
8641 | UnresolvedReductions.push_back( |
8642 | UnresolvedLookupExpr::Create( |
8643 | SemaRef.Context, , |
8644 | ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), |
8645 | NameInfo, , ULE->isOverloaded(), |
8646 | Decls.begin(), Decls.end())); |
8647 | } else |
8648 | UnresolvedReductions.push_back(nullptr); |
8649 | } |
8650 | return getDerived().RebuildOMPReductionClause( |
8651 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), |
8652 | C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions); |
8653 | } |
8654 | |
8655 | template <typename Derived> |
8656 | OMPClause *TreeTransform<Derived>::TransformOMPTaskReductionClause( |
8657 | OMPTaskReductionClause *C) { |
8658 | llvm::SmallVector<Expr *, 16> Vars; |
8659 | Vars.reserve(C->varlist_size()); |
8660 | for (auto *VE : C->varlists()) { |
8661 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8662 | if (EVar.isInvalid()) |
8663 | return nullptr; |
8664 | Vars.push_back(EVar.get()); |
8665 | } |
8666 | CXXScopeSpec ReductionIdScopeSpec; |
8667 | ReductionIdScopeSpec.Adopt(C->getQualifierLoc()); |
8668 | |
8669 | DeclarationNameInfo NameInfo = C->getNameInfo(); |
8670 | if (NameInfo.getName()) { |
8671 | NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo); |
8672 | if (!NameInfo.getName()) |
8673 | return nullptr; |
8674 | } |
8675 | |
8676 | |
8677 | llvm::SmallVector<Expr *, 16> UnresolvedReductions; |
8678 | for (auto *E : C->reduction_ops()) { |
8679 | |
8680 | if (E) { |
8681 | auto *ULE = cast<UnresolvedLookupExpr>(E); |
8682 | UnresolvedSet<8> Decls; |
8683 | for (auto *D : ULE->decls()) { |
8684 | NamedDecl *InstD = |
8685 | cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D)); |
8686 | Decls.addDecl(InstD, InstD->getAccess()); |
8687 | } |
8688 | UnresolvedReductions.push_back(UnresolvedLookupExpr::Create( |
8689 | SemaRef.Context, , |
8690 | ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo, |
8691 | , ULE->isOverloaded(), Decls.begin(), Decls.end())); |
8692 | } else |
8693 | UnresolvedReductions.push_back(nullptr); |
8694 | } |
8695 | return getDerived().RebuildOMPTaskReductionClause( |
8696 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), |
8697 | C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions); |
8698 | } |
8699 | |
8700 | template <typename Derived> |
8701 | OMPClause * |
8702 | TreeTransform<Derived>::TransformOMPInReductionClause(OMPInReductionClause *C) { |
8703 | llvm::SmallVector<Expr *, 16> Vars; |
8704 | Vars.reserve(C->varlist_size()); |
8705 | for (auto *VE : C->varlists()) { |
8706 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8707 | if (EVar.isInvalid()) |
8708 | return nullptr; |
8709 | Vars.push_back(EVar.get()); |
8710 | } |
8711 | CXXScopeSpec ReductionIdScopeSpec; |
8712 | ReductionIdScopeSpec.Adopt(C->getQualifierLoc()); |
8713 | |
8714 | DeclarationNameInfo NameInfo = C->getNameInfo(); |
8715 | if (NameInfo.getName()) { |
8716 | NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo); |
8717 | if (!NameInfo.getName()) |
8718 | return nullptr; |
8719 | } |
8720 | |
8721 | |
8722 | llvm::SmallVector<Expr *, 16> UnresolvedReductions; |
8723 | for (auto *E : C->reduction_ops()) { |
8724 | |
8725 | if (E) { |
8726 | auto *ULE = cast<UnresolvedLookupExpr>(E); |
8727 | UnresolvedSet<8> Decls; |
8728 | for (auto *D : ULE->decls()) { |
8729 | NamedDecl *InstD = |
8730 | cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D)); |
8731 | Decls.addDecl(InstD, InstD->getAccess()); |
8732 | } |
8733 | UnresolvedReductions.push_back(UnresolvedLookupExpr::Create( |
8734 | SemaRef.Context, , |
8735 | ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo, |
8736 | , ULE->isOverloaded(), Decls.begin(), Decls.end())); |
8737 | } else |
8738 | UnresolvedReductions.push_back(nullptr); |
8739 | } |
8740 | return getDerived().RebuildOMPInReductionClause( |
8741 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), |
8742 | C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions); |
8743 | } |
8744 | |
8745 | template <typename Derived> |
8746 | OMPClause * |
8747 | TreeTransform<Derived>::TransformOMPLinearClause(OMPLinearClause *C) { |
8748 | llvm::SmallVector<Expr *, 16> Vars; |
8749 | Vars.reserve(C->varlist_size()); |
8750 | for (auto *VE : C->varlists()) { |
8751 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8752 | if (EVar.isInvalid()) |
8753 | return nullptr; |
8754 | Vars.push_back(EVar.get()); |
8755 | } |
8756 | ExprResult Step = getDerived().TransformExpr(C->getStep()); |
8757 | if (Step.isInvalid()) |
8758 | return nullptr; |
8759 | return getDerived().RebuildOMPLinearClause( |
8760 | Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(), |
8761 | C->getModifierLoc(), C->getColonLoc(), C->getEndLoc()); |
8762 | } |
8763 | |
8764 | template <typename Derived> |
8765 | OMPClause * |
8766 | TreeTransform<Derived>::TransformOMPAlignedClause(OMPAlignedClause *C) { |
8767 | llvm::SmallVector<Expr *, 16> Vars; |
8768 | Vars.reserve(C->varlist_size()); |
8769 | for (auto *VE : C->varlists()) { |
8770 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8771 | if (EVar.isInvalid()) |
8772 | return nullptr; |
8773 | Vars.push_back(EVar.get()); |
8774 | } |
8775 | ExprResult Alignment = getDerived().TransformExpr(C->getAlignment()); |
8776 | if (Alignment.isInvalid()) |
8777 | return nullptr; |
8778 | return getDerived().RebuildOMPAlignedClause( |
8779 | Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(), |
8780 | C->getColonLoc(), C->getEndLoc()); |
8781 | } |
8782 | |
8783 | template <typename Derived> |
8784 | OMPClause * |
8785 | TreeTransform<Derived>::TransformOMPCopyinClause(OMPCopyinClause *C) { |
8786 | llvm::SmallVector<Expr *, 16> Vars; |
8787 | Vars.reserve(C->varlist_size()); |
8788 | for (auto *VE : C->varlists()) { |
8789 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8790 | if (EVar.isInvalid()) |
8791 | return nullptr; |
8792 | Vars.push_back(EVar.get()); |
8793 | } |
8794 | return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(), |
8795 | C->getLParenLoc(), C->getEndLoc()); |
8796 | } |
8797 | |
8798 | template <typename Derived> |
8799 | OMPClause * |
8800 | TreeTransform<Derived>::TransformOMPCopyprivateClause(OMPCopyprivateClause *C) { |
8801 | llvm::SmallVector<Expr *, 16> Vars; |
8802 | Vars.reserve(C->varlist_size()); |
8803 | for (auto *VE : C->varlists()) { |
8804 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8805 | if (EVar.isInvalid()) |
8806 | return nullptr; |
8807 | Vars.push_back(EVar.get()); |
8808 | } |
8809 | return getDerived().RebuildOMPCopyprivateClause( |
8810 | Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8811 | } |
8812 | |
8813 | template <typename Derived> |
8814 | OMPClause *TreeTransform<Derived>::TransformOMPFlushClause(OMPFlushClause *C) { |
8815 | llvm::SmallVector<Expr *, 16> Vars; |
8816 | Vars.reserve(C->varlist_size()); |
8817 | for (auto *VE : C->varlists()) { |
8818 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8819 | if (EVar.isInvalid()) |
8820 | return nullptr; |
8821 | Vars.push_back(EVar.get()); |
8822 | } |
8823 | return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(), |
8824 | C->getLParenLoc(), C->getEndLoc()); |
8825 | } |
8826 | |
8827 | template <typename Derived> |
8828 | OMPClause * |
8829 | TreeTransform<Derived>::TransformOMPDependClause(OMPDependClause *C) { |
8830 | llvm::SmallVector<Expr *, 16> Vars; |
8831 | Vars.reserve(C->varlist_size()); |
8832 | for (auto *VE : C->varlists()) { |
8833 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8834 | if (EVar.isInvalid()) |
8835 | return nullptr; |
8836 | Vars.push_back(EVar.get()); |
8837 | } |
8838 | return getDerived().RebuildOMPDependClause( |
8839 | C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(), Vars, |
8840 | C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8841 | } |
8842 | |
8843 | template <typename Derived> |
8844 | OMPClause * |
8845 | TreeTransform<Derived>::TransformOMPDeviceClause(OMPDeviceClause *C) { |
8846 | ExprResult E = getDerived().TransformExpr(C->getDevice()); |
8847 | if (E.isInvalid()) |
8848 | return nullptr; |
8849 | return getDerived().RebuildOMPDeviceClause(E.get(), C->getBeginLoc(), |
8850 | C->getLParenLoc(), C->getEndLoc()); |
8851 | } |
8852 | |
8853 | template <typename Derived, class T> |
8854 | bool transformOMPMappableExprListClause( |
8855 | TreeTransform<Derived> &TT, OMPMappableExprListClause<T> *C, |
8856 | llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec, |
8857 | DeclarationNameInfo &MapperIdInfo, |
8858 | llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) { |
8859 | |
8860 | Vars.reserve(C->varlist_size()); |
8861 | for (auto *VE : C->varlists()) { |
8862 | ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE)); |
8863 | if (EVar.isInvalid()) |
8864 | return true; |
8865 | Vars.push_back(EVar.get()); |
8866 | } |
8867 | |
8868 | NestedNameSpecifierLoc QualifierLoc; |
8869 | if (C->getMapperQualifierLoc()) { |
8870 | QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc( |
8871 | C->getMapperQualifierLoc()); |
8872 | if (!QualifierLoc) |
8873 | return true; |
8874 | } |
8875 | MapperIdScopeSpec.Adopt(QualifierLoc); |
8876 | MapperIdInfo = C->getMapperIdInfo(); |
8877 | if (MapperIdInfo.getName()) { |
8878 | MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo); |
8879 | if (!MapperIdInfo.getName()) |
8880 | return true; |
8881 | } |
8882 | |
8883 | |
8884 | for (auto *E : C->mapperlists()) { |
8885 | |
8886 | if (E) { |
8887 | auto *ULE = cast<UnresolvedLookupExpr>(E); |
8888 | UnresolvedSet<8> Decls; |
8889 | for (auto *D : ULE->decls()) { |
8890 | NamedDecl *InstD = |
8891 | cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D)); |
8892 | Decls.addDecl(InstD, InstD->getAccess()); |
8893 | } |
8894 | UnresolvedMappers.push_back(UnresolvedLookupExpr::Create( |
8895 | TT.getSema().Context, , |
8896 | MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context), |
8897 | MapperIdInfo, , ULE->isOverloaded(), Decls.begin(), |
8898 | Decls.end())); |
8899 | } else { |
8900 | UnresolvedMappers.push_back(nullptr); |
8901 | } |
8902 | } |
8903 | return false; |
8904 | } |
8905 | |
8906 | template <typename Derived> |
8907 | OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) { |
8908 | OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8909 | llvm::SmallVector<Expr *, 16> Vars; |
8910 | CXXScopeSpec MapperIdScopeSpec; |
8911 | DeclarationNameInfo MapperIdInfo; |
8912 | llvm::SmallVector<Expr *, 16> UnresolvedMappers; |
8913 | if (transformOMPMappableExprListClause<Derived, OMPMapClause>( |
8914 | *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers)) |
8915 | return nullptr; |
8916 | return getDerived().RebuildOMPMapClause( |
8917 | C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(), MapperIdScopeSpec, |
8918 | MapperIdInfo, C->getMapType(), C->isImplicitMapType(), C->getMapLoc(), |
8919 | C->getColonLoc(), Vars, Locs, UnresolvedMappers); |
8920 | } |
8921 | |
8922 | template <typename Derived> |
8923 | OMPClause * |
8924 | TreeTransform<Derived>::TransformOMPAllocateClause(OMPAllocateClause *C) { |
8925 | Expr *Allocator = C->getAllocator(); |
8926 | if (Allocator) { |
8927 | ExprResult AllocatorRes = getDerived().TransformExpr(Allocator); |
8928 | if (AllocatorRes.isInvalid()) |
8929 | return nullptr; |
8930 | Allocator = AllocatorRes.get(); |
8931 | } |
8932 | llvm::SmallVector<Expr *, 16> Vars; |
8933 | Vars.reserve(C->varlist_size()); |
8934 | for (auto *VE : C->varlists()) { |
8935 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
8936 | if (EVar.isInvalid()) |
8937 | return nullptr; |
8938 | Vars.push_back(EVar.get()); |
8939 | } |
8940 | return getDerived().RebuildOMPAllocateClause( |
8941 | Allocator, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), |
8942 | C->getEndLoc()); |
8943 | } |
8944 | |
8945 | template <typename Derived> |
8946 | OMPClause * |
8947 | TreeTransform<Derived>::TransformOMPNumTeamsClause(OMPNumTeamsClause *C) { |
8948 | ExprResult E = getDerived().TransformExpr(C->getNumTeams()); |
8949 | if (E.isInvalid()) |
8950 | return nullptr; |
8951 | return getDerived().RebuildOMPNumTeamsClause( |
8952 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8953 | } |
8954 | |
8955 | template <typename Derived> |
8956 | OMPClause * |
8957 | TreeTransform<Derived>::TransformOMPThreadLimitClause(OMPThreadLimitClause *C) { |
8958 | ExprResult E = getDerived().TransformExpr(C->getThreadLimit()); |
8959 | if (E.isInvalid()) |
8960 | return nullptr; |
8961 | return getDerived().RebuildOMPThreadLimitClause( |
8962 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8963 | } |
8964 | |
8965 | template <typename Derived> |
8966 | OMPClause * |
8967 | TreeTransform<Derived>::TransformOMPPriorityClause(OMPPriorityClause *C) { |
8968 | ExprResult E = getDerived().TransformExpr(C->getPriority()); |
8969 | if (E.isInvalid()) |
8970 | return nullptr; |
8971 | return getDerived().RebuildOMPPriorityClause( |
8972 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8973 | } |
8974 | |
8975 | template <typename Derived> |
8976 | OMPClause * |
8977 | TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *C) { |
8978 | ExprResult E = getDerived().TransformExpr(C->getGrainsize()); |
8979 | if (E.isInvalid()) |
8980 | return nullptr; |
8981 | return getDerived().RebuildOMPGrainsizeClause( |
8982 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8983 | } |
8984 | |
8985 | template <typename Derived> |
8986 | OMPClause * |
8987 | TreeTransform<Derived>::TransformOMPNumTasksClause(OMPNumTasksClause *C) { |
8988 | ExprResult E = getDerived().TransformExpr(C->getNumTasks()); |
8989 | if (E.isInvalid()) |
8990 | return nullptr; |
8991 | return getDerived().RebuildOMPNumTasksClause( |
8992 | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
8993 | } |
8994 | |
8995 | template <typename Derived> |
8996 | OMPClause *TreeTransform<Derived>::TransformOMPHintClause(OMPHintClause *C) { |
8997 | ExprResult E = getDerived().TransformExpr(C->getHint()); |
8998 | if (E.isInvalid()) |
8999 | return nullptr; |
9000 | return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(), |
9001 | C->getLParenLoc(), C->getEndLoc()); |
9002 | } |
9003 | |
9004 | template <typename Derived> |
9005 | OMPClause *TreeTransform<Derived>::TransformOMPDistScheduleClause( |
9006 | OMPDistScheduleClause *C) { |
9007 | ExprResult E = getDerived().TransformExpr(C->getChunkSize()); |
9008 | if (E.isInvalid()) |
9009 | return nullptr; |
9010 | return getDerived().RebuildOMPDistScheduleClause( |
9011 | C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(), |
9012 | C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc()); |
9013 | } |
9014 | |
9015 | template <typename Derived> |
9016 | OMPClause * |
9017 | TreeTransform<Derived>::TransformOMPDefaultmapClause(OMPDefaultmapClause *C) { |
9018 | return C; |
9019 | } |
9020 | |
9021 | template <typename Derived> |
9022 | OMPClause *TreeTransform<Derived>::TransformOMPToClause(OMPToClause *C) { |
9023 | OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
9024 | llvm::SmallVector<Expr *, 16> Vars; |
9025 | CXXScopeSpec MapperIdScopeSpec; |
9026 | DeclarationNameInfo MapperIdInfo; |
9027 | llvm::SmallVector<Expr *, 16> UnresolvedMappers; |
9028 | if (transformOMPMappableExprListClause<Derived, OMPToClause>( |
9029 | *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers)) |
9030 | return nullptr; |
9031 | return getDerived().RebuildOMPToClause(Vars, MapperIdScopeSpec, MapperIdInfo, |
9032 | Locs, UnresolvedMappers); |
9033 | } |
9034 | |
9035 | template <typename Derived> |
9036 | OMPClause *TreeTransform<Derived>::TransformOMPFromClause(OMPFromClause *C) { |
9037 | OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
9038 | llvm::SmallVector<Expr *, 16> Vars; |
9039 | CXXScopeSpec MapperIdScopeSpec; |
9040 | DeclarationNameInfo MapperIdInfo; |
9041 | llvm::SmallVector<Expr *, 16> UnresolvedMappers; |
9042 | if (transformOMPMappableExprListClause<Derived, OMPFromClause>( |
9043 | *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers)) |
9044 | return nullptr; |
9045 | return getDerived().RebuildOMPFromClause( |
9046 | Vars, MapperIdScopeSpec, MapperIdInfo, Locs, UnresolvedMappers); |
9047 | } |
9048 | |
9049 | template <typename Derived> |
9050 | OMPClause *TreeTransform<Derived>::TransformOMPUseDevicePtrClause( |
9051 | OMPUseDevicePtrClause *C) { |
9052 | llvm::SmallVector<Expr *, 16> Vars; |
9053 | Vars.reserve(C->varlist_size()); |
9054 | for (auto *VE : C->varlists()) { |
9055 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
9056 | if (EVar.isInvalid()) |
9057 | return nullptr; |
9058 | Vars.push_back(EVar.get()); |
9059 | } |
9060 | OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
9061 | return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs); |
9062 | } |
9063 | |
9064 | template <typename Derived> |
9065 | OMPClause * |
9066 | TreeTransform<Derived>::TransformOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { |
9067 | llvm::SmallVector<Expr *, 16> Vars; |
9068 | Vars.reserve(C->varlist_size()); |
9069 | for (auto *VE : C->varlists()) { |
9070 | ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); |
9071 | if (EVar.isInvalid()) |
9072 | return nullptr; |
9073 | Vars.push_back(EVar.get()); |
9074 | } |
9075 | OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); |
9076 | return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs); |
9077 | } |
9078 | |
9079 | |
9080 | |
9081 | |
9082 | template<typename Derived> |
9083 | ExprResult |
9084 | TreeTransform<Derived>::TransformConstantExpr(ConstantExpr *E) { |
9085 | return TransformExpr(E->getSubExpr()); |
9086 | } |
9087 | |
9088 | template<typename Derived> |
9089 | ExprResult |
9090 | TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) { |
9091 | if (!E->isTypeDependent()) |
9092 | return E; |
9093 | |
9094 | return getDerived().RebuildPredefinedExpr(E->getLocation(), |
9095 | E->getIdentKind()); |
9096 | } |
9097 | |
9098 | template<typename Derived> |
9099 | ExprResult |
9100 | TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) { |
9101 | NestedNameSpecifierLoc QualifierLoc; |
9102 | if (E->getQualifierLoc()) { |
9103 | QualifierLoc |
9104 | = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc()); |
9105 | if (!QualifierLoc) |
9106 | return ExprError(); |
9107 | } |
9108 | |
9109 | ValueDecl *ND |
9110 | = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(), |
9111 | E->getDecl())); |
9112 | if (!ND) |
9113 | return ExprError(); |
9114 | |
9115 | DeclarationNameInfo NameInfo = E->getNameInfo(); |
9116 | if (NameInfo.getName()) { |
9117 | NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo); |
9118 | if (!NameInfo.getName()) |
9119 | return ExprError(); |
9120 | } |
9121 | |
9122 | if (!getDerived().AlwaysRebuild() && |
9123 | QualifierLoc == E->getQualifierLoc() && |
9124 | ND == E->getDecl() && |
9125 | NameInfo.getName() == E->getDecl()->getDeclName() && |
9126 | !E->hasExplicitTemplateArgs()) { |
9127 | |
9128 | |
9129 | |
9130 | SemaRef.MarkDeclRefReferenced(E); |
9131 | |
9132 | return E; |
9133 | } |
9134 | |
9135 | TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr; |
9136 | if (E->hasExplicitTemplateArgs()) { |
9137 | TemplateArgs = &TransArgs; |
9138 | TransArgs.setLAngleLoc(E->getLAngleLoc()); |
9139 | TransArgs.setRAngleLoc(E->getRAngleLoc()); |
9140 | if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), |
9141 | E->getNumTemplateArgs(), |
9142 | TransArgs)) |
9143 | return ExprError(); |
9144 | } |
9145 | |
9146 | return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo, |
9147 | TemplateArgs); |
9148 | } |
9149 | |
9150 | template<typename Derived> |
9151 | ExprResult |
9152 | TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) { |
9153 | return E; |
9154 | } |
9155 | |
9156 | template <typename Derived> |
9157 | ExprResult TreeTransform<Derived>::TransformFixedPointLiteral( |
9158 | FixedPointLiteral *E) { |
9159 | return E; |
9160 | } |
9161 | |
9162 | template<typename Derived> |
9163 | ExprResult |
9164 | TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) { |
9165 | return E; |
9166 | } |
9167 | |
9168 | template<typename Derived> |
9169 | ExprResult |
9170 | TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) { |
9171 | return E; |
9172 | } |
9173 | |
9174 | template<typename Derived> |
9175 | ExprResult |
9176 | TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) { |
9177 | return E; |
9178 | } |
9179 | |
9180 | template<typename Derived> |
9181 | ExprResult |
9182 | TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) { |
9183 | return E; |
9184 | } |
9185 | |
9186 | template<typename Derived> |
9187 | ExprResult |
9188 | TreeTransform<Derived>::TransformUserDefinedLiteral(UserDefinedLiteral *E) { |
9189 | if (FunctionDecl *FD = E->getDirectCallee()) |
9190 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), FD); |
9191 | return SemaRef.MaybeBindToTemporary(E); |
9192 | } |
9193 | |
9194 | template<typename Derived> |
9195 | ExprResult |
9196 | TreeTransform<Derived>::TransformGenericSelectionExpr(GenericSelectionExpr *E) { |
9197 | ExprResult ControllingExpr = |
9198 | getDerived().TransformExpr(E->getControllingExpr()); |
9199 | if (ControllingExpr.isInvalid()) |
9200 | return ExprError(); |
9201 | |
9202 | SmallVector<Expr *, 4> AssocExprs; |
9203 | SmallVector<TypeSourceInfo *, 4> AssocTypes; |
9204 | for (const GenericSelectionExpr::Association &Assoc : E->associations()) { |
9205 | TypeSourceInfo *TSI = Assoc.getTypeSourceInfo(); |
9206 | if (TSI) { |
9207 | TypeSourceInfo *AssocType = getDerived().TransformType(TSI); |
9208 | if (!AssocType) |
9209 | return ExprError(); |
9210 | AssocTypes.push_back(AssocType); |
9211 | } else { |
9212 | AssocTypes.push_back(nullptr); |
9213 | } |
9214 | |
9215 | ExprResult AssocExpr = |
9216 | getDerived().TransformExpr(Assoc.getAssociationExpr()); |
9217 | if (AssocExpr.isInvalid()) |
9218 | return ExprError(); |
9219 | AssocExprs.push_back(AssocExpr.get()); |
9220 | } |
9221 | |
9222 | return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(), |
9223 | E->getDefaultLoc(), |
9224 | E->getRParenLoc(), |
9225 | ControllingExpr.get(), |
9226 | AssocTypes, |
9227 | AssocExprs); |
9228 | } |
9229 | |
9230 | template<typename Derived> |
9231 | ExprResult |
9232 | TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) { |
9233 | ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); |
9234 | if (SubExpr.isInvalid()) |
9235 | return ExprError(); |
9236 | |
9237 | if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) |
9238 | return E; |
9239 | |
9240 | return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(), |
9241 | E->getRParen()); |
9242 | } |
9243 | |
9244 | |
9245 | |
9246 | |
9247 | template<typename Derived> |
9248 | ExprResult |
9249 | TreeTransform<Derived>::TransformAddressOfOperand(Expr *E) { |
9250 | if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E)) |
9251 | return getDerived().TransformDependentScopeDeclRefExpr(DRE, true, nullptr); |
9252 | else |
9253 | return getDerived().TransformExpr(E); |
9254 | } |
9255 | |
9256 | template<typename Derived> |
9257 | ExprResult |
9258 | TreeTransform<Derived>::TransformUnaryOperator(UnaryOperator *E) { |
9259 | ExprResult SubExpr; |
9260 | if (E->getOpcode() == UO_AddrOf) |
9261 | SubExpr = TransformAddressOfOperand(E->getSubExpr()); |
9262 | else |
9263 | SubExpr = TransformExpr(E->getSubExpr()); |
9264 | if (SubExpr.isInvalid()) |
9265 | return ExprError(); |
9266 | |
9267 | if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) |
9268 | return E; |
9269 | |
9270 | return getDerived().RebuildUnaryOperator(E->getOperatorLoc(), |
9271 | E->getOpcode(), |
9272 | SubExpr.get()); |
9273 | } |
9274 | |
9275 | template<typename Derived> |
9276 | ExprResult |
9277 | TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) { |
9278 | |
9279 | TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo()); |
9280 | if (!Type) |
9281 | return ExprError(); |
9282 | |
9283 | |
9284 | |
9285 | |
9286 | |
9287 | |
9288 | |
9289 | bool ExprChanged = false; |
9290 | typedef Sema::OffsetOfComponent Component; |
9291 | SmallVector<Component, 4> Components; |
9292 | for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { |
9293 | const OffsetOfNode &ON = E->getComponent(I); |
9294 | Component Comp; |
9295 | Comp.isBrackets = true; |
9296 | Comp.LocStart = ON.getSourceRange().getBegin(); |
9297 | Comp.LocEnd = ON.getSourceRange().getEnd(); |
9298 | switch (ON.getKind()) { |
9299 | case OffsetOfNode::Array: { |
9300 | Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex()); |
9301 | ExprResult Index = getDerived().TransformExpr(FromIndex); |
9302 | if (Index.isInvalid()) |
9303 | return ExprError(); |
9304 | |
9305 | ExprChanged = ExprChanged || Index.get() != FromIndex; |
9306 | Comp.isBrackets = true; |
9307 | Comp.U.E = Index.get(); |
9308 | break; |
9309 | } |
9310 | |
9311 | case OffsetOfNode::Field: |
9312 | case OffsetOfNode::Identifier: |
9313 | Comp.isBrackets = false; |
9314 | Comp.U.IdentInfo = ON.getFieldName(); |
9315 | if (!Comp.U.IdentInfo) |
9316 | continue; |
9317 | |
9318 | break; |
9319 | |
9320 | case OffsetOfNode::Base: |
9321 | |
9322 | continue; |
9323 | } |
9324 | |
9325 | Components.push_back(Comp); |
9326 | } |
9327 | |
9328 | |
9329 | if (!getDerived().AlwaysRebuild() && |
9330 | Type == E->getTypeSourceInfo() && |
9331 | !ExprChanged) |
9332 | return E; |
9333 | |
9334 | |
9335 | return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type, |
9336 | Components, E->getRParenLoc()); |
9337 | } |
9338 | |
9339 | template<typename Derived> |
9340 | ExprResult |
9341 | TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) { |
9342 | (0) . __assert_fail ("(!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) && \"opaque value expression requires transformation\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 9343, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) && |
9343 | (0) . __assert_fail ("(!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) && \"opaque value expression requires transformation\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 9343, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "opaque value expression requires transformation"); |
9344 | return E; |
9345 | } |
9346 | |
9347 | template<typename Derived> |
9348 | ExprResult |
9349 | TreeTransform<Derived>::TransformTypoExpr(TypoExpr *E) { |
9350 | return E; |
9351 | } |
9352 | |
9353 | template<typename Derived> |
9354 | ExprResult |
9355 | TreeTransform<Derived>::TransformPseudoObjectExpr(PseudoObjectExpr *E) { |
9356 | |
9357 | |
9358 | |
9359 | |
9360 | |
9361 | |
9362 | Expr *newSyntacticForm = SemaRef.recreateSyntacticForm(E); |
9363 | ExprResult result = getDerived().TransformExpr(newSyntacticForm); |
9364 | if (result.isInvalid()) return ExprError(); |
9365 | |
9366 | |
9367 | |
9368 | |
9369 | if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject)) |
9370 | result = SemaRef.checkPseudoObjectRValue(result.get()); |
9371 | |
9372 | return result; |
9373 | } |
9374 | |
9375 | template<typename Derived> |
9376 | ExprResult |
9377 | TreeTransform<Derived>::TransformUnaryExprOrTypeTraitExpr( |
9378 | UnaryExprOrTypeTraitExpr *E) { |
9379 | if (E->isArgumentType()) { |
9380 | TypeSourceInfo *OldT = E->getArgumentTypeInfo(); |
9381 | |
9382 | TypeSourceInfo *NewT = getDerived().TransformType(OldT); |
9383 | if (!NewT) |
9384 | return ExprError(); |
9385 | |
9386 | if (!getDerived().AlwaysRebuild() && OldT == NewT) |
9387 | return E; |
9388 | |
9389 | return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(), |
9390 | E->getKind(), |
9391 | E->getSourceRange()); |
9392 | } |
9393 | |
9394 | |
9395 | |
9396 | |
9397 | EnterExpressionEvaluationContext Unevaluated( |
9398 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, |
9399 | Sema::ReuseLambdaContextDecl); |
9400 | |
9401 | |
9402 | |
9403 | TypeSourceInfo *RecoveryTSI = nullptr; |
9404 | ExprResult SubExpr; |
9405 | auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr()); |
9406 | if (auto *DRE = |
9407 | PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr) |
9408 | SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr( |
9409 | PE, DRE, false, &RecoveryTSI); |
9410 | else |
9411 | SubExpr = getDerived().TransformExpr(E->getArgumentExpr()); |
9412 | |
9413 | if (RecoveryTSI) { |
9414 | return getDerived().RebuildUnaryExprOrTypeTrait( |
9415 | RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange()); |
9416 | } else if (SubExpr.isInvalid()) |
9417 | return ExprError(); |
9418 | |
9419 | if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr()) |
9420 | return E; |
9421 | |
9422 | return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(), |
9423 | E->getOperatorLoc(), |
9424 | E->getKind(), |
9425 | E->getSourceRange()); |
9426 | } |
9427 | |
9428 | template<typename Derived> |
9429 | ExprResult |
9430 | TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) { |
9431 | ExprResult LHS = getDerived().TransformExpr(E->getLHS()); |
9432 | if (LHS.isInvalid()) |
9433 | return ExprError(); |
9434 | |
9435 | ExprResult RHS = getDerived().TransformExpr(E->getRHS()); |
9436 | if (RHS.isInvalid()) |
9437 | return ExprError(); |
9438 | |
9439 | |
9440 | if (!getDerived().AlwaysRebuild() && |
9441 | LHS.get() == E->getLHS() && |
9442 | RHS.get() == E->getRHS()) |
9443 | return E; |
9444 | |
9445 | return getDerived().RebuildArraySubscriptExpr( |
9446 | LHS.get(), |
9447 | E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc()); |
9448 | } |
9449 | |
9450 | template <typename Derived> |
9451 | ExprResult |
9452 | TreeTransform<Derived>::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) { |
9453 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
9454 | if (Base.isInvalid()) |
9455 | return ExprError(); |
9456 | |
9457 | ExprResult LowerBound; |
9458 | if (E->getLowerBound()) { |
9459 | LowerBound = getDerived().TransformExpr(E->getLowerBound()); |
9460 | if (LowerBound.isInvalid()) |
9461 | return ExprError(); |
9462 | } |
9463 | |
9464 | ExprResult Length; |
9465 | if (E->getLength()) { |
9466 | Length = getDerived().TransformExpr(E->getLength()); |
9467 | if (Length.isInvalid()) |
9468 | return ExprError(); |
9469 | } |
9470 | |
9471 | if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() && |
9472 | LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength()) |
9473 | return E; |
9474 | |
9475 | return getDerived().RebuildOMPArraySectionExpr( |
9476 | Base.get(), E->getBase()->getEndLoc(), LowerBound.get(), E->getColonLoc(), |
9477 | Length.get(), E->getRBracketLoc()); |
9478 | } |
9479 | |
9480 | template<typename Derived> |
9481 | ExprResult |
9482 | TreeTransform<Derived>::TransformCallExpr(CallExpr *E) { |
9483 | |
9484 | ExprResult Callee = getDerived().TransformExpr(E->getCallee()); |
9485 | if (Callee.isInvalid()) |
9486 | return ExprError(); |
9487 | |
9488 | |
9489 | bool ArgChanged = false; |
9490 | SmallVector<Expr*, 8> Args; |
9491 | if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, |
9492 | &ArgChanged)) |
9493 | return ExprError(); |
9494 | |
9495 | if (!getDerived().AlwaysRebuild() && |
9496 | Callee.get() == E->getCallee() && |
9497 | !ArgChanged) |
9498 | return SemaRef.MaybeBindToTemporary(E); |
9499 | |
9500 | |
9501 | SourceLocation FakeLParenLoc |
9502 | = ((Expr *)Callee.get())->getSourceRange().getBegin(); |
9503 | return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc, |
9504 | Args, |
9505 | E->getRParenLoc()); |
9506 | } |
9507 | |
9508 | template<typename Derived> |
9509 | ExprResult |
9510 | TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) { |
9511 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
9512 | if (Base.isInvalid()) |
9513 | return ExprError(); |
9514 | |
9515 | NestedNameSpecifierLoc QualifierLoc; |
9516 | if (E->hasQualifier()) { |
9517 | QualifierLoc |
9518 | = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc()); |
9519 | |
9520 | if (!QualifierLoc) |
9521 | return ExprError(); |
9522 | } |
9523 | SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc(); |
9524 | |
9525 | ValueDecl *Member |
9526 | = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(), |
9527 | E->getMemberDecl())); |
9528 | if (!Member) |
9529 | return ExprError(); |
9530 | |
9531 | NamedDecl *FoundDecl = E->getFoundDecl(); |
9532 | if (FoundDecl == E->getMemberDecl()) { |
9533 | FoundDecl = Member; |
9534 | } else { |
9535 | FoundDecl = cast_or_null<NamedDecl>( |
9536 | getDerived().TransformDecl(E->getMemberLoc(), FoundDecl)); |
9537 | if (!FoundDecl) |
9538 | return ExprError(); |
9539 | } |
9540 | |
9541 | if (!getDerived().AlwaysRebuild() && |
9542 | Base.get() == E->getBase() && |
9543 | QualifierLoc == E->getQualifierLoc() && |
9544 | Member == E->getMemberDecl() && |
9545 | FoundDecl == E->getFoundDecl() && |
9546 | !E->hasExplicitTemplateArgs()) { |
9547 | |
9548 | |
9549 | |
9550 | SemaRef.MarkMemberReferenced(E); |
9551 | |
9552 | return E; |
9553 | } |
9554 | |
9555 | TemplateArgumentListInfo TransArgs; |
9556 | if (E->hasExplicitTemplateArgs()) { |
9557 | TransArgs.setLAngleLoc(E->getLAngleLoc()); |
9558 | TransArgs.setRAngleLoc(E->getRAngleLoc()); |
9559 | if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), |
9560 | E->getNumTemplateArgs(), |
9561 | TransArgs)) |
9562 | return ExprError(); |
9563 | } |
9564 | |
9565 | |
9566 | SourceLocation FakeOperatorLoc = |
9567 | SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd()); |
9568 | |
9569 | |
9570 | |
9571 | |
9572 | |
9573 | NamedDecl *FirstQualifierInScope = nullptr; |
9574 | DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo(); |
9575 | if (MemberNameInfo.getName()) { |
9576 | MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo); |
9577 | if (!MemberNameInfo.getName()) |
9578 | return ExprError(); |
9579 | } |
9580 | |
9581 | return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc, |
9582 | E->isArrow(), |
9583 | QualifierLoc, |
9584 | TemplateKWLoc, |
9585 | MemberNameInfo, |
9586 | Member, |
9587 | FoundDecl, |
9588 | (E->hasExplicitTemplateArgs() |
9589 | ? &TransArgs : nullptr), |
9590 | FirstQualifierInScope); |
9591 | } |
9592 | |
9593 | template<typename Derived> |
9594 | ExprResult |
9595 | TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) { |
9596 | ExprResult LHS = getDerived().TransformExpr(E->getLHS()); |
9597 | if (LHS.isInvalid()) |
9598 | return ExprError(); |
9599 | |
9600 | ExprResult RHS = getDerived().TransformExpr(E->getRHS()); |
9601 | if (RHS.isInvalid()) |
9602 | return ExprError(); |
9603 | |
9604 | if (!getDerived().AlwaysRebuild() && |
9605 | LHS.get() == E->getLHS() && |
9606 | RHS.get() == E->getRHS()) |
9607 | return E; |
9608 | |
9609 | Sema::FPContractStateRAII FPContractState(getSema()); |
9610 | getSema().FPFeatures = E->getFPFeatures(); |
9611 | |
9612 | return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(), |
9613 | LHS.get(), RHS.get()); |
9614 | } |
9615 | |
9616 | template<typename Derived> |
9617 | ExprResult |
9618 | TreeTransform<Derived>::TransformCompoundAssignOperator( |
9619 | CompoundAssignOperator *E) { |
9620 | return getDerived().TransformBinaryOperator(E); |
9621 | } |
9622 | |
9623 | template<typename Derived> |
9624 | ExprResult TreeTransform<Derived>:: |
9625 | TransformBinaryConditionalOperator(BinaryConditionalOperator *e) { |
9626 | |
9627 | |
9628 | |
9629 | ExprResult commonExpr = getDerived().TransformExpr(e->getCommon()); |
9630 | if (commonExpr.isInvalid()) |
9631 | return ExprError(); |
9632 | |
9633 | ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr()); |
9634 | if (rhs.isInvalid()) |
9635 | return ExprError(); |
9636 | |
9637 | if (!getDerived().AlwaysRebuild() && |
9638 | commonExpr.get() == e->getCommon() && |
9639 | rhs.get() == e->getFalseExpr()) |
9640 | return e; |
9641 | |
9642 | return getDerived().RebuildConditionalOperator(commonExpr.get(), |
9643 | e->getQuestionLoc(), |
9644 | nullptr, |
9645 | e->getColonLoc(), |
9646 | rhs.get()); |
9647 | } |
9648 | |
9649 | template<typename Derived> |
9650 | ExprResult |
9651 | TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) { |
9652 | ExprResult Cond = getDerived().TransformExpr(E->getCond()); |
9653 | if (Cond.isInvalid()) |
9654 | return ExprError(); |
9655 | |
9656 | ExprResult LHS = getDerived().TransformExpr(E->getLHS()); |
9657 | if (LHS.isInvalid()) |
9658 | return ExprError(); |
9659 | |
9660 | ExprResult RHS = getDerived().TransformExpr(E->getRHS()); |
9661 | if (RHS.isInvalid()) |
9662 | return ExprError(); |
9663 | |
9664 | if (!getDerived().AlwaysRebuild() && |
9665 | Cond.get() == E->getCond() && |
9666 | LHS.get() == E->getLHS() && |
9667 | RHS.get() == E->getRHS()) |
9668 | return E; |
9669 | |
9670 | return getDerived().RebuildConditionalOperator(Cond.get(), |
9671 | E->getQuestionLoc(), |
9672 | LHS.get(), |
9673 | E->getColonLoc(), |
9674 | RHS.get()); |
9675 | } |
9676 | |
9677 | template<typename Derived> |
9678 | ExprResult |
9679 | TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) { |
9680 | |
9681 | |
9682 | return getDerived().TransformExpr(E->getSubExprAsWritten()); |
9683 | } |
9684 | |
9685 | template<typename Derived> |
9686 | ExprResult |
9687 | TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) { |
9688 | TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten()); |
9689 | if (!Type) |
9690 | return ExprError(); |
9691 | |
9692 | ExprResult SubExpr |
9693 | = getDerived().TransformExpr(E->getSubExprAsWritten()); |
9694 | if (SubExpr.isInvalid()) |
9695 | return ExprError(); |
9696 | |
9697 | if (!getDerived().AlwaysRebuild() && |
9698 | Type == E->getTypeInfoAsWritten() && |
9699 | SubExpr.get() == E->getSubExpr()) |
9700 | return E; |
9701 | |
9702 | return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(), |
9703 | Type, |
9704 | E->getRParenLoc(), |
9705 | SubExpr.get()); |
9706 | } |
9707 | |
9708 | template<typename Derived> |
9709 | ExprResult |
9710 | TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) { |
9711 | TypeSourceInfo *OldT = E->getTypeSourceInfo(); |
9712 | TypeSourceInfo *NewT = getDerived().TransformType(OldT); |
9713 | if (!NewT) |
9714 | return ExprError(); |
9715 | |
9716 | ExprResult Init = getDerived().TransformExpr(E->getInitializer()); |
9717 | if (Init.isInvalid()) |
9718 | return ExprError(); |
9719 | |
9720 | if (!getDerived().AlwaysRebuild() && |
9721 | OldT == NewT && |
9722 | Init.get() == E->getInitializer()) |
9723 | return SemaRef.MaybeBindToTemporary(E); |
9724 | |
9725 | |
9726 | |
9727 | |
9728 | |
9729 | return getDerived().RebuildCompoundLiteralExpr( |
9730 | E->getLParenLoc(), NewT, |
9731 | E->getInitializer()->getEndLoc(), Init.get()); |
9732 | } |
9733 | |
9734 | template<typename Derived> |
9735 | ExprResult |
9736 | TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) { |
9737 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
9738 | if (Base.isInvalid()) |
9739 | return ExprError(); |
9740 | |
9741 | if (!getDerived().AlwaysRebuild() && |
9742 | Base.get() == E->getBase()) |
9743 | return E; |
9744 | |
9745 | |
9746 | SourceLocation FakeOperatorLoc = |
9747 | SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc()); |
9748 | return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc, |
9749 | E->getAccessorLoc(), |
9750 | E->getAccessor()); |
9751 | } |
9752 | |
9753 | template<typename Derived> |
9754 | ExprResult |
9755 | TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) { |
9756 | if (InitListExpr *Syntactic = E->getSyntacticForm()) |
9757 | E = Syntactic; |
9758 | |
9759 | bool InitChanged = false; |
9760 | |
9761 | EnterExpressionEvaluationContext Context( |
9762 | getSema(), EnterExpressionEvaluationContext::InitList); |
9763 | |
9764 | SmallVector<Expr*, 4> Inits; |
9765 | if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false, |
9766 | Inits, &InitChanged)) |
9767 | return ExprError(); |
9768 | |
9769 | if (!getDerived().AlwaysRebuild() && !InitChanged) { |
9770 | |
9771 | |
9772 | |
9773 | |
9774 | } |
9775 | |
9776 | return getDerived().RebuildInitList(E->getLBraceLoc(), Inits, |
9777 | E->getRBraceLoc()); |
9778 | } |
9779 | |
9780 | template<typename Derived> |
9781 | ExprResult |
9782 | TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) { |
9783 | Designation Desig; |
9784 | |
9785 | |
9786 | ExprResult Init = getDerived().TransformExpr(E->getInit()); |
9787 | if (Init.isInvalid()) |
9788 | return ExprError(); |
9789 | |
9790 | |
9791 | SmallVector<Expr*, 4> ArrayExprs; |
9792 | bool ExprChanged = false; |
9793 | for (const DesignatedInitExpr::Designator &D : E->designators()) { |
9794 | if (D.isFieldDesignator()) { |
9795 | Desig.AddDesignator(Designator::getField(D.getFieldName(), |
9796 | D.getDotLoc(), |
9797 | D.getFieldLoc())); |
9798 | if (D.getField()) { |
9799 | FieldDecl *Field = cast_or_null<FieldDecl>( |
9800 | getDerived().TransformDecl(D.getFieldLoc(), D.getField())); |
9801 | if (Field != D.getField()) |
9802 | |
9803 | |
9804 | ExprChanged = true; |
9805 | } else { |
9806 | |
9807 | |
9808 | |
9809 | ExprChanged = true; |
9810 | } |
9811 | continue; |
9812 | } |
9813 | |
9814 | if (D.isArrayDesignator()) { |
9815 | ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D)); |
9816 | if (Index.isInvalid()) |
9817 | return ExprError(); |
9818 | |
9819 | Desig.AddDesignator( |
9820 | Designator::getArray(Index.get(), D.getLBracketLoc())); |
9821 | |
9822 | ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D); |
9823 | ArrayExprs.push_back(Index.get()); |
9824 | continue; |
9825 | } |
9826 | |
9827 | (0) . __assert_fail ("D.isArrayRangeDesignator() && \"New kind of designator?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 9827, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D.isArrayRangeDesignator() && "New kind of designator?"); |
9828 | ExprResult Start |
9829 | = getDerived().TransformExpr(E->getArrayRangeStart(D)); |
9830 | if (Start.isInvalid()) |
9831 | return ExprError(); |
9832 | |
9833 | ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D)); |
9834 | if (End.isInvalid()) |
9835 | return ExprError(); |
9836 | |
9837 | Desig.AddDesignator(Designator::getArrayRange(Start.get(), |
9838 | End.get(), |
9839 | D.getLBracketLoc(), |
9840 | D.getEllipsisLoc())); |
9841 | |
9842 | ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) || |
9843 | End.get() != E->getArrayRangeEnd(D); |
9844 | |
9845 | ArrayExprs.push_back(Start.get()); |
9846 | ArrayExprs.push_back(End.get()); |
9847 | } |
9848 | |
9849 | if (!getDerived().AlwaysRebuild() && |
9850 | Init.get() == E->getInit() && |
9851 | !ExprChanged) |
9852 | return E; |
9853 | |
9854 | return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs, |
9855 | E->getEqualOrColonLoc(), |
9856 | E->usesGNUSyntax(), Init.get()); |
9857 | } |
9858 | |
9859 | |
9860 | |
9861 | template<typename Derived> |
9862 | ExprResult |
9863 | TreeTransform<Derived>::TransformDesignatedInitUpdateExpr( |
9864 | DesignatedInitUpdateExpr *E) { |
9865 | llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of " |
9866 | "initializer"); |
9867 | return ExprError(); |
9868 | } |
9869 | |
9870 | template<typename Derived> |
9871 | ExprResult |
9872 | TreeTransform<Derived>::TransformNoInitExpr( |
9873 | NoInitExpr *E) { |
9874 | llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer"); |
9875 | return ExprError(); |
9876 | } |
9877 | |
9878 | template<typename Derived> |
9879 | ExprResult |
9880 | TreeTransform<Derived>::TransformArrayInitLoopExpr(ArrayInitLoopExpr *E) { |
9881 | llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer"); |
9882 | return ExprError(); |
9883 | } |
9884 | |
9885 | template<typename Derived> |
9886 | ExprResult |
9887 | TreeTransform<Derived>::TransformArrayInitIndexExpr(ArrayInitIndexExpr *E) { |
9888 | llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer"); |
9889 | return ExprError(); |
9890 | } |
9891 | |
9892 | template<typename Derived> |
9893 | ExprResult |
9894 | TreeTransform<Derived>::TransformImplicitValueInitExpr( |
9895 | ImplicitValueInitExpr *E) { |
9896 | TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName()); |
9897 | |
9898 | |
9899 | |
9900 | QualType T = getDerived().TransformType(E->getType()); |
9901 | if (T.isNull()) |
9902 | return ExprError(); |
9903 | |
9904 | if (!getDerived().AlwaysRebuild() && |
9905 | T == E->getType()) |
9906 | return E; |
9907 | |
9908 | return getDerived().RebuildImplicitValueInitExpr(T); |
9909 | } |
9910 | |
9911 | template<typename Derived> |
9912 | ExprResult |
9913 | TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) { |
9914 | TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo()); |
9915 | if (!TInfo) |
9916 | return ExprError(); |
9917 | |
9918 | ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); |
9919 | if (SubExpr.isInvalid()) |
9920 | return ExprError(); |
9921 | |
9922 | if (!getDerived().AlwaysRebuild() && |
9923 | TInfo == E->getWrittenTypeInfo() && |
9924 | SubExpr.get() == E->getSubExpr()) |
9925 | return E; |
9926 | |
9927 | return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(), |
9928 | TInfo, E->getRParenLoc()); |
9929 | } |
9930 | |
9931 | template<typename Derived> |
9932 | ExprResult |
9933 | TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) { |
9934 | bool ArgumentChanged = false; |
9935 | SmallVector<Expr*, 4> Inits; |
9936 | if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits, |
9937 | &ArgumentChanged)) |
9938 | return ExprError(); |
9939 | |
9940 | return getDerived().RebuildParenListExpr(E->getLParenLoc(), |
9941 | Inits, |
9942 | E->getRParenLoc()); |
9943 | } |
9944 | |
9945 | |
9946 | |
9947 | |
9948 | |
9949 | |
9950 | template<typename Derived> |
9951 | ExprResult |
9952 | TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) { |
9953 | Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(), |
9954 | E->getLabel()); |
9955 | if (!LD) |
9956 | return ExprError(); |
9957 | |
9958 | return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(), |
9959 | cast<LabelDecl>(LD)); |
9960 | } |
9961 | |
9962 | template<typename Derived> |
9963 | ExprResult |
9964 | TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) { |
9965 | SemaRef.ActOnStartStmtExpr(); |
9966 | StmtResult SubStmt |
9967 | = getDerived().TransformCompoundStmt(E->getSubStmt(), true); |
9968 | if (SubStmt.isInvalid()) { |
9969 | SemaRef.ActOnStmtExprError(); |
9970 | return ExprError(); |
9971 | } |
9972 | |
9973 | if (!getDerived().AlwaysRebuild() && |
9974 | SubStmt.get() == E->getSubStmt()) { |
9975 | |
9976 | SemaRef.ActOnStmtExprError(); |
9977 | return SemaRef.MaybeBindToTemporary(E); |
9978 | } |
9979 | |
9980 | return getDerived().RebuildStmtExpr(E->getLParenLoc(), |
9981 | SubStmt.get(), |
9982 | E->getRParenLoc()); |
9983 | } |
9984 | |
9985 | template<typename Derived> |
9986 | ExprResult |
9987 | TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) { |
9988 | ExprResult Cond = getDerived().TransformExpr(E->getCond()); |
9989 | if (Cond.isInvalid()) |
9990 | return ExprError(); |
9991 | |
9992 | ExprResult LHS = getDerived().TransformExpr(E->getLHS()); |
9993 | if (LHS.isInvalid()) |
9994 | return ExprError(); |
9995 | |
9996 | ExprResult RHS = getDerived().TransformExpr(E->getRHS()); |
9997 | if (RHS.isInvalid()) |
9998 | return ExprError(); |
9999 | |
10000 | if (!getDerived().AlwaysRebuild() && |
10001 | Cond.get() == E->getCond() && |
10002 | LHS.get() == E->getLHS() && |
10003 | RHS.get() == E->getRHS()) |
10004 | return E; |
10005 | |
10006 | return getDerived().RebuildChooseExpr(E->getBuiltinLoc(), |
10007 | Cond.get(), LHS.get(), RHS.get(), |
10008 | E->getRParenLoc()); |
10009 | } |
10010 | |
10011 | template<typename Derived> |
10012 | ExprResult |
10013 | TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) { |
10014 | return E; |
10015 | } |
10016 | |
10017 | template<typename Derived> |
10018 | ExprResult |
10019 | TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) { |
10020 | switch (E->getOperator()) { |
10021 | case OO_New: |
10022 | case OO_Delete: |
10023 | case OO_Array_New: |
10024 | case OO_Array_Delete: |
10025 | llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr"); |
10026 | |
10027 | case OO_Call: { |
10028 | |
10029 | (0) . __assert_fail ("E->getNumArgs() >= 1 && \"Object call is missing arguments\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 10029, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(E->getNumArgs() >= 1 && "Object call is missing arguments"); |
10030 | |
10031 | |
10032 | ExprResult Object = getDerived().TransformExpr(E->getArg(0)); |
10033 | if (Object.isInvalid()) |
10034 | return ExprError(); |
10035 | |
10036 | |
10037 | SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken( |
10038 | static_cast<Expr *>(Object.get())->getEndLoc()); |
10039 | |
10040 | |
10041 | SmallVector<Expr*, 8> Args; |
10042 | if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true, |
10043 | Args)) |
10044 | return ExprError(); |
10045 | |
10046 | return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args, |
10047 | E->getEndLoc()); |
10048 | } |
10049 | |
10050 | #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ |
10051 | case OO_##Name: |
10052 | #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) |
10053 | #include "clang/Basic/OperatorKinds.def" |
10054 | case OO_Subscript: |
10055 | |
10056 | break; |
10057 | |
10058 | case OO_Conditional: |
10059 | llvm_unreachable("conditional operator is not actually overloadable"); |
10060 | |
10061 | case OO_None: |
10062 | case NUM_OVERLOADED_OPERATORS: |
10063 | llvm_unreachable("not an overloaded operator?"); |
10064 | } |
10065 | |
10066 | ExprResult Callee = getDerived().TransformExpr(E->getCallee()); |
10067 | if (Callee.isInvalid()) |
10068 | return ExprError(); |
10069 | |
10070 | ExprResult First; |
10071 | if (E->getOperator() == OO_Amp) |
10072 | First = getDerived().TransformAddressOfOperand(E->getArg(0)); |
10073 | else |
10074 | First = getDerived().TransformExpr(E->getArg(0)); |
10075 | if (First.isInvalid()) |
10076 | return ExprError(); |
10077 | |
10078 | ExprResult Second; |
10079 | if (E->getNumArgs() == 2) { |
10080 | Second = getDerived().TransformExpr(E->getArg(1)); |
10081 | if (Second.isInvalid()) |
10082 | return ExprError(); |
10083 | } |
10084 | |
10085 | if (!getDerived().AlwaysRebuild() && |
10086 | Callee.get() == E->getCallee() && |
10087 | First.get() == E->getArg(0) && |
10088 | (E->getNumArgs() != 2 || Second.get() == E->getArg(1))) |
10089 | return SemaRef.MaybeBindToTemporary(E); |
10090 | |
10091 | Sema::FPContractStateRAII FPContractState(getSema()); |
10092 | getSema().FPFeatures = E->getFPFeatures(); |
10093 | |
10094 | return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(), |
10095 | E->getOperatorLoc(), |
10096 | Callee.get(), |
10097 | First.get(), |
10098 | Second.get()); |
10099 | } |
10100 | |
10101 | template<typename Derived> |
10102 | ExprResult |
10103 | TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) { |
10104 | return getDerived().TransformCallExpr(E); |
10105 | } |
10106 | |
10107 | template<typename Derived> |
10108 | ExprResult |
10109 | TreeTransform<Derived>::TransformCUDAKernelCallExpr(CUDAKernelCallExpr *E) { |
10110 | |
10111 | ExprResult Callee = getDerived().TransformExpr(E->getCallee()); |
10112 | if (Callee.isInvalid()) |
10113 | return ExprError(); |
10114 | |
10115 | |
10116 | ExprResult EC = getDerived().TransformCallExpr(E->getConfig()); |
10117 | if (EC.isInvalid()) |
10118 | return ExprError(); |
10119 | |
10120 | |
10121 | bool ArgChanged = false; |
10122 | SmallVector<Expr*, 8> Args; |
10123 | if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, |
10124 | &ArgChanged)) |
10125 | return ExprError(); |
10126 | |
10127 | if (!getDerived().AlwaysRebuild() && |
10128 | Callee.get() == E->getCallee() && |
10129 | !ArgChanged) |
10130 | return SemaRef.MaybeBindToTemporary(E); |
10131 | |
10132 | |
10133 | SourceLocation FakeLParenLoc |
10134 | = ((Expr *)Callee.get())->getSourceRange().getBegin(); |
10135 | return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc, |
10136 | Args, |
10137 | E->getRParenLoc(), EC.get()); |
10138 | } |
10139 | |
10140 | template<typename Derived> |
10141 | ExprResult |
10142 | TreeTransform<Derived>::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) { |
10143 | TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten()); |
10144 | if (!Type) |
10145 | return ExprError(); |
10146 | |
10147 | ExprResult SubExpr |
10148 | = getDerived().TransformExpr(E->getSubExprAsWritten()); |
10149 | if (SubExpr.isInvalid()) |
10150 | return ExprError(); |
10151 | |
10152 | if (!getDerived().AlwaysRebuild() && |
10153 | Type == E->getTypeInfoAsWritten() && |
10154 | SubExpr.get() == E->getSubExpr()) |
10155 | return E; |
10156 | return getDerived().RebuildCXXNamedCastExpr( |
10157 | E->getOperatorLoc(), E->getStmtClass(), E->getAngleBrackets().getBegin(), |
10158 | Type, E->getAngleBrackets().getEnd(), |
10159 | |
10160 | E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc()); |
10161 | } |
10162 | |
10163 | template<typename Derived> |
10164 | ExprResult |
10165 | TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) { |
10166 | return getDerived().TransformCXXNamedCastExpr(E); |
10167 | } |
10168 | |
10169 | template<typename Derived> |
10170 | ExprResult |
10171 | TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) { |
10172 | return getDerived().TransformCXXNamedCastExpr(E); |
10173 | } |
10174 | |
10175 | template<typename Derived> |
10176 | ExprResult |
10177 | TreeTransform<Derived>::TransformCXXReinterpretCastExpr( |
10178 | CXXReinterpretCastExpr *E) { |
10179 | return getDerived().TransformCXXNamedCastExpr(E); |
10180 | } |
10181 | |
10182 | template<typename Derived> |
10183 | ExprResult |
10184 | TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) { |
10185 | return getDerived().TransformCXXNamedCastExpr(E); |
10186 | } |
10187 | |
10188 | template<typename Derived> |
10189 | ExprResult |
10190 | TreeTransform<Derived>::TransformCXXFunctionalCastExpr( |
10191 | CXXFunctionalCastExpr *E) { |
10192 | TypeSourceInfo *Type = |
10193 | getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten()); |
10194 | if (!Type) |
10195 | return ExprError(); |
10196 | |
10197 | ExprResult SubExpr |
10198 | = getDerived().TransformExpr(E->getSubExprAsWritten()); |
10199 | if (SubExpr.isInvalid()) |
10200 | return ExprError(); |
10201 | |
10202 | if (!getDerived().AlwaysRebuild() && |
10203 | Type == E->getTypeInfoAsWritten() && |
10204 | SubExpr.get() == E->getSubExpr()) |
10205 | return E; |
10206 | |
10207 | return getDerived().RebuildCXXFunctionalCastExpr(Type, |
10208 | E->getLParenLoc(), |
10209 | SubExpr.get(), |
10210 | E->getRParenLoc(), |
10211 | E->isListInitialization()); |
10212 | } |
10213 | |
10214 | template<typename Derived> |
10215 | ExprResult |
10216 | TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) { |
10217 | if (E->isTypeOperand()) { |
10218 | TypeSourceInfo *TInfo |
10219 | = getDerived().TransformType(E->getTypeOperandSourceInfo()); |
10220 | if (!TInfo) |
10221 | return ExprError(); |
10222 | |
10223 | if (!getDerived().AlwaysRebuild() && |
10224 | TInfo == E->getTypeOperandSourceInfo()) |
10225 | return E; |
10226 | |
10227 | return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(), |
10228 | TInfo, E->getEndLoc()); |
10229 | } |
10230 | |
10231 | |
10232 | |
10233 | |
10234 | |
10235 | EnterExpressionEvaluationContext Unevaluated( |
10236 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated, |
10237 | Sema::ReuseLambdaContextDecl); |
10238 | |
10239 | ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand()); |
10240 | if (SubExpr.isInvalid()) |
10241 | return ExprError(); |
10242 | |
10243 | if (!getDerived().AlwaysRebuild() && |
10244 | SubExpr.get() == E->getExprOperand()) |
10245 | return E; |
10246 | |
10247 | return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(), |
10248 | SubExpr.get(), E->getEndLoc()); |
10249 | } |
10250 | |
10251 | template<typename Derived> |
10252 | ExprResult |
10253 | TreeTransform<Derived>::TransformCXXUuidofExpr(CXXUuidofExpr *E) { |
10254 | if (E->isTypeOperand()) { |
10255 | TypeSourceInfo *TInfo |
10256 | = getDerived().TransformType(E->getTypeOperandSourceInfo()); |
10257 | if (!TInfo) |
10258 | return ExprError(); |
10259 | |
10260 | if (!getDerived().AlwaysRebuild() && |
10261 | TInfo == E->getTypeOperandSourceInfo()) |
10262 | return E; |
10263 | |
10264 | return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(), |
10265 | TInfo, E->getEndLoc()); |
10266 | } |
10267 | |
10268 | EnterExpressionEvaluationContext Unevaluated( |
10269 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated); |
10270 | |
10271 | ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand()); |
10272 | if (SubExpr.isInvalid()) |
10273 | return ExprError(); |
10274 | |
10275 | if (!getDerived().AlwaysRebuild() && |
10276 | SubExpr.get() == E->getExprOperand()) |
10277 | return E; |
10278 | |
10279 | return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(), |
10280 | SubExpr.get(), E->getEndLoc()); |
10281 | } |
10282 | |
10283 | template<typename Derived> |
10284 | ExprResult |
10285 | TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { |
10286 | return E; |
10287 | } |
10288 | |
10289 | template<typename Derived> |
10290 | ExprResult |
10291 | TreeTransform<Derived>::TransformCXXNullPtrLiteralExpr( |
10292 | CXXNullPtrLiteralExpr *E) { |
10293 | return E; |
10294 | } |
10295 | |
10296 | template<typename Derived> |
10297 | ExprResult |
10298 | TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) { |
10299 | QualType T = getSema().getCurrentThisType(); |
10300 | |
10301 | if (!getDerived().AlwaysRebuild() && T == E->getType()) { |
10302 | |
10303 | getSema().CheckCXXThisCapture(E->getBeginLoc()); |
10304 | return E; |
10305 | } |
10306 | |
10307 | return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit()); |
10308 | } |
10309 | |
10310 | template<typename Derived> |
10311 | ExprResult |
10312 | TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) { |
10313 | ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); |
10314 | if (SubExpr.isInvalid()) |
10315 | return ExprError(); |
10316 | |
10317 | if (!getDerived().AlwaysRebuild() && |
10318 | SubExpr.get() == E->getSubExpr()) |
10319 | return E; |
10320 | |
10321 | return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(), |
10322 | E->isThrownVariableInScope()); |
10323 | } |
10324 | |
10325 | template<typename Derived> |
10326 | ExprResult |
10327 | TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) { |
10328 | ParmVarDecl *Param = cast_or_null<ParmVarDecl>( |
10329 | getDerived().TransformDecl(E->getBeginLoc(), E->getParam())); |
10330 | if (!Param) |
10331 | return ExprError(); |
10332 | |
10333 | if (!getDerived().AlwaysRebuild() && |
10334 | Param == E->getParam()) |
10335 | return E; |
10336 | |
10337 | return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param); |
10338 | } |
10339 | |
10340 | template<typename Derived> |
10341 | ExprResult |
10342 | TreeTransform<Derived>::TransformCXXDefaultInitExpr(CXXDefaultInitExpr *E) { |
10343 | FieldDecl *Field = cast_or_null<FieldDecl>( |
10344 | getDerived().TransformDecl(E->getBeginLoc(), E->getField())); |
10345 | if (!Field) |
10346 | return ExprError(); |
10347 | |
10348 | if (!getDerived().AlwaysRebuild() && Field == E->getField()) |
10349 | return E; |
10350 | |
10351 | return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field); |
10352 | } |
10353 | |
10354 | template<typename Derived> |
10355 | ExprResult |
10356 | TreeTransform<Derived>::TransformCXXScalarValueInitExpr( |
10357 | CXXScalarValueInitExpr *E) { |
10358 | TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo()); |
10359 | if (!T) |
10360 | return ExprError(); |
10361 | |
10362 | if (!getDerived().AlwaysRebuild() && |
10363 | T == E->getTypeSourceInfo()) |
10364 | return E; |
10365 | |
10366 | return getDerived().RebuildCXXScalarValueInitExpr(T, |
10367 | ->getTypeLoc().getEndLoc(), |
10368 | E->getRParenLoc()); |
10369 | } |
10370 | |
10371 | template<typename Derived> |
10372 | ExprResult |
10373 | TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) { |
10374 | |
10375 | TypeSourceInfo *AllocTypeInfo = |
10376 | getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo()); |
10377 | if (!AllocTypeInfo) |
10378 | return ExprError(); |
10379 | |
10380 | |
10381 | ExprResult ArraySize = getDerived().TransformExpr(E->getArraySize()); |
10382 | if (ArraySize.isInvalid()) |
10383 | return ExprError(); |
10384 | |
10385 | |
10386 | bool ArgumentChanged = false; |
10387 | SmallVector<Expr*, 8> PlacementArgs; |
10388 | if (getDerived().TransformExprs(E->getPlacementArgs(), |
10389 | E->getNumPlacementArgs(), true, |
10390 | PlacementArgs, &ArgumentChanged)) |
10391 | return ExprError(); |
10392 | |
10393 | |
10394 | Expr *OldInit = E->getInitializer(); |
10395 | ExprResult NewInit; |
10396 | if (OldInit) |
10397 | NewInit = getDerived().TransformInitializer(OldInit, true); |
10398 | if (NewInit.isInvalid()) |
10399 | return ExprError(); |
10400 | |
10401 | |
10402 | FunctionDecl *OperatorNew = nullptr; |
10403 | if (E->getOperatorNew()) { |
10404 | OperatorNew = cast_or_null<FunctionDecl>( |
10405 | getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew())); |
10406 | if (!OperatorNew) |
10407 | return ExprError(); |
10408 | } |
10409 | |
10410 | FunctionDecl *OperatorDelete = nullptr; |
10411 | if (E->getOperatorDelete()) { |
10412 | OperatorDelete = cast_or_null<FunctionDecl>( |
10413 | getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete())); |
10414 | if (!OperatorDelete) |
10415 | return ExprError(); |
10416 | } |
10417 | |
10418 | if (!getDerived().AlwaysRebuild() && |
10419 | AllocTypeInfo == E->getAllocatedTypeSourceInfo() && |
10420 | ArraySize.get() == E->getArraySize() && |
10421 | NewInit.get() == OldInit && |
10422 | OperatorNew == E->getOperatorNew() && |
10423 | OperatorDelete == E->getOperatorDelete() && |
10424 | !ArgumentChanged) { |
10425 | |
10426 | |
10427 | if (OperatorNew) |
10428 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew); |
10429 | if (OperatorDelete) |
10430 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete); |
10431 | |
10432 | if (E->isArray() && !E->getAllocatedType()->isDependentType()) { |
10433 | QualType ElementType |
10434 | = SemaRef.Context.getBaseElementType(E->getAllocatedType()); |
10435 | if (const RecordType *RecordT = ElementType->getAs<RecordType>()) { |
10436 | CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl()); |
10437 | if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) { |
10438 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor); |
10439 | } |
10440 | } |
10441 | } |
10442 | |
10443 | return E; |
10444 | } |
10445 | |
10446 | QualType AllocType = AllocTypeInfo->getType(); |
10447 | if (!ArraySize.get()) { |
10448 | |
10449 | |
10450 | |
10451 | |
10452 | |
10453 | const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType); |
10454 | if (!ArrayT) { |
10455 | |
10456 | } else if (const ConstantArrayType *ConsArrayT |
10457 | = dyn_cast<ConstantArrayType>(ArrayT)) { |
10458 | ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(), |
10459 | SemaRef.Context.getSizeType(), |
10460 | E->getBeginLoc()); |
10461 | AllocType = ConsArrayT->getElementType(); |
10462 | } else if (const DependentSizedArrayType *DepArrayT |
10463 | = dyn_cast<DependentSizedArrayType>(ArrayT)) { |
10464 | if (DepArrayT->getSizeExpr()) { |
10465 | ArraySize = DepArrayT->getSizeExpr(); |
10466 | AllocType = DepArrayT->getElementType(); |
10467 | } |
10468 | } |
10469 | } |
10470 | |
10471 | return getDerived().RebuildCXXNewExpr( |
10472 | E->getBeginLoc(), E->isGlobalNew(), |
10473 | E->getBeginLoc(), PlacementArgs, |
10474 | E->getBeginLoc(), E->getTypeIdParens(), AllocType, |
10475 | AllocTypeInfo, ArraySize.get(), E->getDirectInitRange(), NewInit.get()); |
10476 | } |
10477 | |
10478 | template<typename Derived> |
10479 | ExprResult |
10480 | TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) { |
10481 | ExprResult Operand = getDerived().TransformExpr(E->getArgument()); |
10482 | if (Operand.isInvalid()) |
10483 | return ExprError(); |
10484 | |
10485 | |
10486 | FunctionDecl *OperatorDelete = nullptr; |
10487 | if (E->getOperatorDelete()) { |
10488 | OperatorDelete = cast_or_null<FunctionDecl>( |
10489 | getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete())); |
10490 | if (!OperatorDelete) |
10491 | return ExprError(); |
10492 | } |
10493 | |
10494 | if (!getDerived().AlwaysRebuild() && |
10495 | Operand.get() == E->getArgument() && |
10496 | OperatorDelete == E->getOperatorDelete()) { |
10497 | |
10498 | |
10499 | if (OperatorDelete) |
10500 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete); |
10501 | |
10502 | if (!E->getArgument()->isTypeDependent()) { |
10503 | QualType Destroyed = SemaRef.Context.getBaseElementType( |
10504 | E->getDestroyedType()); |
10505 | if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) { |
10506 | CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl()); |
10507 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), |
10508 | SemaRef.LookupDestructor(Record)); |
10509 | } |
10510 | } |
10511 | |
10512 | return E; |
10513 | } |
10514 | |
10515 | return getDerived().RebuildCXXDeleteExpr( |
10516 | E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get()); |
10517 | } |
10518 | |
10519 | template<typename Derived> |
10520 | ExprResult |
10521 | TreeTransform<Derived>::TransformCXXPseudoDestructorExpr( |
10522 | CXXPseudoDestructorExpr *E) { |
10523 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
10524 | if (Base.isInvalid()) |
10525 | return ExprError(); |
10526 | |
10527 | ParsedType ObjectTypePtr; |
10528 | bool MayBePseudoDestructor = false; |
10529 | Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(), |
10530 | E->getOperatorLoc(), |
10531 | E->isArrow()? tok::arrow : tok::period, |
10532 | ObjectTypePtr, |
10533 | MayBePseudoDestructor); |
10534 | if (Base.isInvalid()) |
10535 | return ExprError(); |
10536 | |
10537 | QualType ObjectType = ObjectTypePtr.get(); |
10538 | NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc(); |
10539 | if (QualifierLoc) { |
10540 | QualifierLoc |
10541 | = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType); |
10542 | if (!QualifierLoc) |
10543 | return ExprError(); |
10544 | } |
10545 | CXXScopeSpec SS; |
10546 | SS.Adopt(QualifierLoc); |
10547 | |
10548 | PseudoDestructorTypeStorage Destroyed; |
10549 | if (E->getDestroyedTypeInfo()) { |
10550 | TypeSourceInfo *DestroyedTypeInfo |
10551 | = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(), |
10552 | ObjectType, nullptr, SS); |
10553 | if (!DestroyedTypeInfo) |
10554 | return ExprError(); |
10555 | Destroyed = DestroyedTypeInfo; |
10556 | } else if (!ObjectType.isNull() && ObjectType->isDependentType()) { |
10557 | |
10558 | |
10559 | Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(), |
10560 | E->getDestroyedTypeLoc()); |
10561 | } else { |
10562 | |
10563 | ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(), |
10564 | *E->getDestroyedTypeIdentifier(), |
10565 | E->getDestroyedTypeLoc(), |
10566 | , |
10567 | SS, ObjectTypePtr, |
10568 | false); |
10569 | if (!T) |
10570 | return ExprError(); |
10571 | |
10572 | Destroyed |
10573 | = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T), |
10574 | E->getDestroyedTypeLoc()); |
10575 | } |
10576 | |
10577 | TypeSourceInfo *ScopeTypeInfo = nullptr; |
10578 | if (E->getScopeTypeInfo()) { |
10579 | CXXScopeSpec EmptySS; |
10580 | ScopeTypeInfo = getDerived().TransformTypeInObjectScope( |
10581 | E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS); |
10582 | if (!ScopeTypeInfo) |
10583 | return ExprError(); |
10584 | } |
10585 | |
10586 | return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(), |
10587 | E->getOperatorLoc(), |
10588 | E->isArrow(), |
10589 | SS, |
10590 | ScopeTypeInfo, |
10591 | E->getColonColonLoc(), |
10592 | E->getTildeLoc(), |
10593 | Destroyed); |
10594 | } |
10595 | |
10596 | template <typename Derived> |
10597 | bool TreeTransform<Derived>::TransformOverloadExprDecls(OverloadExpr *Old, |
10598 | bool RequiresADL, |
10599 | LookupResult &R) { |
10600 | |
10601 | bool AllEmptyPacks = true; |
10602 | for (auto *OldD : Old->decls()) { |
10603 | Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD); |
10604 | if (!InstD) { |
10605 | |
10606 | |
10607 | if (isa<UsingShadowDecl>(OldD)) |
10608 | continue; |
10609 | else { |
10610 | R.clear(); |
10611 | return true; |
10612 | } |
10613 | } |
10614 | |
10615 | |
10616 | NamedDecl *SingleDecl = cast<NamedDecl>(InstD); |
10617 | ArrayRef<NamedDecl*> Decls = SingleDecl; |
10618 | if (auto *UPD = dyn_cast<UsingPackDecl>(InstD)) |
10619 | Decls = UPD->expansions(); |
10620 | |
10621 | |
10622 | for (auto *D : Decls) { |
10623 | if (auto *UD = dyn_cast<UsingDecl>(D)) { |
10624 | for (auto *SD : UD->shadows()) |
10625 | R.addDecl(SD); |
10626 | } else { |
10627 | R.addDecl(D); |
10628 | } |
10629 | } |
10630 | |
10631 | AllEmptyPacks &= Decls.empty(); |
10632 | }; |
10633 | |
10634 | |
10635 | |
10636 | |
10637 | |
10638 | |
10639 | |
10640 | if (AllEmptyPacks && !RequiresADL) { |
10641 | getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty) |
10642 | << isa<UnresolvedMemberExpr>(Old) << Old->getName(); |
10643 | return true; |
10644 | } |
10645 | |
10646 | |
10647 | |
10648 | R.resolveKind(); |
10649 | return false; |
10650 | } |
10651 | |
10652 | template<typename Derived> |
10653 | ExprResult |
10654 | TreeTransform<Derived>::TransformUnresolvedLookupExpr( |
10655 | UnresolvedLookupExpr *Old) { |
10656 | LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(), |
10657 | Sema::LookupOrdinaryName); |
10658 | |
10659 | |
10660 | if (TransformOverloadExprDecls(Old, Old->requiresADL(), R)) |
10661 | return ExprError(); |
10662 | |
10663 | |
10664 | CXXScopeSpec SS; |
10665 | if (Old->getQualifierLoc()) { |
10666 | NestedNameSpecifierLoc QualifierLoc |
10667 | = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc()); |
10668 | if (!QualifierLoc) |
10669 | return ExprError(); |
10670 | |
10671 | SS.Adopt(QualifierLoc); |
10672 | } |
10673 | |
10674 | if (Old->getNamingClass()) { |
10675 | CXXRecordDecl *NamingClass |
10676 | = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl( |
10677 | Old->getNameLoc(), |
10678 | Old->getNamingClass())); |
10679 | if (!NamingClass) { |
10680 | R.clear(); |
10681 | return ExprError(); |
10682 | } |
10683 | |
10684 | R.setNamingClass(NamingClass); |
10685 | } |
10686 | |
10687 | SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc(); |
10688 | |
10689 | |
10690 | |
10691 | if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) { |
10692 | NamedDecl *D = R.getAsSingle<NamedDecl>(); |
10693 | |
10694 | |
10695 | |
10696 | if (D && D->isCXXInstanceMember()) { |
10697 | return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R, |
10698 | , |
10699 | ); |
10700 | } |
10701 | |
10702 | return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL()); |
10703 | } |
10704 | |
10705 | |
10706 | |
10707 | TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc()); |
10708 | if (Old->hasExplicitTemplateArgs() && |
10709 | getDerived().TransformTemplateArguments(Old->getTemplateArgs(), |
10710 | Old->getNumTemplateArgs(), |
10711 | TransArgs)) { |
10712 | R.clear(); |
10713 | return ExprError(); |
10714 | } |
10715 | |
10716 | return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R, |
10717 | Old->requiresADL(), &TransArgs); |
10718 | } |
10719 | |
10720 | template<typename Derived> |
10721 | ExprResult |
10722 | TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) { |
10723 | bool ArgChanged = false; |
10724 | SmallVector<TypeSourceInfo *, 4> Args; |
10725 | for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) { |
10726 | TypeSourceInfo *From = E->getArg(I); |
10727 | TypeLoc FromTL = From->getTypeLoc(); |
10728 | if (!FromTL.getAs<PackExpansionTypeLoc>()) { |
10729 | TypeLocBuilder TLB; |
10730 | TLB.reserve(FromTL.getFullDataSize()); |
10731 | QualType To = getDerived().TransformType(TLB, FromTL); |
10732 | if (To.isNull()) |
10733 | return ExprError(); |
10734 | |
10735 | if (To == From->getType()) |
10736 | Args.push_back(From); |
10737 | else { |
10738 | Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To)); |
10739 | ArgChanged = true; |
10740 | } |
10741 | continue; |
10742 | } |
10743 | |
10744 | ArgChanged = true; |
10745 | |
10746 | |
10747 | PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>(); |
10748 | TypeLoc PatternTL = ExpansionTL.getPatternLoc(); |
10749 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
10750 | SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded); |
10751 | |
10752 | |
10753 | |
10754 | bool Expand = true; |
10755 | bool RetainExpansion = false; |
10756 | Optional<unsigned> OrigNumExpansions = |
10757 | ExpansionTL.getTypePtr()->getNumExpansions(); |
10758 | Optional<unsigned> NumExpansions = OrigNumExpansions; |
10759 | if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(), |
10760 | PatternTL.getSourceRange(), |
10761 | Unexpanded, |
10762 | Expand, RetainExpansion, |
10763 | NumExpansions)) |
10764 | return ExprError(); |
10765 | |
10766 | if (!Expand) { |
10767 | |
10768 | |
10769 | |
10770 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
10771 | |
10772 | TypeLocBuilder TLB; |
10773 | TLB.reserve(From->getTypeLoc().getFullDataSize()); |
10774 | |
10775 | QualType To = getDerived().TransformType(TLB, PatternTL); |
10776 | if (To.isNull()) |
10777 | return ExprError(); |
10778 | |
10779 | To = getDerived().RebuildPackExpansionType(To, |
10780 | PatternTL.getSourceRange(), |
10781 | ExpansionTL.getEllipsisLoc(), |
10782 | NumExpansions); |
10783 | if (To.isNull()) |
10784 | return ExprError(); |
10785 | |
10786 | PackExpansionTypeLoc ToExpansionTL |
10787 | = TLB.push<PackExpansionTypeLoc>(To); |
10788 | ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc()); |
10789 | Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To)); |
10790 | continue; |
10791 | } |
10792 | |
10793 | |
10794 | |
10795 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
10796 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I); |
10797 | TypeLocBuilder TLB; |
10798 | TLB.reserve(PatternTL.getFullDataSize()); |
10799 | QualType To = getDerived().TransformType(TLB, PatternTL); |
10800 | if (To.isNull()) |
10801 | return ExprError(); |
10802 | |
10803 | if (To->containsUnexpandedParameterPack()) { |
10804 | To = getDerived().RebuildPackExpansionType(To, |
10805 | PatternTL.getSourceRange(), |
10806 | ExpansionTL.getEllipsisLoc(), |
10807 | NumExpansions); |
10808 | if (To.isNull()) |
10809 | return ExprError(); |
10810 | |
10811 | PackExpansionTypeLoc ToExpansionTL |
10812 | = TLB.push<PackExpansionTypeLoc>(To); |
10813 | ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc()); |
10814 | } |
10815 | |
10816 | Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To)); |
10817 | } |
10818 | |
10819 | if (!RetainExpansion) |
10820 | continue; |
10821 | |
10822 | |
10823 | |
10824 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
10825 | |
10826 | TypeLocBuilder TLB; |
10827 | TLB.reserve(From->getTypeLoc().getFullDataSize()); |
10828 | |
10829 | QualType To = getDerived().TransformType(TLB, PatternTL); |
10830 | if (To.isNull()) |
10831 | return ExprError(); |
10832 | |
10833 | To = getDerived().RebuildPackExpansionType(To, |
10834 | PatternTL.getSourceRange(), |
10835 | ExpansionTL.getEllipsisLoc(), |
10836 | NumExpansions); |
10837 | if (To.isNull()) |
10838 | return ExprError(); |
10839 | |
10840 | PackExpansionTypeLoc ToExpansionTL |
10841 | = TLB.push<PackExpansionTypeLoc>(To); |
10842 | ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc()); |
10843 | Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To)); |
10844 | } |
10845 | |
10846 | if (!getDerived().AlwaysRebuild() && !ArgChanged) |
10847 | return E; |
10848 | |
10849 | return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args, |
10850 | E->getEndLoc()); |
10851 | } |
10852 | |
10853 | template<typename Derived> |
10854 | ExprResult |
10855 | TreeTransform<Derived>::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { |
10856 | TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo()); |
10857 | if (!T) |
10858 | return ExprError(); |
10859 | |
10860 | if (!getDerived().AlwaysRebuild() && |
10861 | T == E->getQueriedTypeSourceInfo()) |
10862 | return E; |
10863 | |
10864 | ExprResult SubExpr; |
10865 | { |
10866 | EnterExpressionEvaluationContext Unevaluated( |
10867 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated); |
10868 | SubExpr = getDerived().TransformExpr(E->getDimensionExpression()); |
10869 | if (SubExpr.isInvalid()) |
10870 | return ExprError(); |
10871 | |
10872 | if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression()) |
10873 | return E; |
10874 | } |
10875 | |
10876 | return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T, |
10877 | SubExpr.get(), E->getEndLoc()); |
10878 | } |
10879 | |
10880 | template<typename Derived> |
10881 | ExprResult |
10882 | TreeTransform<Derived>::TransformExpressionTraitExpr(ExpressionTraitExpr *E) { |
10883 | ExprResult SubExpr; |
10884 | { |
10885 | EnterExpressionEvaluationContext Unevaluated( |
10886 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated); |
10887 | SubExpr = getDerived().TransformExpr(E->getQueriedExpression()); |
10888 | if (SubExpr.isInvalid()) |
10889 | return ExprError(); |
10890 | |
10891 | if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression()) |
10892 | return E; |
10893 | } |
10894 | |
10895 | return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(), |
10896 | SubExpr.get(), E->getEndLoc()); |
10897 | } |
10898 | |
10899 | template <typename Derived> |
10900 | ExprResult TreeTransform<Derived>::TransformParenDependentScopeDeclRefExpr( |
10901 | ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken, |
10902 | TypeSourceInfo **RecoveryTSI) { |
10903 | ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr( |
10904 | DRE, AddrTaken, RecoveryTSI); |
10905 | |
10906 | |
10907 | if (!NewDRE.isUsable()) |
10908 | return NewDRE; |
10909 | |
10910 | |
10911 | if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE) |
10912 | return PE; |
10913 | return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(), |
10914 | PE->getRParen()); |
10915 | } |
10916 | |
10917 | template <typename Derived> |
10918 | ExprResult TreeTransform<Derived>::TransformDependentScopeDeclRefExpr( |
10919 | DependentScopeDeclRefExpr *E) { |
10920 | return TransformDependentScopeDeclRefExpr(E, , |
10921 | nullptr); |
10922 | } |
10923 | |
10924 | template<typename Derived> |
10925 | ExprResult |
10926 | TreeTransform<Derived>::TransformDependentScopeDeclRefExpr( |
10927 | DependentScopeDeclRefExpr *E, |
10928 | bool IsAddressOfOperand, |
10929 | TypeSourceInfo **RecoveryTSI) { |
10930 | getQualifierLoc()", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 10930, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(E->getQualifierLoc()); |
10931 | NestedNameSpecifierLoc QualifierLoc |
10932 | = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc()); |
10933 | if (!QualifierLoc) |
10934 | return ExprError(); |
10935 | SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc(); |
10936 | |
10937 | |
10938 | |
10939 | |
10940 | |
10941 | DeclarationNameInfo NameInfo |
10942 | = getDerived().TransformDeclarationNameInfo(E->getNameInfo()); |
10943 | if (!NameInfo.getName()) |
10944 | return ExprError(); |
10945 | |
10946 | if (!E->hasExplicitTemplateArgs()) { |
10947 | if (!getDerived().AlwaysRebuild() && |
10948 | QualifierLoc == E->getQualifierLoc() && |
10949 | |
10950 | |
10951 | NameInfo.getName() == E->getDeclName()) |
10952 | return E; |
10953 | |
10954 | return getDerived().RebuildDependentScopeDeclRefExpr( |
10955 | QualifierLoc, TemplateKWLoc, NameInfo, , |
10956 | IsAddressOfOperand, RecoveryTSI); |
10957 | } |
10958 | |
10959 | TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc()); |
10960 | if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), |
10961 | E->getNumTemplateArgs(), |
10962 | TransArgs)) |
10963 | return ExprError(); |
10964 | |
10965 | return getDerived().RebuildDependentScopeDeclRefExpr( |
10966 | QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand, |
10967 | RecoveryTSI); |
10968 | } |
10969 | |
10970 | template<typename Derived> |
10971 | ExprResult |
10972 | TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) { |
10973 | |
10974 | |
10975 | |
10976 | if ((E->getNumArgs() == 1 || |
10977 | (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) && |
10978 | (!getDerived().DropCallArgument(E->getArg(0))) && |
10979 | !E->isListInitialization()) |
10980 | return getDerived().TransformExpr(E->getArg(0)); |
10981 | |
10982 | TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName()); |
10983 | |
10984 | QualType T = getDerived().TransformType(E->getType()); |
10985 | if (T.isNull()) |
10986 | return ExprError(); |
10987 | |
10988 | CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>( |
10989 | getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor())); |
10990 | if (!Constructor) |
10991 | return ExprError(); |
10992 | |
10993 | bool ArgumentChanged = false; |
10994 | SmallVector<Expr*, 8> Args; |
10995 | { |
10996 | EnterExpressionEvaluationContext Context( |
10997 | getSema(), EnterExpressionEvaluationContext::InitList, |
10998 | E->isListInitialization()); |
10999 | if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, |
11000 | &ArgumentChanged)) |
11001 | return ExprError(); |
11002 | } |
11003 | |
11004 | if (!getDerived().AlwaysRebuild() && |
11005 | T == E->getType() && |
11006 | Constructor == E->getConstructor() && |
11007 | !ArgumentChanged) { |
11008 | |
11009 | |
11010 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor); |
11011 | return E; |
11012 | } |
11013 | |
11014 | return getDerived().RebuildCXXConstructExpr( |
11015 | T, E->getBeginLoc(), Constructor, E->isElidable(), Args, |
11016 | E->hadMultipleCandidates(), E->isListInitialization(), |
11017 | E->isStdInitListInitialization(), E->requiresZeroInitialization(), |
11018 | E->getConstructionKind(), E->getParenOrBraceRange()); |
11019 | } |
11020 | |
11021 | template<typename Derived> |
11022 | ExprResult TreeTransform<Derived>::TransformCXXInheritedCtorInitExpr( |
11023 | CXXInheritedCtorInitExpr *E) { |
11024 | QualType T = getDerived().TransformType(E->getType()); |
11025 | if (T.isNull()) |
11026 | return ExprError(); |
11027 | |
11028 | CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>( |
11029 | getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor())); |
11030 | if (!Constructor) |
11031 | return ExprError(); |
11032 | |
11033 | if (!getDerived().AlwaysRebuild() && |
11034 | T == E->getType() && |
11035 | Constructor == E->getConstructor()) { |
11036 | |
11037 | |
11038 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor); |
11039 | return E; |
11040 | } |
11041 | |
11042 | return getDerived().RebuildCXXInheritedCtorInitExpr( |
11043 | T, E->getLocation(), Constructor, |
11044 | E->constructsVBase(), E->inheritedFromVBase()); |
11045 | } |
11046 | |
11047 | |
11048 | |
11049 | |
11050 | |
11051 | template<typename Derived> |
11052 | ExprResult |
11053 | TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { |
11054 | return getDerived().TransformExpr(E->getSubExpr()); |
11055 | } |
11056 | |
11057 | |
11058 | |
11059 | |
11060 | |
11061 | |
11062 | template<typename Derived> |
11063 | ExprResult |
11064 | TreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *E) { |
11065 | return getDerived().TransformExpr(E->getSubExpr()); |
11066 | } |
11067 | |
11068 | template<typename Derived> |
11069 | ExprResult |
11070 | TreeTransform<Derived>::TransformCXXTemporaryObjectExpr( |
11071 | CXXTemporaryObjectExpr *E) { |
11072 | TypeSourceInfo *T = |
11073 | getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo()); |
11074 | if (!T) |
11075 | return ExprError(); |
11076 | |
11077 | CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>( |
11078 | getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor())); |
11079 | if (!Constructor) |
11080 | return ExprError(); |
11081 | |
11082 | bool ArgumentChanged = false; |
11083 | SmallVector<Expr*, 8> Args; |
11084 | Args.reserve(E->getNumArgs()); |
11085 | { |
11086 | EnterExpressionEvaluationContext Context( |
11087 | getSema(), EnterExpressionEvaluationContext::InitList, |
11088 | E->isListInitialization()); |
11089 | if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, |
11090 | &ArgumentChanged)) |
11091 | return ExprError(); |
11092 | } |
11093 | |
11094 | if (!getDerived().AlwaysRebuild() && |
11095 | T == E->getTypeSourceInfo() && |
11096 | Constructor == E->getConstructor() && |
11097 | !ArgumentChanged) { |
11098 | |
11099 | SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor); |
11100 | return SemaRef.MaybeBindToTemporary(E); |
11101 | } |
11102 | |
11103 | |
11104 | |
11105 | SourceLocation LParenLoc = T->getTypeLoc().getEndLoc(); |
11106 | return getDerived().RebuildCXXTemporaryObjectExpr( |
11107 | T, LParenLoc, Args, E->getEndLoc(), |
11108 | LParenLoc.isInvalid()); |
11109 | } |
11110 | |
11111 | template<typename Derived> |
11112 | ExprResult |
11113 | TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) { |
11114 | |
11115 | |
11116 | typedef std::pair<ExprResult, QualType> InitCaptureInfoTy; |
11117 | SmallVector<InitCaptureInfoTy, 8> InitCaptureExprsAndTypes; |
11118 | InitCaptureExprsAndTypes.resize(E->explicit_capture_end() - |
11119 | E->explicit_capture_begin()); |
11120 | for (LambdaExpr::capture_iterator C = E->capture_begin(), |
11121 | CEnd = E->capture_end(); |
11122 | C != CEnd; ++C) { |
11123 | if (!E->isInitCapture(C)) |
11124 | continue; |
11125 | EnterExpressionEvaluationContext EEEC( |
11126 | getSema(), Sema::ExpressionEvaluationContext::PotentiallyEvaluated); |
11127 | ExprResult NewExprInitResult = getDerived().TransformInitializer( |
11128 | C->getCapturedVar()->getInit(), |
11129 | C->getCapturedVar()->getInitStyle() == VarDecl::CallInit); |
11130 | |
11131 | if (NewExprInitResult.isInvalid()) |
11132 | return ExprError(); |
11133 | Expr *NewExprInit = NewExprInitResult.get(); |
11134 | |
11135 | VarDecl *OldVD = C->getCapturedVar(); |
11136 | QualType NewInitCaptureType = |
11137 | getSema().buildLambdaInitCaptureInitialization( |
11138 | C->getLocation(), OldVD->getType()->isReferenceType(), |
11139 | OldVD->getIdentifier(), |
11140 | C->getCapturedVar()->getInitStyle() != VarDecl::CInit, NewExprInit); |
11141 | NewExprInitResult = NewExprInit; |
11142 | InitCaptureExprsAndTypes[C - E->capture_begin()] = |
11143 | std::make_pair(NewExprInitResult, NewInitCaptureType); |
11144 | } |
11145 | |
11146 | |
11147 | |
11148 | auto TPL = getDerived().TransformTemplateParameterList( |
11149 | E->getTemplateParameterList()); |
11150 | |
11151 | |
11152 | |
11153 | |
11154 | |
11155 | TypeSourceInfo *NewCallOpTSI = nullptr; |
11156 | { |
11157 | TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo(); |
11158 | FunctionProtoTypeLoc OldCallOpFPTL = |
11159 | OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>(); |
11160 | |
11161 | TypeLocBuilder NewCallOpTLBuilder; |
11162 | SmallVector<QualType, 4> ExceptionStorage; |
11163 | TreeTransform *This = this; |
11164 | QualType NewCallOpType = TransformFunctionProtoType( |
11165 | NewCallOpTLBuilder, OldCallOpFPTL, nullptr, Qualifiers(), |
11166 | [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) { |
11167 | return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI, |
11168 | ExceptionStorage, Changed); |
11169 | }); |
11170 | if (NewCallOpType.isNull()) |
11171 | return ExprError(); |
11172 | NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, |
11173 | NewCallOpType); |
11174 | } |
11175 | |
11176 | LambdaScopeInfo *LSI = getSema().PushLambdaScope(); |
11177 | Sema::FunctionScopeRAII FuncScopeCleanup(getSema()); |
11178 | LSI->GLTemplateParameterList = TPL; |
11179 | |
11180 | |
11181 | CXXRecordDecl *Class |
11182 | = getSema().createLambdaClosureType(E->getIntroducerRange(), |
11183 | NewCallOpTSI, |
11184 | , |
11185 | E->getCaptureDefault()); |
11186 | getDerived().transformedLocalDecl(E->getLambdaClass(), Class); |
11187 | |
11188 | |
11189 | CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition( |
11190 | Class, E->getIntroducerRange(), NewCallOpTSI, |
11191 | E->getCallOperator()->getEndLoc(), |
11192 | NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(), |
11193 | E->getCallOperator()->isConstexpr()); |
11194 | |
11195 | LSI->CallOperator = NewCallOperator; |
11196 | |
11197 | for (unsigned I = 0, NumParams = NewCallOperator->getNumParams(); |
11198 | I != NumParams; ++I) { |
11199 | auto *P = NewCallOperator->getParamDecl(I); |
11200 | if (P->hasUninstantiatedDefaultArg()) { |
11201 | EnterExpressionEvaluationContext Eval( |
11202 | getSema(), |
11203 | Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P); |
11204 | ExprResult R = getDerived().TransformExpr( |
11205 | E->getCallOperator()->getParamDecl(I)->getDefaultArg()); |
11206 | P->setDefaultArg(R.get()); |
11207 | } |
11208 | } |
11209 | |
11210 | getDerived().transformAttrs(E->getCallOperator(), NewCallOperator); |
11211 | getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator); |
11212 | |
11213 | |
11214 | Sema::ContextRAII SavedContext(getSema(), NewCallOperator, |
11215 | ); |
11216 | |
11217 | |
11218 | getSema().buildLambdaScope(LSI, NewCallOperator, |
11219 | E->getIntroducerRange(), |
11220 | E->getCaptureDefault(), |
11221 | E->getCaptureDefaultLoc(), |
11222 | E->hasExplicitParameters(), |
11223 | E->hasExplicitResultType(), |
11224 | E->isMutable()); |
11225 | |
11226 | bool Invalid = false; |
11227 | |
11228 | |
11229 | bool FinishedExplicitCaptures = false; |
11230 | for (LambdaExpr::capture_iterator C = E->capture_begin(), |
11231 | CEnd = E->capture_end(); |
11232 | C != CEnd; ++C) { |
11233 | |
11234 | |
11235 | if (!FinishedExplicitCaptures && C->isImplicit()) { |
11236 | getSema().finishLambdaExplicitCaptures(LSI); |
11237 | FinishedExplicitCaptures = true; |
11238 | } |
11239 | |
11240 | |
11241 | if (C->capturesThis()) { |
11242 | getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(), |
11243 | true, nullptr, |
11244 | C->getCaptureKind() == LCK_StarThis); |
11245 | continue; |
11246 | } |
11247 | |
11248 | |
11249 | if (C->capturesVLAType()) |
11250 | continue; |
11251 | |
11252 | |
11253 | if (E->isInitCapture(C)) { |
11254 | InitCaptureInfoTy InitExprTypePair = |
11255 | InitCaptureExprsAndTypes[C - E->capture_begin()]; |
11256 | ExprResult Init = InitExprTypePair.first; |
11257 | QualType InitQualType = InitExprTypePair.second; |
11258 | if (Init.isInvalid() || InitQualType.isNull()) { |
11259 | Invalid = true; |
11260 | continue; |
11261 | } |
11262 | VarDecl *OldVD = C->getCapturedVar(); |
11263 | VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl( |
11264 | OldVD->getLocation(), InitExprTypePair.second, OldVD->getIdentifier(), |
11265 | OldVD->getInitStyle(), Init.get()); |
11266 | if (!NewVD) |
11267 | Invalid = true; |
11268 | else { |
11269 | getDerived().transformedLocalDecl(OldVD, NewVD); |
11270 | } |
11271 | getSema().buildInitCaptureField(LSI, NewVD); |
11272 | continue; |
11273 | } |
11274 | |
11275 | (0) . __assert_fail ("C->capturesVariable() && \"unexpected kind of lambda capture\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 11275, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(C->capturesVariable() && "unexpected kind of lambda capture"); |
11276 | |
11277 | |
11278 | Sema::TryCaptureKind Kind |
11279 | = C->isImplicit()? Sema::TryCapture_Implicit |
11280 | : C->getCaptureKind() == LCK_ByCopy |
11281 | ? Sema::TryCapture_ExplicitByVal |
11282 | : Sema::TryCapture_ExplicitByRef; |
11283 | SourceLocation EllipsisLoc; |
11284 | if (C->isPackExpansion()) { |
11285 | UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation()); |
11286 | bool ShouldExpand = false; |
11287 | bool RetainExpansion = false; |
11288 | Optional<unsigned> NumExpansions; |
11289 | if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(), |
11290 | C->getLocation(), |
11291 | Unexpanded, |
11292 | ShouldExpand, RetainExpansion, |
11293 | NumExpansions)) { |
11294 | Invalid = true; |
11295 | continue; |
11296 | } |
11297 | |
11298 | if (ShouldExpand) { |
11299 | |
11300 | |
11301 | |
11302 | VarDecl *Pack = C->getCapturedVar(); |
11303 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
11304 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); |
11305 | VarDecl *CapturedVar |
11306 | = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(), |
11307 | Pack)); |
11308 | if (!CapturedVar) { |
11309 | Invalid = true; |
11310 | continue; |
11311 | } |
11312 | |
11313 | |
11314 | getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind); |
11315 | } |
11316 | |
11317 | |
11318 | |
11319 | continue; |
11320 | } |
11321 | |
11322 | EllipsisLoc = C->getEllipsisLoc(); |
11323 | } |
11324 | |
11325 | |
11326 | VarDecl *CapturedVar |
11327 | = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(), |
11328 | C->getCapturedVar())); |
11329 | if (!CapturedVar || CapturedVar->isInvalidDecl()) { |
11330 | Invalid = true; |
11331 | continue; |
11332 | } |
11333 | |
11334 | |
11335 | getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind, |
11336 | EllipsisLoc); |
11337 | } |
11338 | if (!FinishedExplicitCaptures) |
11339 | getSema().finishLambdaExplicitCaptures(LSI); |
11340 | |
11341 | |
11342 | |
11343 | getSema().PushExpressionEvaluationContext( |
11344 | Sema::ExpressionEvaluationContext::PotentiallyEvaluated); |
11345 | |
11346 | |
11347 | StmtResult Body = |
11348 | Invalid ? StmtError() : getDerived().TransformStmt(E->getBody()); |
11349 | |
11350 | |
11351 | FuncScopeCleanup.disable(); |
11352 | |
11353 | if (Body.isInvalid()) { |
11354 | SavedContext.pop(); |
11355 | getSema().ActOnLambdaError(E->getBeginLoc(), , |
11356 | ); |
11357 | return ExprError(); |
11358 | } |
11359 | |
11360 | |
11361 | |
11362 | |
11363 | auto LSICopy = *LSI; |
11364 | getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(), |
11365 | true); |
11366 | SavedContext.pop(); |
11367 | |
11368 | return getSema().BuildLambdaExpr(E->getBeginLoc(), Body.get()->getEndLoc(), |
11369 | &LSICopy); |
11370 | } |
11371 | |
11372 | template<typename Derived> |
11373 | ExprResult |
11374 | TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr( |
11375 | CXXUnresolvedConstructExpr *E) { |
11376 | TypeSourceInfo *T = |
11377 | getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo()); |
11378 | if (!T) |
11379 | return ExprError(); |
11380 | |
11381 | bool ArgumentChanged = false; |
11382 | SmallVector<Expr*, 8> Args; |
11383 | Args.reserve(E->arg_size()); |
11384 | { |
11385 | EnterExpressionEvaluationContext Context( |
11386 | getSema(), EnterExpressionEvaluationContext::InitList, |
11387 | E->isListInitialization()); |
11388 | if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args, |
11389 | &ArgumentChanged)) |
11390 | return ExprError(); |
11391 | } |
11392 | |
11393 | if (!getDerived().AlwaysRebuild() && |
11394 | T == E->getTypeSourceInfo() && |
11395 | !ArgumentChanged) |
11396 | return E; |
11397 | |
11398 | |
11399 | return getDerived().RebuildCXXUnresolvedConstructExpr( |
11400 | T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization()); |
11401 | } |
11402 | |
11403 | template<typename Derived> |
11404 | ExprResult |
11405 | TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr( |
11406 | CXXDependentScopeMemberExpr *E) { |
11407 | |
11408 | ExprResult Base((Expr*) nullptr); |
11409 | Expr *OldBase; |
11410 | QualType BaseType; |
11411 | QualType ObjectType; |
11412 | if (!E->isImplicitAccess()) { |
11413 | OldBase = E->getBase(); |
11414 | Base = getDerived().TransformExpr(OldBase); |
11415 | if (Base.isInvalid()) |
11416 | return ExprError(); |
11417 | |
11418 | |
11419 | ParsedType ObjectTy; |
11420 | bool MayBePseudoDestructor = false; |
11421 | Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(), |
11422 | E->getOperatorLoc(), |
11423 | E->isArrow()? tok::arrow : tok::period, |
11424 | ObjectTy, |
11425 | MayBePseudoDestructor); |
11426 | if (Base.isInvalid()) |
11427 | return ExprError(); |
11428 | |
11429 | ObjectType = ObjectTy.get(); |
11430 | BaseType = ((Expr*) Base.get())->getType(); |
11431 | } else { |
11432 | OldBase = nullptr; |
11433 | BaseType = getDerived().TransformType(E->getBaseType()); |
11434 | ObjectType = BaseType->getAs<PointerType>()->getPointeeType(); |
11435 | } |
11436 | |
11437 | |
11438 | |
11439 | NamedDecl *FirstQualifierInScope |
11440 | = getDerived().TransformFirstQualifierInScope( |
11441 | E->getFirstQualifierFoundInScope(), |
11442 | E->getQualifierLoc().getBeginLoc()); |
11443 | |
11444 | NestedNameSpecifierLoc QualifierLoc; |
11445 | if (E->getQualifier()) { |
11446 | QualifierLoc |
11447 | = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(), |
11448 | ObjectType, |
11449 | FirstQualifierInScope); |
11450 | if (!QualifierLoc) |
11451 | return ExprError(); |
11452 | } |
11453 | |
11454 | SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc(); |
11455 | |
11456 | |
11457 | |
11458 | |
11459 | |
11460 | DeclarationNameInfo NameInfo |
11461 | = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo()); |
11462 | if (!NameInfo.getName()) |
11463 | return ExprError(); |
11464 | |
11465 | if (!E->hasExplicitTemplateArgs()) { |
11466 | |
11467 | |
11468 | if (!getDerived().AlwaysRebuild() && |
11469 | Base.get() == OldBase && |
11470 | BaseType == E->getBaseType() && |
11471 | QualifierLoc == E->getQualifierLoc() && |
11472 | NameInfo.getName() == E->getMember() && |
11473 | FirstQualifierInScope == E->getFirstQualifierFoundInScope()) |
11474 | return E; |
11475 | |
11476 | return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(), |
11477 | BaseType, |
11478 | E->isArrow(), |
11479 | E->getOperatorLoc(), |
11480 | QualifierLoc, |
11481 | TemplateKWLoc, |
11482 | FirstQualifierInScope, |
11483 | NameInfo, |
11484 | ); |
11485 | } |
11486 | |
11487 | TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc()); |
11488 | if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), |
11489 | E->getNumTemplateArgs(), |
11490 | TransArgs)) |
11491 | return ExprError(); |
11492 | |
11493 | return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(), |
11494 | BaseType, |
11495 | E->isArrow(), |
11496 | E->getOperatorLoc(), |
11497 | QualifierLoc, |
11498 | TemplateKWLoc, |
11499 | FirstQualifierInScope, |
11500 | NameInfo, |
11501 | &TransArgs); |
11502 | } |
11503 | |
11504 | template<typename Derived> |
11505 | ExprResult |
11506 | TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) { |
11507 | |
11508 | ExprResult Base((Expr*) nullptr); |
11509 | QualType BaseType; |
11510 | if (!Old->isImplicitAccess()) { |
11511 | Base = getDerived().TransformExpr(Old->getBase()); |
11512 | if (Base.isInvalid()) |
11513 | return ExprError(); |
11514 | Base = getSema().PerformMemberExprBaseConversion(Base.get(), |
11515 | Old->isArrow()); |
11516 | if (Base.isInvalid()) |
11517 | return ExprError(); |
11518 | BaseType = Base.get()->getType(); |
11519 | } else { |
11520 | BaseType = getDerived().TransformType(Old->getBaseType()); |
11521 | } |
11522 | |
11523 | NestedNameSpecifierLoc QualifierLoc; |
11524 | if (Old->getQualifierLoc()) { |
11525 | QualifierLoc |
11526 | = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc()); |
11527 | if (!QualifierLoc) |
11528 | return ExprError(); |
11529 | } |
11530 | |
11531 | SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc(); |
11532 | |
11533 | LookupResult R(SemaRef, Old->getMemberNameInfo(), |
11534 | Sema::LookupOrdinaryName); |
11535 | |
11536 | |
11537 | if (TransformOverloadExprDecls(Old, , R)) |
11538 | return ExprError(); |
11539 | |
11540 | |
11541 | if (Old->getNamingClass()) { |
11542 | CXXRecordDecl *NamingClass |
11543 | = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl( |
11544 | Old->getMemberLoc(), |
11545 | Old->getNamingClass())); |
11546 | if (!NamingClass) |
11547 | return ExprError(); |
11548 | |
11549 | R.setNamingClass(NamingClass); |
11550 | } |
11551 | |
11552 | TemplateArgumentListInfo TransArgs; |
11553 | if (Old->hasExplicitTemplateArgs()) { |
11554 | TransArgs.setLAngleLoc(Old->getLAngleLoc()); |
11555 | TransArgs.setRAngleLoc(Old->getRAngleLoc()); |
11556 | if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(), |
11557 | Old->getNumTemplateArgs(), |
11558 | TransArgs)) |
11559 | return ExprError(); |
11560 | } |
11561 | |
11562 | |
11563 | |
11564 | |
11565 | |
11566 | NamedDecl *FirstQualifierInScope = nullptr; |
11567 | |
11568 | return getDerived().RebuildUnresolvedMemberExpr(Base.get(), |
11569 | BaseType, |
11570 | Old->getOperatorLoc(), |
11571 | Old->isArrow(), |
11572 | QualifierLoc, |
11573 | TemplateKWLoc, |
11574 | FirstQualifierInScope, |
11575 | R, |
11576 | (Old->hasExplicitTemplateArgs() |
11577 | ? &TransArgs : nullptr)); |
11578 | } |
11579 | |
11580 | template<typename Derived> |
11581 | ExprResult |
11582 | TreeTransform<Derived>::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) { |
11583 | EnterExpressionEvaluationContext Unevaluated( |
11584 | SemaRef, Sema::ExpressionEvaluationContext::Unevaluated); |
11585 | ExprResult SubExpr = getDerived().TransformExpr(E->getOperand()); |
11586 | if (SubExpr.isInvalid()) |
11587 | return ExprError(); |
11588 | |
11589 | if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand()) |
11590 | return E; |
11591 | |
11592 | return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get()); |
11593 | } |
11594 | |
11595 | template<typename Derived> |
11596 | ExprResult |
11597 | TreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) { |
11598 | ExprResult Pattern = getDerived().TransformExpr(E->getPattern()); |
11599 | if (Pattern.isInvalid()) |
11600 | return ExprError(); |
11601 | |
11602 | if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern()) |
11603 | return E; |
11604 | |
11605 | return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(), |
11606 | E->getNumExpansions()); |
11607 | } |
11608 | |
11609 | template<typename Derived> |
11610 | ExprResult |
11611 | TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) { |
11612 | |
11613 | |
11614 | if (!E->isValueDependent()) |
11615 | return E; |
11616 | |
11617 | EnterExpressionEvaluationContext Unevaluated( |
11618 | getSema(), Sema::ExpressionEvaluationContext::Unevaluated); |
11619 | |
11620 | ArrayRef<TemplateArgument> PackArgs; |
11621 | TemplateArgument ArgStorage; |
11622 | |
11623 | |
11624 | if (E->isPartiallySubstituted()) { |
11625 | PackArgs = E->getPartialArguments(); |
11626 | } else if (E->isValueDependent()) { |
11627 | UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc()); |
11628 | bool ShouldExpand = false; |
11629 | bool RetainExpansion = false; |
11630 | Optional<unsigned> NumExpansions; |
11631 | if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(), |
11632 | Unexpanded, |
11633 | ShouldExpand, RetainExpansion, |
11634 | NumExpansions)) |
11635 | return ExprError(); |
11636 | |
11637 | |
11638 | |
11639 | if (ShouldExpand) { |
11640 | auto *Pack = E->getPack(); |
11641 | if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) { |
11642 | ArgStorage = getSema().Context.getPackExpansionType( |
11643 | getSema().Context.getTypeDeclType(TTPD), None); |
11644 | } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) { |
11645 | ArgStorage = TemplateArgument(TemplateName(TTPD), None); |
11646 | } else { |
11647 | auto *VD = cast<ValueDecl>(Pack); |
11648 | ExprResult DRE = getSema().BuildDeclRefExpr( |
11649 | VD, VD->getType().getNonLValueExprType(getSema().Context), |
11650 | VD->getType()->isReferenceType() ? VK_LValue : VK_RValue, |
11651 | E->getPackLoc()); |
11652 | if (DRE.isInvalid()) |
11653 | return ExprError(); |
11654 | ArgStorage = new (getSema().Context) PackExpansionExpr( |
11655 | getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None); |
11656 | } |
11657 | PackArgs = ArgStorage; |
11658 | } |
11659 | } |
11660 | |
11661 | |
11662 | if (!PackArgs.size()) { |
11663 | auto *Pack = cast_or_null<NamedDecl>( |
11664 | getDerived().TransformDecl(E->getPackLoc(), E->getPack())); |
11665 | if (!Pack) |
11666 | return ExprError(); |
11667 | return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack, |
11668 | E->getPackLoc(), |
11669 | E->getRParenLoc(), None, None); |
11670 | } |
11671 | |
11672 | |
11673 | Optional<unsigned> Result = 0; |
11674 | for (const TemplateArgument &Arg : PackArgs) { |
11675 | if (!Arg.isPackExpansion()) { |
11676 | Result = *Result + 1; |
11677 | continue; |
11678 | } |
11679 | |
11680 | TemplateArgumentLoc ArgLoc; |
11681 | InventTemplateArgumentLoc(Arg, ArgLoc); |
11682 | |
11683 | |
11684 | SourceLocation Ellipsis; |
11685 | Optional<unsigned> OrigNumExpansions; |
11686 | TemplateArgumentLoc Pattern = |
11687 | getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis, |
11688 | OrigNumExpansions); |
11689 | |
11690 | |
11691 | TemplateArgumentLoc OutPattern; |
11692 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
11693 | if (getDerived().TransformTemplateArgument(Pattern, OutPattern, |
11694 | true)) |
11695 | return true; |
11696 | |
11697 | |
11698 | Optional<unsigned> NumExpansions = |
11699 | getSema().getFullyPackExpandedSize(OutPattern.getArgument()); |
11700 | if (!NumExpansions) { |
11701 | |
11702 | |
11703 | Result = None; |
11704 | break; |
11705 | } |
11706 | |
11707 | Result = *Result + *NumExpansions; |
11708 | } |
11709 | |
11710 | |
11711 | |
11712 | if (Result) |
11713 | return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(), |
11714 | E->getPackLoc(), |
11715 | E->getRParenLoc(), *Result, None); |
11716 | |
11717 | TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(), |
11718 | E->getPackLoc()); |
11719 | { |
11720 | TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity()); |
11721 | typedef TemplateArgumentLocInventIterator< |
11722 | Derived, const TemplateArgument*> PackLocIterator; |
11723 | if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()), |
11724 | PackLocIterator(*this, PackArgs.end()), |
11725 | TransformedPackArgs, )) |
11726 | return ExprError(); |
11727 | } |
11728 | |
11729 | |
11730 | |
11731 | SmallVector<TemplateArgument, 8> Args; |
11732 | bool PartialSubstitution = false; |
11733 | for (auto &Loc : TransformedPackArgs.arguments()) { |
11734 | Args.push_back(Loc.getArgument()); |
11735 | if (Loc.getArgument().isPackExpansion()) |
11736 | PartialSubstitution = true; |
11737 | } |
11738 | |
11739 | if (PartialSubstitution) |
11740 | return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(), |
11741 | E->getPackLoc(), |
11742 | E->getRParenLoc(), None, Args); |
11743 | |
11744 | return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(), |
11745 | E->getPackLoc(), E->getRParenLoc(), |
11746 | Args.size(), None); |
11747 | } |
11748 | |
11749 | template<typename Derived> |
11750 | ExprResult |
11751 | TreeTransform<Derived>::TransformSubstNonTypeTemplateParmPackExpr( |
11752 | SubstNonTypeTemplateParmPackExpr *E) { |
11753 | |
11754 | return E; |
11755 | } |
11756 | |
11757 | template<typename Derived> |
11758 | ExprResult |
11759 | TreeTransform<Derived>::TransformSubstNonTypeTemplateParmExpr( |
11760 | SubstNonTypeTemplateParmExpr *E) { |
11761 | |
11762 | return E; |
11763 | } |
11764 | |
11765 | template<typename Derived> |
11766 | ExprResult |
11767 | TreeTransform<Derived>::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) { |
11768 | |
11769 | return E; |
11770 | } |
11771 | |
11772 | template<typename Derived> |
11773 | ExprResult |
11774 | TreeTransform<Derived>::TransformMaterializeTemporaryExpr( |
11775 | MaterializeTemporaryExpr *E) { |
11776 | return getDerived().TransformExpr(E->GetTemporaryExpr()); |
11777 | } |
11778 | |
11779 | template<typename Derived> |
11780 | ExprResult |
11781 | TreeTransform<Derived>::TransformCXXFoldExpr(CXXFoldExpr *E) { |
11782 | Expr *Pattern = E->getPattern(); |
11783 | |
11784 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
11785 | getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); |
11786 | (0) . __assert_fail ("!Unexpanded.empty() && \"Pack expansion without parameter packs?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 11786, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); |
11787 | |
11788 | |
11789 | |
11790 | bool Expand = true; |
11791 | bool RetainExpansion = false; |
11792 | Optional<unsigned> NumExpansions; |
11793 | if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(), |
11794 | Pattern->getSourceRange(), |
11795 | Unexpanded, |
11796 | Expand, RetainExpansion, |
11797 | NumExpansions)) |
11798 | return true; |
11799 | |
11800 | if (!Expand) { |
11801 | |
11802 | |
11803 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
11804 | |
11805 | ExprResult LHS = |
11806 | E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult(); |
11807 | if (LHS.isInvalid()) |
11808 | return true; |
11809 | |
11810 | ExprResult RHS = |
11811 | E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult(); |
11812 | if (RHS.isInvalid()) |
11813 | return true; |
11814 | |
11815 | if (!getDerived().AlwaysRebuild() && |
11816 | LHS.get() == E->getLHS() && RHS.get() == E->getRHS()) |
11817 | return E; |
11818 | |
11819 | return getDerived().RebuildCXXFoldExpr( |
11820 | E->getBeginLoc(), LHS.get(), E->getOperator(), E->getEllipsisLoc(), |
11821 | RHS.get(), E->getEndLoc()); |
11822 | } |
11823 | |
11824 | |
11825 | |
11826 | ExprResult Result = getDerived().TransformExpr(E->getInit()); |
11827 | if (Result.isInvalid()) |
11828 | return true; |
11829 | bool LeftFold = E->isLeftFold(); |
11830 | |
11831 | |
11832 | |
11833 | if (!LeftFold && RetainExpansion) { |
11834 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
11835 | |
11836 | ExprResult Out = getDerived().TransformExpr(Pattern); |
11837 | if (Out.isInvalid()) |
11838 | return true; |
11839 | |
11840 | Result = getDerived().RebuildCXXFoldExpr( |
11841 | E->getBeginLoc(), Out.get(), E->getOperator(), E->getEllipsisLoc(), |
11842 | Result.get(), E->getEndLoc()); |
11843 | if (Result.isInvalid()) |
11844 | return true; |
11845 | } |
11846 | |
11847 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
11848 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex( |
11849 | getSema(), LeftFold ? I : *NumExpansions - I - 1); |
11850 | ExprResult Out = getDerived().TransformExpr(Pattern); |
11851 | if (Out.isInvalid()) |
11852 | return true; |
11853 | |
11854 | if (Out.get()->containsUnexpandedParameterPack()) { |
11855 | |
11856 | Result = getDerived().RebuildCXXFoldExpr( |
11857 | E->getBeginLoc(), LeftFold ? Result.get() : Out.get(), |
11858 | E->getOperator(), E->getEllipsisLoc(), |
11859 | LeftFold ? Out.get() : Result.get(), E->getEndLoc()); |
11860 | } else if (Result.isUsable()) { |
11861 | |
11862 | Result = getDerived().RebuildBinaryOperator( |
11863 | E->getEllipsisLoc(), E->getOperator(), |
11864 | LeftFold ? Result.get() : Out.get(), |
11865 | LeftFold ? Out.get() : Result.get()); |
11866 | } else |
11867 | Result = Out; |
11868 | |
11869 | if (Result.isInvalid()) |
11870 | return true; |
11871 | } |
11872 | |
11873 | |
11874 | |
11875 | if (LeftFold && RetainExpansion) { |
11876 | ForgetPartiallySubstitutedPackRAII Forget(getDerived()); |
11877 | |
11878 | ExprResult Out = getDerived().TransformExpr(Pattern); |
11879 | if (Out.isInvalid()) |
11880 | return true; |
11881 | |
11882 | Result = getDerived().RebuildCXXFoldExpr( |
11883 | E->getBeginLoc(), Result.get(), E->getOperator(), E->getEllipsisLoc(), |
11884 | Out.get(), E->getEndLoc()); |
11885 | if (Result.isInvalid()) |
11886 | return true; |
11887 | } |
11888 | |
11889 | |
11890 | |
11891 | if (Result.isUnset()) |
11892 | return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(), |
11893 | E->getOperator()); |
11894 | |
11895 | return Result; |
11896 | } |
11897 | |
11898 | template<typename Derived> |
11899 | ExprResult |
11900 | TreeTransform<Derived>::TransformCXXStdInitializerListExpr( |
11901 | CXXStdInitializerListExpr *E) { |
11902 | return getDerived().TransformExpr(E->getSubExpr()); |
11903 | } |
11904 | |
11905 | template<typename Derived> |
11906 | ExprResult |
11907 | TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) { |
11908 | return SemaRef.MaybeBindToTemporary(E); |
11909 | } |
11910 | |
11911 | template<typename Derived> |
11912 | ExprResult |
11913 | TreeTransform<Derived>::TransformObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { |
11914 | return E; |
11915 | } |
11916 | |
11917 | template<typename Derived> |
11918 | ExprResult |
11919 | TreeTransform<Derived>::TransformObjCBoxedExpr(ObjCBoxedExpr *E) { |
11920 | ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); |
11921 | if (SubExpr.isInvalid()) |
11922 | return ExprError(); |
11923 | |
11924 | if (!getDerived().AlwaysRebuild() && |
11925 | SubExpr.get() == E->getSubExpr()) |
11926 | return E; |
11927 | |
11928 | return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get()); |
11929 | } |
11930 | |
11931 | template<typename Derived> |
11932 | ExprResult |
11933 | TreeTransform<Derived>::TransformObjCArrayLiteral(ObjCArrayLiteral *E) { |
11934 | |
11935 | SmallVector<Expr *, 8> Elements; |
11936 | bool ArgChanged = false; |
11937 | if (getDerived().TransformExprs(E->getElements(), E->getNumElements(), |
11938 | , Elements, &ArgChanged)) |
11939 | return ExprError(); |
11940 | |
11941 | if (!getDerived().AlwaysRebuild() && !ArgChanged) |
11942 | return SemaRef.MaybeBindToTemporary(E); |
11943 | |
11944 | return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(), |
11945 | Elements.data(), |
11946 | Elements.size()); |
11947 | } |
11948 | |
11949 | template<typename Derived> |
11950 | ExprResult |
11951 | TreeTransform<Derived>::TransformObjCDictionaryLiteral( |
11952 | ObjCDictionaryLiteral *E) { |
11953 | |
11954 | SmallVector<ObjCDictionaryElement, 8> Elements; |
11955 | bool ArgChanged = false; |
11956 | for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) { |
11957 | ObjCDictionaryElement OrigElement = E->getKeyValueElement(I); |
11958 | |
11959 | if (OrigElement.isPackExpansion()) { |
11960 | |
11961 | SmallVector<UnexpandedParameterPack, 2> Unexpanded; |
11962 | getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded); |
11963 | getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded); |
11964 | (0) . __assert_fail ("!Unexpanded.empty() && \"Pack expansion without parameter packs?\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 11964, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); |
11965 | |
11966 | |
11967 | |
11968 | bool Expand = true; |
11969 | bool RetainExpansion = false; |
11970 | Optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions; |
11971 | Optional<unsigned> NumExpansions = OrigNumExpansions; |
11972 | SourceRange PatternRange(OrigElement.Key->getBeginLoc(), |
11973 | OrigElement.Value->getEndLoc()); |
11974 | if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc, |
11975 | PatternRange, Unexpanded, Expand, |
11976 | RetainExpansion, NumExpansions)) |
11977 | return ExprError(); |
11978 | |
11979 | if (!Expand) { |
11980 | |
11981 | |
11982 | |
11983 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); |
11984 | ExprResult Key = getDerived().TransformExpr(OrigElement.Key); |
11985 | if (Key.isInvalid()) |
11986 | return ExprError(); |
11987 | |
11988 | if (Key.get() != OrigElement.Key) |
11989 | ArgChanged = true; |
11990 | |
11991 | ExprResult Value = getDerived().TransformExpr(OrigElement.Value); |
11992 | if (Value.isInvalid()) |
11993 | return ExprError(); |
11994 | |
11995 | if (Value.get() != OrigElement.Value) |
11996 | ArgChanged = true; |
11997 | |
11998 | ObjCDictionaryElement Expansion = { |
11999 | Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions |
12000 | }; |
12001 | Elements.push_back(Expansion); |
12002 | continue; |
12003 | } |
12004 | |
12005 | |
12006 | |
12007 | ArgChanged = true; |
12008 | |
12009 | |
12010 | |
12011 | for (unsigned I = 0; I != *NumExpansions; ++I) { |
12012 | Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); |
12013 | ExprResult Key = getDerived().TransformExpr(OrigElement.Key); |
12014 | if (Key.isInvalid()) |
12015 | return ExprError(); |
12016 | |
12017 | ExprResult Value = getDerived().TransformExpr(OrigElement.Value); |
12018 | if (Value.isInvalid()) |
12019 | return ExprError(); |
12020 | |
12021 | ObjCDictionaryElement Element = { |
12022 | Key.get(), Value.get(), SourceLocation(), NumExpansions |
12023 | }; |
12024 | |
12025 | |
12026 | |
12027 | |
12028 | if (Key.get()->containsUnexpandedParameterPack() || |
12029 | Value.get()->containsUnexpandedParameterPack()) |
12030 | Element.EllipsisLoc = OrigElement.EllipsisLoc; |
12031 | |
12032 | Elements.push_back(Element); |
12033 | } |
12034 | |
12035 | |
12036 | |
12037 | |
12038 | continue; |
12039 | } |
12040 | |
12041 | |
12042 | ExprResult Key = getDerived().TransformExpr(OrigElement.Key); |
12043 | if (Key.isInvalid()) |
12044 | return ExprError(); |
12045 | |
12046 | if (Key.get() != OrigElement.Key) |
12047 | ArgChanged = true; |
12048 | |
12049 | |
12050 | ExprResult Value |
12051 | = getDerived().TransformExpr(OrigElement.Value); |
12052 | if (Value.isInvalid()) |
12053 | return ExprError(); |
12054 | |
12055 | if (Value.get() != OrigElement.Value) |
12056 | ArgChanged = true; |
12057 | |
12058 | ObjCDictionaryElement Element = { |
12059 | Key.get(), Value.get(), SourceLocation(), None |
12060 | }; |
12061 | Elements.push_back(Element); |
12062 | } |
12063 | |
12064 | if (!getDerived().AlwaysRebuild() && !ArgChanged) |
12065 | return SemaRef.MaybeBindToTemporary(E); |
12066 | |
12067 | return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(), |
12068 | Elements); |
12069 | } |
12070 | |
12071 | template<typename Derived> |
12072 | ExprResult |
12073 | TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) { |
12074 | TypeSourceInfo *EncodedTypeInfo |
12075 | = getDerived().TransformType(E->getEncodedTypeSourceInfo()); |
12076 | if (!EncodedTypeInfo) |
12077 | return ExprError(); |
12078 | |
12079 | if (!getDerived().AlwaysRebuild() && |
12080 | EncodedTypeInfo == E->getEncodedTypeSourceInfo()) |
12081 | return E; |
12082 | |
12083 | return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(), |
12084 | EncodedTypeInfo, |
12085 | E->getRParenLoc()); |
12086 | } |
12087 | |
12088 | template<typename Derived> |
12089 | ExprResult TreeTransform<Derived>:: |
12090 | TransformObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) { |
12091 | |
12092 | |
12093 | |
12094 | |
12095 | return getDerived().TransformExpr(E->getSubExpr()); |
12096 | } |
12097 | |
12098 | template<typename Derived> |
12099 | ExprResult TreeTransform<Derived>:: |
12100 | TransformObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { |
12101 | TypeSourceInfo *TSInfo |
12102 | = getDerived().TransformType(E->getTypeInfoAsWritten()); |
12103 | if (!TSInfo) |
12104 | return ExprError(); |
12105 | |
12106 | ExprResult Result = getDerived().TransformExpr(E->getSubExpr()); |
12107 | if (Result.isInvalid()) |
12108 | return ExprError(); |
12109 | |
12110 | if (!getDerived().AlwaysRebuild() && |
12111 | TSInfo == E->getTypeInfoAsWritten() && |
12112 | Result.get() == E->getSubExpr()) |
12113 | return E; |
12114 | |
12115 | return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(), |
12116 | E->getBridgeKeywordLoc(), TSInfo, |
12117 | Result.get()); |
12118 | } |
12119 | |
12120 | template <typename Derived> |
12121 | ExprResult TreeTransform<Derived>::TransformObjCAvailabilityCheckExpr( |
12122 | ObjCAvailabilityCheckExpr *E) { |
12123 | return E; |
12124 | } |
12125 | |
12126 | template<typename Derived> |
12127 | ExprResult |
12128 | TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) { |
12129 | |
12130 | bool ArgChanged = false; |
12131 | SmallVector<Expr*, 8> Args; |
12132 | Args.reserve(E->getNumArgs()); |
12133 | if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args, |
12134 | &ArgChanged)) |
12135 | return ExprError(); |
12136 | |
12137 | if (E->getReceiverKind() == ObjCMessageExpr::Class) { |
12138 | |
12139 | TypeSourceInfo *ReceiverTypeInfo |
12140 | = getDerived().TransformType(E->getClassReceiverTypeInfo()); |
12141 | if (!ReceiverTypeInfo) |
12142 | return ExprError(); |
12143 | |
12144 | |
12145 | if (!getDerived().AlwaysRebuild() && |
12146 | ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged) |
12147 | return SemaRef.MaybeBindToTemporary(E); |
12148 | |
12149 | |
12150 | SmallVector<SourceLocation, 16> SelLocs; |
12151 | E->getSelectorLocs(SelLocs); |
12152 | return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo, |
12153 | E->getSelector(), |
12154 | SelLocs, |
12155 | E->getMethodDecl(), |
12156 | E->getLeftLoc(), |
12157 | Args, |
12158 | E->getRightLoc()); |
12159 | } |
12160 | else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass || |
12161 | E->getReceiverKind() == ObjCMessageExpr::SuperInstance) { |
12162 | if (!E->getMethodDecl()) |
12163 | return ExprError(); |
12164 | |
12165 | |
12166 | SmallVector<SourceLocation, 16> SelLocs; |
12167 | E->getSelectorLocs(SelLocs); |
12168 | return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(), |
12169 | E->getSelector(), |
12170 | SelLocs, |
12171 | E->getReceiverType(), |
12172 | E->getMethodDecl(), |
12173 | E->getLeftLoc(), |
12174 | Args, |
12175 | E->getRightLoc()); |
12176 | } |
12177 | |
12178 | |
12179 | (0) . __assert_fail ("E->getReceiverKind() == ObjCMessageExpr..Instance && \"Only class and instance messages may be instantiated\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12180, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(E->getReceiverKind() == ObjCMessageExpr::Instance && |
12180 | (0) . __assert_fail ("E->getReceiverKind() == ObjCMessageExpr..Instance && \"Only class and instance messages may be instantiated\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12180, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Only class and instance messages may be instantiated"); |
12181 | ExprResult Receiver |
12182 | = getDerived().TransformExpr(E->getInstanceReceiver()); |
12183 | if (Receiver.isInvalid()) |
12184 | return ExprError(); |
12185 | |
12186 | |
12187 | if (!getDerived().AlwaysRebuild() && |
12188 | Receiver.get() == E->getInstanceReceiver() && !ArgChanged) |
12189 | return SemaRef.MaybeBindToTemporary(E); |
12190 | |
12191 | |
12192 | SmallVector<SourceLocation, 16> SelLocs; |
12193 | E->getSelectorLocs(SelLocs); |
12194 | return getDerived().RebuildObjCMessageExpr(Receiver.get(), |
12195 | E->getSelector(), |
12196 | SelLocs, |
12197 | E->getMethodDecl(), |
12198 | E->getLeftLoc(), |
12199 | Args, |
12200 | E->getRightLoc()); |
12201 | } |
12202 | |
12203 | template<typename Derived> |
12204 | ExprResult |
12205 | TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) { |
12206 | return E; |
12207 | } |
12208 | |
12209 | template<typename Derived> |
12210 | ExprResult |
12211 | TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) { |
12212 | return E; |
12213 | } |
12214 | |
12215 | template<typename Derived> |
12216 | ExprResult |
12217 | TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) { |
12218 | |
12219 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
12220 | if (Base.isInvalid()) |
12221 | return ExprError(); |
12222 | |
12223 | |
12224 | |
12225 | |
12226 | if (!getDerived().AlwaysRebuild() && |
12227 | Base.get() == E->getBase()) |
12228 | return E; |
12229 | |
12230 | return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(), |
12231 | E->getLocation(), |
12232 | E->isArrow(), E->isFreeIvar()); |
12233 | } |
12234 | |
12235 | template<typename Derived> |
12236 | ExprResult |
12237 | TreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { |
12238 | |
12239 | |
12240 | if (!E->isObjectReceiver()) |
12241 | return E; |
12242 | |
12243 | |
12244 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
12245 | if (Base.isInvalid()) |
12246 | return ExprError(); |
12247 | |
12248 | |
12249 | |
12250 | |
12251 | if (!getDerived().AlwaysRebuild() && |
12252 | Base.get() == E->getBase()) |
12253 | return E; |
12254 | |
12255 | if (E->isExplicitProperty()) |
12256 | return getDerived().RebuildObjCPropertyRefExpr(Base.get(), |
12257 | E->getExplicitProperty(), |
12258 | E->getLocation()); |
12259 | |
12260 | return getDerived().RebuildObjCPropertyRefExpr(Base.get(), |
12261 | SemaRef.Context.PseudoObjectTy, |
12262 | E->getImplicitPropertyGetter(), |
12263 | E->getImplicitPropertySetter(), |
12264 | E->getLocation()); |
12265 | } |
12266 | |
12267 | template<typename Derived> |
12268 | ExprResult |
12269 | TreeTransform<Derived>::TransformObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { |
12270 | |
12271 | ExprResult Base = getDerived().TransformExpr(E->getBaseExpr()); |
12272 | if (Base.isInvalid()) |
12273 | return ExprError(); |
12274 | |
12275 | |
12276 | ExprResult Key = getDerived().TransformExpr(E->getKeyExpr()); |
12277 | if (Key.isInvalid()) |
12278 | return ExprError(); |
12279 | |
12280 | |
12281 | if (!getDerived().AlwaysRebuild() && |
12282 | Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr()) |
12283 | return E; |
12284 | |
12285 | return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(), |
12286 | Base.get(), Key.get(), |
12287 | E->getAtIndexMethodDecl(), |
12288 | E->setAtIndexMethodDecl()); |
12289 | } |
12290 | |
12291 | template<typename Derived> |
12292 | ExprResult |
12293 | TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) { |
12294 | |
12295 | ExprResult Base = getDerived().TransformExpr(E->getBase()); |
12296 | if (Base.isInvalid()) |
12297 | return ExprError(); |
12298 | |
12299 | |
12300 | if (!getDerived().AlwaysRebuild() && |
12301 | Base.get() == E->getBase()) |
12302 | return E; |
12303 | |
12304 | return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(), |
12305 | E->getOpLoc(), |
12306 | E->isArrow()); |
12307 | } |
12308 | |
12309 | template<typename Derived> |
12310 | ExprResult |
12311 | TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) { |
12312 | bool ArgumentChanged = false; |
12313 | SmallVector<Expr*, 8> SubExprs; |
12314 | SubExprs.reserve(E->getNumSubExprs()); |
12315 | if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false, |
12316 | SubExprs, &ArgumentChanged)) |
12317 | return ExprError(); |
12318 | |
12319 | if (!getDerived().AlwaysRebuild() && |
12320 | !ArgumentChanged) |
12321 | return E; |
12322 | |
12323 | return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(), |
12324 | SubExprs, |
12325 | E->getRParenLoc()); |
12326 | } |
12327 | |
12328 | template<typename Derived> |
12329 | ExprResult |
12330 | TreeTransform<Derived>::TransformConvertVectorExpr(ConvertVectorExpr *E) { |
12331 | ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr()); |
12332 | if (SrcExpr.isInvalid()) |
12333 | return ExprError(); |
12334 | |
12335 | TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo()); |
12336 | if (!Type) |
12337 | return ExprError(); |
12338 | |
12339 | if (!getDerived().AlwaysRebuild() && |
12340 | Type == E->getTypeSourceInfo() && |
12341 | SrcExpr.get() == E->getSrcExpr()) |
12342 | return E; |
12343 | |
12344 | return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(), |
12345 | SrcExpr.get(), Type, |
12346 | E->getRParenLoc()); |
12347 | } |
12348 | |
12349 | template<typename Derived> |
12350 | ExprResult |
12351 | TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) { |
12352 | BlockDecl *oldBlock = E->getBlockDecl(); |
12353 | |
12354 | SemaRef.ActOnBlockStart(E->getCaretLocation(), ); |
12355 | BlockScopeInfo *blockScope = SemaRef.getCurBlock(); |
12356 | |
12357 | blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic()); |
12358 | blockScope->TheDecl->setBlockMissingReturnType( |
12359 | oldBlock->blockMissingReturnType()); |
12360 | |
12361 | SmallVector<ParmVarDecl*, 4> params; |
12362 | SmallVector<QualType, 4> paramTypes; |
12363 | |
12364 | const FunctionProtoType *exprFunctionType = E->getFunctionType(); |
12365 | |
12366 | |
12367 | Sema::ExtParameterInfoBuilder extParamInfos; |
12368 | if (getDerived().TransformFunctionTypeParams( |
12369 | E->getCaretLocation(), oldBlock->parameters(), nullptr, |
12370 | exprFunctionType->getExtParameterInfosOrNull(), paramTypes, ¶ms, |
12371 | extParamInfos)) { |
12372 | getSema().ActOnBlockError(E->getCaretLocation(), ); |
12373 | return ExprError(); |
12374 | } |
12375 | |
12376 | QualType exprResultType = |
12377 | getDerived().TransformType(exprFunctionType->getReturnType()); |
12378 | |
12379 | auto epi = exprFunctionType->getExtProtoInfo(); |
12380 | epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size()); |
12381 | |
12382 | QualType functionType = |
12383 | getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi); |
12384 | blockScope->FunctionType = functionType; |
12385 | |
12386 | |
12387 | if (!params.empty()) |
12388 | blockScope->TheDecl->setParams(params); |
12389 | |
12390 | if (!oldBlock->blockMissingReturnType()) { |
12391 | blockScope->HasImplicitReturnType = false; |
12392 | blockScope->ReturnType = exprResultType; |
12393 | } |
12394 | |
12395 | |
12396 | StmtResult body = getDerived().TransformStmt(E->getBody()); |
12397 | if (body.isInvalid()) { |
12398 | getSema().ActOnBlockError(E->getCaretLocation(), ); |
12399 | return ExprError(); |
12400 | } |
12401 | |
12402 | #ifndef NDEBUG |
12403 | |
12404 | |
12405 | if (!SemaRef.getDiagnostics().hasErrorOccurred()) { |
12406 | for (const auto &I : oldBlock->captures()) { |
12407 | VarDecl *oldCapture = I.getVariable(); |
12408 | |
12409 | |
12410 | if (isa<ParmVarDecl>(oldCapture) && |
12411 | cast<ParmVarDecl>(oldCapture)->isParameterPack()) |
12412 | continue; |
12413 | |
12414 | VarDecl *newCapture = |
12415 | cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(), |
12416 | oldCapture)); |
12417 | CaptureMap.count(newCapture)", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12417, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(blockScope->CaptureMap.count(newCapture)); |
12418 | } |
12419 | capturesCXXThis() == blockScope->isCXXThisCaptured()", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12419, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured()); |
12420 | } |
12421 | #endif |
12422 | |
12423 | return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(), |
12424 | ); |
12425 | } |
12426 | |
12427 | template<typename Derived> |
12428 | ExprResult |
12429 | TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) { |
12430 | llvm_unreachable("Cannot transform asType expressions yet"); |
12431 | } |
12432 | |
12433 | template<typename Derived> |
12434 | ExprResult |
12435 | TreeTransform<Derived>::TransformAtomicExpr(AtomicExpr *E) { |
12436 | QualType RetTy = getDerived().TransformType(E->getType()); |
12437 | bool ArgumentChanged = false; |
12438 | SmallVector<Expr*, 8> SubExprs; |
12439 | SubExprs.reserve(E->getNumSubExprs()); |
12440 | if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false, |
12441 | SubExprs, &ArgumentChanged)) |
12442 | return ExprError(); |
12443 | |
12444 | if (!getDerived().AlwaysRebuild() && |
12445 | !ArgumentChanged) |
12446 | return E; |
12447 | |
12448 | return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs, |
12449 | RetTy, E->getOp(), E->getRParenLoc()); |
12450 | } |
12451 | |
12452 | |
12453 | |
12454 | |
12455 | |
12456 | template<typename Derived> |
12457 | QualType TreeTransform<Derived>::RebuildPointerType(QualType PointeeType, |
12458 | SourceLocation Star) { |
12459 | return SemaRef.BuildPointerType(PointeeType, Star, |
12460 | getDerived().getBaseEntity()); |
12461 | } |
12462 | |
12463 | template<typename Derived> |
12464 | QualType TreeTransform<Derived>::RebuildBlockPointerType(QualType PointeeType, |
12465 | SourceLocation Star) { |
12466 | return SemaRef.BuildBlockPointerType(PointeeType, Star, |
12467 | getDerived().getBaseEntity()); |
12468 | } |
12469 | |
12470 | template<typename Derived> |
12471 | QualType |
12472 | TreeTransform<Derived>::RebuildReferenceType(QualType ReferentType, |
12473 | bool WrittenAsLValue, |
12474 | SourceLocation Sigil) { |
12475 | return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue, |
12476 | Sigil, getDerived().getBaseEntity()); |
12477 | } |
12478 | |
12479 | template<typename Derived> |
12480 | QualType |
12481 | TreeTransform<Derived>::RebuildMemberPointerType(QualType PointeeType, |
12482 | QualType ClassType, |
12483 | SourceLocation Sigil) { |
12484 | return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil, |
12485 | getDerived().getBaseEntity()); |
12486 | } |
12487 | |
12488 | template<typename Derived> |
12489 | QualType TreeTransform<Derived>::RebuildObjCTypeParamType( |
12490 | const ObjCTypeParamDecl *Decl, |
12491 | SourceLocation ProtocolLAngleLoc, |
12492 | ArrayRef<ObjCProtocolDecl *> Protocols, |
12493 | ArrayRef<SourceLocation> ProtocolLocs, |
12494 | SourceLocation ProtocolRAngleLoc) { |
12495 | return SemaRef.BuildObjCTypeParamType(Decl, |
12496 | ProtocolLAngleLoc, Protocols, |
12497 | ProtocolLocs, ProtocolRAngleLoc, |
12498 | ); |
12499 | } |
12500 | |
12501 | template<typename Derived> |
12502 | QualType TreeTransform<Derived>::RebuildObjCObjectType( |
12503 | QualType BaseType, |
12504 | SourceLocation Loc, |
12505 | SourceLocation TypeArgsLAngleLoc, |
12506 | ArrayRef<TypeSourceInfo *> TypeArgs, |
12507 | SourceLocation TypeArgsRAngleLoc, |
12508 | SourceLocation ProtocolLAngleLoc, |
12509 | ArrayRef<ObjCProtocolDecl *> Protocols, |
12510 | ArrayRef<SourceLocation> ProtocolLocs, |
12511 | SourceLocation ProtocolRAngleLoc) { |
12512 | return SemaRef.BuildObjCObjectType(BaseType, Loc, TypeArgsLAngleLoc, |
12513 | TypeArgs, TypeArgsRAngleLoc, |
12514 | ProtocolLAngleLoc, Protocols, ProtocolLocs, |
12515 | ProtocolRAngleLoc, |
12516 | ); |
12517 | } |
12518 | |
12519 | template<typename Derived> |
12520 | QualType TreeTransform<Derived>::RebuildObjCObjectPointerType( |
12521 | QualType PointeeType, |
12522 | SourceLocation Star) { |
12523 | return SemaRef.Context.getObjCObjectPointerType(PointeeType); |
12524 | } |
12525 | |
12526 | template<typename Derived> |
12527 | QualType |
12528 | TreeTransform<Derived>::RebuildArrayType(QualType ElementType, |
12529 | ArrayType::ArraySizeModifier SizeMod, |
12530 | const llvm::APInt *Size, |
12531 | Expr *SizeExpr, |
12532 | unsigned IndexTypeQuals, |
12533 | SourceRange BracketsRange) { |
12534 | if (SizeExpr || !Size) |
12535 | return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr, |
12536 | IndexTypeQuals, BracketsRange, |
12537 | getDerived().getBaseEntity()); |
12538 | |
12539 | QualType Types[] = { |
12540 | SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy, |
12541 | SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy, |
12542 | SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty |
12543 | }; |
12544 | const unsigned NumTypes = llvm::array_lengthof(Types); |
12545 | QualType SizeType; |
12546 | for (unsigned I = 0; I != NumTypes; ++I) |
12547 | if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) { |
12548 | SizeType = Types[I]; |
12549 | break; |
12550 | } |
12551 | |
12552 | |
12553 | |
12554 | IntegerLiteral *ArraySize |
12555 | = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType, |
12556 | BracketsRange.getBegin()); |
12557 | return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize, |
12558 | IndexTypeQuals, BracketsRange, |
12559 | getDerived().getBaseEntity()); |
12560 | } |
12561 | |
12562 | template<typename Derived> |
12563 | QualType |
12564 | TreeTransform<Derived>::RebuildConstantArrayType(QualType ElementType, |
12565 | ArrayType::ArraySizeModifier SizeMod, |
12566 | const llvm::APInt &Size, |
12567 | unsigned IndexTypeQuals, |
12568 | SourceRange BracketsRange) { |
12569 | return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, nullptr, |
12570 | IndexTypeQuals, BracketsRange); |
12571 | } |
12572 | |
12573 | template<typename Derived> |
12574 | QualType |
12575 | TreeTransform<Derived>::RebuildIncompleteArrayType(QualType ElementType, |
12576 | ArrayType::ArraySizeModifier SizeMod, |
12577 | unsigned IndexTypeQuals, |
12578 | SourceRange BracketsRange) { |
12579 | return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr, |
12580 | IndexTypeQuals, BracketsRange); |
12581 | } |
12582 | |
12583 | template<typename Derived> |
12584 | QualType |
12585 | TreeTransform<Derived>::RebuildVariableArrayType(QualType ElementType, |
12586 | ArrayType::ArraySizeModifier SizeMod, |
12587 | Expr *SizeExpr, |
12588 | unsigned IndexTypeQuals, |
12589 | SourceRange BracketsRange) { |
12590 | return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, |
12591 | SizeExpr, |
12592 | IndexTypeQuals, BracketsRange); |
12593 | } |
12594 | |
12595 | template<typename Derived> |
12596 | QualType |
12597 | TreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType, |
12598 | ArrayType::ArraySizeModifier SizeMod, |
12599 | Expr *SizeExpr, |
12600 | unsigned IndexTypeQuals, |
12601 | SourceRange BracketsRange) { |
12602 | return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, |
12603 | SizeExpr, |
12604 | IndexTypeQuals, BracketsRange); |
12605 | } |
12606 | |
12607 | template <typename Derived> |
12608 | QualType TreeTransform<Derived>::RebuildDependentAddressSpaceType( |
12609 | QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) { |
12610 | return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr, |
12611 | AttributeLoc); |
12612 | } |
12613 | |
12614 | template <typename Derived> |
12615 | QualType |
12616 | TreeTransform<Derived>::RebuildVectorType(QualType ElementType, |
12617 | unsigned NumElements, |
12618 | VectorType::VectorKind VecKind) { |
12619 | |
12620 | return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind); |
12621 | } |
12622 | |
12623 | template <typename Derived> |
12624 | QualType TreeTransform<Derived>::RebuildDependentVectorType( |
12625 | QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, |
12626 | VectorType::VectorKind VecKind) { |
12627 | return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc); |
12628 | } |
12629 | |
12630 | template<typename Derived> |
12631 | QualType TreeTransform<Derived>::RebuildExtVectorType(QualType ElementType, |
12632 | unsigned NumElements, |
12633 | SourceLocation AttributeLoc) { |
12634 | llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy), |
12635 | NumElements, true); |
12636 | IntegerLiteral *VectorSize |
12637 | = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy, |
12638 | AttributeLoc); |
12639 | return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc); |
12640 | } |
12641 | |
12642 | template<typename Derived> |
12643 | QualType |
12644 | TreeTransform<Derived>::RebuildDependentSizedExtVectorType(QualType ElementType, |
12645 | Expr *SizeExpr, |
12646 | SourceLocation AttributeLoc) { |
12647 | return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc); |
12648 | } |
12649 | |
12650 | template<typename Derived> |
12651 | QualType TreeTransform<Derived>::RebuildFunctionProtoType( |
12652 | QualType T, |
12653 | MutableArrayRef<QualType> ParamTypes, |
12654 | const FunctionProtoType::ExtProtoInfo &EPI) { |
12655 | return SemaRef.BuildFunctionType(T, ParamTypes, |
12656 | getDerived().getBaseLocation(), |
12657 | getDerived().getBaseEntity(), |
12658 | EPI); |
12659 | } |
12660 | |
12661 | template<typename Derived> |
12662 | QualType TreeTransform<Derived>::RebuildFunctionNoProtoType(QualType T) { |
12663 | return SemaRef.Context.getFunctionNoProtoType(T); |
12664 | } |
12665 | |
12666 | template<typename Derived> |
12667 | QualType TreeTransform<Derived>::RebuildUnresolvedUsingType(SourceLocation Loc, |
12668 | Decl *D) { |
12669 | (0) . __assert_fail ("D && \"no decl found\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12669, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D && "no decl found"); |
12670 | if (D->isInvalidDecl()) return QualType(); |
12671 | |
12672 | |
12673 | TypeDecl *Ty; |
12674 | if (auto *UPD = dyn_cast<UsingPackDecl>(D)) { |
12675 | |
12676 | |
12677 | |
12678 | if (UPD->expansions().empty()) { |
12679 | getSema().Diag(Loc, diag::err_using_pack_expansion_empty) |
12680 | << UPD->isCXXClassMember() << UPD; |
12681 | return QualType(); |
12682 | } |
12683 | |
12684 | |
12685 | |
12686 | |
12687 | QualType FallbackT; |
12688 | QualType T; |
12689 | for (auto *E : UPD->expansions()) { |
12690 | QualType ThisT = RebuildUnresolvedUsingType(Loc, E); |
12691 | if (ThisT.isNull()) |
12692 | continue; |
12693 | else if (ThisT->getAs<UnresolvedUsingType>()) |
12694 | FallbackT = ThisT; |
12695 | else if (T.isNull()) |
12696 | T = ThisT; |
12697 | else |
12698 | (0) . __assert_fail ("getSema().Context.hasSameType(ThisT, T) && \"mismatched resolved types in using pack expansion\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12699, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(getSema().Context.hasSameType(ThisT, T) && |
12699 | (0) . __assert_fail ("getSema().Context.hasSameType(ThisT, T) && \"mismatched resolved types in using pack expansion\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12699, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "mismatched resolved types in using pack expansion"); |
12700 | } |
12701 | return T.isNull() ? FallbackT : T; |
12702 | } else if (auto *Using = dyn_cast<UsingDecl>(D)) { |
12703 | (0) . __assert_fail ("Using->hasTypename() && \"UnresolvedUsingTypenameDecl transformed to non-typename using\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12704, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Using->hasTypename() && |
12704 | (0) . __assert_fail ("Using->hasTypename() && \"UnresolvedUsingTypenameDecl transformed to non-typename using\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12704, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "UnresolvedUsingTypenameDecl transformed to non-typename using"); |
12705 | |
12706 | |
12707 | shadow_begin() == Using->shadow_end()", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12707, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(++Using->shadow_begin() == Using->shadow_end()); |
12708 | Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl()); |
12709 | } else { |
12710 | (0) . __assert_fail ("isa(D) && \"UnresolvedUsingTypenameDecl transformed to non-using decl\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12711, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isa<UnresolvedUsingTypenameDecl>(D) && |
12711 | (0) . __assert_fail ("isa(D) && \"UnresolvedUsingTypenameDecl transformed to non-using decl\"", "/home/seafit/code_projects/clang_source/clang/lib/Sema/TreeTransform.h", 12711, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "UnresolvedUsingTypenameDecl transformed to non-using decl"); |
12712 | Ty = cast<UnresolvedUsingTypenameDecl>(D); |
12713 | } |
12714 | |
12715 | return SemaRef.Context.getTypeDeclType(Ty); |
12716 | } |
12717 | |
12718 | template<typename Derived> |
12719 | QualType TreeTransform<Derived>::RebuildTypeOfExprType(Expr *E, |
12720 | SourceLocation Loc) { |
12721 | return SemaRef.BuildTypeofExprType(E, Loc); |
12722 | } |
12723 | |
12724 | template<typename Derived> |
12725 | QualType TreeTransform<Derived>::RebuildTypeOfType(QualType Underlying) { |
12726 | return SemaRef.Context.getTypeOfType(Underlying); |
12727 | } |
12728 | |
12729 | template<typename Derived> |
12730 | QualType TreeTransform<Derived>::RebuildDecltypeType(Expr *E, |
12731 | SourceLocation Loc) { |
12732 | return SemaRef.BuildDecltypeType(E, Loc); |
12733 | } |
12734 | |
12735 | template<typename Derived> |
12736 | QualType TreeTransform<Derived>::RebuildUnaryTransformType(QualType BaseType, |
12737 | UnaryTransformType::UTTKind UKind, |
12738 | SourceLocation Loc) { |
12739 | return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc); |
12740 | } |
12741 | |
12742 | template<typename Derived> |
12743 | QualType TreeTransform<Derived>::RebuildTemplateSpecializationType( |
12744 | TemplateName Template, |
12745 | SourceLocation TemplateNameLoc, |
12746 | TemplateArgumentListInfo &TemplateArgs) { |
12747 | return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs); |
12748 | } |
12749 | |
12750 | template<typename Derived> |
12751 | QualType TreeTransform<Derived>::RebuildAtomicType(QualType ValueType, |
12752 | SourceLocation KWLoc) { |
12753 | return SemaRef.BuildAtomicType(ValueType, KWLoc); |
12754 | } |
12755 | |
12756 | template<typename Derived> |
12757 | QualType TreeTransform<Derived>::RebuildPipeType(QualType ValueType, |
12758 | SourceLocation KWLoc, |
12759 | bool isReadPipe) { |
12760 | return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc) |
12761 | : SemaRef.BuildWritePipeType(ValueType, KWLoc); |
12762 | } |
12763 | |
12764 | template<typename Derived> |
12765 | TemplateName |
12766 | TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS, |
12767 | bool TemplateKW, |
12768 | TemplateDecl *Template) { |
12769 | return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW, |
12770 | Template); |
12771 | } |
12772 | |
12773 | template<typename Derived> |
12774 | TemplateName |
12775 | TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS, |
12776 | SourceLocation TemplateKWLoc, |
12777 | const IdentifierInfo &Name, |
12778 | SourceLocation NameLoc, |
12779 | QualType ObjectType, |
12780 | NamedDecl *FirstQualifierInScope, |
12781 | bool AllowInjectedClassName) { |
12782 | UnqualifiedId TemplateName; |
12783 | TemplateName.setIdentifier(&Name, NameLoc); |
12784 | Sema::TemplateTy Template; |
12785 | getSema().ActOnDependentTemplateName(, |
12786 | SS, TemplateKWLoc, TemplateName, |
12787 | ParsedType::make(ObjectType), |
12788 | , |
12789 | Template, AllowInjectedClassName); |
12790 | return Template.get(); |
12791 | } |
12792 | |
12793 | template<typename Derived> |
12794 | TemplateName |
12795 | TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS, |
12796 | SourceLocation TemplateKWLoc, |
12797 | OverloadedOperatorKind Operator, |
12798 | SourceLocation NameLoc, |
12799 | QualType ObjectType, |
12800 | bool AllowInjectedClassName) { |
12801 | UnqualifiedId Name; |
12802 | |
12803 | SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc }; |
12804 | Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations); |
12805 | Sema::TemplateTy Template; |
12806 | getSema().ActOnDependentTemplateName(, |
12807 | SS, TemplateKWLoc, Name, |
12808 | ParsedType::make(ObjectType), |
12809 | , |
12810 | Template, AllowInjectedClassName); |
12811 | return Template.get(); |
12812 | } |
12813 | |
12814 | template<typename Derived> |
12815 | ExprResult |
12816 | TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, |
12817 | SourceLocation OpLoc, |
12818 | Expr *OrigCallee, |
12819 | Expr *First, |
12820 | Expr *Second) { |
12821 | Expr *Callee = OrigCallee->IgnoreParenCasts(); |
12822 | bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus); |
12823 | |
12824 | if (First->getObjectKind() == OK_ObjCProperty) { |
12825 | BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); |
12826 | if (BinaryOperator::isAssignmentOp(Opc)) |
12827 | return SemaRef.checkPseudoObjectAssignment(, OpLoc, Opc, |
12828 | First, Second); |
12829 | ExprResult Result = SemaRef.CheckPlaceholderExpr(First); |
12830 | if (Result.isInvalid()) |
12831 | return ExprError(); |
12832 | First = Result.get(); |
12833 | } |
12834 | |
12835 | if (Second && Second->getObjectKind() == OK_ObjCProperty) { |
12836 | ExprResult Result = SemaRef.CheckPlaceholderExpr(Second); |
12837 | if (Result.isInvalid()) |
12838 | return ExprError(); |
12839 | Second = Result.get(); |
12840 | } |
12841 | |
12842 | |
12843 | if (Op == OO_Subscript) { |
12844 | if (!First->getType()->isOverloadableType() && |
12845 | !Second->getType()->isOverloadableType()) |
12846 | return getSema().CreateBuiltinArraySubscriptExpr( |
12847 | First, Callee->getBeginLoc(), Second, OpLoc); |
12848 | } else if (Op == OO_Arrow) { |
12849 | |
12850 | return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc); |
12851 | } else if (Second == nullptr || isPostIncDec) { |
12852 | if (!First->getType()->isOverloadableType() || |
12853 | (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) { |
12854 | |
12855 | |
12856 | |
12857 | UnaryOperatorKind Opc |
12858 | = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec); |
12859 | |
12860 | return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First); |
12861 | } |
12862 | } else { |
12863 | if (!First->getType()->isOverloadableType() && |
12864 | !Second->getType()->isOverloadableType()) { |
12865 | |
12866 | |
12867 | BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); |
12868 | ExprResult Result |
12869 | = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second); |
12870 | if (Result.isInvalid()) |
12871 | return ExprError(); |
12872 | |
12873 | return Result; |
12874 | } |
12875 | } |
12876 | |
12877 | |
12878 | |
12879 | UnresolvedSet<16> Functions; |
12880 | bool RequiresADL; |
12881 | |
12882 | if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) { |
12883 | Functions.append(ULE->decls_begin(), ULE->decls_end()); |
12884 | |
12885 | |
12886 | |
12887 | RequiresADL = ULE->requiresADL(); |
12888 | } else { |
12889 | |
12890 | |
12891 | |
12892 | NamedDecl *ND = cast<DeclRefExpr>(Callee)->getDecl(); |
12893 | if (!isa<CXXMethodDecl>(ND)) |
12894 | Functions.addDecl(ND); |
12895 | RequiresADL = false; |
12896 | } |
12897 | |
12898 | |
12899 | Expr *Args[2] = { First, Second }; |
12900 | unsigned NumArgs = 1 + (Second != nullptr); |
12901 | |
12902 | |
12903 | if (NumArgs == 1 || isPostIncDec) { |
12904 | UnaryOperatorKind Opc |
12905 | = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec); |
12906 | return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First, |
12907 | RequiresADL); |
12908 | } |
12909 | |
12910 | if (Op == OO_Subscript) { |
12911 | SourceLocation LBrace; |
12912 | SourceLocation RBrace; |
12913 | |
12914 | if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) { |
12915 | DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo(); |
12916 | LBrace = SourceLocation::getFromRawEncoding( |
12917 | NameLoc.CXXOperatorName.BeginOpNameLoc); |
12918 | RBrace = SourceLocation::getFromRawEncoding( |
12919 | NameLoc.CXXOperatorName.EndOpNameLoc); |
12920 | } else { |
12921 | LBrace = Callee->getBeginLoc(); |
12922 | RBrace = OpLoc; |
12923 | } |
12924 | |
12925 | return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace, |
12926 | First, Second); |
12927 | } |
12928 | |
12929 | |
12930 | BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); |
12931 | ExprResult Result = SemaRef.CreateOverloadedBinOp( |
12932 | OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL); |
12933 | if (Result.isInvalid()) |
12934 | return ExprError(); |
12935 | |
12936 | return Result; |
12937 | } |
12938 | |
12939 | template<typename Derived> |
12940 | ExprResult |
12941 | TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base, |
12942 | SourceLocation OperatorLoc, |
12943 | bool isArrow, |
12944 | CXXScopeSpec &SS, |
12945 | TypeSourceInfo *ScopeType, |
12946 | SourceLocation CCLoc, |
12947 | SourceLocation TildeLoc, |
12948 | PseudoDestructorTypeStorage Destroyed) { |
12949 | QualType BaseType = Base->getType(); |
12950 | if (Base->isTypeDependent() || Destroyed.getIdentifier() || |
12951 | (!isArrow && !BaseType->getAs<RecordType>()) || |
12952 | (isArrow && BaseType->getAs<PointerType>() && |
12953 | !BaseType->getAs<PointerType>()->getPointeeType() |
12954 | ->template getAs<RecordType>())){ |
12955 | |
12956 | return SemaRef.BuildPseudoDestructorExpr( |
12957 | Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType, |
12958 | CCLoc, TildeLoc, Destroyed); |
12959 | } |
12960 | |
12961 | TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo(); |
12962 | DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName( |
12963 | SemaRef.Context.getCanonicalType(DestroyedType->getType()))); |
12964 | DeclarationNameInfo NameInfo(Name, Destroyed.getLocation()); |
12965 | NameInfo.setNamedTypeInfo(DestroyedType); |
12966 | |
12967 | |
12968 | |
12969 | if (ScopeType) { |
12970 | if (!ScopeType->getType()->getAs<TagType>()) { |
12971 | getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(), |
12972 | diag::err_expected_class_or_namespace) |
12973 | << ScopeType->getType() << getSema().getLangOpts().CPlusPlus; |
12974 | return ExprError(); |
12975 | } |
12976 | SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(), |
12977 | CCLoc); |
12978 | } |
12979 | |
12980 | SourceLocation TemplateKWLoc; |
12981 | return getSema().BuildMemberReferenceExpr(Base, BaseType, |
12982 | OperatorLoc, isArrow, |
12983 | SS, TemplateKWLoc, |
12984 | nullptr, |
12985 | NameInfo, |
12986 | nullptr, |
12987 | ); |
12988 | } |
12989 | |
12990 | template<typename Derived> |
12991 | StmtResult |
12992 | TreeTransform<Derived>::TransformCapturedStmt(CapturedStmt *S) { |
12993 | SourceLocation Loc = S->getBeginLoc(); |
12994 | CapturedDecl *CD = S->getCapturedDecl(); |
12995 | unsigned NumParams = CD->getNumParams(); |
12996 | unsigned ContextParamPos = CD->getContextParamPosition(); |
12997 | SmallVector<Sema::CapturedParamNameType, 4> Params; |
12998 | for (unsigned I = 0; I < NumParams; ++I) { |
12999 | if (I != ContextParamPos) { |
13000 | Params.push_back( |
13001 | std::make_pair( |
13002 | CD->getParam(I)->getName(), |
13003 | getDerived().TransformType(CD->getParam(I)->getType()))); |
13004 | } else { |
13005 | Params.push_back(std::make_pair(StringRef(), QualType())); |
13006 | } |
13007 | } |
13008 | getSema().ActOnCapturedRegionStart(Loc, , |
13009 | S->getCapturedRegionKind(), Params); |
13010 | StmtResult Body; |
13011 | { |
13012 | Sema::CompoundScopeRAII CompoundScope(getSema()); |
13013 | Body = getDerived().TransformStmt(S->getCapturedStmt()); |
13014 | } |
13015 | |
13016 | if (Body.isInvalid()) { |
13017 | getSema().ActOnCapturedRegionError(); |
13018 | return StmtError(); |
13019 | } |
13020 | |
13021 | return getSema().ActOnCapturedRegionEnd(Body.get()); |
13022 | } |
13023 | |
13024 | } |
13025 | |
13026 | #endif |
13027 | |