MCPcopy Create free account
hub / github.com/KDE/kdevelop / cleanIfNotEncountered

Method cleanIfNotEncountered

kdevplatform/language/duchain/ducontext.cpp:1462–1486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1460}
1461
1462void 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
1488TopDUContext* DUContext::topContext() const
1489{

Callers 1

closeContextMethod · 0.80

Calls 6

topContextFunction · 0.85
isAutoDeclarationMethod · 0.80
appendMethod · 0.45
dataMethod · 0.45
containsMethod · 0.45
hasUsesMethod · 0.45

Tested by

no test coverage detected