[libcxx-commits] [PATCH] D136191: [libc++][PMR] Add attributes

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 19 04:04:49 PDT 2022


philnik updated this revision to Diff 468864.
philnik added a comment.

Try to fix CI


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136191/new/

https://reviews.llvm.org/D136191

Files:
  libcxx/include/__memory_resource/memory_resource.h
  libcxx/include/__memory_resource/unsynchronized_pool_resource.h
  libcxx/test/std/utilities/utility/mem.res/mem.res.global/null_memory_resource.pass.cpp
  libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.public/allocate.pass.cpp


Index: libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.public/allocate.pass.cpp
===================================================================
--- libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.public/allocate.pass.cpp
+++ libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.public/allocate.pass.cpp
@@ -37,11 +37,11 @@
   auto& P                      = R.getController();
   std::pmr::memory_resource& M = R;
   {
-    static_assert(std::is_same<decltype(M.allocate(0, 0)), void*>::value, "Must be void*");
+    static_assert(std::is_same<decltype(M.allocate(0, 1)), void*>::value, "Must be void*");
     static_assert(std::is_same<decltype(M.allocate(0)), void*>::value, "Must be void*");
   }
   {
-    static_assert(!noexcept(M.allocate(0, 0)), "Must not be noexcept.");
+    static_assert(!noexcept(M.allocate(0, 1)), "Must not be noexcept.");
     static_assert(!noexcept(M.allocate(0)), "Must not be noexcept.");
   }
   {
Index: libcxx/test/std/utilities/utility/mem.res/mem.res.global/null_memory_resource.pass.cpp
===================================================================
--- libcxx/test/std/utilities/utility/mem.res/mem.res.global/null_memory_resource.pass.cpp
+++ libcxx/test/std/utilities/utility/mem.res/mem.res.global/null_memory_resource.pass.cpp
@@ -90,7 +90,6 @@
   globalMemCounter.reset();
 
   int x = 42;
-  std::pmr::null_memory_resource()->deallocate(nullptr, 0);
   std::pmr::null_memory_resource()->deallocate(&x, 0);
 
   assert(globalMemCounter.checkDeleteCalledEq(0));
Index: libcxx/include/__memory_resource/unsynchronized_pool_resource.h
===================================================================
--- libcxx/include/__memory_resource/unsynchronized_pool_resource.h
+++ libcxx/include/__memory_resource/unsynchronized_pool_resource.h
@@ -78,7 +78,7 @@
 
   _LIBCPP_HIDE_FROM_ABI memory_resource* upstream_resource() const { return __res_; }
 
-  pool_options options() const;
+  [[__gnu__::__pure__]] pool_options options() const;
 
 protected:
   void* do_allocate(size_t __bytes, size_t __align) override; // key function
Index: libcxx/include/__memory_resource/memory_resource.h
===================================================================
--- libcxx/include/__memory_resource/memory_resource.h
+++ libcxx/include/__memory_resource/memory_resource.h
@@ -32,11 +32,13 @@
 public:
   virtual ~memory_resource() = default;
 
-  _LIBCPP_HIDE_FROM_ABI void* allocate(size_t __bytes, size_t __align = __max_align) {
+  [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]] _LIBCPP_HIDE_FROM_ABI void*
+  allocate(size_t __bytes, size_t __align = __max_align) {
     return do_allocate(__bytes, __align);
   }
 
-  _LIBCPP_HIDE_FROM_ABI void deallocate(void* __p, size_t __bytes, size_t __align = __max_align) {
+  [[__gnu__::__nonnull__]] _LIBCPP_HIDE_FROM_ABI void
+  deallocate(void* __p, size_t __bytes, size_t __align = __max_align) {
     do_deallocate(__p, __bytes, __align);
   }
 
@@ -63,10 +65,14 @@
 
 // [mem.res.global]
 
-_LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource* get_default_resource() noexcept;
-_LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource* set_default_resource(memory_resource*) noexcept;
-_LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource* new_delete_resource() noexcept;
-_LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource* null_memory_resource() noexcept;
+[[__gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource*
+get_default_resource() noexcept;
+[[__gnu__::__returns_nonnull__]] _LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource*
+set_default_resource(memory_resource*) noexcept;
+[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource*
+new_delete_resource() noexcept;
+[[using __gnu__: __returns_nonnull__, __const__]] _LIBCPP_AVAILABILITY_MEMORY_RESOURCE _LIBCPP_FUNC_VIS memory_resource*
+null_memory_resource() noexcept;
 
 } // namespace pmr
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136191.468864.patch
Type: text/x-patch
Size: 4108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221019/27633f08/attachment-0001.bin>


More information about the libcxx-commits mailing list