@@ -368,58 +368,9 @@ namespace clang {
368
368
369
369
// Importing types
370
370
ExpectedType VisitType (const Type *T);
371
- ExpectedType VisitAtomicType (const AtomicType *T);
372
- ExpectedType VisitBuiltinType (const BuiltinType *T);
373
- ExpectedType VisitDecayedType (const DecayedType *T);
374
- ExpectedType VisitComplexType (const ComplexType *T);
375
- ExpectedType VisitPointerType (const PointerType *T);
376
- ExpectedType VisitBlockPointerType (const BlockPointerType *T);
377
- ExpectedType VisitLValueReferenceType (const LValueReferenceType *T);
378
- ExpectedType VisitRValueReferenceType (const RValueReferenceType *T);
379
- ExpectedType VisitMemberPointerType (const MemberPointerType *T);
380
- ExpectedType VisitConstantArrayType (const ConstantArrayType *T);
381
- ExpectedType VisitIncompleteArrayType (const IncompleteArrayType *T);
382
- ExpectedType VisitVariableArrayType (const VariableArrayType *T);
383
- ExpectedType VisitDependentSizedArrayType (const DependentSizedArrayType *T);
384
- ExpectedType
385
- VisitDependentSizedExtVectorType (const DependentSizedExtVectorType *T);
386
- ExpectedType VisitVectorType (const VectorType *T);
387
- ExpectedType VisitExtVectorType (const ExtVectorType *T);
388
- ExpectedType VisitFunctionNoProtoType (const FunctionNoProtoType *T);
389
- ExpectedType VisitFunctionProtoType (const FunctionProtoType *T);
390
- ExpectedType VisitUnresolvedUsingType (const UnresolvedUsingType *T);
391
- ExpectedType VisitParenType (const ParenType *T);
392
- ExpectedType VisitTypedefType (const TypedefType *T);
393
- ExpectedType VisitTypeOfExprType (const TypeOfExprType *T);
394
- // FIXME: DependentTypeOfExprType
395
- ExpectedType VisitTypeOfType (const TypeOfType *T);
396
- ExpectedType VisitUsingType (const UsingType *T);
397
- ExpectedType VisitDecltypeType (const DecltypeType *T);
398
- ExpectedType VisitUnaryTransformType (const UnaryTransformType *T);
399
- ExpectedType VisitAutoType (const AutoType *T);
400
- ExpectedType VisitDeducedTemplateSpecializationType (
401
- const DeducedTemplateSpecializationType *T);
402
- ExpectedType VisitInjectedClassNameType (const InjectedClassNameType *T);
403
- // FIXME: DependentDecltypeType
404
- ExpectedType VisitRecordType (const RecordType *T);
405
- ExpectedType VisitEnumType (const EnumType *T);
406
- ExpectedType VisitAttributedType (const AttributedType *T);
407
- ExpectedType VisitTemplateTypeParmType (const TemplateTypeParmType *T);
408
- ExpectedType VisitSubstTemplateTypeParmType (
409
- const SubstTemplateTypeParmType *T);
410
- ExpectedType
411
- VisitSubstTemplateTypeParmPackType (const SubstTemplateTypeParmPackType *T);
412
- ExpectedType VisitTemplateSpecializationType (
413
- const TemplateSpecializationType *T);
414
- ExpectedType VisitElaboratedType (const ElaboratedType *T);
415
- ExpectedType VisitDependentNameType (const DependentNameType *T);
416
- ExpectedType VisitPackExpansionType (const PackExpansionType *T);
417
- ExpectedType VisitDependentTemplateSpecializationType (
418
- const DependentTemplateSpecializationType *T);
419
- ExpectedType VisitObjCInterfaceType (const ObjCInterfaceType *T);
420
- ExpectedType VisitObjCObjectType (const ObjCObjectType *T);
421
- ExpectedType VisitObjCObjectPointerType (const ObjCObjectPointerType *T);
422
- ExpectedType VisitMacroQualifiedType (const MacroQualifiedType *T);
371
+ #define TYPE (Class, Base ) \
372
+ ExpectedType Visit##Class##Type(const Class##Type *T);
373
+ #include " clang/AST/TypeNodes.inc"
423
374
424
375
// Importing declarations
425
376
Error ImportDeclParts (NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD,
@@ -1741,6 +1692,123 @@ ASTNodeImporter::VisitMacroQualifiedType(const MacroQualifiedType *T) {
1741
1692
ToIdentifier);
1742
1693
}
1743
1694
1695
+ ExpectedType clang::ASTNodeImporter::VisitAdjustedType (const AdjustedType *T) {
1696
+ Error Err = Error::success ();
1697
+ QualType ToOriginalType = importChecked (Err, T->getOriginalType ());
1698
+ QualType ToAdjustedType = importChecked (Err, T->getAdjustedType ());
1699
+ if (Err)
1700
+ return std::move (Err);
1701
+
1702
+ return Importer.getToContext ().getAdjustedType (ToOriginalType,
1703
+ ToAdjustedType);
1704
+ }
1705
+
1706
+ ExpectedType clang::ASTNodeImporter::VisitBitIntType (const BitIntType *T) {
1707
+ return Importer.getToContext ().getBitIntType (T->isUnsigned (),
1708
+ T->getNumBits ());
1709
+ }
1710
+
1711
+ ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType (
1712
+ const clang::BTFTagAttributedType *T) {
1713
+ Error Err = Error::success ();
1714
+ const BTFTypeTagAttr *ToBTFAttr = importChecked (Err, T->getAttr ());
1715
+ QualType ToWrappedType = importChecked (Err, T->getWrappedType ());
1716
+ if (Err)
1717
+ return std::move (Err);
1718
+
1719
+ return Importer.getToContext ().getBTFTagAttributedType (ToBTFAttr,
1720
+ ToWrappedType);
1721
+ }
1722
+
1723
+ ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType (
1724
+ const clang::ConstantMatrixType *T) {
1725
+ ExpectedType ToElementTypeOrErr = import (T->getElementType ());
1726
+ if (!ToElementTypeOrErr)
1727
+ return ToElementTypeOrErr.takeError ();
1728
+
1729
+ return Importer.getToContext ().getConstantMatrixType (
1730
+ *ToElementTypeOrErr, T->getNumRows (), T->getNumColumns ());
1731
+ }
1732
+
1733
+ ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType (
1734
+ const clang::DependentAddressSpaceType *T) {
1735
+ Error Err = Error::success ();
1736
+ QualType ToPointeeType = importChecked (Err, T->getPointeeType ());
1737
+ Expr *ToAddrSpaceExpr = importChecked (Err, T->getAddrSpaceExpr ());
1738
+ SourceLocation ToAttrLoc = importChecked (Err, T->getAttributeLoc ());
1739
+ if (Err)
1740
+ return std::move (Err);
1741
+
1742
+ return Importer.getToContext ().getDependentAddressSpaceType (
1743
+ ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
1744
+ }
1745
+
1746
+ ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType (
1747
+ const clang::DependentBitIntType *T) {
1748
+ ExpectedExpr ToNumBitsExprOrErr = import (T->getNumBitsExpr ());
1749
+ if (!ToNumBitsExprOrErr)
1750
+ return ToNumBitsExprOrErr.takeError ();
1751
+ return Importer.getToContext ().getDependentBitIntType (T->isUnsigned (),
1752
+ *ToNumBitsExprOrErr);
1753
+ }
1754
+
1755
+ ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType (
1756
+ const clang::DependentSizedMatrixType *T) {
1757
+ Error Err = Error::success ();
1758
+ QualType ToElementType = importChecked (Err, T->getElementType ());
1759
+ Expr *ToRowExpr = importChecked (Err, T->getRowExpr ());
1760
+ Expr *ToColumnExpr = importChecked (Err, T->getColumnExpr ());
1761
+ SourceLocation ToAttrLoc = importChecked (Err, T->getAttributeLoc ());
1762
+ if (Err)
1763
+ return std::move (Err);
1764
+
1765
+ return Importer.getToContext ().getDependentSizedMatrixType (
1766
+ ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
1767
+ }
1768
+
1769
+ ExpectedType clang::ASTNodeImporter::VisitDependentVectorType (
1770
+ const clang::DependentVectorType *T) {
1771
+ Error Err = Error::success ();
1772
+ QualType ToElementType = importChecked (Err, T->getElementType ());
1773
+ Expr *ToSizeExpr = importChecked (Err, T->getSizeExpr ());
1774
+ SourceLocation ToAttrLoc = importChecked (Err, T->getAttributeLoc ());
1775
+ if (Err)
1776
+ return std::move (Err);
1777
+
1778
+ return Importer.getToContext ().getDependentVectorType (
1779
+ ToElementType, ToSizeExpr, ToAttrLoc, T->getVectorKind ());
1780
+ }
1781
+
1782
+ ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType (
1783
+ const clang::ObjCTypeParamType *T) {
1784
+ Expected<ObjCTypeParamDecl *> ToDeclOrErr = import (T->getDecl ());
1785
+ if (!ToDeclOrErr)
1786
+ return ToDeclOrErr.takeError ();
1787
+
1788
+ SmallVector<ObjCProtocolDecl *, 4 > ToProtocols;
1789
+ for (ObjCProtocolDecl *FromProtocol : T->getProtocols ()) {
1790
+ Expected<ObjCProtocolDecl *> ToProtocolOrErr = import (FromProtocol);
1791
+ if (!ToProtocolOrErr)
1792
+ return ToProtocolOrErr.takeError ();
1793
+ ToProtocols.push_back (*ToProtocolOrErr);
1794
+ }
1795
+
1796
+ return Importer.getToContext ().getObjCTypeParamType (*ToDeclOrErr,
1797
+ ToProtocols);
1798
+ }
1799
+
1800
+ ExpectedType clang::ASTNodeImporter::VisitPipeType (const clang::PipeType *T) {
1801
+ ExpectedType ToElementTypeOrErr = import (T->getElementType ());
1802
+ if (!ToElementTypeOrErr)
1803
+ return ToElementTypeOrErr.takeError ();
1804
+
1805
+ ASTContext &ToCtx = Importer.getToContext ();
1806
+ if (T->isReadOnly ())
1807
+ return ToCtx.getReadPipeType (*ToElementTypeOrErr);
1808
+ else
1809
+ return ToCtx.getWritePipeType (*ToElementTypeOrErr);
1810
+ }
1811
+
1744
1812
// ----------------------------------------------------------------------------
1745
1813
// Import Declarations
1746
1814
// ----------------------------------------------------------------------------
@@ -4681,6 +4749,11 @@ ExpectedDecl ASTNodeImporter::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) {
4681
4749
ToColonLoc, ToTypeSourceInfo))
4682
4750
return Result;
4683
4751
4752
+ // Only import 'ObjCTypeParamType' after the decl is created.
4753
+ auto ToTypeForDecl = importChecked (Err, D->getTypeForDecl ());
4754
+ if (Err)
4755
+ return std::move (Err);
4756
+ Result->setTypeForDecl (ToTypeForDecl);
4684
4757
Result->setLexicalDeclContext (LexicalDC);
4685
4758
return Result;
4686
4759
}
0 commit comments