[cxx-interop] Rewrite missing RETURNS_RETAINED diagnostics#87752
Draft
j-hui wants to merge 6 commits intoswiftlang:mainfrom
Draft
[cxx-interop] Rewrite missing RETURNS_RETAINED diagnostics#87752j-hui wants to merge 6 commits intoswiftlang:mainfrom
j-hui wants to merge 6 commits intoswiftlang:mainfrom
Conversation
Moving this here gives us access to ClangImporter's internal APIs for future improvements. It also keeps changes to interop-specific diagnostics localized to the interop-specific part of the compiler.
Contributor
Author
|
@swift-ci please smoke test |
bb9a82b to
04a3672
Compare
We shouldn't need to be defensive about calling things that aren't functions or ObjC methods (technically distinct from functions), or about calling deduction guides and destructors (technically functions, but not imported into Swift). Also, move around the checking logic a little so that it flows more intuitively---check whether the warning should apply to the function decl in the first place, *then* look at its return type and determine whether the called function is missing annotations. Note that clang::FunctionTemplateDecls are also exempt from this annotation. Previously, it was implicitly exempted because the logic for extracting the return type from a function decl simply did not account for function templates. Now, the exemption is made explicit.
Rename getCxxRefConventionWithAttrs() to getOwnershipOfReturnedFRT() (since this isn't specific to C++) Move it to ClangAnalysis.cpp and reuse some helper functions in there rather than duplicating code.
This helper function is barely doing anything. Inline it for more clarity about control flow.
04a3672 to
dcb3dca
Compare
Note that this actually tightens the default ownership checking a little bit; it was too permissive before. Tests to come. rdar://170130742
dcb3dca to
776f573
Compare
Contributor
Author
|
@swift-ci please smoke test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.