-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
Description
New Issue Checklist
- I have read and understood the CONTRIBUTING guide
- I have read the Documentation
- I have searched for a similar issue in the project and found none
Issue Info
| Info | Value |
|---|---|
| SDWebImage Version | 5.x` |
Issue Description and Steps
// Marks functions which return a CF type that needs to be released by the caller but whose names are not consistent with CoreFoundation naming rules. The recommended fix to this is to rename the functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed.
// This macro is ONLY to be used in exceptional circumstances, not to annotate functions which conform to the CoreFoundation naming rules.
#ifndef CF_RETURNS_RETAINED
#if __has_feature(attribute_cf_returns_retained)
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#else
#define CF_RETURNS_RETAINED
#endif
#endif
// Marks functions which return a CF type that may need to be retained by the caller but whose names are not consistent with CoreFoundation naming rules. The recommended fix to this is to rename the functions, but this macro can be used to let the clang static analyzer know of any exceptions that cannot be fixed.
// This macro is ONLY to be used in exceptional circumstances, not to annotate functions which conform to the CoreFoundation naming rules.
#ifndef CF_RETURNS_NOT_RETAINED
#if __has_feature(attribute_cf_returns_not_retained)
#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
#else
#define CF_RETURNS_NOT_RETAINED
#endif
#endif
CF_RETURNS_RETAINED and CF_RETURNS_NOT_RETAINED can only used in exceptional circumstances, which is to say, if function name conforms the naming rules, we should not annotate it. But currently, we don't conform this rule, like :
+ (CGColorSpaceRef _Nonnull)colorSpaceGetDeviceRGB CF_RETURNS_NOT_RETAINED;
+ (CGImageRef _Nullable)CGImageCreateDecoded:(_Nonnull CGImageRef)cgImage CF_RETURNS_RETAINED;
and so on.....
From the git log, seems it try to optimize Swift Unmanaged type.
Two options we can solve issues:
- Remove all
CF_RETURNS_*annotate if it already satisfy naming rules. LetUnmanagedtype exist. - Remove all
CF_RETURNS_*annotate if it already satisfy naming rules. RefactorSDImageCoderHelper, make all class methods to beCfunctions, useCF_IMPLICIT_BRIDGING_ENABLEDto fix swiftUnmanagedtype issues.