mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Pass the indices for writeback-conflict diagnostics on coroutines.
To do this, I had to introduce a way to unsafely copy an argument list for the purposes of diagnostics. rdar:://43802132
This commit is contained in:
@@ -473,3 +473,38 @@ bool ArgumentSource::isObviouslyEqual(const ArgumentSource &other) const {
|
||||
}
|
||||
llvm_unreachable("bad kind");
|
||||
}
|
||||
|
||||
PreparedArguments PreparedArguments::copyForDiagnostics() const {
|
||||
if (isNull())
|
||||
return PreparedArguments();
|
||||
|
||||
assert(isValid());
|
||||
PreparedArguments result(getFormalType(), isScalar());
|
||||
for (auto &arg : Arguments) {
|
||||
result.Arguments.push_back(arg.copyForDiagnostics());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ArgumentSource ArgumentSource::copyForDiagnostics() const {
|
||||
switch (StoredKind) {
|
||||
case Kind::Invalid:
|
||||
return ArgumentSource();
|
||||
case Kind::LValue:
|
||||
// We have no way to copy an l-value for diagnostics.
|
||||
return {getKnownLValueLocation(), LValue()};
|
||||
case Kind::RValue:
|
||||
return {getKnownRValueLocation(), asKnownRValue().copyForDiagnostics()};
|
||||
case Kind::Expr:
|
||||
return asKnownExpr();
|
||||
case Kind::Tuple: {
|
||||
auto &tuple = Storage.get<TupleStorage>(StoredKind);
|
||||
SmallVector<ArgumentSource, 4> copiedElements;
|
||||
for (auto &elt : tuple.Elements) {
|
||||
copiedElements.push_back(elt.copyForDiagnostics());
|
||||
}
|
||||
return {tuple.Loc, tuple.SubstType, copiedElements};
|
||||
}
|
||||
}
|
||||
llvm_unreachable("bad kind");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user