aboutsummaryrefslogtreecommitdiff
path: root/clang/docs
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2022-06-28 11:01:55 +0200
committerserge-sans-paille <sguelton@redhat.com>2022-07-18 12:45:52 +0200
commitf764dc99b37e1e6428724a61f36bcb49c015dc70 (patch)
tree63232db1fb62062e17a95f4cbaf5e562d3304432 /clang/docs
parent432cbd7827202e4316225820f3f90417b9fcce6c (diff)
downloadllvm-f764dc99b37e1e6428724a61f36bcb49c015dc70.zip
llvm-f764dc99b37e1e6428724a61f36bcb49c015dc70.tar.gz
llvm-f764dc99b37e1e6428724a61f36bcb49c015dc70.tar.bz2
[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible arrays
Some code [0] consider that trailing arrays are flexible, whatever their size. Support for these legacy code has been introduced in f8f632498307d22e10fab0704548b270b15f1e1e but it prevents evaluation of __builtin_object_size and __builtin_dynamic_object_size in some legit cases. Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is desirable. n = 0: current behavior, any trailing array member is a flexible array. The default. n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member n = 2: any trailing array member of undefined or 0 size is a flexible array member This takes into account two specificities of clang: array bounds as macro id disqualify FAM, as well as non standard layout. Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
Diffstat (limited to 'clang/docs')
-rw-r--r--clang/docs/ClangCommandLineReference.rst6
-rw-r--r--clang/docs/ReleaseNotes.rst4
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst
index 216872b..223990e 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2647,6 +2647,12 @@ Enable unstable and experimental features
.. option:: -fuse-init-array, -fno-use-init-array
+.. option:: -fstrict-flex-arrays=<arg>, -fno-strict-flex-arrays
+
+Control which arrays are considered as flexible arrays members. <arg>
+can be 1 (array of size 0, 1 and undefined are considered) or 2 (array of size 0
+and undefined are considered).
+
.. option:: -fuse-ld=<arg>
.. option:: -fuse-line-directives, -fno-use-line-directives
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 17c1dac..cb64cd2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -68,6 +68,10 @@ Major New Features
Randomizing structure layout is a C-only feature.
+- Clang now supports the ``-fstrict-flex-arrays=<arg>`` option to control which
+ array bounds lead to flexible array members. The option yields more accurate
+ ``__builtin_object_size`` and ``__builtin_dynamic_object_size`` results in
+ most cases but may be overly conservative for some legacy code.
- Experimental support for HLSL has been added. The implementation is
incomplete and highly experimental. For more information about the ongoing
work to support HLSL see the `documentation