Skip to content

Commit ae93474

Browse files
committed
Revert "[cxx-interop] Do not import template type arguments"
This reverts commit d5473fe.
1 parent 4389cc9 commit ae93474

File tree

2 files changed

+28
-53
lines changed

2 files changed

+28
-53
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,6 +2301,34 @@ namespace {
23012301
}
23022302
}
23032303

2304+
// We have to do this after populating ImportedDecls to avoid importing
2305+
// the same decl multiple times. Also after we imported the bases.
2306+
if (const auto *ctsd =
2307+
dyn_cast<clang::ClassTemplateSpecializationDecl>(decl)) {
2308+
for (auto arg : ctsd->getTemplateArgs().asArray()) {
2309+
llvm::SmallVector<clang::TemplateArgument, 1> nonPackArgs;
2310+
if (arg.getKind() == clang::TemplateArgument::Pack) {
2311+
auto pack = arg.getPackAsArray();
2312+
nonPackArgs.assign(pack.begin(), pack.end());
2313+
} else {
2314+
nonPackArgs.push_back(arg);
2315+
}
2316+
for (auto realArg : nonPackArgs) {
2317+
if (realArg.getKind() != clang::TemplateArgument::Type)
2318+
continue;
2319+
auto SwiftType = Impl.importTypeIgnoreIUO(
2320+
realArg.getAsType(), ImportTypeKind::Abstract,
2321+
[](Diagnostic &&diag) {}, false, Bridgeability::None,
2322+
ImportTypeAttrs());
2323+
if (SwiftType && SwiftType->isUnsafe()) {
2324+
auto attr = new (Impl.SwiftContext) UnsafeAttr(/*implicit=*/true);
2325+
result->getAttrs().add(attr);
2326+
break;
2327+
}
2328+
}
2329+
}
2330+
}
2331+
23042332
bool isNonEscapable = false;
23052333
if (evaluateOrDefault(
23062334
Impl.SwiftContext.evaluator,

test/Interop/Cxx/templates/sfinae-template-type-arguments.swift

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)