forked from OSchip/llvm-project
Clean up the CXXConstructExpr constructor, add Arg getters.
llvm-svn: 81178
This commit is contained in:
parent
4ad0b4c544
commit
6d5de59d09
|
@ -517,6 +517,16 @@ public:
|
|||
|
||||
unsigned getNumArgs() const { return NumArgs; }
|
||||
|
||||
/// getArg - Return the specified argument.
|
||||
Expr *getArg(unsigned Arg) {
|
||||
assert(Arg < NumArgs && "Arg access out of range!");
|
||||
return cast<Expr>(Args[Arg]);
|
||||
}
|
||||
const Expr *getArg(unsigned Arg) const {
|
||||
assert(Arg < NumArgs && "Arg access out of range!");
|
||||
return cast<Expr>(Args[Arg]);
|
||||
}
|
||||
|
||||
/// setArg - Set the specified argument.
|
||||
void setArg(unsigned Arg, Expr *ArgExpr) {
|
||||
assert(Arg < NumArgs && "Arg access out of range!");
|
||||
|
|
|
@ -396,15 +396,22 @@ CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
|
|||
CallExpr::hasAnyValueDependentArguments(args, numargs))),
|
||||
Constructor(D), Elidable(elidable), Args(0), NumArgs(numargs) {
|
||||
// leave room for default arguments;
|
||||
FunctionDecl *FDecl = cast<FunctionDecl>(D);
|
||||
unsigned NumArgsInProto = FDecl->param_size();
|
||||
NumArgs += (NumArgsInProto - numargs);
|
||||
if (NumArgs > 0) {
|
||||
Args = new (C) Stmt*[NumArgs];
|
||||
for (unsigned i = 0; i < numargs; ++i)
|
||||
const FunctionProtoType *FTy =
|
||||
cast<FunctionDecl>(D)->getType()->getAsFunctionProtoType();
|
||||
|
||||
unsigned NumArgsInProto = FTy->getNumArgs();
|
||||
unsigned NumArgsToAllocate = FTy->isVariadic() ? NumArgs : NumArgsInProto;
|
||||
if (NumArgsToAllocate) {
|
||||
Args = new (C) Stmt*[NumArgsToAllocate];
|
||||
|
||||
for (unsigned i = 0; i != NumArgs; ++i)
|
||||
Args[i] = args[i];
|
||||
for (unsigned i = numargs; i < NumArgs; ++i)
|
||||
|
||||
// Set default arguments to 0.
|
||||
for (unsigned i = NumArgs; i != NumArgsToAllocate; ++i)
|
||||
Args[i] = 0;
|
||||
|
||||
NumArgs = NumArgsToAllocate;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue