[clang] 5bd0611 - Update documentation for __builtin_operator_new and
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 23 16:31:18 PDT 2020
Author: Richard Smith
Date: 2020-03-23T16:31:10-07:00
New Revision: 5bd06118c2a798f1f87b9251953bae8a27f21e5f
URL: https://github.com/llvm/llvm-project/commit/5bd06118c2a798f1f87b9251953bae8a27f21e5f
DIFF: https://github.com/llvm/llvm-project/commit/5bd06118c2a798f1f87b9251953bae8a27f21e5f.diff
LOG: Update documentation for __builtin_operator_new and
__builtin_operator_delete to match r328134.
Added:
Modified:
clang/docs/LanguageExtensions.rst
Removed:
################################################################################
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index aee0b82880ba..f9511dc1a02f 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2129,21 +2129,32 @@ object that overloads ``operator&``.
``__builtin_operator_new`` and ``__builtin_operator_delete``
------------------------------------------------------------
-``__builtin_operator_new`` allocates memory just like a non-placement non-class
-*new-expression*. This is exactly like directly calling the normal
-non-placement ``::operator new``, except that it allows certain optimizations
+A call to ``__builtin_operator_new(args)`` is exactly the same as a call to
+``::operator new(args)``, except that it allows certain optimizations
that the C++ standard does not permit for a direct function call to
``::operator new`` (in particular, removing ``new`` / ``delete`` pairs and
-merging allocations).
+merging allocations), and that the call is required to resolve to a
+`replaceable global allocation function
+<https://en.cppreference.com/w/cpp/memory/new/operator_new>`_.
-Likewise, ``__builtin_operator_delete`` deallocates memory just like a
-non-class *delete-expression*, and is exactly like directly calling the normal
-``::operator delete``, except that it permits optimizations. Only the unsized
-form of ``__builtin_operator_delete`` is currently available.
+Likewise, ``__builtin_operator_delete`` is exactly the same as a call to
+``::operator delete(args)``, except that it permits optimizations
+and that the call is required to resolve to a
+`replaceable global deallocation function
+<https://en.cppreference.com/w/cpp/memory/new/operator_delete>`_.
These builtins are intended for use in the implementation of ``std::allocator``
and other similar allocation libraries, and are only available in C++.
+Query for this feature with ``__has_builtin(__builtin_operator_new)`` or
+``__has_builtin(__builtin_operator_delete)``:
+
+ * If the value is at least ``201802L``, the builtins behave as described above.
+
+ * If the value is non-zero, the builtins may not support calling arbitrary
+ replaceable global (de)allocation functions, but do support calling at least
+ ``::operator new(size_t)`` and ``::operator delete(void*)``.
+
``__builtin_preserve_access_index``
-----------------------------------
More information about the cfe-commits
mailing list