[Lldb-commits] [lldb] [lldb] Migrate away from ValueRange(std::nullopt) (NFC) (PR #145245)

Kazu Hirata via lldb-commits lldb-commits at lists.llvm.org
Sun Jun 22 13:07:38 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/145245

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the lldb side of migration.


>From 939e745c6af0b228a0be8925361dfc684c65d1b4 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 22 Jun 2025 07:52:11 -0700
Subject: [PATCH] [lldb] Migrate away from ValueRange(std::nullopt) (NFC)

ArrayRef has a constructor that accepts std::nullopt.  This
constructor dates back to the days when we still had llvm::Optional.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.

This patch takes care of the lldb side of migration.
---
 lldb/source/Symbol/Function.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 4fc793750f84f..6114eccd935ee 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -343,7 +343,7 @@ llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
   Block &block = GetBlock(/*can_create*/true);
   SymbolFile *sym_file = block.GetSymbolFile();
   if (!sym_file)
-    return std::nullopt;
+    return {};
 
   // Lazily read call site information from the SymbolFile.
   m_call_edges = sym_file->ParseCallEdgesInFunction(GetID());



More information about the lldb-commits mailing list