[Lldb-commits] [lldb] [lldb] Eliminate check for HasLoadedSections (NFC) (PR #145366)

via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 23 10:19:31 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

We can omit the call to Target::HasLoadedSections as Address::HasLoadedSections already "does the right thing" and returns LLDB_INVALID_ADDRESS if no sections are loaded.

---
Full diff: https://github.com/llvm/llvm-project/pull/145366.diff


1 Files Affected:

- (modified) lldb/source/Core/FormatEntity.cpp (+1-3) 


``````````diff
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index 8e3c3c18863fa..ca389bc88cf79 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -470,9 +470,7 @@ static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc,
                                   bool print_file_addr_or_load_addr) {
   Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
 
-  addr_t vaddr = LLDB_INVALID_ADDRESS;
-  if (target && target->HasLoadedSections())
-    vaddr = addr.GetLoadAddress(target);
+  addr_t vaddr = addr.GetLoadAddress(target);
   if (vaddr == LLDB_INVALID_ADDRESS)
     vaddr = addr.GetFileAddress();
   if (vaddr == LLDB_INVALID_ADDRESS)

``````````

</details>


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


More information about the lldb-commits mailing list