diff options
Diffstat (limited to 'docs/ReleaseNotes.rst')
-rw-r--r-- | docs/ReleaseNotes.rst | 292 |
1 files changed, 135 insertions, 157 deletions
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 8dce92341c3ba..342fed3393b18 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -1,5 +1,5 @@ ======================================= -Clang 6.0.0 (In-Progress) Release Notes +Clang 7.0.0 (In-Progress) Release Notes ======================================= .. contents:: @@ -10,7 +10,7 @@ Written by the `LLVM Team <http://llvm.org/>`_ .. warning:: - These are in-progress notes for the upcoming Clang 6 release. + These are in-progress notes for the upcoming Clang 7 release. Release notes for previous releases can be found on `the Download Page <http://releases.llvm.org/download.html>`_. @@ -18,7 +18,7 @@ Introduction ============ This document contains the release notes for the Clang C/C++/Objective-C -frontend, part of the LLVM Compiler Infrastructure, release 6.0.0. Here we +frontend, part of the LLVM Compiler Infrastructure, release 7.0.0. Here we describe the status of Clang in some detail, including major improvements from the previous release and new feature work. For the general LLVM release notes, see `the LLVM @@ -35,7 +35,7 @@ main Clang web page, this document applies to the *next* release, not the current one. To see the release notes for a specific release, please see the `releases page <http://llvm.org/releases/>`_. -What's New in Clang 6.0.0? +What's New in Clang 7.0.0? ========================== Some of the major new features and improvements to Clang are listed @@ -51,86 +51,81 @@ Major New Features Improvements to Clang's diagnostics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- ``-Wpragma-pack`` is a new warning that warns in the following cases: +- ``-Wc++98-compat-extra-semi`` is a new flag, which was previously inseparable + from ``-Wc++98-compat-pedantic``. The latter still controls the new flag. - - When a translation unit is missing terminating ``#pragma pack (pop)`` - directives. +- ``-Wextra-semi`` now also controls ``-Wc++98-compat-extra-semi``. + Please do note that if you pass ``-Wno-c++98-compat-pedantic``, it implies + ``-Wno-c++98-compat-extra-semi``, so if you want that diagnostic, you need + to explicitly re-enable it (e.g. by appending ``-Wextra-semi``). - - When leaving an included file that changes the current alignment value, - i.e. when the alignment before ``#include`` is different to the alignment - after ``#include``. - - - ``-Wpragma-pack-suspicious-include`` (disabled by default) warns on an - ``#include`` when the included file contains structures or unions affected by - a non-default alignment that has been specified using a ``#pragma pack`` - directive prior to the ``#include``. - -- ``-Wobjc-messaging-id`` is a new, non-default warning that warns about - message sends to unqualified ``id`` in Objective-C. This warning is useful - for projects that would like to avoid any potential future compiler - errors/warnings, as the system frameworks might add a method with the same - selector which could make the message send to ``id`` ambiguous. - -- ``-Wtautological-compare`` now warns when comparing an unsigned integer and 0 - regardless of whether the constant is signed or unsigned." - -- ``-Wtautological-compare`` now warns about comparing a signed integer and 0 - when the signed integer is coerced to an unsigned type for the comparison. - ``-Wsign-compare`` was adjusted not to warn in this case. - -- ``-Wtautological-constant-compare`` is a new warning that warns on - tautological comparisons between integer variable of the type ``T`` and the - largest/smallest possible integer constant of that same type. - -- For C code, ``-Wsign-compare``, ``-Wsign-conversion``, - ``-Wtautological-constant-compare`` and - ``-Wtautological-constant-out-of-range-compare`` were adjusted to use the - underlying datatype of ``enum``. - -- ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic - on a null pointer. Such pointer arithmetic has an undefined behavior if the - offset is nonzero. It also now warns about arithmetic on a null pointer - treated as a cast from integer to pointer (GNU extension). - -- ``-Wzero-as-null-pointer-constant`` was adjusted not to warn on null pointer - constants that originate from system macros, except ``NULL`` macro. +- ``-Wself-assign`` and ``-Wself-assign-field`` were extended to diagnose + self-assignment operations using overloaded operators (i.e. classes). + If you are doing such an assignment intentionally, e.g. in a unit test for + a data structure, the first warning can be disabled by passing + ``-Wno-self-assign-overloaded``, also the warning can be suppressed by adding + ``*&`` to the right-hand side or casting it to the appropriate reference type. Non-comprehensive list of changes in this release ------------------------------------------------- -- Bitrig OS was merged back into OpenBSD, so Bitrig support has been - removed from Clang/LLVM. - -- The default value of _MSC_VER was raised from 1800 to 1911, making it - compatible with the Visual Studio 2015 and 2017 C++ standard library headers. - Users should generally expect this to be regularly raised to match the most - recently released version of the Visual C++ compiler. +- Clang binary and libraries have been renamed from 7.0 to 7. + For example, the ``clang`` binary will be called ``clang-7`` + instead of ``clang-7.0``. + +- Clang implements a collection of recent fixes to the C++ standard's definition + of "standard-layout". In particular, a class is only considered to be + standard-layout if all base classes and the first data member (or bit-field) + can be laid out at offset zero. + +- Clang's handling of the GCC ``packed`` class attribute in C++ has been fixed + to apply only to non-static data members and not to base classes. This fixes + an ABI difference between Clang and GCC, but creates an ABI difference between + Clang 7 and earlier versions. The old behavior can be restored by setting + ``-fclang-abi-compat`` to ``6`` or earlier. + +- Clang implements the proposed resolution of LWG issue 2358, along with the + `corresponding change to the Itanium C++ ABI + <https://github.com/itanium-cxx-abi/cxx-abi/pull/51>`_, which make classes + containing only unnamed non-zero-length bit-fields be considered non-empty. + This is an ABI break compared to prior Clang releases, but makes Clang + generate code that is ABI-compatible with other compilers. The old + behavior can be restored by setting ``-fclang-abi-compat`` to ``6`` or + lower. + +- An existing tool named ``diagtool`` has been added to the release. As the + name suggests, it helps with dealing with diagnostics in ``clang``, such as + finding out the warning hierarchy, and which of them are enabled by default + or for a particular compiler invocation. + +- By default, Clang emits an address-significance table into + every ELF object file when using the integrated assembler. + Address-significance tables allow linkers to implement `safe ICF + <https://research.google.com/pubs/archive/36912.pdf>`_ without the false + positives that can result from other implementation techniques such as + relocation scanning. The ``-faddrsig`` and ``-fno-addrsig`` flags can be + used to control whether to emit the address-significance table. -- clang now defaults to ``.init_array`` if no gcc installation can be found. - If a gcc installation is found, it still prefers ``.ctors`` if the found - gcc is older than 4.7.0. - -- The new builtin preprocessor macros ``__is_target_arch``, - ``__is_target_vendor``, ``__is_target_os``, and ``__is_target_environment`` - can be used to to examine the individual components of the target triple. +- ... New Compiler Flags ------------------ -- --autocomplete was implemented to obtain a list of flags and its arguments. This is used for shell autocompletion. - -- The ``-fdouble-square-bracket-attributes`` and corresponding - ``-fno-double-square-bracket-attributes`` flags were added to enable or - disable [[]] attributes in any language mode. Currently, only a limited - number of attributes are supported outside of C++ mode. See the Clang - attribute documentation for more information about which attributes are - supported for each syntax. - -- Added the ``-std=c17``, ``-std=gnu17``, and ``-std=iso9899:2017`` language - mode flags for compatibility with GCC. This enables support for the next - version of the C standard, expected to be published by ISO in 2018. The only - difference between the ``-std=c17`` and ``-std=c11`` language modes is the - value of the ``__STDC_VERSION__`` macro, as C17 is a bug fix release. +- ``-fstrict-float-cast-overflow`` and ``-fno-strict-float-cast-overflow``. + + When a floating-point value is not representable in a destination integer + type, the code has undefined behavior according to the language standard. By + default, Clang will not guarantee any particular result in that case. With the + 'no-strict' option, Clang attempts to match the overflowing behavior of the + target's native float-to-int conversion instructions. + +- ``-fforce-emit-vtables`` and ``-fno-force-emit-vtables``. + + In order to improve devirtualization, forces emitting of vtables even in + modules where it isn't necessary. It causes more inline virtual functions + to be emitted. + +- ... Deprecated Compiler Flags ------------------------- @@ -140,35 +135,50 @@ future versions of Clang. - ... -New Pragmas in Clang +Modified Compiler Flags ----------------------- +- Before Clang 7, we prepended the `#` character to the `--autocomplete` + argument to enable cc1 flags. For example, when the `-cc1` or `-Xclang` flag + is in the :program:`clang` invocation, the shell executed + `clang --autocomplete=#-<flag to be completed>`. Clang 7 now requires the + whole invocation including all flags to be passed to the `--autocomplete` like + this: `clang --autocomplete=-cc1,-xc++,-fsyn`. + +New Pragmas in Clang +-------------------- + Clang now supports the ... Attribute Changes in Clang -------------------------- -- Clang now supports the majority of its attributes under both the GNU-style - spelling (``__attribute((name))``) and the double square-bracket spelling - in the ``clang`` vendor namespace (``[[clang::name]]``). Attributes whose - syntax is specified by some other standard (such as CUDA and OpenCL - attributes) continue to follow their respective specification. - -- Added the ``__has_c_attribute()`` builtin preprocessor macro which allows - users to dynamically detect whether a double square-bracket attribute is - supported in C mode. This attribute syntax can be enabled with the - ``-fdouble-square-bracket-attributes`` flag. - -- The presence of __attribute__((availability(...))) on a declaration no longer - implies default visibility for that declaration on macOS. +- Clang now supports function multiversioning with attribute 'target' on ELF + based x86/x86-64 environments by using indirect functions. This implementation + has a few minor limitations over the GCC implementation for the sake of AST + sanity, however it is otherwise compatible with existing code using this + feature for GCC. Consult the documentation for the target attribute for more + information. - ... Windows Support --------------- -Clang's support for building native Windows programs ... +- clang-cl's support for precompiled headers has been much improved: + + - When using a pch file, clang-cl now no longer redundantly emits inline + methods that are already stored in the obj that was built together with + the pch file (matching cl.exe). This speeds up builds using pch files + by around 30%. + + - The /Ycfoo.h and /Yufoo.h flags can now be used without /FIfoo.h when + foo.h is instead included by an explicit `#include` directive. This means + Visual Studio's default stdafx.h setup now uses precompiled headers with + clang-cl. + +- ... C Language Changes in Clang @@ -186,10 +196,7 @@ C11 Feature Support C++ Language Changes in Clang ----------------------------- -- Clang's default C++ dialect is now ``gnu++14`` instead of ``gnu++98``. This - means Clang will by default accept code using features from C++14 and - conforming GNU extensions. Projects incompatible with C++14 can add - ``-std=gnu++98`` to their build settings to restore the previous behaviour. +- ... C++1z Feature Support ^^^^^^^^^^^^^^^^^^^^^ @@ -209,12 +216,38 @@ OpenCL C Language Changes in Clang OpenMP Support in Clang ---------------------------------- -... +- Clang gained basic support for OpenMP 4.5 offloading for NVPTX target. + To compile your program for NVPTX target use the following options: + `-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda` for 64 bit platforms or + `-fopenmp -fopenmp-targets=nvptx-nvidia-cuda` for 32 bit platform. + +- Passing options to the OpenMP device offloading toolchain can be done using + the `-Xopenmp-target=<triple> -opt=val` flag. In this way the `-opt=val` + option will be forwarded to the respective OpenMP device offloading toolchain + described by the triple. For example passing the compute capability to + the OpenMP NVPTX offloading toolchain can be done as follows: + `-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_60`. For the case when only one + target offload toolchain is specified under the `-fopenmp-targets=<triples>` + option, then the triple can be skipped: `-Xopenmp-target -march=sm_60`. + +- Other bugfixes. + +CUDA Support in Clang +--------------------- + +- Clang will now try to locate the CUDA installation next to :program:`ptxas` + in the `PATH` environment variable. This behavior can be turned off by passing + the new flag `--cuda-path-ignore-env`. + +- Clang now supports generating object files with relocatable device code. This + feature needs to be enabled with `-fcuda-rdc` and my result in performance + penalties compared to whole program compilation. Please note that NVIDIA's + :program:`nvcc` must be used for linking. Internal API Changes -------------------- -These are major API changes that have happened since the 4.0.0 release of +These are major API changes that have happened since the 6.0.0 release of Clang. If upgrading an external codebase that uses Clang as a library, this section should help get you past the largest hurdles of upgrading. @@ -223,67 +256,16 @@ this section should help get you past the largest hurdles of upgrading. AST Matchers ------------ -The hasDeclaration matcher now works the same for Type and QualType and only -ever looks through one level of sugaring in a limited number of cases. - -There are two main patterns affected by this: - -- qualType(hasDeclaration(recordDecl(...))): previously, we would look through - sugar like TypedefType to get at the underlying recordDecl; now, we need - to explicitly remove the sugaring: - qualType(hasUnqualifiedDesugaredType(hasDeclaration(recordDecl(...)))) - -- hasType(recordDecl(...)): hasType internally uses hasDeclaration; previously, - this matcher used to match for example TypedefTypes of the RecordType, but - after the change they don't; to fix, use: - -:: - hasType(hasUnqualifiedDesugaredType( - recordType(hasDeclaration(recordDecl(...))))) - -- templateSpecializationType(hasDeclaration(classTemplateDecl(...))): - previously, we would directly match the underlying ClassTemplateDecl; - now, we can explicitly match the ClassTemplateSpecializationDecl, but that - requires to explicitly get the ClassTemplateDecl: - -:: - templateSpecializationType(hasDeclaration( - classTemplateSpecializationDecl( - hasSpecializedTemplate(classTemplateDecl(...))))) +- ... clang-format ------------ -* Option *IndentPPDirectives* added to indent preprocessor directives on - conditionals. - - +----------------------+----------------------+ - | Before | After | - +======================+======================+ - | .. code-block:: c++ | .. code-block:: c++ | - | | | - | #if FOO | #if FOO | - | #if BAR | # if BAR | - | #include <foo> | # include <foo> | - | #endif | # endif | - | #endif | #endif | - +----------------------+----------------------+ - -* Option -verbose added to the command line. - Shows the list of processed files. - -* Option *IncludeBlocks* added to merge and regroup multiple ``#include`` blocks during sorting. - - +-------------------------+-------------------------+-------------------------+ - | Before (Preserve) | Merge | Regroup | - +=========================+=========================+=========================+ - | .. code-block:: c++ | .. code-block:: c++ | .. code-block:: c++ | - | | | | - | #include "b.h" | #include "a.h" | #include "a.h" | - | | #include "b.h" | #include "b.h" | - | #include "a.b" | #include <lib/main.h> | | - | #include <lib/main.h> | | #include <lib/main.h> | - +-------------------------+-------------------------+-------------------------+ +- Clang-format will now support detecting and formatting code snippets in raw + string literals. This is configured through the `RawStringFormats` style + option. + +- ... libclang -------- @@ -294,18 +276,14 @@ libclang Static Analyzer --------------- -- Static Analyzer can now properly detect and diagnose unary pre-/post- - increment/decrement on an uninitialized value. +- ... ... Undefined Behavior Sanitizer (UBSan) ------------------------------------ -* A minimal runtime is now available. It is suitable for use in production - environments, and has a small attack surface. It only provides very basic - issue logging and deduplication, and does not support ``-fsanitize=vptr`` - checking. +* ... Core Analysis Improvements ========================== |