diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-13 05:10:00 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-13 05:10:00 +0000 |
commit | 02a0acd0bc3e26c551fc0ee33659cfa2378eeb7c (patch) | |
tree | cd63d101d6ff372db0b17dd48f5c50fb3bf9fb69 /clang/lib/Sema/SemaOverload.cpp | |
parent | fab583b7c6010b85353fce571ce2700c8e914c4a (diff) | |
download | bcm5719-llvm-02a0acd0bc3e26c551fc0ee33659cfa2378eeb7c.tar.gz bcm5719-llvm-02a0acd0bc3e26c551fc0ee33659cfa2378eeb7c.zip |
Fix argument-passing bugs in a call to object
llvm-svn: 62147
Diffstat (limited to 'clang/lib/Sema/SemaOverload.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index be1a27e5c68..c66db173ebd 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -3542,25 +3542,31 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, ResultTy, RParenLoc)); delete [] MethodArgs; + // We may have default arguments. If so, we need to allocate more + // slots in the call for them. + if (NumArgs < NumArgsInProto) + TheCall->setNumArgs(NumArgsInProto + 1); + else if (NumArgs > NumArgsInProto) + NumArgsToCheck = NumArgsInProto; + // Initialize the implicit object parameter. - if (!PerformObjectArgumentInitialization(Object, Method)) + if (PerformObjectArgumentInitialization(Object, Method)) return true; TheCall->setArg(0, Object); // Check the argument types. for (unsigned i = 0; i != NumArgsToCheck; i++) { - QualType ProtoArgType = Proto->getArgType(i); - Expr *Arg; - if (i < NumArgs) + if (i < NumArgs) { Arg = Args[i]; - else + + // Pass the argument. + QualType ProtoArgType = Proto->getArgType(i); + if (PerformCopyInitialization(Arg, ProtoArgType, "passing")) + return true; + } else { Arg = new CXXDefaultArgExpr(Method->getParamDecl(i)); - QualType ArgType = Arg->getType(); - - // Pass the argument. - if (PerformCopyInitialization(Arg, ProtoArgType, "passing")) - return true; + } TheCall->setArg(i + 1, Arg); } |