[libcxx-commits] [clang] [libcxx] [clang][ThreadSafety] Add requires_negative_capability attribute (PR #203099)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 11 06:46:49 PDT 2026


================
@@ -654,36 +654,41 @@ As a result, ``EXCLUDES`` can easily produce false negatives:
 
 
 Negative requirements are an alternative to ``EXCLUDES`` that provide
-a stronger safety guarantee.  A negative requirement uses the  ``REQUIRES``
-attribute, in conjunction with the ``!`` operator, to indicate that a capability
-should *not* be held.
-
-For example, using ``REQUIRES(!mu)`` instead of ``EXCLUDES(mu)`` will produce
-the appropriate warnings:
+a stronger safety guarantee.  A negative requirement uses either
+``REQUIRES_NEGATIVE`` or the ``REQUIRES`` attribute in conjunction with the
+``!`` operator to indicate that a capability should *not* be held.
+``REQUIRES_NEGATIVE(mu)`` does not require ``!mu`` to be a well-formed
+expression. More generally, its argument is interpreted the same way as a
+``REQUIRES`` argument, and then the capability requirement is inverted. For
+example, if ``!mu`` is well-formed, ``REQUIRES_NEGATIVE(!mu)`` is equivalent
+to ``REQUIRES(mu)``.
+
----------------
AnthonyCalandraGeotab wrote:

I used `REQUIRES_NEGATIVE` but another option I considered was `REQUIRES_NOT`.

https://github.com/llvm/llvm-project/pull/203099


More information about the libcxx-commits mailing list