Fix a couple cases of ArrayRef capturing compiler temps.

Use a SmallVector for scratch space to use to build the ArrayRefs
instead.
This commit is contained in:
Mark Lacey
2016-10-07 15:36:45 -07:00
parent 34d81d4f10
commit 5356cc37bd
2 changed files with 18 additions and 8 deletions

View File

@@ -6143,12 +6143,17 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
ArrayRef<Expr *> arguments; ArrayRef<Expr *> arguments;
ArrayRef<TypeBase *> types; ArrayRef<TypeBase *> types;
SmallVector<Expr *, 1> Scratch;
if (auto *TE = dyn_cast<TupleExpr>(CEA)) if (auto *TE = dyn_cast<TupleExpr>(CEA))
arguments = TE->getElements(); arguments = TE->getElements();
else if (auto *PE = dyn_cast<ParenExpr>(CEA)) else if (auto *PE = dyn_cast<ParenExpr>(CEA)) {
arguments = PE->getSubExpr(); Scratch.push_back(PE->getSubExpr());
else arguments = makeArrayRef(Scratch);
arguments = apply->getArg(); }
else {
Scratch.push_back(apply->getArg());
arguments = makeArrayRef(Scratch);
}
for (auto arg: arguments) { for (auto arg: arguments) {
bool isNoEscape = false; bool isNoEscape = false;

View File

@@ -299,12 +299,17 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
// The argument is either a ParenExpr or TupleExpr. // The argument is either a ParenExpr or TupleExpr.
ArrayRef<Expr*> arguments; ArrayRef<Expr*> arguments;
SmallVector<Expr *, 1> Scratch;
if (auto *TE = dyn_cast<TupleExpr>(Arg)) if (auto *TE = dyn_cast<TupleExpr>(Arg))
arguments = TE->getElements(); arguments = TE->getElements();
else if (auto *PE = dyn_cast<ParenExpr>(Arg)) else if (auto *PE = dyn_cast<ParenExpr>(Arg)) {
arguments = PE->getSubExpr(); Scratch.push_back(PE->getSubExpr());
else arguments = makeArrayRef(Scratch);
arguments = Call->getArg(); }
else {
Scratch.push_back(Call->getArg());
arguments = makeArrayRef(Scratch);
}
// Check each argument. // Check each argument.
for (auto arg : arguments) { for (auto arg : arguments) {