From 99890659385f052412d479e8569b10069ac2b12b Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 16 Jan 2009 18:40:33 +0000 Subject: [PATCH] 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 --- lib/Analysis/CFRefCount.cpp | 4 +++- test/Analysis/retain-release.m | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index af96c0672b..c72d2a3070 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -737,7 +737,9 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) { break; } - FunctionType* FT = cast(FD->getType()); + // [PR 3337] Use 'getDesugaredType' to strip away any typedefs on the + // function's type. + FunctionType* FT = cast(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 b548f2d26b..bf833bf2ac 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -237,3 +237,10 @@ void f11() { 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}} +} -- 2.40.0