Don't assume that the type of a FunctionDecl is a FunctionType; that 
assumption isn't accurate in the presence of typedefs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51951 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index e3d83af..1bfad2e 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -492,7 +492,7 @@
   unsigned getMinRequiredArguments() const;
 
   QualType getResultType() const { 
-    return cast<FunctionType>(getType())->getResultType();
+    return getType()->getAsFunctionType()->getResultType();
   }
   StorageClass getStorageClass() const { return StorageClass(SClass); }
   bool isInline() const { return IsInline; }
diff --git a/test/CodeGen/typedef-func.c b/test/CodeGen/typedef-func.c
new file mode 100644
index 0000000..08328e6
--- /dev/null
+++ b/test/CodeGen/typedef-func.c
@@ -0,0 +1,13 @@
+// RUN: clang -emit-llvm < %s
+
+// PR2414
+typedef void filter_func_t();
+filter_func_t mono_filter;
+
+void addfilter2(filter_func_t *func){}
+
+void setup_filters()
+{
+        addfilter2( mono_filter);
+}
+