Files
swift-mirror/test/Interop/C/swiftify-import/counted-by-no-swiftify.swift
John Hui e5b1f4a251 [Swiftify] Do not swiftify non-Swift-like counted_by exprs
__counted_by (and __sized_by) expressions can have arbitrary C syntax
in them, such as:

    void foo(int * __counted_by(*len) p, int *len);

When @_SwififyImport tries to generate Swift code for this, the
expression `*len` leads to a syntax error, since it isn't valid Swift.

This patch adds a check to ensure we only attach the Swiftify macro to
__counted_by expressions that are also syntactically valid in Swift.

rdar://150956352
2025-05-08 21:13:20 -07:00

15 lines
754 B
Swift

// RUN: %target-swift-ide-test -print-module -module-to-print=CountedByClang -plugin-path %swift-plugin-dir -I %S/Inputs -source-filename=x -enable-experimental-feature SafeInteropWrappers | %FileCheck %s
// REQUIRES: swift_feature_SafeInteropWrappers
// These functions use __counted_by annotations that are not syntactically valid
// in Swift, so they should not be Swiftified
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} derefLen
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} lNot
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} lAnd
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} lOr
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} floatCastToInt
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} pointerCastToInt
// CHECK-NOT: @_alwaysEmitIntoClient {{.*}} nanAsInt