@@ -1443,17 +1443,15 @@ class DeclAndTypePrinter::Implementation
1443
1443
}
1444
1444
1445
1445
// / If \p typeDecl is one of the standard library types used to map in Clang
1446
- // / primitives and basic types, return the address of the info in
1447
- // / \c specialNames containing the Clang name and whether it can be optional.
1448
- // /
1449
- // / Returns null if the name is not one of these known types.
1450
- const NameAndOptional *getKnownTypeInfo (const TypeDecl *typeDecl) {
1446
+ // / primitives and basic types, return the info in \c specialNames containing
1447
+ // / the Clang name and whether it can be nullable in C.
1448
+ Optional<CTypeInfo> getKnownTypeInfo (const TypeDecl *typeDecl) {
1451
1449
auto &specialNames = owningPrinter.specialNames ;
1452
1450
if (specialNames.empty ()) {
1453
1451
ASTContext &ctx = getASTContext ();
1454
1452
#define MAP (SWIFT_NAME, CLANG_REPR, NEEDS_NULLABILITY ) \
1455
1453
specialNames[{ctx.StdlibModuleName , ctx.getIdentifier (#SWIFT_NAME)}] = \
1456
- { CLANG_REPR, NEEDS_NULLABILITY}
1454
+ { CLANG_REPR, NEEDS_NULLABILITY }
1457
1455
1458
1456
MAP (CBool, " bool" , false );
1459
1457
@@ -1534,8 +1532,8 @@ class DeclAndTypePrinter::Implementation
1534
1532
Identifier name = typeDecl->getName ();
1535
1533
auto iter = specialNames.find ({moduleName, name});
1536
1534
if (iter == specialNames.end ())
1537
- return nullptr ;
1538
- return & iter->second ;
1535
+ return None ;
1536
+ return iter->second ;
1539
1537
}
1540
1538
1541
1539
// / If \p typeDecl is one of the standard library types used to map in Clang
@@ -1546,11 +1544,11 @@ class DeclAndTypePrinter::Implementation
1546
1544
// / for interfacing with C and Objective-C.
1547
1545
bool printIfKnownSimpleType (const TypeDecl *typeDecl,
1548
1546
Optional<OptionalTypeKind> optionalKind) {
1549
- auto * knownTypeInfo = getKnownTypeInfo (typeDecl);
1547
+ Optional<CTypeInfo> knownTypeInfo = getKnownTypeInfo (typeDecl);
1550
1548
if (!knownTypeInfo)
1551
1549
return false ;
1552
- os << knownTypeInfo->first ;
1553
- if (knownTypeInfo->second )
1550
+ os << knownTypeInfo->name ;
1551
+ if (knownTypeInfo->canBeNullable )
1554
1552
printNullability (optionalKind);
1555
1553
return true ;
1556
1554
}
0 commit comments