@@ -1927,22 +1927,35 @@ void importer::addEntryToLookupTable(SwiftLookupTable &table,
1927
1927
// possible to find these decls during deserialization. For any C++ typedef
1928
1928
// that defines a name for a class template instantiation (e.g. std::string),
1929
1929
// import the mangled name of this instantiation, and add it to the table.
1930
+ auto addTemplateSpecialization =
1931
+ [&](clang::ClassTemplateSpecializationDecl *specializationDecl) {
1932
+ auto name = nameImporter.importName (specializationDecl, currentVersion);
1933
+
1934
+ // Avoid adding duplicate entries into the table.
1935
+ auto existingEntries =
1936
+ table.lookup (DeclBaseName (name.getDeclName ().getBaseName ()),
1937
+ name.getEffectiveContext ());
1938
+ if (existingEntries.empty ()) {
1939
+ table.addEntry (name.getDeclName (), specializationDecl,
1940
+ name.getEffectiveContext ());
1941
+ }
1942
+ };
1930
1943
if (auto typedefNameDecl = dyn_cast<clang::TypedefNameDecl>(named)) {
1931
1944
auto underlyingDecl = typedefNameDecl->getUnderlyingType ()->getAsTagDecl ();
1932
1945
1933
1946
if (auto specializationDecl =
1934
1947
dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>(
1935
1948
underlyingDecl)) {
1936
- auto name = nameImporter. importName (specializationDecl, currentVersion );
1937
-
1938
- // Avoid adding duplicate entries into the table.
1939
- auto existingEntries =
1940
- table. lookup ( DeclBaseName (name. getDeclName (). getBaseName ()),
1941
- name. getEffectiveContext ());
1942
- if (existingEntries. empty ()) {
1943
- table. addEntry (name. getDeclName (), specializationDecl,
1944
- name. getEffectiveContext ());
1945
- }
1949
+ addTemplateSpecialization (specializationDecl);
1950
+ }
1951
+ }
1952
+ if ( auto valueDecl = dyn_cast<clang::ValueDecl>(named)) {
1953
+ auto valueTypeDecl = valueDecl-> getType ()-> getAsTagDecl ();
1954
+
1955
+ if (auto specializationDecl =
1956
+ dyn_cast_or_null<clang::ClassTemplateSpecializationDecl>(
1957
+ valueTypeDecl)) {
1958
+ addTemplateSpecialization (specializationDecl);
1946
1959
}
1947
1960
}
1948
1961
0 commit comments