[interop] do not warn about a template with too many specializations that can't be imported

This commit is contained in:
Alex Lorenz
2023-07-06 13:40:05 -07:00
committed by Alex Lorenz
parent c413a80346
commit 8ed840f9c1
6 changed files with 3034 additions and 14 deletions

View File

@@ -128,10 +128,6 @@ WARNING(libstdcxx_modulemap_not_found, none,
"module map for libstdc++ not found for '%0'; C++ stdlib may be unavailable",
(StringRef))
WARNING(too_many_class_template_instantiations, none,
"template instantiation for '%0' not imported: too many instantiations",
(StringRef))
WARNING(api_pattern_attr_ignored, none,
"'%0' swift attribute ignored on type '%1': type is not copyable or destructible",
(StringRef, StringRef))

View File

@@ -2914,12 +2914,12 @@ namespace {
if (size_t(
llvm::size(decl->getSpecializedTemplate()->specializations())) >
specializationLimit) {
std::string name;
llvm::raw_string_ostream os(name);
decl->printQualifiedName(os);
// Emit a warning if we haven't warned about this decl yet.
if (Impl.tooDeepTemplateSpecializations.insert(name).second)
Impl.diagnose({}, diag::too_many_class_template_instantiations, name);
// 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.
return nullptr;
}

View File

@@ -655,10 +655,6 @@ public:
llvm::DenseMap<clang::FunctionDecl *, ValueDecl *>
specializedFunctionTemplates;
/// Stores qualified names of C++ template specializations that were too deep
/// to import into Swift.
llvm::StringSet<> tooDeepTemplateSpecializations;
/// Keeps track of the Clang functions that have been turned into
/// properties.
llvm::DenseMap<const clang::FunctionDecl *, VarDecl *> FunctionsAsProperties;

File diff suppressed because it is too large Load Diff

View File

@@ -152,3 +152,8 @@ module UnevaluatedContext {
header "unevaluated-context.h"
requires cplusplus
}
module ManySpecializations {
header "many-specializations.h"
requires cplusplus
}

View File

@@ -0,0 +1,8 @@
// RUN: %target-swift-ide-test -print-module -module-to-print=ManySpecializations -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
// CHECK: @available(*, unavailable, message: "Un-specialized class templates are not currently supported. Please use a specialization of this type.")
// CHECK-NEXT: struct TemplateStruct<T> {
// CHECK-NEXT: }
// CHECK-NOT: typealias