Fix PR 3337 [retain/release checker]: Handle FunctionDecl's declared using typedefs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62331 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index af96c06..c72d2a3 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -737,7 +737,9 @@
break;
}
- FunctionType* FT = cast<FunctionType>(FD->getType());
+ // [PR 3337] Use 'getDesugaredType' to strip away any typedefs on the
+ // function's type.
+ FunctionType* FT = cast<FunctionType>(FD->getType()->getDesugaredType());
const char* FName = FD->getIdentifier()->getName();
// Inspect the result type.
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index b548f2d..bf833bf 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -237,3 +237,10 @@
CFRelease(s1); // expected-warning{{Incorrect decrement of the reference count}}
}
+// PR 3337: Handle functions declared using typedefs.
+typedef CFTypeRef CREATEFUN();
+CREATEFUN MyCreateFun;
+
+void f12() {
+ CFTypeRef o = MyCreateFun(); // expected-warning {{leak}}
+}