[libcxx-commits] [libcxx] 97b9c24 - Add missing annotations for Apple platforms (#198864)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 27 08:16:01 PDT 2026


Author: Paul Kirth
Date: 2026-05-27T15:15:56Z
New Revision: 97b9c24cb9f2e46ce917bf2e5aea5d4511ae8298

URL: https://github.com/llvm/llvm-project/commit/97b9c24cb9f2e46ce917bf2e5aea5d4511ae8298
DIFF: https://github.com/llvm/llvm-project/commit/97b9c24cb9f2e46ce917bf2e5aea5d4511ae8298.diff

LOG: Add missing annotations for Apple platforms (#198864)

These seemed to be missed in #193045.

Added: 
    libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp

Modified: 
    libcxx/include/__functional/function.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index 3185a1942455a..73fd43ec073fc 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -529,9 +529,13 @@ class __policy_func<_Rp(_ArgTypes...)> {
 
 #  if _LIBCPP_HAS_BLOCKS_RUNTIME
 
+_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
+
 extern "C" void* _Block_copy(const void*);
 extern "C" void _Block_release(const void*);
 
+_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
+
 template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes>
 class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
   typedef _Rp1 (^__block_type)(_ArgTypes1...);

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..967e3ed83632f
--- /dev/null
+++ b/libcxx/test/libcxx/utilities/function.objects/block.func.compile.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// 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;
+}


        


More information about the libcxx-commits mailing list