@@ -470,35 +470,22 @@ SILGenModule::getKeyPathProjectionCoroutine(bool isReadAccess,
470
470
471
471
472
472
SILFunction *SILGenModule::emitTopLevelFunction (SILLocation Loc) {
473
- ASTContext &C = M. getASTContext ();
473
+ ASTContext &C = getASTContext ();
474
474
auto extInfo = SILFunctionType::ExtInfo ()
475
475
.withRepresentation (SILFunctionType::Representation::CFunctionPointer);
476
476
477
- auto findStdlibDecl = [&](StringRef name) -> ValueDecl* {
478
- if (!getASTContext ().getStdlibModule ())
479
- return nullptr ;
480
- SmallVector<ValueDecl*, 1 > lookupBuffer;
481
- getASTContext ().getStdlibModule ()->lookupValue ({},
482
- getASTContext ().getIdentifier (name),
483
- NLKind::QualifiedLookup,
484
- lookupBuffer);
485
- if (lookupBuffer.size () == 1 )
486
- return lookupBuffer[0 ];
487
- return nullptr ;
488
- };
489
-
490
477
// Use standard library types if we have them; otherwise, fall back to
491
478
// builtins.
492
479
CanType Int32Ty;
493
- if (auto Int32Decl = dyn_cast_or_null<TypeDecl>( findStdlibDecl ( " Int32 " ) )) {
480
+ if (auto Int32Decl = C. getInt32Decl ( )) {
494
481
Int32Ty = Int32Decl->getDeclaredInterfaceType ()->getCanonicalType ();
495
482
} else {
496
483
Int32Ty = CanType (BuiltinIntegerType::get (32 , C));
497
484
}
498
485
499
486
CanType PtrPtrInt8Ty = C.TheRawPointerType ;
500
487
if (auto PointerDecl = C.getUnsafeMutablePointerDecl ()) {
501
- if (auto Int8Decl = cast<TypeDecl>( findStdlibDecl ( " Int8 " ) )) {
488
+ if (auto Int8Decl = C. getInt8Decl ( )) {
502
489
Type Int8Ty = Int8Decl->getDeclaredInterfaceType ();
503
490
Type PointerInt8Ty = BoundGenericType::get (PointerDecl,
504
491
nullptr ,
0 commit comments