[cfe-commits] r51951 - in /cfe/trunk: include/clang/AST/Decl.h test/CodeGen/typedef-func.c

Eli Friedman eli.friedman at gmail.com
Wed Jun 4 10:58:42 PDT 2008


Author: efriedma
Date: Wed Jun  4 12:58:41 2008
New Revision: 51951

URL: http://llvm.org/viewvc/llvm-project?rev=51951&view=rev
Log:
Don't assume that the type of a FunctionDecl is a FunctionType; that 
assumption isn't accurate in the presence of typedefs.


Added:
    cfe/trunk/test/CodeGen/typedef-func.c
Modified:
    cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=51951&r1=51950&r2=51951&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Jun  4 12:58:41 2008
@@ -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; }

Added: cfe/trunk/test/CodeGen/typedef-func.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/typedef-func.c?rev=51951&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/typedef-func.c (added)
+++ cfe/trunk/test/CodeGen/typedef-func.c Wed Jun  4 12:58:41 2008
@@ -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);
+}
+





More information about the cfe-commits mailing list