[cxx-interop] [NFC] Stabilize interface order of Clang record members#87026
[cxx-interop] [NFC] Stabilize interface order of Clang record members#87026j-hui merged 1 commit intoswiftlang:mainfrom
Conversation
|
@swift-ci please test |
Xazax-hun
left a comment
There was a problem hiding this comment.
Overall looks good to me but I had a question and a small nit inline.
| // CHECK-NEXT: init(a: UnsafeMutablePointer<Int{{[0-9]+}}>!, len: Int{{[0-9]+}}) | ||
| // CHECK-NEXT: var a: UnsafeMutablePointer<Int{{[0-9]+}}>! | ||
| // CHECK-NEXT: var len: Int{{[0-9]+}} | ||
| // CHECK-DAG: init() |
There was a problem hiding this comment.
If this patch stabilises the order, I don't think we should use CHECK-DAG. It's significantly worse in terms of output when the checks fail.
There was a problem hiding this comment.
For these, the order differs between C vs C++
There was a problem hiding this comment.
I think it's because the default constructors are generated differently for C vs C++. C++ already has a notion of a default constructor, while in C it's entirely synthetic.
test/Interop/Cxx/class/inheritance/virtual-methods-module-interface.swift
Show resolved
Hide resolved
| // CHECK-DAG: /// This is an auto-generated wrapper for safer interop | ||
| // CHECK-DAG: @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) | ||
| // CHECK-DAG: @_alwaysEmitIntoClient @_disfavoredOverload public mutating func methodWithSafeWrapper(_ s: Span<CInt>) | ||
| // CHECK-DAG: /// This is an auto-generated wrapper for safer interop | ||
| // CHECK-DAG: @available(visionOS 1.0, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) | ||
| // CHECK-DAG: @_lifetime(&self) | ||
| // CHECK-DAG: @_alwaysEmitIntoClient @_disfavoredOverload public mutating func getMutable(_ s: Span<CInt>) -> MutableSpan<CInt> |
There was a problem hiding this comment.
Also not a fan of this CHECK-DAG
There was a problem hiding this comment.
These appear to be unstable. I'm not entirely sure why but I think it's because they are being sorted according to the filename of the macro-generated buffer.
There was a problem hiding this comment.
urgh... can we sort macro expansion nodes according to the clang node the macro is expanded from?
There was a problem hiding this comment.
Done, I think that worked. Fingers crossed for the CI runs
There was a problem hiding this comment.
whelp. using SourceManager::getGeneratedSourceInfo() didn't work.
I hate to ask this, but would you be ok with punting this to follow-up work? I agree that the -DAG checks here is not great, but their "span" (no pun intended) is bounded by the following lines:
// CHECK-DAG: @_alwaysEmitIntoClient @_disfavoredOverload public mutating func getMutable(_ s: Span<CInt>) -> MutableSpan<CInt>
// CHECK-NEXT: init()
// CHECK-NEXT: mutating func methodWithSafeWrapper(_ s: ConstSpanOfInt)
// CHECK-NEXT: mutating func getMutable(_ s: ConstSpanOfInt) -> SpanOfIntI'm not familiar with how the -DAG matching algorithm is designed in lit but I would hope that having the CHECK-NEXTs here limit how much it needs to backtrack in the case of a non-match.
| // CHECK-NEXT: } | ||
|
|
||
| // CHECK: struct LongNameAllLower { | ||
| // CHECK-NOT: var |
There was a problem hiding this comment.
I have no idea what the intention of this original CHECK-NOT was supposed to be. It doesn't catch anything that consecutive CHECK-NEXTs would not catch.
hnrklssn
left a comment
There was a problem hiding this comment.
thanks for adding the extra QoL edits
|
@swift-ci please test |
|
@swift-ci please test |
|
@swift-ci please test |
We may visit and thus import these members in an unpredictable order. To avoid future churn for module interface test cases, sort the printed module interface output according to some rough heuristics.
|
@swift-ci please test |
| @@ -1,54 +1,54 @@ | |||
| // RUN: %target-swift-ide-test -print-module -module-to-print=UsingNonPublic -print-access -I %S/Inputs -source-filename=x -cxx-interoperability-mode=default -enable-experimental-feature ImportNonPublicCxxMembers | %FileCheck %s | |||
| // RUN: %target-swift-ide-test -print-module -module-to-print=UsingNonPublic -print-access -I %S/Inputs -source-filename=x -cxx-interoperability-mode=default -enable-experimental-feature ImportNonPublicCxxMembers | tee %s.out | %FileCheck %s | |||
There was a problem hiding this comment.
@j-hui I guess the tee %s.out is just a left over from debugging. It produces the output file in the source directory. Can you please remove it?
There was a problem hiding this comment.
Yes I'm very sorry, it is being removed here: #87075
We may visit and thus import these members in an unpredictable order.
To avoid future churn for module interface test cases, sort the printed
module interface output according to some rough heuristics.