[all-commits] [llvm/llvm-project] 3f151a: [libc++][memory] Applied `[[nodiscard]]` to smart ...

Hristo Hristov via All-commits all-commits at lists.llvm.org
Wed Nov 19 18:19:36 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3f151a3fa6ccb00523d8e0e36fa8d9046d5a936f
      https://github.com/llvm/llvm-project/commit/3f151a3fa6ccb00523d8e0e36fa8d9046d5a936f
  Author: Hristo Hristov <hristo.goshev.hristov at gmail.com>
  Date:   2025-11-20 (Thu, 20 Nov 2025)

  Changed paths:
    M libcxx/include/__memory/shared_ptr.h
    M libcxx/include/__memory/unique_ptr.h
    M libcxx/test/libcxx/utilities/smartptr/nodiscard.verify.cpp
    M libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.deprecated_in_cxx17.verify.cpp

  Log Message:
  -----------
  [libc++][memory] Applied `[[nodiscard]]` to smart pointers (#168483)

Applied `[[nodiscard]]` where relevant to smart pointers and related
functions.

- [x] - `std::unique_ptr`
- [x] - `std::shared_ptr`
- [x] - `std::weak_ptr`

See guidelines:
-
https://libcxx.llvm.org/CodingGuidelines.html#apply-nodiscard-where-relevant
- `[[nodiscard]]` should be applied to functions where discarding the
return value is most likely a correctness issue. For example a locking
constructor in unique_lock.

---------

Co-authored-by: Hristo Hristov <zingam at outlook.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list