@@ -219,7 +219,7 @@ bool SwiftLookupTable::contextRequiresName(ContextKind kind) {
219
219
220
220
// / Try to translate the given Clang declaration into a context.
221
221
static std::optional<SwiftLookupTable::StoredContext>
222
- translateDeclToContext (const clang::NamedDecl *decl) {
222
+ translateDeclToContext (clang::NamedDecl *decl) {
223
223
// Tag declaration.
224
224
if (auto tag = dyn_cast<clang::TagDecl>(decl)) {
225
225
if (tag->getIdentifier ())
@@ -324,46 +324,22 @@ SwiftLookupTable::translateContext(EffectiveClangContext context) {
324
324
325
325
// / Lookup an unresolved context name and resolve it to a Clang
326
326
// / declaration context or typedef name.
327
- const clang::NamedDecl *
328
- SwiftLookupTable::resolveContext (StringRef unresolvedName) {
329
- SmallVector<StringRef, 1 > nameComponents;
330
- unresolvedName.split (nameComponents, ' .' );
331
-
332
- EffectiveClangContext parentContext;
333
-
327
+ clang::NamedDecl *SwiftLookupTable::resolveContext (StringRef unresolvedName) {
334
328
// Look for a context with the given Swift name.
335
- for (auto nameComponent : nameComponents) {
336
- auto entries =
337
- parentContext
338
- ? lookup (SerializedSwiftName (nameComponent), parentContext)
339
- : lookup (SerializedSwiftName (nameComponent),
340
- std::make_pair (ContextKind::TranslationUnit, StringRef ()));
341
- bool entryFound = false ;
342
- for (auto entry : entries) {
343
- if (auto decl = entry.dyn_cast <clang::NamedDecl *>()) {
344
- if (isa<clang::TagDecl>(decl) ||
345
- isa<clang::ObjCInterfaceDecl>(decl) ||
346
- isa<clang::NamespaceDecl>(decl)) {
347
- entryFound = true ;
348
- parentContext = EffectiveClangContext (cast<clang::DeclContext>(decl));
349
- break ;
350
- }
351
- if (auto typedefDecl = dyn_cast<clang::TypedefNameDecl>(decl)) {
352
- entryFound = true ;
353
- parentContext = EffectiveClangContext (typedefDecl);
354
- break ;
355
- }
356
- }
329
+ for (auto entry :
330
+ lookup (SerializedSwiftName (unresolvedName),
331
+ std::make_pair (ContextKind::TranslationUnit, StringRef ()))) {
332
+ if (auto decl = entry.dyn_cast <clang::NamedDecl *>()) {
333
+ if (isa<clang::TagDecl>(decl) ||
334
+ isa<clang::ObjCInterfaceDecl>(decl) ||
335
+ isa<clang::TypedefNameDecl>(decl))
336
+ return decl;
357
337
}
358
-
359
- // If we could not resolve this component of the qualified name, bail.
360
- if (!entryFound)
361
- return nullptr ;
362
338
}
363
339
364
- return parentContext. getAsDeclContext ()
365
- ? cast<clang::NamedDecl>(parentContext. getAsDeclContext ())
366
- : parentContext. getTypedefName () ;
340
+ // FIXME: Search imported modules to resolve the context.
341
+
342
+ return nullptr ;
367
343
}
368
344
369
345
void SwiftLookupTable::addCategory (clang::ObjCCategoryDecl *category) {
0 commit comments