summaryrefslogtreecommitdiffstats
path: root/clang/docs/LanguageExtensions.rst
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-01-20 00:57:59 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-01-20 00:57:59 +0000
commit67d484bc82faecd7d2683f3bf5cec4ea49778df9 (patch)
tree047bece02c79dd0c314e0dc8f2e27e9fa1dbf243 /clang/docs/LanguageExtensions.rst
parentb26ed3924f0f2bd6c7f1109c637064c9785e0485 (diff)
downloadbcm5719-llvm-67d484bc82faecd7d2683f3bf5cec4ea49778df9.tar.gz
bcm5719-llvm-67d484bc82faecd7d2683f3bf5cec4ea49778df9.zip
Add documentation for constexpr string builtin support.
llvm-svn: 292558
Diffstat (limited to 'clang/docs/LanguageExtensions.rst')
-rw-r--r--clang/docs/LanguageExtensions.rst40
1 files changed, 40 insertions, 0 deletions
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 64e6ffb7f3e..3a86a599a3b 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1776,6 +1776,46 @@ numeric primitives such as frexp. See `LLVM canonicalize intrinsic
<http://llvm.org/docs/LangRef.html#llvm-canonicalize-intrinsic>`_ for
more information on the semantics.
+String builtins
+---------------
+
+Clang provides constant expression evaluation support for builtins forms of
+the following functions from the C standard library ``<strings.h>`` header:
+
+* ``memchr``
+* ``memcmp``
+* ``strchr``
+* ``strcmp``
+* ``strlen``
+* ``strncmp``
+* ``wcschr``
+* ``wcscmp``
+* ``wcslen``
+* ``wcsncmp``
+* ``wmemchr``
+* ``wmemcmp``
+
+In each case, the builtin form has the name of the C library function prefixed
+by ``__builtin``. Example:
+
+.. code-block:: c
+
+ void *p = __builtin_memchr("foobar", 'b', 5);
+
+In addition to the above, one further builtin is provided:
+
+.. code-block:: c
+
+ char *__builtin_char_memchr(const char *haystack, int needle, size_t size);
+
+``__builtin_char_memchr(a, b, c)`` is identical to
+``(char*)__builtin_memchr(a, b, c)`` except that its use is permitted within
+constant expressions in C++11 onwards (where a cast from ``void*`` to ``char*``
+is disallowed in general).
+
+Support for constant expression evaluation for the above builtins be detected
+with ``__has_feature(cxx_constexpr_string_builtins)``.
+
.. _langext-__c11_atomic:
__c11_atomic builtins
OpenPOWER on IntegriCloud