mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[interop] do not warn about a template with too many specializations that can't be imported
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
3015
test/Interop/Cxx/templates/Inputs/many-specializations.h
Normal file
3015
test/Interop/Cxx/templates/Inputs/many-specializations.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -152,3 +152,8 @@ module UnevaluatedContext {
|
||||
header "unevaluated-context.h"
|
||||
requires cplusplus
|
||||
}
|
||||
|
||||
module ManySpecializations {
|
||||
header "many-specializations.h"
|
||||
requires cplusplus
|
||||
}
|
||||
|
||||
8
test/Interop/Cxx/templates/many-specializations.swift
Normal file
8
test/Interop/Cxx/templates/many-specializations.swift
Normal 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
|
||||
Reference in New Issue
Block a user