Skip to content

Commit 929d0d8

Browse files
committed
[cxx-interop] Avoid cycles in ClangDeclExplicitSafety requests
1 parent d2632d2 commit 929d0d8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8709,9 +8709,14 @@ ExplicitSafety ClangTypeExplicitSafety::evaluate(
87098709
if (auto recordDecl = clangType->getAsTagDecl()) {
87108710
// If we reached this point the types is not imported as a shared reference,
87118711
// so we don't need to check the bases whether they are shared references.
8712-
return evaluateOrDefault(evaluator,
8713-
ClangDeclExplicitSafety({recordDecl, false}),
8714-
ExplicitSafety::Unspecified);
8712+
auto req = ClangDeclExplicitSafety({recordDecl, false});
8713+
if (evaluator.hasActiveRequest(req))
8714+
// Cycles are allowed in templates, e.g.:
8715+
// template <typename> class Foo { ... }; // throws away template arg
8716+
// template <typename T> class Bar : Foo<Bar<T>> { ... };
8717+
// We need to avoid them here.
8718+
return ExplicitSafety::Unspecified;
8719+
return evaluateOrDefault(evaluator, req, ExplicitSafety::Unspecified);
87158720
}
87168721

87178722
// Everything else is safe.

0 commit comments

Comments
 (0)