Skip to content

Commit daf7d24

Browse files
authored
Merge pull request #22471 from Azoy/main-cleanups
2 parents a1d38c1 + f464cce commit daf7d24

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -470,35 +470,22 @@ SILGenModule::getKeyPathProjectionCoroutine(bool isReadAccess,
470470

471471

472472
SILFunction *SILGenModule::emitTopLevelFunction(SILLocation Loc) {
473-
ASTContext &C = M.getASTContext();
473+
ASTContext &C = getASTContext();
474474
auto extInfo = SILFunctionType::ExtInfo()
475475
.withRepresentation(SILFunctionType::Representation::CFunctionPointer);
476476

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-
490477
// Use standard library types if we have them; otherwise, fall back to
491478
// builtins.
492479
CanType Int32Ty;
493-
if (auto Int32Decl = dyn_cast_or_null<TypeDecl>(findStdlibDecl("Int32"))) {
480+
if (auto Int32Decl = C.getInt32Decl()) {
494481
Int32Ty = Int32Decl->getDeclaredInterfaceType()->getCanonicalType();
495482
} else {
496483
Int32Ty = CanType(BuiltinIntegerType::get(32, C));
497484
}
498485

499486
CanType PtrPtrInt8Ty = C.TheRawPointerType;
500487
if (auto PointerDecl = C.getUnsafeMutablePointerDecl()) {
501-
if (auto Int8Decl = cast<TypeDecl>(findStdlibDecl("Int8"))) {
488+
if (auto Int8Decl = C.getInt8Decl()) {
502489
Type Int8Ty = Int8Decl->getDeclaredInterfaceType();
503490
Type PointerInt8Ty = BoundGenericType::get(PointerDecl,
504491
nullptr,

0 commit comments

Comments
 (0)