Skip to content

Commit b10c2c8

Browse files
committed
Paramterize module in lookupIntrinsic
The lookupConcurrencyIntrinsic function only looked in the concurrency module. It is useful to look in other modules for intrinsics too.
1 parent 20f9aff commit b10c2c8

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -338,24 +338,15 @@ SILGenModule::getConformanceToBridgedStoredNSError(SILLocation loc, Type type) {
338338
return SwiftModule->lookupConformance(type, proto);
339339
}
340340

341-
static FuncDecl *lookupConcurrencyIntrinsic(ASTContext &C,
342-
Optional<FuncDecl*> &cache,
343-
StringRef name) {
341+
static FuncDecl *lookupIntrinsic(ModuleDecl &module,
342+
Optional<FuncDecl *> &cache, Identifier name) {
344343
if (cache)
345344
return *cache;
346-
347-
auto *module = C.getLoadedModule(C.Id_Concurrency);
348-
if (!module) {
349-
cache = nullptr;
350-
return nullptr;
351-
}
352-
353-
SmallVector<ValueDecl *, 1> decls;
354-
module->lookupQualified(module,
355-
DeclNameRef(C.getIdentifier(name)),
356-
NL_QualifiedDefault | NL_IncludeUsableFromInline,
357-
decls);
358345

346+
SmallVector<ValueDecl *, 1> decls;
347+
module.lookupQualified(&module, DeclNameRef(name),
348+
NL_QualifiedDefault | NL_IncludeUsableFromInline,
349+
decls);
359350
if (decls.size() != 1) {
360351
cache = nullptr;
361352
return nullptr;
@@ -365,6 +356,18 @@ static FuncDecl *lookupConcurrencyIntrinsic(ASTContext &C,
365356
return func;
366357
}
367358

359+
static FuncDecl *lookupConcurrencyIntrinsic(ASTContext &C,
360+
Optional<FuncDecl *> &cache,
361+
StringRef name) {
362+
auto *module = C.getLoadedModule(C.Id_Concurrency);
363+
if (!module) {
364+
cache = nullptr;
365+
return nullptr;
366+
}
367+
368+
return lookupIntrinsic(*module, cache, C.getIdentifier(name));
369+
}
370+
368371
FuncDecl *
369372
SILGenModule::getAsyncLetStart() {
370373
return lookupConcurrencyIntrinsic(getASTContext(),

0 commit comments

Comments
 (0)