[llvm] [NFC][DebugInfo] Wrap DILineInfo return type with std::optional to handle missing debug info. (PR #129792)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 5 08:33:31 PST 2025


================
@@ -84,9 +85,11 @@ PDBContext::getLineInfoForAddressRange(object::SectionedAddress Address,
     return Table;
 
   while (auto LineInfo = LineNumbers->getNext()) {
-    DILineInfo LineEntry = getLineInfoForAddress(
+    std::optional<DILineInfo> LineEntry = getLineInfoForAddress(
         {LineInfo->getVirtualAddress(), Address.SectionIndex}, Specifier);
-    Table.push_back(std::make_pair(LineInfo->getVirtualAddress(), LineEntry));
+    if (LineEntry)
----------------
dwblaikie wrote:

collapse these together:
```
if (std::optional<DILineInfo> LineEntry = ... )
```

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


More information about the llvm-commits mailing list