Skip to content

Commit 9d6fe19

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 3f9a378 commit 9d6fe19

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
@@ -327,24 +327,15 @@ SILGenModule::getConformanceToBridgedStoredNSError(SILLocation loc, Type type) {
327327
return SwiftModule->lookupConformance(type, proto);
328328
}
329329

330-
static FuncDecl *lookupConcurrencyIntrinsic(ASTContext &C,
331-
Optional<FuncDecl*> &cache,
332-
StringRef name) {
330+
static FuncDecl *lookupIntrinsic(ModuleDecl &module,
331+
Optional<FuncDecl *> &cache, Identifier name) {
333332
if (cache)
334333
return *cache;
335-
336-
auto *module = C.getLoadedModule(C.Id_Concurrency);
337-
if (!module) {
338-
cache = nullptr;
339-
return nullptr;
340-
}
341-
342-
SmallVector<ValueDecl *, 1> decls;
343-
module->lookupQualified(module,
344-
DeclNameRef(C.getIdentifier(name)),
345-
NL_QualifiedDefault | NL_IncludeUsableFromInline,
346-
decls);
347334

335+
SmallVector<ValueDecl *, 1> decls;
336+
module.lookupQualified(&module, DeclNameRef(name),
337+
NL_QualifiedDefault | NL_IncludeUsableFromInline,
338+
decls);
348339
if (decls.size() != 1) {
349340
cache = nullptr;
350341
return nullptr;
@@ -354,6 +345,18 @@ static FuncDecl *lookupConcurrencyIntrinsic(ASTContext &C,
354345
return func;
355346
}
356347

348+
static FuncDecl *lookupConcurrencyIntrinsic(ASTContext &C,
349+
Optional<FuncDecl *> &cache,
350+
StringRef name) {
351+
auto *module = C.getLoadedModule(C.Id_Concurrency);
352+
if (!module) {
353+
cache = nullptr;
354+
return nullptr;
355+
}
356+
357+
return lookupIntrinsic(*module, cache, C.getIdentifier(name));
358+
}
359+
357360
FuncDecl *
358361
SILGenModule::getAsyncLetStart() {
359362
return lookupConcurrencyIntrinsic(getASTContext(),

0 commit comments

Comments
 (0)