[clang] [llvm] Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)" (PR #165032)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 06:55:28 PST 2025


================
@@ -538,55 +546,71 @@ class MetadataLoader::MetadataLoaderImpl {
 
   /// Move local imports from DICompileUnit's 'imports' field to
   /// DISubprogram's retainedNodes.
+  /// Move function-local enums from DICompileUnit's enums
+  /// to DISubprogram's retainedNodes.
   void upgradeCULocals() {
     if (NamedMDNode *CUNodes = TheModule.getNamedMetadata("llvm.dbg.cu")) {
       for (MDNode *N : CUNodes->operands()) {
         auto *CU = dyn_cast<DICompileUnit>(N);
         if (!CU)
           continue;
 
-        if (CU->getRawImportedEntities()) {
-          // Collect a set of imported entities to be moved.
-          SetVector<Metadata *> EntitiesToRemove;
+        SetVector<Metadata *> MetadataToRemove;
+        // Collect imported entities to be moved.
+        if (CU->getRawImportedEntities())
----------------
jmorse wrote:

Could you give an overview of the algorithm being used in this function, as I can't piece it together: we've got the collection of metadata-to-remove _from_ the CU, and the `NewImports` `NewEnums` collections are the remainder of `retainedNodes` elements that won't be moved to `DISubprogram`s? If so, I think the term "New" is giving me slight confusion, could we use the term "remaining" or "KeepInCU" or something like that?

https://github.com/llvm/llvm-project/pull/165032


More information about the llvm-commits mailing list