simplify some code, add support for functions without a proto


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44485 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index b7f85e9..16233b1 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -242,7 +242,8 @@
 }
 
 unsigned FunctionDecl::getNumParams() const {
-  return cast<FunctionTypeProto>(getType().getTypePtr())->getNumArgs();
+  if (isa<FunctionTypeNoProto>(getType())) return 0;
+  return cast<FunctionTypeProto>(getType())->getNumArgs();
 }
 
 void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {