Fix a bug handling typedefs of functions, patch by Nuno Lopes!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44661 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index 16233b1..cebd295 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -242,8 +242,8 @@
}
unsigned FunctionDecl::getNumParams() const {
- if (isa<FunctionTypeNoProto>(getType())) return 0;
- return cast<FunctionTypeProto>(getType())->getNumArgs();
+ if (isa<FunctionTypeNoProto>(getCanonicalType())) return 0;
+ return cast<FunctionTypeProto>(getCanonicalType())->getNumArgs();
}
void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {
diff --git a/test/Sema/ast-print.c b/test/Sema/ast-print.c
index 97ee84f..34b0411 100644
--- a/test/Sema/ast-print.c
+++ b/test/Sema/ast-print.c
@@ -3,4 +3,6 @@
typedef void func_typedef();
func_typedef xxx;
+typedef void func_t(int x);
+func_t a;