forked from OSchip/llvm-project
[analyzer] Hotfix for RetainCountChecker: assert was too strong.
Bridged casts can happen to non-CF objects as well. llvm-svn: 352938
This commit is contained in:
parent
00056ed0e6
commit
77b3530865
|
@ -187,11 +187,10 @@ void RetainCountChecker::checkPostStmt(const CastExpr *CE,
|
|||
|
||||
QualType QT = CE->getType();
|
||||
ObjKind K;
|
||||
if (coreFoundation::isCFObjectRef(QT)) {
|
||||
K = ObjKind::CF;
|
||||
} else {
|
||||
assert(cocoa::isCocoaObjectRef(QT));
|
||||
if (QT->isObjCObjectPointerType()) {
|
||||
K = ObjKind::ObjC;
|
||||
} else {
|
||||
K = ObjKind::CF;
|
||||
}
|
||||
|
||||
ArgEffect AE = ArgEffect(IncRef, K);
|
||||
|
|
|
@ -239,8 +239,23 @@ extern const CFAllocatorRef kCFAllocatorDefault;
|
|||
extern CFTypeRef CFRetain(CFTypeRef cf);
|
||||
extern void CFRelease(CFTypeRef cf);
|
||||
|
||||
|
||||
void check_bridge_retained_cast() {
|
||||
NSString *nsStr = [[NSString alloc] init];
|
||||
CFStringRef cfStr = (__bridge_retained CFStringRef)nsStr;
|
||||
CFRelease(cfStr); // no-warning
|
||||
}
|
||||
|
||||
@interface A;
|
||||
@end
|
||||
|
||||
void check_bridge_to_non_cocoa(CFStringRef s) {
|
||||
A *a = (__bridge_transfer A *) s; // no-crash
|
||||
}
|
||||
|
||||
struct B;
|
||||
|
||||
struct B * check_bridge_to_non_cf() {
|
||||
NSString *s = [[NSString alloc] init];
|
||||
return (__bridge struct B*) s;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue