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",
|
"module map for libstdc++ not found for '%0'; C++ stdlib may be unavailable",
|
||||||
(StringRef))
|
(StringRef))
|
||||||
|
|
||||||
WARNING(too_many_class_template_instantiations, none,
|
|
||||||
"template instantiation for '%0' not imported: too many instantiations",
|
|
||||||
(StringRef))
|
|
||||||
|
|
||||||
WARNING(api_pattern_attr_ignored, none,
|
WARNING(api_pattern_attr_ignored, none,
|
||||||
"'%0' swift attribute ignored on type '%1': type is not copyable or destructible",
|
"'%0' swift attribute ignored on type '%1': type is not copyable or destructible",
|
||||||
(StringRef, StringRef))
|
(StringRef, StringRef))
|
||||||
|
|||||||
@@ -2914,12 +2914,12 @@ namespace {
|
|||||||
if (size_t(
|
if (size_t(
|
||||||
llvm::size(decl->getSpecializedTemplate()->specializations())) >
|
llvm::size(decl->getSpecializedTemplate()->specializations())) >
|
||||||
specializationLimit) {
|
specializationLimit) {
|
||||||
std::string name;
|
// Note: it would be nice to import a dummy unavailable struct,
|
||||||
llvm::raw_string_ostream os(name);
|
// but we would then need to instantiate the template here,
|
||||||
decl->printQualifiedName(os);
|
// as we cannot import a struct without a definition. That would
|
||||||
// Emit a warning if we haven't warned about this decl yet.
|
// defeat the purpose. Also, we can't make the dummy
|
||||||
if (Impl.tooDeepTemplateSpecializations.insert(name).second)
|
// struct simply unavailable, as that still makes the
|
||||||
Impl.diagnose({}, diag::too_many_class_template_instantiations, name);
|
// typelias that references it available.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -655,10 +655,6 @@ public:
|
|||||||
llvm::DenseMap<clang::FunctionDecl *, ValueDecl *>
|
llvm::DenseMap<clang::FunctionDecl *, ValueDecl *>
|
||||||
specializedFunctionTemplates;
|
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
|
/// Keeps track of the Clang functions that have been turned into
|
||||||
/// properties.
|
/// properties.
|
||||||
llvm::DenseMap<const clang::FunctionDecl *, VarDecl *> FunctionsAsProperties;
|
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"
|
header "unevaluated-context.h"
|
||||||
requires cplusplus
|
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