Skip to content

Commit edf90fd

Browse files
authored
Merge pull request #85177 from j-hui/template-arg-safety-in-req
[cxx-interop] Avoid cycles in ClangTypeExplicitSafety requests
2 parents fc168a0 + c005445 commit edf90fd

22 files changed

+8
-68
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8789,11 +8789,13 @@ CustomRefCountingOperationResult CustomRefCountingOperation::evaluate(
87898789

87908790
/// Check whether the given Clang type involves an unsafe type.
87918791
static bool hasUnsafeType(Evaluator &evaluator, clang::QualType clangType) {
8792-
8793-
auto safety =
8794-
evaluateOrDefault(evaluator, ClangTypeExplicitSafety({clangType}),
8795-
ExplicitSafety::Unspecified);
8796-
return safety == ExplicitSafety::Unsafe;
8792+
auto req = ClangTypeExplicitSafety({clangType});
8793+
if (evaluator.hasActiveRequest(req))
8794+
// If there is a cycle in a type, assume ExplicitSafety is Unspecified,
8795+
// i.e., not unsafe:
8796+
return false;
8797+
return evaluateOrDefault(evaluator, req, ExplicitSafety::Unspecified) ==
8798+
ExplicitSafety::Unsafe;
87978799
}
87988800

87998801
ExplicitSafety

test/Interop/Cxx/class/access/swiftify-private-fileid.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
// REQUIRES: swift_feature_SafeInteropWrappers
77
// REQUIRES: std_span
88

9-
// rdar://163511959 error: circular reference
10-
// XFAIL: *
11-
129
//--- Inputs/swiftify-non-public.h
1310
#pragma once
1411

test/Interop/Cxx/class/noncopyable-typechecker.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// RUN: %target-swift-frontend -cxx-interoperability-mode=default -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t%{fs-sep}Inputs %t%{fs-sep}test.swift -verify-additional-file %t%{fs-sep}Inputs%{fs-sep}noncopyable.h
44
// RUN: %target-swift-frontend -cxx-interoperability-mode=default -Xcc -std=c++20 -verify-additional-prefix cpp20- -D CPP20 -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t%{fs-sep}Inputs %t%{fs-sep}test.swift -verify-additional-file %t%{fs-sep}Inputs%{fs-sep}noncopyable.h
55

6-
// rdar://163511959 error: circular reference
7-
// XFAIL: *
8-
96
//--- Inputs/module.modulemap
107
module Test {
118
header "noncopyable.h"

test/Interop/Cxx/class/safe-interop-mode-darwin.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
// REQUIRES: swift_feature_LifetimeDependence
77
// REQUIRES: OS=macosx
88

9-
// rdar://163511959 error: circular reference
10-
// XFAIL: *
11-
129
//--- Inputs/module.modulemap
1310
module Test {
1411
header "nonescapable.h"
@@ -34,4 +31,4 @@ func simdConsideredSafe(x : MySimd) {
3431

3532
func simdVecConsideredSafe(x : VecOfSimd) {
3633
let _ = x
37-
}
34+
}

test/Interop/Cxx/class/safe-interop-mode.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
// REQUIRES: swift_feature_LifetimeDependence
88
// REQUIRES: std_span
99

10-
// rdar://163511959 error: circular reference
11-
// XFAIL: *
12-
1310
//--- Inputs/module.modulemap
1411
module Test {
1512
header "nonescapable.h"

test/Interop/Cxx/operators/member-inline.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
//
55
// REQUIRES: executable_test
66

7-
// rdar://163511959 error: circular reference
8-
// XFAIL: *
9-
107
import MemberInline
118
import StdlibUnittest
129

test/Interop/Cxx/stdlib/foundation-and-std-module.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
// RUN: ls -R %/t | %FileCheck %s
1111

12-
// rdar://163511959 error: circular reference
13-
// XFAIL: *
14-
1512
#if canImport(Foundation)
1613
import Foundation
1714
#endif

test/Interop/Cxx/stdlib/std-span-interface.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
// REQUIRES: swift_feature_Lifetimes
1010
// REQUIRES: std_span
1111

12-
// rdar://163511959 error: circular reference
13-
// XFAIL: *
14-
1512
#if !BRIDGING_HEADER
1613
import StdSpan
1714
#endif

test/Interop/Cxx/stdlib/std-span-transformed-execution.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
// REQUIRES: executable_test
1010
// REQUIRES: std_span
1111

12-
// rdar://163511959 error: circular reference
13-
// XFAIL: *
14-
1512
#if !BRIDGING_HEADER
1613
import StdSpan
1714
#endif

test/Interop/Cxx/stdlib/use-std-any.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// type, which Swift isn't able to instantiate.
99
// UNSUPPORTED: OS=windows-msvc
1010

11-
// rdar://163511959 error: circular reference
12-
// XFAIL: *
13-
1411
import StdlibUnittest
1512
import StdAny
1613
import CxxStdlib

0 commit comments

Comments
 (0)