]> granicus.if.org Git - clang/commitdiff
add a new helper function to FunctionDecl instead of it being
authorChris Lattner <sabre@nondot.org>
Sat, 25 Apr 2009 05:56:45 +0000 (05:56 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 25 Apr 2009 05:56:45 +0000 (05:56 +0000)
static in Decl.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70014 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/AST/Decl.cpp

index 1d2c39e18a106719f53cef2f361d8c86daa86e4d..901da704ce9e41bf0baae1ec91b8c553cd3181a8 100644 (file)
@@ -643,6 +643,11 @@ public:
 
   unsigned getBuiltinID(ASTContext &Context) const;
 
+  /// getNumParmVarDeclsFromType - Ignoring the actual argument list, this
+  /// returns the number of ParmVarDecls that the FunctionType of this function
+  /// expects.
+  unsigned getNumParmVarDeclsFromType() const;
+  
   // Iterator access to formal parameters.
   unsigned param_size() const { return getNumParams(); }
   typedef ParmVarDecl **param_iterator;
index 0326b34960fc281fdd8760223218fb07f8834ab8..a715531c74a5896909cbb31306e68973c706ff26 100644 (file)
@@ -431,12 +431,15 @@ unsigned FunctionDecl::getBuiltinID(ASTContext &Context) const {
 }
 
 
-// Helper function for FunctionDecl::getNumParams and FunctionDecl::setParams()
-static unsigned getNumTypeParams(QualType T) {
-  const FunctionType *FT = T->getAsFunctionType();
+/// getNumParmVarDeclsFromType - Ignoring the actual argument list, this
+/// returns the number of ParmVarDecls that the FunctionType of this function
+/// expects.
+unsigned FunctionDecl::getNumParmVarDeclsFromType() const {
+  const FunctionType *FT = getType()->getAsFunctionType();
   if (isa<FunctionNoProtoType>(FT))
     return 0;
   return cast<FunctionProtoType>(FT)->getNumArgs();
+  
 }
 
 unsigned FunctionDecl::getNumParams() const {
@@ -444,13 +447,13 @@ unsigned FunctionDecl::getNumParams() const {
   if (!ParamInfo)
     return 0;
   
-  return getNumTypeParams(getType());
+  return getNumParmVarDeclsFromType();
 }
 
 void FunctionDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
                              unsigned NumParams) {
   assert(ParamInfo == 0 && "Already has param info!");
-  assert(NumParams == getNumTypeParams(getType()) &&
+  assert(NumParams == getNumParmVarDeclsFromType() &&
          "Parameter count mismatch!");
   
   // Zero params -> null pointer.