[cfe-commits] r70014 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp

Chris Lattner sabre at nondot.org
Fri Apr 24 22:56:45 PDT 2009


Author: lattner
Date: Sat Apr 25 00:56:45 2009
New Revision: 70014

URL: http://llvm.org/viewvc/llvm-project?rev=70014&view=rev
Log:
add a new helper function to FunctionDecl instead of it being
static in Decl.cpp.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/lib/AST/Decl.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Apr 25 00:56:45 2009
@@ -643,6 +643,11 @@
 
   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;

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=70014&r1=70013&r2=70014&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Apr 25 00:56:45 2009
@@ -431,12 +431,15 @@
 }
 
 
-// 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 @@
   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.





More information about the cfe-commits mailing list