@@ -4587,7 +4587,8 @@ namespace {
4587
4587
4588
4588
// While importing the DeclContext, we might have imported the decl
4589
4589
// itself.
4590
- if (auto Known = Impl.importDeclCached (decl, getVersion ()))
4590
+ if (auto Known =
4591
+ Impl.importDeclCached (decl, getVersion ()).getValueOr (nullptr ))
4591
4592
return Known;
4592
4593
4593
4594
ImportedName importedName;
@@ -5615,7 +5616,8 @@ namespace {
5615
5616
5616
5617
// While importing the DeclContext, we might have imported the decl
5617
5618
// itself.
5618
- if (auto Known = Impl.importDeclCached (decl, getVersion ()))
5619
+ if (auto Known =
5620
+ Impl.importDeclCached (decl, getVersion ()).getValueOr (nullptr ))
5619
5621
return Known;
5620
5622
5621
5623
return importObjCPropertyDecl (decl, dc);
@@ -8271,16 +8273,16 @@ void SwiftDeclConverter::importInheritedConstructors(
8271
8273
}
8272
8274
}
8273
8275
8274
- Decl *ClangImporter::Implementation::importDeclCached (
8275
- const clang::NamedDecl *ClangDecl,
8276
- ImportNameVersion version,
8276
+ Optional<Decl *> ClangImporter::Implementation::importDeclCached (
8277
+ const clang::NamedDecl *ClangDecl, ImportNameVersion version,
8277
8278
bool UseCanonical) {
8278
- auto Known = ImportedDecls.find (
8279
- { UseCanonical? ClangDecl->getCanonicalDecl (): ClangDecl, version });
8279
+ std::pair<const clang::Decl *, Version> Key = {
8280
+ UseCanonical ? ClangDecl->getCanonicalDecl () : ClangDecl, version};
8281
+ auto Known = ImportedDecls.find (Key);
8280
8282
if (Known != ImportedDecls.end ())
8281
8283
return Known->second ;
8282
8284
8283
- return nullptr ;
8285
+ return None ;
8284
8286
}
8285
8287
8286
8288
// / Checks if we don't need to import the typedef itself. If the typedef
@@ -9021,12 +9023,11 @@ Decl *ClangImporter::Implementation::importDeclAndCacheImpl(
9021
9023
Instance->getSourceManager (), " importing" );
9022
9024
9023
9025
auto Canon = cast<clang::NamedDecl>(UseCanonicalDecl? ClangDecl->getCanonicalDecl (): ClangDecl);
9024
-
9025
- if (auto Known = importDeclCached (Canon, version, UseCanonicalDecl)) {
9026
- if (!SuperfluousTypedefsAreTransparent &&
9027
- SuperfluousTypedefs.count (Canon))
9026
+ if (Optional<Decl *> Known =
9027
+ importDeclCached (Canon, version, UseCanonicalDecl)) {
9028
+ if (!SuperfluousTypedefsAreTransparent && SuperfluousTypedefs.count (Canon))
9028
9029
return nullptr ;
9029
- return Known;
9030
+ return Known. getValue () ;
9030
9031
}
9031
9032
9032
9033
bool TypedefIsSuperfluous = false ;
@@ -9035,8 +9036,10 @@ Decl *ClangImporter::Implementation::importDeclAndCacheImpl(
9035
9036
startedImportingEntity ();
9036
9037
Decl *Result = importDeclImpl (ClangDecl, version, TypedefIsSuperfluous,
9037
9038
HadForwardDeclaration);
9038
- if (!Result)
9039
+ if (!Result) {
9040
+ ImportedDecls[{Canon, version}] = nullptr ;
9039
9041
return nullptr ;
9042
+ }
9040
9043
9041
9044
if (TypedefIsSuperfluous) {
9042
9045
SuperfluousTypedefs.insert (Canon);
0 commit comments