r352938 - [analyzer] Hotfix for RetainCountChecker: assert was too strong.
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 1 15:06:44 PST 2019
Author: george.karpenkov
Date: Fri Feb 1 15:06:44 2019
New Revision: 352938
URL: http://llvm.org/viewvc/llvm-project?rev=352938&view=rev
Log:
[analyzer] Hotfix for RetainCountChecker: assert was too strong.
Bridged casts can happen to non-CF objects as well.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
cfe/trunk/test/Analysis/objc-arc.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=352938&r1=352937&r2=352938&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp Fri Feb 1 15:06:44 2019
@@ -187,11 +187,10 @@ void RetainCountChecker::checkPostStmt(c
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);
Modified: cfe/trunk/test/Analysis/objc-arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objc-arc.m?rev=352938&r1=352937&r2=352938&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/objc-arc.m (original)
+++ cfe/trunk/test/Analysis/objc-arc.m Fri Feb 1 15:06:44 2019
@@ -239,8 +239,23 @@ extern const CFAllocatorRef kCFAllocator
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
}
+
+ at interface A;
+ at 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;
+}
More information about the cfe-commits
mailing list