================
@@ -546,85 +546,62 @@ class MetadataLoader::MetadataLoaderImpl {
llvm::dyn_cast_or_null<DISubprogram>(S);
}
- /// Move local imports from DICompileUnit's 'imports' field to
- /// DISubprogram's retainedNodes.
- /// Move function-local enums from DICompileUnit's enums
- /// to DISubprogram's retainedNodes.
+ /// Map SP -> {Metadata} to store CU locals that should be attached to
+ /// subprogram retainedNodes list during CU upgrade.
+ using SPToEntitiesMap =
+ SmallDenseMap<DISubprogram *, SmallVector<Metadata *>>;
+
+ /// Retrieve the CU operand at position ListIndex, treat it as an MDTuple,
and
+ /// remove all local debug info nodes from it. Fill SPToEntities map with
+ /// removed local nodes.
+ template <typename NodeT>
+ void upgradeOneCULocalsList(SPToEntitiesMap &SPToEntities, DICompileUnit *CU,
+ unsigned ListIndex) {
+ MDTuple *List = cast_if_present<MDTuple>(CU->getOperand(ListIndex));
+ if (!List)
+ return;
+
+ CU->replaceOperandWith(ListIndex, List->filter([&](Metadata *N) {
----------------
chbessonova wrote:
Consider replacing with a loop. Filter express intent better when no side
effects involved, here we simultaneosly filter and fill SPToEntities which is
misleading.
https://github.com/llvm/llvm-project/pull/187927
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits