[cfe-commits] r81178 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/AST/ExprCXX.cpp
Anders Carlsson
andersca at mac.com
Mon Sep 7 18:23:37 PDT 2009
Author: andersca
Date: Mon Sep 7 20:23:37 2009
New Revision: 81178
URL: http://llvm.org/viewvc/llvm-project?rev=81178&view=rev
Log:
Clean up the CXXConstructExpr constructor, add Arg getters.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=81178&r1=81177&r2=81178&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Sep 7 20:23:37 2009
@@ -517,6 +517,16 @@
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!");
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=81178&r1=81177&r2=81178&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Sep 7 20:23:37 2009
@@ -396,15 +396,22 @@
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;
}
}
More information about the cfe-commits
mailing list