mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Look through copy_addr and opened existentials to diagnose move-only sources.
This commit is contained in:
@@ -93,6 +93,19 @@ static void getVariableNameForValue(SILValue value2,
|
||||
value2->getFunction());
|
||||
while (true) {
|
||||
if (auto *allocInst = dyn_cast<AllocationInst>(searchValue)) {
|
||||
// If the instruction itself doesn't carry any variable info, see whether
|
||||
// it's copied from another place that does.
|
||||
if (!allocInst->getDecl()) {
|
||||
if (auto copy = allocInst->getSingleUserOfType<CopyAddrInst>()) {
|
||||
if (copy->getDest() == allocInst
|
||||
&& !copy->isTakeOfSrc()
|
||||
&& copy->isInitializationOfDest()) {
|
||||
searchValue = copy->getSrc();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variableNamePath.push_back(allocInst);
|
||||
break;
|
||||
}
|
||||
@@ -102,6 +115,11 @@ static void getVariableNameForValue(SILValue value2,
|
||||
break;
|
||||
}
|
||||
|
||||
if (auto *oeInst = dyn_cast<OpenExistentialAddrInst>(searchValue)) {
|
||||
searchValue = oeInst->getOperand();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto *rei = dyn_cast<RefElementAddrInst>(searchValue)) {
|
||||
variableNamePath.push_back(rei);
|
||||
searchValue = rei->getOperand();
|
||||
|
||||
Reference in New Issue
Block a user