diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 3b4c076227277..2ab6224eeb057 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -3237,26 +3237,12 @@ namespace { Decl *VisitClassTemplateSpecializationDecl( const clang::ClassTemplateSpecializationDecl *decl) { - bool isPair = decl->getSpecializedTemplate()->isInStdNamespace() && - decl->getSpecializedTemplate()->getName() == "pair"; - - // Before we go any further, check if we've already got tens of thousands - // of specializations. If so, it means we're likely instantiating a very - // deep/complex template, or we've run into an infinite loop. In either - // case, its not worth the compile time, so bail. - // TODO: this could be configurable at some point. - size_t specializationLimit = !isPair ? 1000 : 10000; - if (size_t( - llvm::size(decl->getSpecializedTemplate()->specializations())) > - specializationLimit) { - // Note: it would be nice to import a dummy unavailable struct, - // but we would then need to instantiate the template here, - // as we cannot import a struct without a definition. That would - // defeat the purpose. Also, we can't make the dummy - // struct simply unavailable, as that still makes the - // typelias that references it available. + // Importing std::conditional substantially increases compile times when + // building with libstdc++, i.e. on most Linux distros. + if (decl->isInStdNamespace() && decl->getIdentifier() && + (decl->getName() == "conditional" || decl->getName() == "__or_" || + decl->getName() == "_Expr")) return nullptr; - } // `decl->getDefinition()` can return nullptr before the call to sema and // return its definition afterwards. diff --git a/test/Interop/Cxx/templates/many-specializations.swift b/test/Interop/Cxx/templates/many-specializations.swift index a1ae3f5f43a75..cc6f6820a15b5 100644 --- a/test/Interop/Cxx/templates/many-specializations.swift +++ b/test/Interop/Cxx/templates/many-specializations.swift @@ -5,4 +5,4 @@ // CHECK-NEXT: struct TemplateStruct { // CHECK-NEXT: } -// CHECK-NOT: typealias +// CHECK: typealias T1000