r347945 - [analyzer] For OSObject, trust that functions starting with Get
George Karpenkov via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 29 18:18:10 PST 2018
Author: george.karpenkov
Date: Thu Nov 29 18:18:10 2018
New Revision: 347945
URL: http://llvm.org/viewvc/llvm-project?rev=347945&view=rev
Log:
[analyzer] For OSObject, trust that functions starting with Get
(uppercase) are also getters.
Differential Revision: https://reviews.llvm.org/D55035
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=347945&r1=347944&r2=347945&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Nov 29 18:18:10 2018
@@ -241,7 +241,9 @@ RetainSummaryManager::generateSummary(co
// All objects returned with functions *not* starting with
// get, or iterators, are returned at +1.
- if (!II->getName().startswith("get") || isOSIteratorSubclass(PD)) {
+ if ((!II->getName().startswith("get") &&
+ !II->getName().startswith("Get")) ||
+ isOSIteratorSubclass(PD)) {
return getOSSummaryCreateRule(FD);
} else {
return getOSSummaryGetRule(FD);
Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=347945&r1=347944&r2=347945&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Thu Nov 29 18:18:10 2018
@@ -20,6 +20,9 @@ struct OSObject {
static OSObject *generateObject(int);
+ static OSObject *getObject();
+ static OSObject *GetObject();
+
static const OSMetaClass * const metaClass;
};
@@ -55,6 +58,14 @@ struct OSMetaClassBase {
static OSObject *safeMetaCast(const OSObject *inst, const OSMetaClass *meta);
};
+void check_get_object() {
+ OSObject::getObject();
+}
+
+void check_Get_object() {
+ OSObject::GetObject();
+}
+
void check_custom_iterator_rule(OSArray *arr) {
OSIterator *it = arr->getIterator();
it->release();
More information about the cfe-commits
mailing list