@@ -2732,36 +2732,41 @@ void ClangImporter::lookupTypeDecl(
2732
2732
clang::DeclarationName clangName (
2733
2733
&Impl.Instance ->getASTContext ().Idents .get (rawName));
2734
2734
2735
- clang::Sema::LookupNameKind lookupKind ;
2735
+ SmallVector< clang::Sema::LookupNameKind, 1 > lookupKinds ;
2736
2736
switch (kind) {
2737
2737
case ClangTypeKind::Typedef:
2738
- lookupKind = clang::Sema::LookupOrdinaryName;
2738
+ lookupKinds. push_back ( clang::Sema::LookupOrdinaryName) ;
2739
2739
break ;
2740
2740
case ClangTypeKind::Tag:
2741
- lookupKind = clang::Sema::LookupTagName;
2741
+ lookupKinds.push_back (clang::Sema::LookupTagName);
2742
+ lookupKinds.push_back (clang::Sema::LookupNamespaceName);
2742
2743
break ;
2743
2744
case ClangTypeKind::ObjCProtocol:
2744
- lookupKind = clang::Sema::LookupObjCProtocolName;
2745
+ lookupKinds. push_back ( clang::Sema::LookupObjCProtocolName) ;
2745
2746
break ;
2746
2747
}
2747
2748
2748
2749
// Perform name lookup into the global scope.
2749
2750
auto &sema = Impl.Instance ->getSema ();
2750
- clang::LookupResult lookupResult (sema, clangName, clang::SourceLocation (),
2751
- lookupKind);
2752
2751
bool foundViaClang = false ;
2753
- if (!Impl.DisableSourceImport &&
2754
- sema.LookupName (lookupResult, /* Scope=*/ nullptr )) {
2755
- for (auto clangDecl : lookupResult) {
2756
- if (!isa<clang::TypeDecl>(clangDecl) &&
2757
- !isa<clang::ObjCContainerDecl>(clangDecl) &&
2758
- !isa<clang::ObjCCompatibleAliasDecl>(clangDecl)) {
2759
- continue ;
2760
- }
2761
- auto *imported = Impl.importDecl (clangDecl, Impl.CurrentVersion );
2762
- if (auto *importedType = dyn_cast_or_null<TypeDecl>(imported)) {
2763
- foundViaClang = true ;
2764
- receiver (importedType);
2752
+
2753
+ for (auto lookupKind : lookupKinds) {
2754
+ clang::LookupResult lookupResult (sema, clangName, clang::SourceLocation (),
2755
+ lookupKind);
2756
+ if (!Impl.DisableSourceImport &&
2757
+ sema.LookupName (lookupResult, /* Scope=*/ sema.TUScope )) {
2758
+ for (auto clangDecl : lookupResult) {
2759
+ if (!isa<clang::TypeDecl>(clangDecl) &&
2760
+ !isa<clang::NamespaceDecl>(clangDecl) &&
2761
+ !isa<clang::ObjCContainerDecl>(clangDecl) &&
2762
+ !isa<clang::ObjCCompatibleAliasDecl>(clangDecl)) {
2763
+ continue ;
2764
+ }
2765
+ auto *imported = Impl.importDecl (clangDecl, Impl.CurrentVersion );
2766
+ if (auto *importedType = dyn_cast_or_null<TypeDecl>(imported)) {
2767
+ foundViaClang = true ;
2768
+ receiver (importedType);
2769
+ }
2765
2770
}
2766
2771
}
2767
2772
}
0 commit comments