[libcxx-commits] [libcxx] Add missing annotatinos for Apple platforms (PR #198864)
Paul Kirth via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 27 08:13:38 PDT 2026
https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/198864
>From 96563f8e8e7500a6ec97aaa4edeedd1f1222891a Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Wed, 20 May 2026 11:11:13 -0700
Subject: [PATCH 1/4] Add missing annotatinos for Apple platforms
These seemed to be missed in #193045.
---
libcxx/include/__functional/function.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index 3185a1942455a..45556907d9d74 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -529,9 +529,15 @@ class __policy_func<_Rp(_ArgTypes...)> {
# if _LIBCPP_HAS_BLOCKS_RUNTIME
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
+
extern "C" void* _Block_copy(const void*);
extern "C" void _Block_release(const void*);
+_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
+_LIBCPP_DIAGNOSTIC_POP
+
template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes>
class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
typedef _Rp1 (^__block_type)(_ArgTypes1...);
>From 81cbce6ff9de1a6d4a934a950110fc558f147dbb Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Thu, 21 May 2026 13:57:50 -0700
Subject: [PATCH 2/4] Remove _LIBCPP_DIAGNOSTIC macros
---
libcxx/include/__functional/function.h | 2 --
1 file changed, 2 deletions(-)
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index 45556907d9d74..73fd43ec073fc 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -529,14 +529,12 @@ class __policy_func<_Rp(_ArgTypes...)> {
# if _LIBCPP_HAS_BLOCKS_RUNTIME
-_LIBCPP_DIAGNOSTIC_PUSH
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
extern "C" void* _Block_copy(const void*);
extern "C" void _Block_release(const void*);
_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
-_LIBCPP_DIAGNOSTIC_POP
template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes>
class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
>From 73a169be500056615077e5b5c3e9fd0334cd8862 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Thu, 21 May 2026 14:55:45 -0700
Subject: [PATCH 3/4] Add regression test
---
.../block.func.compile.pass.cpp | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
diff --git a/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
new file mode 100644
index 0000000000000..0afbf322d9a31
--- /dev/null
+++ b/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// std::function support for the "blocks" extension
+
+// REQUIRES: has-blocks-runtime
+// UNSUPPORTED: c++03
+
+// This test requires the Blocks runtime, which is (only?) available
+// on Darwin out-of-the-box.
+// REQUIRES: has-fblocks && darwin
+
+// ADDITIONAL_COMPILE_FLAGS: -fblocks
+
+// Test that including <Block.h> before <functional> compiles and runs.
+// This is a regression test for an issue where redeclaring the Block runtime
+// functions (_Block_copy, _Block_release) inside libc++'s explicit ABI
+// annotations incorrectly added an 'abi_tag' attribute to them.
+
+#include <Block.h>
+#include <functional>
+
+int main(int, char**) {
+ std::function<void()> f = []() {};
+ (void)f;
+ return 0;
+}
>From 455665d8889b643ca34ba5548ed1455cce6efbf4 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Tue, 26 May 2026 09:30:09 -0700
Subject: [PATCH 4/4] Remove stale/erroneous REQUIRES line
I added this while prototyping before just cribbing from the existing
tests and failed to remove it.
---
.../utilities/function.objects/block.func.compile.pass.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
index 0afbf322d9a31..967e3ed83632f 100644
--- a/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
@@ -8,7 +8,6 @@
// std::function support for the "blocks" extension
-// REQUIRES: has-blocks-runtime
// UNSUPPORTED: c++03
// This test requires the Blocks runtime, which is (only?) available
More information about the libcxx-commits
mailing list