[Lldb-commits] [lldb] [lldb] Use llvm::unique (NFC) (PR #139910)

via lldb-commits lldb-commits at lists.llvm.org
Wed May 14 07:35:26 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

While I am at it, this patch removes the "if" statement.
std::vector::erase(first, last) doesn't do anything when
first == last.


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


1 Files Affected:

- (modified) lldb/source/Target/DynamicRegisterInfo.cpp (+1-4) 


``````````diff
diff --git a/lldb/source/Target/DynamicRegisterInfo.cpp b/lldb/source/Target/DynamicRegisterInfo.cpp
index 9ad98a41c688c..b964dc5877a97 100644
--- a/lldb/source/Target/DynamicRegisterInfo.cpp
+++ b/lldb/source/Target/DynamicRegisterInfo.cpp
@@ -497,10 +497,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
        pos != end; ++pos) {
     if (pos->second.size() > 1) {
       llvm::sort(pos->second);
-      reg_num_collection::iterator unique_end =
-          std::unique(pos->second.begin(), pos->second.end());
-      if (unique_end != pos->second.end())
-        pos->second.erase(unique_end, pos->second.end());
+      pos->second.erase(llvm::unique(pos->second), pos->second.end());
     }
     assert(!pos->second.empty());
     if (pos->second.back() != LLDB_INVALID_REGNUM)

``````````

</details>


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


More information about the lldb-commits mailing list