ArrayRef'ize GenericSelectionExpr

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181592 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dmitri Gribenko 2013-05-10 13:06:58 +00:00
Родитель 0ca318bbad
Коммит 8061322dab
3 изменённых файлов: 22 добавлений и 29 удалений

Просмотреть файл

@ -3144,15 +3144,14 @@ public:
SourceLocation DefaultLoc, SourceLocation DefaultLoc,
SourceLocation RParenLoc, SourceLocation RParenLoc,
Expr *ControllingExpr, Expr *ControllingExpr,
MultiTypeArg ArgTypes, ArrayRef<ParsedType> ArgTypes,
MultiExprArg ArgExprs); ArrayRef<Expr *> ArgExprs);
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc,
SourceLocation DefaultLoc, SourceLocation DefaultLoc,
SourceLocation RParenLoc, SourceLocation RParenLoc,
Expr *ControllingExpr, Expr *ControllingExpr,
TypeSourceInfo **Types, ArrayRef<TypeSourceInfo *> Types,
Expr **Exprs, ArrayRef<Expr *> Exprs);
unsigned NumAssocs);
// Binary/Unary Operators. 'Tok' is the token for the operator. // Binary/Unary Operators. 'Tok' is the token for the operator.
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,

Просмотреть файл

@ -1230,25 +1230,23 @@ Sema::ActOnGenericSelectionExpr(SourceLocation KeyLoc,
SourceLocation DefaultLoc, SourceLocation DefaultLoc,
SourceLocation RParenLoc, SourceLocation RParenLoc,
Expr *ControllingExpr, Expr *ControllingExpr,
MultiTypeArg ArgTypes, ArrayRef<ParsedType> ArgTypes,
MultiExprArg ArgExprs) { ArrayRef<Expr *> ArgExprs) {
unsigned NumAssocs = ArgTypes.size(); unsigned NumAssocs = ArgTypes.size();
assert(NumAssocs == ArgExprs.size()); assert(NumAssocs == ArgExprs.size());
ParsedType *ParsedTypes = ArgTypes.data();
Expr **Exprs = ArgExprs.data();
TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs]; TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs];
for (unsigned i = 0; i < NumAssocs; ++i) { for (unsigned i = 0; i < NumAssocs; ++i) {
if (ParsedTypes[i]) if (ArgTypes[i])
(void) GetTypeFromParser(ParsedTypes[i], &Types[i]); (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
else else
Types[i] = 0; Types[i] = 0;
} }
ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
ControllingExpr, Types, Exprs, ControllingExpr,
NumAssocs); llvm::makeArrayRef(Types, NumAssocs),
ArgExprs);
delete [] Types; delete [] Types;
return ER; return ER;
} }
@ -1258,9 +1256,10 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
SourceLocation DefaultLoc, SourceLocation DefaultLoc,
SourceLocation RParenLoc, SourceLocation RParenLoc,
Expr *ControllingExpr, Expr *ControllingExpr,
TypeSourceInfo **Types, ArrayRef<TypeSourceInfo *> Types,
Expr **Exprs, ArrayRef<Expr *> Exprs) {
unsigned NumAssocs) { unsigned NumAssocs = Types.size();
assert(NumAssocs == Exprs.size());
if (ControllingExpr->getType()->isPlaceholderType()) { if (ControllingExpr->getType()->isPlaceholderType()) {
ExprResult result = CheckPlaceholderExpr(ControllingExpr); ExprResult result = CheckPlaceholderExpr(ControllingExpr);
if (result.isInvalid()) return ExprError(); if (result.isInvalid()) return ExprError();
@ -1328,8 +1327,7 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
if (IsResultDependent) if (IsResultDependent)
return Owned(new (Context) GenericSelectionExpr( return Owned(new (Context) GenericSelectionExpr(
Context, KeyLoc, ControllingExpr, Context, KeyLoc, ControllingExpr,
llvm::makeArrayRef(Types, NumAssocs), Types, Exprs,
llvm::makeArrayRef(Exprs, NumAssocs),
DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack)); DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack));
SmallVector<unsigned, 1> CompatIndices; SmallVector<unsigned, 1> CompatIndices;
@ -1384,8 +1382,7 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
return Owned(new (Context) GenericSelectionExpr( return Owned(new (Context) GenericSelectionExpr(
Context, KeyLoc, ControllingExpr, Context, KeyLoc, ControllingExpr,
llvm::makeArrayRef(Types, NumAssocs), Types, Exprs,
llvm::makeArrayRef(Exprs, NumAssocs),
DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack, DefaultLoc, RParenLoc, ContainsUnexpandedParameterPack,
ResultIndex)); ResultIndex));
} }

Просмотреть файл

@ -1767,12 +1767,10 @@ public:
SourceLocation DefaultLoc, SourceLocation DefaultLoc,
SourceLocation RParenLoc, SourceLocation RParenLoc,
Expr *ControllingExpr, Expr *ControllingExpr,
TypeSourceInfo **Types, ArrayRef<TypeSourceInfo *> Types,
Expr **Exprs, ArrayRef<Expr *> Exprs) {
unsigned NumAssocs) {
return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
ControllingExpr, Types, Exprs, ControllingExpr, Types, Exprs);
NumAssocs);
} }
/// \brief Build a new overloaded operator call expression. /// \brief Build a new overloaded operator call expression.
@ -6289,9 +6287,8 @@ TreeTransform<Derived>::TransformGenericSelectionExpr(GenericSelectionExpr *E) {
E->getDefaultLoc(), E->getDefaultLoc(),
E->getRParenLoc(), E->getRParenLoc(),
ControllingExpr.release(), ControllingExpr.release(),
AssocTypes.data(), AssocTypes,
AssocExprs.data(), AssocExprs);
E->getNumAssocs());
} }
template<typename Derived> template<typename Derived>