add a new helper function to FunctionDecl instead of it being
static in Decl.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70014 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 1d2c39e..901da70 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -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;
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 0326b34..a715531 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -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.