[llvm-branch-commits] [libcxx] release/20.x: [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{, multi}map::value_compare (#137594) (PR #138880)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jun 12 11:31:24 PDT 2025


https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/138880

>From 337beb73abfe05c2db1158f211042eb8763165ea Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 7 May 2025 16:09:40 +0200
Subject: [PATCH] [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to
 flat_{,multi}map::value_compare (#137594)

This breaks the ABI of `flat_{,multi}map::value_compare`, but this type
has only been introduced in LLVM 20, so it should be very unlikely that
we break anybody if we back-port this now.

(cherry picked from commit ed0aa9961caa177098e9b7e69e98034d676f192e)
---
 libcxx/include/__flat_map/flat_map.h      | 2 +-
 libcxx/include/__flat_map/flat_multimap.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h
index a0594ed9dc411..9cc39c0a1e067 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -113,7 +113,7 @@ class flat_map {
 
   class value_compare {
   private:
-    key_compare __comp_;
+    _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
     _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
     friend flat_map;
 
diff --git a/libcxx/include/__flat_map/flat_multimap.h b/libcxx/include/__flat_map/flat_multimap.h
index ea77fb5d79bd2..15fcd7995ad0a 100644
--- a/libcxx/include/__flat_map/flat_multimap.h
+++ b/libcxx/include/__flat_map/flat_multimap.h
@@ -115,7 +115,7 @@ class flat_multimap {
 
   class value_compare {
   private:
-    key_compare __comp_;
+    _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
     _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
     friend flat_multimap;
 



More information about the llvm-branch-commits mailing list