@@ -28,6 +28,7 @@ namespace llvm {
2828
2929namespace clang {
3030 class CXXMethodDecl ;
31+ class CXXRecordDecl ;
3132 class ObjCMethodDecl ;
3233 class Type ;
3334 class ValueDecl ;
@@ -198,6 +199,10 @@ class AbstractionPattern {
198199 // / non-static member function. OrigType is valid and is a function type.
199200 // / CXXMethod is valid.
200201 PartialCurriedCXXMethodType,
202+ // / The type of a constructor that initializes a C++ functional type, e.g.
203+ // / std::function, with a Swift closure. This constructor is synthesized by
204+ // / ClangImporter. ClangType is valid.
205+ CXXFunctionalConstructorType,
201206 // / A Swift function whose parameters and results are opaque. This is
202207 // / like `AP::Type<T>((T) -> T)`, except that the number of parameters is
203208 // / unspecified.
@@ -462,6 +467,7 @@ class AbstractionPattern {
462467 case Kind::CFunctionAsMethodType:
463468 case Kind::CurriedCFunctionAsMethodType:
464469 case Kind::PartialCurriedCFunctionAsMethodType:
470+ case Kind::CXXFunctionalConstructorType:
465471 case Kind::ObjCCompletionHandlerArgumentsType:
466472 return true ;
467473
@@ -632,6 +638,7 @@ class AbstractionPattern {
632638 case Kind::CXXMethodType:
633639 case Kind::CurriedCXXMethodType:
634640 case Kind::PartialCurriedCXXMethodType:
641+ case Kind::CXXFunctionalConstructorType:
635642 case Kind::ObjCCompletionHandlerArgumentsType:
636643 return true ;
637644 case Kind::Invalid:
@@ -766,6 +773,13 @@ class AbstractionPattern {
766773 return pattern;
767774 }
768775
776+ // / Return an abstraction pattern for a constructor of a functional C++ type,
777+ // / e.g. std::function, which takes a Swift closure as a single parameter.
778+ // / This constructor was synthesized by ClangImporter.
779+ static AbstractionPattern
780+ getCXXFunctionalConstructor (CanType origType,
781+ const clang::CXXRecordDecl *functionalTypeDecl);
782+
769783 // / For a C-function-as-method pattern,
770784 // / get the index of the C function parameter that was imported as the
771785 // / `self` parameter of the imported method, or None if this is a static
@@ -1048,6 +1062,7 @@ class AbstractionPattern {
10481062 case Kind::CXXMethodType:
10491063 case Kind::CurriedCXXMethodType:
10501064 case Kind::PartialCurriedCXXMethodType:
1065+ case Kind::CXXFunctionalConstructorType:
10511066 case Kind::Type:
10521067 case Kind::Discard:
10531068 return OrigType;
@@ -1084,6 +1099,7 @@ class AbstractionPattern {
10841099 case Kind::CXXMethodType:
10851100 case Kind::CurriedCXXMethodType:
10861101 case Kind::PartialCurriedCXXMethodType:
1102+ case Kind::CXXFunctionalConstructorType:
10871103 case Kind::Type:
10881104 case Kind::Discard:
10891105 case Kind::ObjCCompletionHandlerArgumentsType:
@@ -1131,6 +1147,7 @@ class AbstractionPattern {
11311147 case Kind::CFunctionAsMethodType:
11321148 case Kind::CurriedCFunctionAsMethodType:
11331149 case Kind::PartialCurriedCFunctionAsMethodType:
1150+ case Kind::CXXFunctionalConstructorType:
11341151 case Kind::CXXMethodType:
11351152 case Kind::CurriedCXXMethodType:
11361153 case Kind::PartialCurriedCXXMethodType:
@@ -1148,7 +1165,8 @@ class AbstractionPattern {
11481165 // / Return whether this abstraction pattern represents a Clang type.
11491166 // / If so, it is legal to return getClangType().
11501167 bool isClangType () const {
1151- return (getKind () == Kind::ClangType);
1168+ return getKind () == Kind::ClangType ||
1169+ getKind () == Kind::CXXFunctionalConstructorType;
11521170 }
11531171
11541172 const clang::Type *getClangType () const {
@@ -1211,6 +1229,7 @@ class AbstractionPattern {
12111229 case Kind::CXXMethodType:
12121230 case Kind::CurriedCXXMethodType:
12131231 case Kind::PartialCurriedCXXMethodType:
1232+ case Kind::CXXFunctionalConstructorType:
12141233 case Kind::OpaqueFunction:
12151234 case Kind::OpaqueDerivativeFunction:
12161235 case Kind::ObjCCompletionHandlerArgumentsType:
@@ -1243,6 +1262,7 @@ class AbstractionPattern {
12431262 case Kind::CFunctionAsMethodType:
12441263 case Kind::CurriedCFunctionAsMethodType:
12451264 case Kind::PartialCurriedCFunctionAsMethodType:
1265+ case Kind::CXXFunctionalConstructorType:
12461266 case Kind::CXXMethodType:
12471267 case Kind::CurriedCXXMethodType:
12481268 case Kind::PartialCurriedCXXMethodType:
@@ -1275,6 +1295,7 @@ class AbstractionPattern {
12751295 case Kind::CXXMethodType:
12761296 case Kind::CurriedCXXMethodType:
12771297 case Kind::PartialCurriedCXXMethodType:
1298+ case Kind::CXXFunctionalConstructorType:
12781299 case Kind::OpaqueFunction:
12791300 case Kind::OpaqueDerivativeFunction:
12801301 case Kind::ObjCCompletionHandlerArgumentsType:
@@ -1306,6 +1327,7 @@ class AbstractionPattern {
13061327 case Kind::CXXMethodType:
13071328 case Kind::CurriedCXXMethodType:
13081329 case Kind::PartialCurriedCXXMethodType:
1330+ case Kind::CXXFunctionalConstructorType:
13091331 case Kind::OpaqueFunction:
13101332 case Kind::OpaqueDerivativeFunction:
13111333 return false ;
@@ -1334,6 +1356,7 @@ class AbstractionPattern {
13341356 case Kind::CXXMethodType:
13351357 case Kind::CurriedCXXMethodType:
13361358 case Kind::PartialCurriedCXXMethodType:
1359+ case Kind::CXXFunctionalConstructorType:
13371360 case Kind::OpaqueFunction:
13381361 case Kind::OpaqueDerivativeFunction:
13391362 llvm_unreachable (" pattern is not a tuple" );
@@ -1414,6 +1437,7 @@ class AbstractionPattern {
14141437 case Kind::CXXMethodType:
14151438 case Kind::CurriedCXXMethodType:
14161439 case Kind::PartialCurriedCXXMethodType:
1440+ case Kind::CXXFunctionalConstructorType:
14171441 case Kind::OpaqueFunction:
14181442 case Kind::OpaqueDerivativeFunction:
14191443 case Kind::ObjCCompletionHandlerArgumentsType:
@@ -1441,6 +1465,7 @@ class AbstractionPattern {
14411465 case Kind::CXXMethodType:
14421466 case Kind::CurriedCXXMethodType:
14431467 case Kind::PartialCurriedCXXMethodType:
1468+ case Kind::CXXFunctionalConstructorType:
14441469 case Kind::OpaqueFunction:
14451470 case Kind::OpaqueDerivativeFunction:
14461471 case Kind::ObjCCompletionHandlerArgumentsType:
0 commit comments