From a3efea1881cd7cf7b7764b3100901b27ac2affe7 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 3 Jan 2011 19:04:46 +0000 Subject: Refactor the tree transform's many loops over sets of expressions (transforming each in turn) into calls into one central routine (TransformExprs) that transforms a list of expressions. This refactoring is preparatory work for pack expansions whose in an expression-list. No functionality change. llvm-svn: 122761 --- clang/include/clang/AST/Expr.h | 9 +++++++++ clang/include/clang/AST/ExprCXX.h | 19 ++++++++++++++----- clang/include/clang/AST/ExprObjC.h | 22 ++++++++++++++-------- 3 files changed, 37 insertions(+), 13 deletions(-) (limited to 'clang/include') diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index d2add78cd8d..8ed16ad59cd 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -1694,6 +1694,9 @@ public: /// unsigned getNumArgs() const { return NumArgs; } + /// \brief Retrieve the call arguments. + Expr **getArgs() { return reinterpret_cast(SubExprs + ARGS_START); } + /// getArg - Return the specified argument. Expr *getArg(unsigned Arg) { assert(Arg < NumArgs && "Arg access out of range!"); @@ -2737,6 +2740,9 @@ public: /// pointers. unsigned getNumSubExprs() const { return NumExprs; } + /// \brief Retrieve the array of expressions. + Expr **getSubExprs() { return reinterpret_cast(SubExprs); } + /// getExpr - Return the Expr at the specified index. Expr *getExpr(unsigned Index) { assert((Index < NumExprs) && "Arg access out of range!"); @@ -2971,6 +2977,9 @@ public: unsigned getNumInits() const { return InitExprs.size(); } + /// \brief Retrieve the set of initializers. + Expr **getInits() { return reinterpret_cast(InitExprs.data()); } + const Expr *getInit(unsigned Init) const { assert(Init < getNumInits() && "Initializer access out of range!"); return cast_or_null(InitExprs[Init]); diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index bd7d3f09c38..5311d9c3a83 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -21,11 +21,11 @@ namespace clang { - class CXXConstructorDecl; - class CXXDestructorDecl; - class CXXMethodDecl; - class CXXTemporary; - class TemplateArgumentListInfo; +class CXXConstructorDecl; +class CXXDestructorDecl; +class CXXMethodDecl; +class CXXTemporary; +class TemplateArgumentListInfo; //===--------------------------------------------------------------------===// // C++ Expressions. @@ -1052,6 +1052,10 @@ public: } unsigned getNumPlacementArgs() const { return NumPlacementArgs; } + Expr **getPlacementArgs() { + return reinterpret_cast(SubExprs + Array); + } + Expr *getPlacementArg(unsigned i) { assert(i < NumPlacementArgs && "Index out of range"); return cast(SubExprs[Array + i]); @@ -1070,6 +1074,11 @@ public: void setHasInitializer(bool V) { Initializer = V; } unsigned getNumConstructorArgs() const { return NumConstructorArgs; } + + Expr **getConstructorArgs() { + return reinterpret_cast(SubExprs + Array + NumPlacementArgs); + } + Expr *getConstructorArg(unsigned i) { assert(i < NumConstructorArgs && "Index out of range"); return cast(SubExprs[Array + NumPlacementArgs + i]); diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h index 0eba6ba9f2e..c89d4e34c11 100644 --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -746,11 +746,11 @@ public: /// \brief Retrieve the arguments to this message, not including the /// receiver. - Stmt **getArgs() { - return reinterpret_cast(this + 1) + 1; + Expr **getArgs() { + return reinterpret_cast(this + 1) + 1; } - const Stmt * const *getArgs() const { - return reinterpret_cast(this + 1) + 1; + const Expr * const *getArgs() const { + return reinterpret_cast(this + 1) + 1; } /// getArg - Return the specified argument. @@ -792,10 +792,16 @@ public: typedef ExprIterator arg_iterator; typedef ConstExprIterator const_arg_iterator; - arg_iterator arg_begin() { return getArgs(); } - arg_iterator arg_end() { return getArgs() + NumArgs; } - const_arg_iterator arg_begin() const { return getArgs(); } - const_arg_iterator arg_end() const { return getArgs() + NumArgs; } + arg_iterator arg_begin() { return reinterpret_cast(getArgs()); } + arg_iterator arg_end() { + return reinterpret_cast(getArgs() + NumArgs); + } + const_arg_iterator arg_begin() const { + return reinterpret_cast(getArgs()); + } + const_arg_iterator arg_end() const { + return reinterpret_cast(getArgs() + NumArgs); + } friend class ASTStmtReader; friend class ASTStmtWriter; -- cgit v1.2.3