aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-25 05:56:45 +0000
committerChris Lattner <sabre@nondot.org>2009-04-25 05:56:45 +0000
commit11ddb7dc22bb398a6727318729680630bfcefaae (patch)
treef90477bd103d73a29bff085eb524cd7b77b6de60 /lib/AST/Decl.cpp
parent7cbeef278d6206941630ea14585ea80f44d68d69 (diff)
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
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 0326b34960..a715531c74 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -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.