|
30 | 30 | #include "swift/AST/ImportCache.h"
|
31 | 31 | #include "swift/AST/LinkLibrary.h"
|
32 | 32 | #include "swift/AST/Module.h"
|
| 33 | +#include "swift/AST/ModuleNameLookup.h" |
33 | 34 | #include "swift/AST/NameLookup.h"
|
34 | 35 | #include "swift/AST/NameLookupRequests.h"
|
35 | 36 | #include "swift/AST/PrettyStackTrace.h"
|
@@ -6917,9 +6918,23 @@ CustomRefCountingOperationResult CustomRefCountingOperation::evaluate(
|
6917 | 6918 | auto *clangMod = swiftDecl->getClangDecl()->getOwningModule();
|
6918 | 6919 | if (clangMod && clangMod->isSubModule())
|
6919 | 6920 | clangMod = clangMod->getTopLevelModule();
|
6920 |
| - auto parentModule = ctx.getClangModuleLoader()->getWrapperForModule(clangMod); |
6921 |
| - ctx.lookupInModule(parentModule, name, results); |
6922 |
| - |
| 6921 | + if (clangMod) { |
| 6922 | + auto parentModule = ctx.getClangModuleLoader()->getWrapperForModule(clangMod); |
| 6923 | + ctx.lookupInModule(parentModule, name, results); |
| 6924 | + } else { |
| 6925 | + // There is no Clang module for this declaration, so perform lookup from |
| 6926 | + // the main module. This will find declarations from the bridging header. |
| 6927 | + namelookup::lookupInModule( |
| 6928 | + ctx.MainModule, ctx.getIdentifier(name), results, |
| 6929 | + NLKind::UnqualifiedLookup, namelookup::ResolutionKind::Overloadable, |
| 6930 | + ctx.MainModule, SourceLoc(), NL_UnqualifiedDefault); |
| 6931 | + |
| 6932 | + // Filter out any declarations that didn't come from Clang. |
| 6933 | + auto newEnd = std::remove_if(results.begin(), results.end(), [&](ValueDecl *decl) { |
| 6934 | + return !decl->getClangDecl(); |
| 6935 | + }); |
| 6936 | + results.erase(newEnd, results.end()); |
| 6937 | + } |
6923 | 6938 | if (results.size() == 1)
|
6924 | 6939 | return {CustomRefCountingOperationResult::foundOperation, results.front(),
|
6925 | 6940 | name};
|
|
0 commit comments