aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-04-10 02:22:51 +0000
committerChris Lattner <sabre@nondot.org>2008-04-10 02:22:51 +0000
commit8123a95c33b792d35c2e4992ba6e27882748fb0d (patch)
tree33cd02a28ced427832214e01d1cfdca997f262b3 /lib/AST/Decl.cpp
parent05cbe1a44e6143d44aac0e769ba120e8c45f34ce (diff)
Several improvements from Doug Gregor related to default
argument handling. I'll fix up the c89 (void) thing next. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index afe4fcd37f..2ef31e42e5 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -385,6 +385,19 @@ void FunctionDecl::setParams(ParmVarDecl **NewParamInfo, unsigned NumParams) {
}
}
+/// getMinRequiredArguments - Returns the minimum number of arguments
+/// needed to call this function. This may be fewer than the number of
+/// function parameters, if some of the parameters have default
+/// arguments.
+unsigned FunctionDecl::getMinRequiredArguments() const {
+ unsigned NumRequiredArgs = getNumParams();
+ while (NumRequiredArgs > 0
+ && getParamDecl(NumRequiredArgs-1)->getDefaultArg())
+ --NumRequiredArgs;
+
+ return NumRequiredArgs;
+}
+
//===----------------------------------------------------------------------===//
// RecordDecl Implementation
//===----------------------------------------------------------------------===//