[llvm] [DebugInfo] Add macro tracking support to DebugInfoFinder (PR #179931)

Vladislav Dzhidzhoev via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 06:10:55 PST 2026


================
@@ -275,6 +278,36 @@ void DebugInfoFinder::processImportedEntity(const DIImportedEntity *Import) {
     processScope(M->getScope());
 }
 
+// Process a macro debug info node (DIMacroNode).
+//
+// A DIMacroNode is one of two types:
+//   - DIMacro: A single macro definition. Add it to the Macros list along with
+//     its containing DIMacroFile.
+//   - DIMacroFile: A file containing macros. Recursively process all nested
+//     macro nodes within it (avoiding duplicates by tracking visited nodes).
+void DebugInfoFinder::processMacroNode(DIMacroNode *Macro,
+                                       DIMacroFile *CurrentMacroFile) {
+  if (!Macro)
+    return;
+
+  if (auto *M = dyn_cast<DIMacro>(Macro)) {
+    addMacro(M, CurrentMacroFile);
+    return;
+  }
+
+  if (auto *MF = dyn_cast<DIMacroFile>(Macro)) {
----------------
dzhidzhoev wrote:

```suggestion

  auto *MF = dyn_cast<DIMacroFile>(Macro);
```

Indentation level can be reduced by removing the if statement, as Macro is not DIMacro at this point.

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


More information about the llvm-commits mailing list