| 1460 | } |
| 1461 | |
| 1462 | void DUContext::cleanIfNotEncountered(const QSet<DUChainBase*>& encountered) |
| 1463 | { |
| 1464 | ENSURE_CAN_WRITE |
| 1465 | |
| 1466 | // It may happen that the deletion of one declaration triggers the deletion of another one |
| 1467 | // Therefore we copy the list of indexed declarations and work on those. Indexed declarations |
| 1468 | // will return zero for already deleted declarations. |
| 1469 | KDevVarLengthArray<LocalIndexedDeclaration> indexedLocal; |
| 1470 | if (d_func()->m_localDeclarations()) { |
| 1471 | indexedLocal.append(d_func()->m_localDeclarations(), d_func()->m_localDeclarationsSize()); |
| 1472 | } |
| 1473 | for (const LocalIndexedDeclaration& indexed : indexedLocal) { |
| 1474 | auto dec = indexed.data(topContext()); |
| 1475 | if (dec && !encountered.contains(dec) && (!dec->isAutoDeclaration() || !dec->hasUses())) { |
| 1476 | delete dec; |
| 1477 | } |
| 1478 | } |
| 1479 | |
| 1480 | const auto currentChildContexts = m_dynamicData->m_childContexts; |
| 1481 | for (DUContext* childContext : currentChildContexts) { |
| 1482 | if (!encountered.contains(childContext)) { |
| 1483 | delete childContext; |
| 1484 | } |
| 1485 | } |
| 1486 | } |
| 1487 | |
| 1488 | TopDUContext* DUContext::topContext() const |
| 1489 | { |
no test coverage detected