]> granicus.if.org Git - clang/commitdiff
Fix PR 3337 [retain/release checker]: Handle FunctionDecl's declared using typedefs.
authorTed Kremenek <kremenek@apple.com>
Fri, 16 Jan 2009 18:40:33 +0000 (18:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 16 Jan 2009 18:40:33 +0000 (18:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62331 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp
test/Analysis/retain-release.m

index af96c0672b607f482880219142faf6ee37dedfe0..c72d2a3070b47b415e6b51fdd00f2196247dc5b4 100644 (file)
@@ -737,7 +737,9 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
       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.
index b548f2d26bae683a720822ae21539c5b0c0534c3..bf833bf2aca79c9fc376cdb5aabab4541841b81d 100644 (file)
@@ -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}}
+}