-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Re-enable warnings for unannotated C++ APIs returning SWIFT_SHARED_REFERENCE types under an experimental feature flag #82488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…S_(UN)RETAINED warning (swiftlang#81411)" This reverts commit 49aea31.
… per source location
@swift-ci please smoke test |
test/Interop/Cxx/foreign-reference/Inputs/cxx-functions-and-methods-returning-frt.h
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any known problems with these diagnostics or does this solve all of the problems? If the false positive fixes are coming in a follow-up patch, I wonder if the flag should be inverted and the warnings should be off by default.
False positives on large codebases still needs to be addressed: rdar://150800115
The warnings are off by default in this patch. WDYM by inverting the flag? |
My bad! I misunderstood something. |
…{diagID, SourceLocation}
@swift-ci please smoke test |
…WIFT_SHARED_REFERENCE types under an experimental feature flag (swiftlang#82488) This patch re-enables diagnostics for unannotated C++ functions or methods returning `SWIFT_SHARED_REFERENCE` types. These warnings now fire only **once per source location**, even in the presence of multiple template instantiations. This avoids diagnostic duplication that was a key source of noise in the compilation of larger codebases. These warnings were previously disabled starting in **Swift 6.2** via [PR-swiftlang#81411](swiftlang#81411) due to concerns around false positives and excessive duplication in projects adopting C++ interop. This patch addresses the duplication issue by adding source-location-based caching, which ensures that a warning is emitted only once per source location, even across template instantiations with different types. However, the false positive issue remains to be investigated and will be addressed in a follow-up patch. Until that happens, the warnings are gated behind a new experimental feature flag: `WarnUnannotatedReturnOfCxxFrt`. This feature will be enabled by default only after thorough qualification and testing on large C++ codebases. rdar://154261051
This patch re-enables diagnostics for unannotated C++ functions or methods returning
SWIFT_SHARED_REFERENCE
types. These warnings now fire only once per source location, even in the presence of multiple template instantiations. This avoids diagnostic duplication that was a key source of noise in the compilation of larger codebases.These warnings were previously disabled starting in Swift 6.2 via PR-#81411 due to concerns around false positives and excessive duplication in projects adopting C++ interop. This patch addresses the duplication issue by adding source-location-based caching, which ensures that a warning is emitted only once per source location, even across template instantiations with different types.
However, the false positive issue remains to be investigated and will be addressed in a follow-up patch. Until that happens, the warnings are gated behind a new experimental feature flag:
WarnUnannotatedReturnOfCxxFrt
. This feature will be enabled by default only after thorough qualification and testing on large C++ codebases.rdar://154261051