From 8061322dabc3adc58ad20832170942eb72f009e6 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 10 May 2013 13:06:58 +0000 Subject: [PATCH] ArrayRef'ize GenericSelectionExpr git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181592 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 9 ++++----- lib/Sema/SemaExpr.cpp | 29 +++++++++++++---------------- lib/Sema/TreeTransform.h | 13 +++++-------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 618574207d..81e00b81f1 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -3144,15 +3144,14 @@ public: SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - MultiTypeArg ArgTypes, - MultiExprArg ArgExprs); + ArrayRef ArgTypes, + ArrayRef ArgExprs); ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - TypeSourceInfo **Types, - Expr **Exprs, - unsigned NumAssocs); + ArrayRef Types, + ArrayRef Exprs); // Binary/Unary Operators. 'Tok' is the token for the operator. ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index ef7e0f2e33..b6b6444738 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1230,25 +1230,23 @@ Sema::ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - MultiTypeArg ArgTypes, - MultiExprArg ArgExprs) { + ArrayRef ArgTypes, + ArrayRef ArgExprs) { unsigned NumAssocs = ArgTypes.size(); assert(NumAssocs == ArgExprs.size()); - ParsedType *ParsedTypes = ArgTypes.data(); - Expr **Exprs = ArgExprs.data(); - TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs]; for (unsigned i = 0; i < NumAssocs; ++i) { - if (ParsedTypes[i]) - (void) GetTypeFromParser(ParsedTypes[i], &Types[i]); + if (ArgTypes[i]) + (void) GetTypeFromParser(ArgTypes[i], &Types[i]); else Types[i] = 0; } ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, - ControllingExpr, Types, Exprs, - NumAssocs); + ControllingExpr, + llvm::makeArrayRef(Types, NumAssocs), + ArgExprs); delete [] Types; return ER; } @@ -1258,9 +1256,10 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - TypeSourceInfo **Types, - Expr **Exprs, - unsigned NumAssocs) { + ArrayRef Types, + ArrayRef Exprs) { + unsigned NumAssocs = Types.size(); + assert(NumAssocs == Exprs.size()); if (ControllingExpr->getType()->isPlaceholderType()) { ExprResult result = CheckPlaceholderExpr(ControllingExpr); if (result.isInvalid()) return ExprError(); @@ -1328,8 +1327,7 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, if (IsResultDependent) return Owned(new (Context) GenericSelectionExpr( Context, KeyLoc, ControllingExpr, - llvm::makeArrayRef(Types, NumAssocs), - llvm::makeArrayRef(Exprs, NumAssocs), + Types, Exprs, DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack)); SmallVector CompatIndices; @@ -1384,8 +1382,7 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc, return Owned(new (Context) GenericSelectionExpr( Context, KeyLoc, ControllingExpr, - llvm::makeArrayRef(Types, NumAssocs), - llvm::makeArrayRef(Exprs, NumAssocs), + Types, Exprs, DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack, ResultIndex)); } diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 89e23ef460..253135ff70 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1767,12 +1767,10 @@ public: SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, - TypeSourceInfo **Types, - Expr **Exprs, - unsigned NumAssocs) { + ArrayRef Types, + ArrayRef Exprs) { return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, - ControllingExpr, Types, Exprs, - NumAssocs); + ControllingExpr, Types, Exprs); } /// \brief Build a new overloaded operator call expression. @@ -6289,9 +6287,8 @@ TreeTransform::TransformGenericSelectionExpr(GenericSelectionExpr *E) { E->getDefaultLoc(), E->getRParenLoc(), ControllingExpr.release(), - AssocTypes.data(), - AssocExprs.data(), - E->getNumAssocs()); + AssocTypes, + AssocExprs); } template