[PATCH] D59123: [analyzer] RetainCount: Fix a crash when a function follows retain/autorelease naming convention but takes no arguments.
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 14 17:28:08 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rC356223: [analyzer] RetainCount: A function isn't a CFRetain if it takes no arguments. (authored by dergachev, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D59123?vs=189807&id=190762#toc
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59123/new/
https://reviews.llvm.org/D59123
Files:
lib/Analysis/RetainSummaryManager.cpp
test/Analysis/retain-release.mm
Index: test/Analysis/retain-release.mm
===================================================================
--- test/Analysis/retain-release.mm
+++ test/Analysis/retain-release.mm
@@ -503,3 +503,15 @@
}
}
+
+namespace yet_another_unexpected_signature_crash {
+
+CFTypeRef CFSomethingSomethingRetain();
+CFTypeRef CFSomethingSomethingAutorelease();
+
+void foo() {
+ CFSomethingSomethingRetain(); // no-crash
+ CFSomethingSomethingAutorelease(); // no-crash
+}
+
+}
Index: lib/Analysis/RetainSummaryManager.cpp
===================================================================
--- lib/Analysis/RetainSummaryManager.cpp
+++ lib/Analysis/RetainSummaryManager.cpp
@@ -722,12 +722,13 @@
// These are not retain. They just return something and retain it.
return None;
}
- if (cocoa::isRefType(ResultTy, "CF", FName) ||
- cocoa::isRefType(ResultTy, "CG", FName) ||
- cocoa::isRefType(ResultTy, "CV", FName))
- if (isRetain(FD, FName) || isAutorelease(FD, FName) ||
- isMakeCollectable(FName))
- return BehaviorSummary::Identity;
+ if (CE->getNumArgs() == 1 &&
+ (cocoa::isRefType(ResultTy, "CF", FName) ||
+ cocoa::isRefType(ResultTy, "CG", FName) ||
+ cocoa::isRefType(ResultTy, "CV", FName)) &&
+ (isRetain(FD, FName) || isAutorelease(FD, FName) ||
+ isMakeCollectable(FName)))
+ return BehaviorSummary::Identity;
// safeMetaCast is called by OSDynamicCast.
// We assume that OSDynamicCast is either an identity (cast is OK,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59123.190762.patch
Type: text/x-patch
Size: 1542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190315/92a2506c/attachment.bin>
More information about the cfe-commits
mailing list