ObjectiveC migrator: More tweaking of heuristics
for an audited cf function to not include those
which are annotated by user.
llvm-svn: 188823
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 0147297..aa432e0 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -843,10 +843,17 @@
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 @@
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.