forked from OSchip/llvm-project
Objective-C ARC++: Prefer references to __strong/__weak over __unsafe_unretained.
Fixes <rdar://problem/15713945>. llvm-svn: 198343
This commit is contained in:
parent
8e6e6abf53
commit
6beabeed39
|
@ -981,6 +981,17 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S,
|
|||
Comparison.Qualifiers = ParamMoreQualified;
|
||||
else if (ArgQuals.isStrictSupersetOf(ParamQuals))
|
||||
Comparison.Qualifiers = ArgMoreQualified;
|
||||
else if (ArgQuals.getObjCLifetime() != ParamQuals.getObjCLifetime() &&
|
||||
ArgQuals.withoutObjCLifetime()
|
||||
== ParamQuals.withoutObjCLifetime()) {
|
||||
// Prefer binding to non-__unsafe_autoretained parameters.
|
||||
if (ArgQuals.getObjCLifetime() == Qualifiers::OCL_ExplicitNone &&
|
||||
ParamQuals.getObjCLifetime())
|
||||
Comparison.Qualifiers = ParamMoreQualified;
|
||||
else if (ParamQuals.getObjCLifetime() == Qualifiers::OCL_ExplicitNone &&
|
||||
ArgQuals.getObjCLifetime())
|
||||
Comparison.Qualifiers = ArgMoreQualified;
|
||||
}
|
||||
RefParamComparisons->push_back(Comparison);
|
||||
}
|
||||
|
||||
|
|
|
@ -302,3 +302,19 @@ namespace rdar14467941 {
|
|||
float &fr2 = takePtr<A>(a);
|
||||
}
|
||||
}
|
||||
|
||||
namespace rdar15713945 {
|
||||
template <class T> int &f(__strong T &);
|
||||
template <class T> float &f(__weak T &);
|
||||
template <class T> double &f(__unsafe_unretained T &);
|
||||
template <class T> char &f(T &);
|
||||
|
||||
void foo() {
|
||||
__strong NSString * const strong = 0;
|
||||
int &ir = (f)(strong);
|
||||
__weak NSString * const weak = 0;
|
||||
float &fr = (f)(weak);
|
||||
__unsafe_unretained NSString * const unsafe = 0;
|
||||
double &dr = (f)(unsafe);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue