mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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](https://github.com/swiftlang/swift/pull/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