[llvm] [DebugInfo] Fix segfault in constructSubprogramScopeDIE with null subprogram type (PR #184299)

Michael Buch via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 04:13:32 PST 2026


================
@@ -1141,15 +1141,19 @@ DIE &DwarfCompileUnit::constructSubprogramScopeDIE(const DISubprogram *Sub,
   }
 
   // If this is a variadic function, add an unspecified parameter.
-  DITypeArray FnArgs = Sub->getType()->getTypeArray();
-
-  // If we have a single element of null, it is a function that returns void.
-  // If we have more than one elements and the last one is null, it is a
-  // variadic function.
-  if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
-      !includeMinimalInlineScopes())
-    ScopeDIE.addChild(
-        DIE::get(DIEValueAllocator, dwarf::DW_TAG_unspecified_parameters));
+  // Sub->getType() may be null when using LineTablesOnly emission, since
+  // DISubprograms are not required to have a type in that mode.
----------------
Michael137 wrote:

Well what I'm trying to figure out is if something changed in a way that made previously valid source code fail to compile. Probably not, but we don't know for sure. In the comment you say "line-tables-only implies no function types". That isn't true for C++ debug-info (though I haven't tried very hard to disprove this). More context from the originator will allow us to guide the direction a fix in a more informed manner.

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


More information about the llvm-commits mailing list