mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Split off ArgumentShuffleExpr from TupleShuffleExpr
Right now we use TupleShuffleExpr for two completely different things: - Tuple conversions, where elements can be re-ordered and labels can be introduced/eliminated - Complex argument lists, involving default arguments or varargs The first case does not allow default arguments or varargs, and the second case does not allow re-ordering or introduction/elimination of labels. Furthermore, the first case has a representation limitation that prevents us from expressing tuple conversions that change the type of tuple elements. For all these reasons, it is better if we use two separate Expr kinds for these purposes. For now, just make an identical copy of TupleShuffleExpr and call it ArgumentShuffleExpr. In CSApply, use ArgumentShuffleExpr when forming the arguments to a call, and keep using TupleShuffleExpr for tuple conversions. Each usage of TupleShuffleExpr has been audited to see if it should instead look at ArgumentShuffleExpr. In sequent commits I plan on redesigning TupleShuffleExpr to correctly represent all tuple conversions without any unnecessary baggage. Longer term, we actually want to change the representation of CallExpr to directly store an argument list; then instead of a single child expression that must be a ParenExpr, TupleExpr or ArgumentShuffleExpr, all CallExprs will have a uniform representation and ArgumentShuffleExpr will go away altogether. This should reduce memory usage and radically simplify parts of SILGen.
This commit is contained in:
@@ -2856,8 +2856,8 @@ static CallExpr *findTrailingClosureTarget(SourceManager &SM,
|
||||
if (!Args)
|
||||
return nullptr;
|
||||
Expr *LastArg;
|
||||
if (auto *TSE = dyn_cast<TupleShuffleExpr>(Args))
|
||||
Args = TSE->getSubExpr();
|
||||
if (auto *ASE = dyn_cast<ArgumentShuffleExpr>(Args))
|
||||
Args = ASE->getSubExpr();
|
||||
if (auto *PE = dyn_cast<ParenExpr>(Args)) {
|
||||
LastArg = PE->getSubExpr();
|
||||
} else {
|
||||
@@ -2886,8 +2886,8 @@ bool RefactoringActionTrailingClosure::performChange() {
|
||||
if (!CE)
|
||||
return true;
|
||||
Expr *Args = CE->getArg();
|
||||
if (auto *TSE = dyn_cast<TupleShuffleExpr>(Args))
|
||||
Args = TSE->getSubExpr();
|
||||
if (auto *ASE = dyn_cast<ArgumentShuffleExpr>(Args))
|
||||
Args = ASE->getSubExpr();
|
||||
|
||||
Expr *ClosureArg = nullptr;
|
||||
Expr *PrevArg = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user