r188823 - ObjectiveC migrator: More tweaking of heuristics
Fariborz Jahanian
fjahanian at apple.com
Tue Aug 20 13:45:29 PDT 2013
Author: fjahanian
Date: Tue Aug 20 15:45:28 2013
New Revision: 188823
URL: http://llvm.org/viewvc/llvm-project?rev=188823&view=rev
Log:
ObjectiveC migrator: More tweaking of heuristics
for an audited cf function to not include those
which are annotated by user.
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=188823&r1=188822&r2=188823&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Tue Aug 20 15:45:28 2013
@@ -843,10 +843,17 @@ bool ObjCMigrateASTConsumer::migrateAddF
const FunctionDecl *FuncDecl) {
if (FuncDecl->hasBody())
return false;
- bool HasAtLeastOnePointer = false;
+
CallEffects CE = CallEffects::getEffect(FuncDecl);
- if (!FuncDecl->getAttr<CFReturnsRetainedAttr>() &&
- !FuncDecl->getAttr<CFReturnsNotRetainedAttr>()) {
+ bool FuncIsReturnAnnotated = (FuncDecl->getAttr<CFReturnsRetainedAttr>() ||
+ FuncDecl->getAttr<CFReturnsNotRetainedAttr>());
+
+ // Trivial case of when funciton is annotated and has no argument.
+ if (FuncIsReturnAnnotated && FuncDecl->getNumParams() == 0)
+ return false;
+
+ bool HasAtLeastOnePointer = FuncIsReturnAnnotated;
+ if (!FuncIsReturnAnnotated) {
RetEffect Ret = CE.getReturnValue();
const char *AnnotationString = 0;
if (Ret.getObjKind() == RetEffect::CF && Ret.isOwned()) {
@@ -866,8 +873,6 @@ bool ObjCMigrateASTConsumer::migrateAddF
else if (!AuditedType(FuncDecl->getResultType(), HasAtLeastOnePointer))
return false;
}
- else
- HasAtLeastOnePointer = true;
// At this point result type is either annotated or audited.
// Now, how about argument types.
Modified: cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result?rev=188823&r1=188822&r2=188823&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-arc-cf-annotations.m.result Tue Aug 20 15:45:28 2013
@@ -1002,14 +1002,8 @@ void IOServiceNameMatching_wrapper(const
IOServiceNameMatching(name); // expected-warning{{leak}}
}
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
CF_RETURNS_RETAINED CFDictionaryRef CreateDict();
-CF_IMPLICIT_BRIDGING_DISABLED
-
-
void IOServiceAddNotification_wrapper(mach_port_t masterPort, const io_name_t notificationType,
mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) {
@@ -2053,15 +2047,9 @@ void test_drain() {
// value as tracked, even if the object isn't a known CF type.
//===----------------------------------------------------------------------===//
-
-CF_IMPLICIT_BRIDGING_ENABLED
-
MyCFType getCustom() __attribute__((cf_returns_not_retained));
MyCFType makeCustom() __attribute__((cf_returns_retained));
-CF_IMPLICIT_BRIDGING_DISABLED
-
-
void testCustomReturnsRetained() {
MyCFType obj = makeCustom(); // expected-warning {{leak of an object stored into 'obj'}}
}
More information about the cfe-commits
mailing list