Skip to content

Commit a2ced86

Browse files
authored
Merge pull request swiftlang#84078 from Xazax-hun/simd-is-escapable-on-6.2
[6.2][cxx-interop] Handle vector types in escapability analysis
2 parents 4008d30 + a2f4aba commit a2ced86

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5322,6 +5322,14 @@ ClangTypeEscapability::evaluate(Evaluator &evaluator,
53225322
ClangTypeEscapability({elemTy, desc.impl, desc.annotationOnly}),
53235323
CxxEscapability::Unknown);
53245324
}
5325+
if (const auto *vecTy = desugared->getAs<clang::VectorType>()) {
5326+
return evaluateOrDefault(
5327+
evaluator,
5328+
ClangTypeEscapability(
5329+
{vecTy->getElementType()->getUnqualifiedDesugaredType(), desc.impl,
5330+
desc.annotationOnly}),
5331+
CxxEscapability::Unknown);
5332+
}
53255333

53265334
// Base cases
53275335
if (desugared->isAnyPointerType() || desugared->isBlockPointerType() ||
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: rm -rf %t
2+
// RUN: split-file %s %t
3+
// RUN: %target-swift-frontend -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging -Xcc -std=c++20 -I %t/Inputs %t/test.swift -strict-memory-safety -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1
4+
5+
// REQUIRES: objc_interop
6+
// REQUIRES: swift_feature_LifetimeDependence
7+
// REQUIRES: OS=macosx
8+
9+
//--- Inputs/module.modulemap
10+
module Test {
11+
header "nonescapable.h"
12+
requires cplusplus
13+
}
14+
15+
//--- Inputs/nonescapable.h
16+
#pragma once
17+
18+
#include <simd/simd.h>
19+
#include <vector>
20+
21+
using VecOfSimd = std::vector<simd::float3>;
22+
using MySimd = simd::float3;
23+
24+
//--- test.swift
25+
import Test
26+
import CxxStdlib
27+
28+
func simdConsideredSafe(x : MySimd) {
29+
let _ = x
30+
}
31+
32+
func simdVecConsideredSafe(x : VecOfSimd) {
33+
let _ = x
34+
}

0 commit comments

Comments
 (0)