mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
__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
15 lines
754 B
Swift
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
|