Skip to content

Commit 677f500

Browse files
committed
TypeReconstruction: Replace FunctionType::getOld() with explicit decomposeInput()
This is not any "better" because we also want to eventually remove decomposeInput() too. However we're planning on scrapping TypeReconstruction altogether so its unlikely that refactoring this to do the right thing will be worth it. Instead just inline what getOld() does so we can move forward.
1 parent 53d82f7 commit 677f500

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

lib/IDE/TypeReconstruction.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,15 +1466,15 @@ static void CreateFunctionType(ASTContext *ast,
14661466
bool escaping,
14671467
bool throws,
14681468
VisitNodeResult &result) {
1469-
Type arg_clang_type;
1470-
Type return_clang_type;
1469+
Type arg_type;
1470+
Type return_type;
14711471

14721472
switch (arg_type_result._types.size()) {
14731473
case 0:
1474-
arg_clang_type = TupleType::getEmpty(*ast);
1474+
arg_type = TupleType::getEmpty(*ast);
14751475
break;
14761476
case 1:
1477-
arg_clang_type = arg_type_result._types.front().getPointer();
1477+
arg_type = arg_type_result._types.front().getPointer();
14781478
break;
14791479
default:
14801480
result._error = "too many argument types for a function type";
@@ -1483,22 +1483,28 @@ static void CreateFunctionType(ASTContext *ast,
14831483

14841484
switch (return_type_result._types.size()) {
14851485
case 0:
1486-
return_clang_type = TupleType::getEmpty(*ast);
1486+
return_type = TupleType::getEmpty(*ast);
14871487
break;
14881488
case 1:
1489-
return_clang_type = return_type_result._types.front().getPointer();
1489+
return_type = return_type_result._types.front().getPointer();
14901490
break;
14911491
default:
14921492
result._error = "too many return types for a function type";
14931493
break;
14941494
}
14951495

1496-
if (arg_clang_type && return_clang_type) {
1497-
result._types.push_back(
1498-
FunctionType::getOld(arg_clang_type, return_clang_type,
1499-
FunctionType::ExtInfo()
1500-
.withNoEscape(!escaping)
1501-
.withThrows(throws)));
1496+
if (arg_type && return_type) {
1497+
// FIXME: We need to either refactor this code to build function parameters
1498+
// directly, or better yet, scrap TypeReconstruction altogether in favor of
1499+
// TypeDecoder which already does the right thing.
1500+
SmallVector<AnyFunctionType::Param, 8> params;
1501+
AnyFunctionType::decomposeInput(arg_type, params);
1502+
1503+
auto ext_info =
1504+
FunctionType::ExtInfo()
1505+
.withNoEscape(!escaping)
1506+
.withThrows(throws);
1507+
result._types.push_back(FunctionType::get(params, return_type, ext_info));
15021508
}
15031509
}
15041510

0 commit comments

Comments
 (0)