Skip to content

[SILGen] NFC: Remove some stdlib lookups #22471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions lib/SILGen/SILGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,35 +470,22 @@ SILGenModule::getKeyPathProjectionCoroutine(bool isReadAccess,


SILFunction *SILGenModule::emitTopLevelFunction(SILLocation Loc) {
ASTContext &C = M.getASTContext();
ASTContext &C = getASTContext();
auto extInfo = SILFunctionType::ExtInfo()
.withRepresentation(SILFunctionType::Representation::CFunctionPointer);

auto findStdlibDecl = [&](StringRef name) -> ValueDecl* {
if (!getASTContext().getStdlibModule())
return nullptr;
SmallVector<ValueDecl*, 1> lookupBuffer;
getASTContext().getStdlibModule()->lookupValue({},
getASTContext().getIdentifier(name),
NLKind::QualifiedLookup,
lookupBuffer);
if (lookupBuffer.size() == 1)
return lookupBuffer[0];
return nullptr;
};

// Use standard library types if we have them; otherwise, fall back to
// builtins.
CanType Int32Ty;
if (auto Int32Decl = dyn_cast_or_null<TypeDecl>(findStdlibDecl("Int32"))) {
if (auto Int32Decl = C.getInt32Decl()) {
Int32Ty = Int32Decl->getDeclaredInterfaceType()->getCanonicalType();
} else {
Int32Ty = CanType(BuiltinIntegerType::get(32, C));
}

CanType PtrPtrInt8Ty = C.TheRawPointerType;
if (auto PointerDecl = C.getUnsafeMutablePointerDecl()) {
if (auto Int8Decl = cast<TypeDecl>(findStdlibDecl("Int8"))) {
if (auto Int8Decl = C.getInt8Decl()) {
Type Int8Ty = Int8Decl->getDeclaredInterfaceType();
Type PointerInt8Ty = BoundGenericType::get(PointerDecl,
nullptr,
Expand Down