| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 1 | ======================================== |
| 2 | Clang 10.0.0 (In-Progress) Release Notes |
| 3 | ======================================== |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 4 | |
| 5 | .. contents:: |
| 6 | :local: |
| 7 | :depth: 2 |
| 8 | |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 9 | Written by the `LLVM Team <https://llvm.org/>`_ |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 10 | |
| 11 | .. warning:: |
| 12 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 13 | These are in-progress notes for the upcoming Clang 10 release. |
| Hans Wennborg | 189f1f3 | 2017-02-09 23:26:34 +0000 | [diff] [blame] | 14 | Release notes for previous releases can be found on |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 15 | `the Download Page <https://releases.llvm.org/download.html>`_. |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 16 | |
| 17 | Introduction |
| 18 | ============ |
| 19 | |
| 20 | This document contains the release notes for the Clang C/C++/Objective-C |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 21 | frontend, part of the LLVM Compiler Infrastructure, release 10.0.0. Here we |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 22 | describe the status of Clang in some detail, including major |
| 23 | improvements from the previous release and new feature work. For the |
| 24 | general LLVM release notes, see `the LLVM |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 25 | documentation <https://llvm.org/docs/ReleaseNotes.html>`_. All LLVM |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 26 | releases may be downloaded from the `LLVM releases web |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 27 | site <https://llvm.org/releases/>`_. |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 28 | |
| Hans Wennborg | d878ca8 | 2017-08-30 18:35:44 +0000 | [diff] [blame] | 29 | For more information about Clang or LLVM, including information about the |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 30 | latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the |
| 31 | `LLVM Web Site <https://llvm.org>`_. |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 32 | |
| 33 | Note that if you are reading this file from a Subversion checkout or the |
| 34 | main Clang web page, this document applies to the *next* release, not |
| 35 | the current one. To see the release notes for a specific release, please |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 36 | see the `releases page <https://llvm.org/releases/>`_. |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 37 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 38 | What's New in Clang 10.0.0? |
| 39 | =========================== |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 40 | |
| 41 | Some of the major new features and improvements to Clang are listed |
| 42 | here. Generic improvements to Clang as a whole or to its underlying |
| 43 | infrastructure are described first, followed by language-specific |
| 44 | sections with improvements to Clang's support for those languages. |
| 45 | |
| 46 | Major New Features |
| 47 | ------------------ |
| 48 | |
| Hans Wennborg | 1fe469a | 2019-01-16 10:57:02 +0000 | [diff] [blame] | 49 | - ... |
| Rafael Espindola | 3497069 | 2013-12-12 16:07:11 +0000 | [diff] [blame] | 50 | |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 51 | Improvements to Clang's diagnostics |
| 52 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 53 | |
| Richard Trieu | 6541c79 | 2019-09-21 02:37:10 +0000 | [diff] [blame] | 54 | - -Wtautological-overlap-compare will warn on negative numbers and non-int |
| 55 | types. |
| Richard Trieu | 4c05de8 | 2019-09-21 03:02:26 +0000 | [diff] [blame] | 56 | - -Wtautological-compare for self comparisons and |
| 57 | -Wtautological-overlap-compare will now look through member and array |
| 58 | access to determine if two operand expressions are the same. |
| Richard Trieu | 8b0d14a | 2019-10-19 00:57:23 +0000 | [diff] [blame] | 59 | - -Wtautological-bitwise-compare is a new warning group. This group has the |
| 60 | current warning which diagnoses the tautological comparison of a bitwise |
| mydeveloperday | 8b5f6c1 | 2019-11-19 08:34:23 +0000 | [diff] [blame] | 61 | operation and a constant. The group also has the new warning which diagnoses |
| Richard Trieu | 8b0d14a | 2019-10-19 00:57:23 +0000 | [diff] [blame] | 62 | when a bitwise-or with a non-negative value is converted to a bool, since |
| 63 | that bool will always be true. |
| Richard Trieu | 637af4c | 2019-10-19 01:47:49 +0000 | [diff] [blame] | 64 | - -Wbitwise-conditional-parentheses will warn on operator precedence issues |
| 65 | when mixing bitwise-and (&) and bitwise-or (|) operator with the |
| 66 | conditional operator (?:). |
| Roman Lebedev | 61061d6 | 2018-04-07 10:39:21 +0000 | [diff] [blame] | 67 | |
| Erich Keane | b0c7809 | 2017-07-26 18:04:45 +0000 | [diff] [blame] | 68 | Non-comprehensive list of changes in this release |
| 69 | ------------------------------------------------- |
| 70 | |
| Roman Lebedev | 536b0ee | 2019-10-10 09:25:02 +0000 | [diff] [blame] | 71 | * In both C and C++ (C17 ``6.5.6p8``, C++ ``[expr.add]``), pointer arithmetic is |
| 72 | only permitted within arrays. In particular, the behavior of a program is not |
| 73 | defined if it adds a non-zero offset (or in C, any offset) to a null pointer, |
| 74 | or if it forms a null pointer by subtracting an integer from a non-null |
| 75 | pointer, and the LLVM optimizer now uses those guarantees for transformations. |
| 76 | This may lead to unintended behavior in code that performs these operations. |
| 77 | The Undefined Behavior Sanitizer ``-fsanitize=pointer-overflow`` check has |
| 78 | been extended to detect these cases, so that code relying on them can be |
| 79 | detected and fixed. |
| 80 | |
| Roman Lebedev | b98a0c7 | 2019-11-27 17:07:06 +0300 | [diff] [blame] | 81 | * The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has |
| 82 | learned to sanitize pre/post increment/decrement of types with bit width |
| 83 | smaller than ``int``. |
| 84 | |
| Craig Topper | 635d383 | 2019-09-11 23:54:36 +0000 | [diff] [blame] | 85 | - For X86 target, -march=skylake-avx512, -march=icelake-client, |
| 86 | -march=icelake-server, -march=cascadelake, -march=cooperlake will default to |
| 87 | not using 512-bit zmm registers in vectorized code unless 512-bit intrinsics |
| 88 | are used in the source code. 512-bit operations are known to cause the CPUs |
| 89 | to run at a lower frequency which can impact performance. This behavior can be |
| 90 | changed by passing -mprefer-vector-width=512 on the command line. |
| Ilya Biryukov | 88aef52 | 2018-12-05 18:32:05 +0000 | [diff] [blame] | 91 | |
| Fangrui Song | e4fce65 | 2019-12-12 10:49:46 -0800 | [diff] [blame^] | 92 | * clang now defaults to ``.init_array`` on Linux. It used to use ``.ctors`` if |
| 93 | the found gcc installation is older than 4.7.0. Add ``-fno-use-init-array`` to |
| 94 | get the old behavior (``.ctors``). |
| 95 | |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 96 | New Compiler Flags |
| 97 | ------------------ |
| 98 | |
| Reid Kleckner | 5e866e4 | 2019-10-10 21:04:25 +0000 | [diff] [blame] | 99 | - The -fgnuc-version= flag now controls the value of ``__GNUC__`` and related |
| 100 | macros. This flag does not enable or disable any GCC extensions implemented in |
| 101 | Clang. Setting the version to zero causes Clang to leave ``__GNUC__`` and |
| 102 | other GNU-namespaced macros, such as ``__GXX_WEAK__``, undefined. |
| Aaron Ballman | 2b3bc4c | 2017-10-21 16:45:08 +0000 | [diff] [blame] | 103 | |
| Craig Topper | b2b6a54 | 2019-11-04 10:20:00 -0800 | [diff] [blame] | 104 | - vzeroupper insertion on X86 targets can now be disabled with -mno-vzeroupper. |
| 105 | You can also force vzeroupper insertion to be used on CPUs that normally |
| 106 | wouldn't with -mvzeroupper. |
| 107 | |
| Joerg Sonnenberger | c919968 | 2017-07-01 21:36:21 +0000 | [diff] [blame] | 108 | Deprecated Compiler Flags |
| 109 | ------------------------- |
| 110 | |
| 111 | The following options are deprecated and ignored. They will be removed in |
| 112 | future versions of Clang. |
| 113 | |
| Craig Topper | 5a43fdd | 2019-08-29 18:09:02 +0000 | [diff] [blame] | 114 | - -mmpx used to enable the __MPX__ preprocessor define for the Intel MPX |
| 115 | instructions. There were no MPX intrinsics. |
| 116 | - -mno-mpx used to disable -mmpx and is the default behavior. |
| 117 | |
| Hans Wennborg | fbb21e0 | 2017-07-19 14:14:07 +0000 | [diff] [blame] | 118 | - ... |
| Joerg Sonnenberger | c919968 | 2017-07-01 21:36:21 +0000 | [diff] [blame] | 119 | |
| Yuka Takahashi | ba900ab | 2018-03-07 11:34:02 +0000 | [diff] [blame] | 120 | Modified Compiler Flags |
| 121 | ----------------------- |
| 122 | |
| Simon Cook | c00e5cf | 2019-11-18 10:44:13 +0000 | [diff] [blame] | 123 | - RISC-V now sets the architecture (riscv32/riscv64) based on the value provided |
| 124 | to the ``-march`` flag, overriding the target provided by ``-triple``. |
| Yuka Takahashi | ba900ab | 2018-03-07 11:34:02 +0000 | [diff] [blame] | 125 | |
| Tyler Nowicki | db2668a | 2014-06-18 00:51:32 +0000 | [diff] [blame] | 126 | New Pragmas in Clang |
| Eugene Zelenko | ad5684a | 2018-05-15 21:45:01 +0000 | [diff] [blame] | 127 | -------------------- |
| Tyler Nowicki | db2668a | 2014-06-18 00:51:32 +0000 | [diff] [blame] | 128 | |
| Hans Wennborg | 1fe469a | 2019-01-16 10:57:02 +0000 | [diff] [blame] | 129 | - ... |
| Paul Robinson | f9ede1c | 2016-07-18 17:19:12 +0000 | [diff] [blame] | 130 | |
| 131 | Attribute Changes in Clang |
| 132 | -------------------------- |
| 133 | |
| Hans Wennborg | fbb21e0 | 2017-07-19 14:14:07 +0000 | [diff] [blame] | 134 | - ... |
| Paul Robinson | f9ede1c | 2016-07-18 17:19:12 +0000 | [diff] [blame] | 135 | |
| Hans Wennborg | 02dc000 | 2014-08-05 00:21:23 +0000 | [diff] [blame] | 136 | Windows Support |
| 137 | --------------- |
| 138 | |
| Hans Wennborg | 99c8651 | 2019-09-25 11:53:17 +0000 | [diff] [blame] | 139 | - Previous Clang versions contained a work-around to avoid an issue with the |
| 140 | standard library headers in Visual Studio 2019 versions prior to 16.3. This |
| 141 | work-around has now been removed, and users of Visual Studio 2019 are |
| 142 | encouraged to upgrade to 16.3 or later, otherwise they may see link errors as |
| 143 | below: |
| 144 | |
| 145 | .. code-block:: console |
| 146 | |
| 147 | error LNK2005: "bool const std::_Is_integral<int>" (??$_Is_integral@H@std@@3_NB) already defined |
| 148 | |
| Renato Golin | f2fcddb | 2013-12-13 09:27:34 +0000 | [diff] [blame] | 149 | C Language Changes in Clang |
| 150 | --------------------------- |
| 151 | |
| Kristina Brooks | c0eb8a9 | 2019-06-05 03:47:02 +0000 | [diff] [blame] | 152 | - ... |
| Renato Golin | f2fcddb | 2013-12-13 09:27:34 +0000 | [diff] [blame] | 153 | |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 154 | C11 Feature Support |
| 155 | ^^^^^^^^^^^^^^^^^^^ |
| 156 | |
| 157 | ... |
| 158 | |
| 159 | C++ Language Changes in Clang |
| 160 | ----------------------------- |
| 161 | |
| Martin Storsjo | 71decf8 | 2019-09-27 12:25:19 +0000 | [diff] [blame] | 162 | - The behaviour of the `gnu_inline` attribute now matches GCC, for cases |
| 163 | where used without the `extern` keyword. As this is a change compared to |
| 164 | how it behaved in previous Clang versions, a warning is emitted for this |
| 165 | combination. |
| Richard Smith | 8eb53c8 | 2016-05-05 18:40:37 +0000 | [diff] [blame] | 166 | |
| 167 | C++1z Feature Support |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 168 | ^^^^^^^^^^^^^^^^^^^^^ |
| 169 | |
| 170 | ... |
| 171 | |
| 172 | Objective-C Language Changes in Clang |
| 173 | ------------------------------------- |
| 174 | |
| James Y Knight | d11a901 | 2019-11-04 12:44:31 -0500 | [diff] [blame] | 175 | - In both Objective-C and |
| 176 | Objective-C++, ``-Wcompare-distinct-pointer-types`` will now warn when |
| 177 | comparing ObjC ``Class`` with an ObjC instance type pointer. |
| 178 | |
| 179 | .. code-block:: objc |
| 180 | |
| 181 | Class clz = ...; |
| 182 | MyType *instance = ...; |
| 183 | bool eq = (clz == instance); // Previously undiagnosed, now warns. |
| 184 | |
| 185 | - Objective-C++ now diagnoses conversions between ``Class`` and ObjC |
| 186 | instance type pointers. Such conversions already emitted an |
| 187 | on-by-default ``-Wincompatible-pointer-types`` warning in Objective-C |
| 188 | mode, but had inadvertently been missed entirely in |
| 189 | Objective-C++. This has been fixed, and they are now diagnosed as |
| 190 | errors, consistent with the usual C++ treatment for conversions |
| 191 | between unrelated pointer types. |
| 192 | |
| 193 | .. code-block:: objc |
| 194 | |
| 195 | Class clz = ...; |
| 196 | MyType *instance = ...; |
| 197 | clz = instance; // Previously undiagnosed, now an error. |
| 198 | instance = clz; // Previously undiagnosed, now an error. |
| 199 | |
| 200 | One particular issue you may run into is attempting to use a class |
| 201 | as a key in a dictionary literal. This will now result in an error, |
| 202 | because ``Class`` is not convertable to ``id<NSCopying>``. (Note that |
| 203 | this was already a warning in Objective-C mode.) While an arbitrary |
| 204 | ``Class`` object is not guaranteed to implement ``NSCopying``, the |
| 205 | default metaclass implementation does. Therefore, the recommended |
| 206 | solution is to insert an explicit cast to ``id``, which disables the |
| 207 | type-checking here. |
| 208 | |
| 209 | .. code-block:: objc |
| 210 | |
| 211 | Class cls = ...; |
| 212 | |
| 213 | // Error: cannot convert from Class to id<NSCoding>. |
| 214 | NSDictionary* d = @{cls : @"Hello"}; |
| 215 | |
| 216 | // Fix: add an explicit cast to 'id'. |
| 217 | NSDictionary* d = @{(id)cls : @"Hello"}; |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 218 | |
| Erik Schnetter | 489700d | 2013-11-11 06:36:33 +0000 | [diff] [blame] | 219 | OpenCL C Language Changes in Clang |
| 220 | ---------------------------------- |
| 221 | |
| Bill Wendling | 0a794a4b | 2013-11-20 10:13:37 +0000 | [diff] [blame] | 222 | ... |
| Erik Schnetter | 489700d | 2013-11-11 06:36:33 +0000 | [diff] [blame] | 223 | |
| Richard Smith | 6822bd7 | 2018-10-26 19:26:45 +0000 | [diff] [blame] | 224 | ABI Changes in Clang |
| 225 | -------------------- |
| 226 | |
| Craig Topper | 6c8a34e | 2019-09-06 06:02:13 +0000 | [diff] [blame] | 227 | - gcc passes vectors of __int128 in memory on X86-64. Clang historically |
| 228 | broke the vectors into multiple scalars using two 64-bit values for each |
| 229 | element. Clang now matches the gcc behavior on Linux and NetBSD. You can |
| 230 | switch back to old API behavior with flag: -fclang-abi-compat=9.0. |
| Richard Smith | 6822bd7 | 2018-10-26 19:26:45 +0000 | [diff] [blame] | 231 | |
| Sam Elliott | e3d5ff5 | 2019-11-15 15:10:02 +0000 | [diff] [blame] | 232 | - RISC-V now chooses a default ``-march=`` and ``-mabi=`` to match (in almost |
| 233 | all cases) the GCC defaults. On baremetal targets, where neither ``-march=`` |
| 234 | nor ``-mabi=`` are specified, Clang now differs from GCC by defaulting to |
| 235 | ``-march=rv32imac -mabi=ilp32`` or ``-march=rv64imac -mabi=lp64`` depending on |
| 236 | the architecture in the target triple. These do not always match the defaults |
| 237 | in Clang 9. We strongly suggest that you explicitly pass `-march=` and |
| 238 | `-mabi=` when compiling for RISC-V, due to how extensible this architecture |
| 239 | is. |
| 240 | |
| Alexey Bataev | 44b6750 | 2016-05-31 11:17:08 +0000 | [diff] [blame] | 241 | OpenMP Support in Clang |
| Shoaib Meenai | 5be71fa | 2019-03-04 21:19:53 +0000 | [diff] [blame] | 242 | ----------------------- |
| Alexey Bataev | 44b6750 | 2016-05-31 11:17:08 +0000 | [diff] [blame] | 243 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 244 | - ... |
| Alexey Bataev | 44b6750 | 2016-05-31 11:17:08 +0000 | [diff] [blame] | 245 | |
| Jonas Hahnfeld | 8da9c2a | 2018-04-20 13:04:54 +0000 | [diff] [blame] | 246 | CUDA Support in Clang |
| 247 | --------------------- |
| 248 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 249 | - ... |
| Jonas Hahnfeld | 8da9c2a | 2018-04-20 13:04:54 +0000 | [diff] [blame] | 250 | |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 251 | Internal API Changes |
| 252 | -------------------- |
| 253 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 254 | These are major API changes that have happened since the 9.0.0 release of |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 255 | Clang. If upgrading an external codebase that uses Clang as a library, |
| 256 | this section should help get you past the largest hurdles of upgrading. |
| 257 | |
| Dmitri Gribenko | b22804b | 2019-08-30 09:29:34 +0000 | [diff] [blame] | 258 | - libTooling APIs that transfer ownership of `FrontendAction` objects now pass |
| 259 | them by `unique_ptr`, making the ownership transfer obvious in the type |
| 260 | system. `FrontendActionFactory::create()` now returns a |
| 261 | `unique_ptr<FrontendAction>`. `runToolOnCode`, `runToolOnCodeWithArgs`, |
| 262 | `ToolInvocation::ToolInvocation()` now take a `unique_ptr<FrontendAction>`. |
| 263 | |
| Shoaib Meenai | 5be71fa | 2019-03-04 21:19:53 +0000 | [diff] [blame] | 264 | Build System Changes |
| 265 | -------------------- |
| 266 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 267 | These are major changes to the build system that have happened since the 9.0.0 |
| Shoaib Meenai | 5be71fa | 2019-03-04 21:19:53 +0000 | [diff] [blame] | 268 | release of Clang. Users of the build system should adjust accordingly. |
| 269 | |
| 270 | - In 8.0.0 and below, the install-clang-headers target would install clang's |
| 271 | resource directory headers. This installation is now performed by the |
| 272 | install-clang-resource-headers target. Users of the old install-clang-headers |
| Shoaib Meenai | 20e7c0c | 2019-03-11 18:53:57 +0000 | [diff] [blame] | 273 | target should switch to the new install-clang-resource-headers target. The |
| 274 | install-clang-headers target now installs clang's API headers (corresponding |
| 275 | to its libraries), which is consistent with the install-llvm-headers target. |
| Shoaib Meenai | 5be71fa | 2019-03-04 21:19:53 +0000 | [diff] [blame] | 276 | |
| Chris Bieneman | a80a3a2b | 2019-08-14 16:49:52 +0000 | [diff] [blame] | 277 | - In 9.0.0 and later Clang added a new target, clang-cpp, which generates a |
| 278 | shared library comprised of all the clang component libraries and exporting |
| 279 | the clang C++ APIs. Additionally the build system gained the new |
| 280 | "CLANG_LINK_CLANG_DYLIB" option, which defaults Off, and when set to On, will |
| 281 | force clang (and clang-based tools) to link the clang-cpp library instead of |
| 282 | statically linking clang's components. This option will reduce the size of |
| 283 | binary distributions at the expense of compiler performance. |
| 284 | |
| 285 | - ... |
| Richard Smith | a0334a9 | 2015-05-14 00:22:12 +0000 | [diff] [blame] | 286 | |
| Aaron Ballman | cdc43af | 2015-09-17 13:47:22 +0000 | [diff] [blame] | 287 | AST Matchers |
| 288 | ------------ |
| Aaron Ballman | cdc43af | 2015-09-17 13:47:22 +0000 | [diff] [blame] | 289 | |
| Paul Hoad | ccc6f83 | 2019-03-22 22:47:34 +0000 | [diff] [blame] | 290 | - ... |
| Sylvestre Ledru | 72e3fa7 | 2017-03-14 09:43:55 +0000 | [diff] [blame] | 291 | |
| 292 | clang-format |
| 293 | ------------ |
| 294 | |
| Sam McCall | 08bfd9e | 2019-10-02 09:52:52 +0000 | [diff] [blame] | 295 | - The ``Standard`` style option specifies which version of C++ should be used |
| 296 | when parsing and formatting C++ code. The set of allowed values has changed: |
| Simon Pilgrim | 68f21b3 | 2019-10-05 16:08:17 +0000 | [diff] [blame] | 297 | |
| Sam McCall | 08bfd9e | 2019-10-02 09:52:52 +0000 | [diff] [blame] | 298 | - ``Latest`` will always enable new C++ language features. |
| 299 | - ``c++03``, ``c++11``, ``c++14``, ``c++17``, ``c++20`` will pin to exactly |
| 300 | that language version. |
| 301 | - ``Auto`` is the default and detects style from the code (this is unchanged). |
| Simon Pilgrim | 68f21b3 | 2019-10-05 16:08:17 +0000 | [diff] [blame] | 302 | |
| 303 | The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that |
| mydeveloperday | 8b5f6c1 | 2019-11-19 08:34:23 +0000 | [diff] [blame] | 304 | ``Cpp11`` is treated as ``Latest``, as this was always clang-format's |
| 305 | behavior. (One motivation for this change is the new name describes the |
| 306 | behavior better). |
| Sylvestre Ledru | c941039 | 2017-12-05 09:23:47 +0000 | [diff] [blame] | 307 | |
| mydeveloperday | 8b5f6c1 | 2019-11-19 08:34:23 +0000 | [diff] [blame] | 308 | - Clang-format has a new option called ``--dry-run`` or ``-n`` to emit a |
| 309 | warning for clang-format violations. This can be used together |
| 310 | with --ferror-limit=N to limit the number of warnings per file and --Werror |
| 311 | to make warnings into errors. |
| Sylvestre Ledru | 4c44fd3 | 2019-11-08 23:26:29 +0100 | [diff] [blame] | 312 | |
| mydeveloperday | 8b5f6c1 | 2019-11-19 08:34:23 +0000 | [diff] [blame] | 313 | - Option *IncludeIsMainSourceRegex* has been added to allow for additional |
| mydeveloperday | 335ac2e | 2019-11-12 21:15:17 +0000 | [diff] [blame] | 314 | suffixes and file extensions to be considered as a source file |
| 315 | for execution of logic that looks for "main *include* file" to put |
| 316 | it on top. |
| 317 | |
| 318 | By default, clang-format considers *source* files as "main" only when |
| 319 | they end with: ``.c``, ``.cc``, ``.cpp``, ``.c++``, ``.cxx``, |
| 320 | ``.m`` or ``.mm`` extensions. This config option allows to |
| 321 | extend this set of source files considered as "main". |
| mydeveloperday | 8b5f6c1 | 2019-11-19 08:34:23 +0000 | [diff] [blame] | 322 | |
| mydeveloperday | 335ac2e | 2019-11-12 21:15:17 +0000 | [diff] [blame] | 323 | For example, if this option is configured to ``(Impl\.hpp)$``, |
| 324 | then a file ``ClassImpl.hpp`` is considered "main" (in addition to |
| 325 | ``Class.c``, ``Class.cc``, ``Class.cpp`` and so on) and "main |
| 326 | include file" logic will be executed (with *IncludeIsMainRegex* setting |
| 327 | also being respected in later phase). Without this option set, |
| 328 | ``ClassImpl.hpp`` would not have the main include file put on top |
| 329 | before any other include. |
| 330 | |
| mydeveloperday | 8b5f6c1 | 2019-11-19 08:34:23 +0000 | [diff] [blame] | 331 | - Options ``DeriveLineEnding`` and ``UseCRLF`` have been added to allow |
| 332 | clang-format to control the newlines. ``DeriveLineEnding`` is by default |
| 333 | ``true`` and reflects is the existing mechanism, which based is on majority |
| 334 | rule. The new options allows this to be turned off and ``UseCRLF`` to control |
| 335 | the decision as to which sort of line ending to use. |
| 336 | |
| 337 | - Option ``SpaceBeforeSquareBrackets`` has been added to insert a space before |
| 338 | array declarations. |
| 339 | |
| 340 | .. code-block:: c++ |
| 341 | |
| 342 | int a [5]; vs int a[5]; |
| 343 | |
| 344 | - Clang-format now supports JavaScript null operators. |
| 345 | |
| 346 | .. code-block:: c++ |
| 347 | |
| 348 | const x = foo ?? default; |
| 349 | const z = foo?.bar?.baz; |
| 350 | |
| Ted Kremenek | 3a2291b | 2013-04-24 07:33:52 +0000 | [diff] [blame] | 351 | libclang |
| 352 | -------- |
| 353 | |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 354 | - ... |
| Ted Kremenek | 3a2291b | 2013-04-24 07:33:52 +0000 | [diff] [blame] | 355 | |
| Anna Zaks | b6219a9 | 2013-04-25 23:14:38 +0000 | [diff] [blame] | 356 | Static Analyzer |
| Ted Kremenek | 004e823 | 2013-04-26 00:01:34 +0000 | [diff] [blame] | 357 | --------------- |
| Anna Zaks | b6219a9 | 2013-04-25 23:14:38 +0000 | [diff] [blame] | 358 | |
| Sylvestre Ledru | 9bea4ec | 2019-10-11 20:33:43 +0000 | [diff] [blame] | 359 | - The Clang analyzer checker ``DeadStores`` gets a new option called |
| 360 | ``WarnForDeadNestedAssignments`` to detect nested dead assignments |
| 361 | (enabled by default). |
| Hans Wennborg | 8f5b44a | 2019-07-18 11:51:05 +0000 | [diff] [blame] | 362 | - ... |
| Ted Kremenek | 004e823 | 2013-04-26 00:01:34 +0000 | [diff] [blame] | 363 | |
| Roman Lebedev | b69ba22 | 2018-07-30 18:58:30 +0000 | [diff] [blame] | 364 | .. _release-notes-ubsan: |
| 365 | |
| Vedant Kumar | 840c2c7 | 2017-06-13 02:52:31 +0000 | [diff] [blame] | 366 | Undefined Behavior Sanitizer (UBSan) |
| 367 | ------------------------------------ |
| 368 | |
| Roman Lebedev | 536b0ee | 2019-10-10 09:25:02 +0000 | [diff] [blame] | 369 | - * The ``pointer-overflow`` check was extended added to catch the cases where |
| 370 | a non-zero offset is applied to a null pointer, or the result of |
| 371 | applying the offset is a null pointer. |
| 372 | |
| 373 | .. code-block:: c++ |
| 374 | |
| 375 | #include <cstdint> // for intptr_t |
| 376 | |
| 377 | static char *getelementpointer_inbounds(char *base, unsigned long offset) { |
| 378 | // Potentially UB. |
| 379 | return base + offset; |
| 380 | } |
| 381 | |
| 382 | char *getelementpointer_unsafe(char *base, unsigned long offset) { |
| 383 | // Always apply offset. UB if base is ``nullptr`` and ``offset`` is not |
| 384 | // zero, or if ``base`` is non-``nullptr`` and ``offset`` is |
| 385 | // ``-reinterpret_cast<intptr_t>(base)``. |
| 386 | return getelementpointer_inbounds(base, offset); |
| 387 | } |
| 388 | |
| 389 | char *getelementpointer_safe(char *base, unsigned long offset) { |
| 390 | // Cast pointer to integer, perform usual arithmetic addition, |
| 391 | // and cast to pointer. This is legal. |
| 392 | char *computed = |
| 393 | reinterpret_cast<char *>(reinterpret_cast<intptr_t>(base) + offset); |
| 394 | // If either the pointer becomes non-``nullptr``, or becomes |
| 395 | // ``nullptr``, we must use ``computed`` result. |
| 396 | if (((base == nullptr) && (computed != nullptr)) || |
| 397 | ((base != nullptr) && (computed == nullptr))) |
| 398 | return computed; |
| 399 | // Else we can use ``getelementpointer_inbounds()``. |
| 400 | return getelementpointer_inbounds(base, offset); |
| 401 | } |
| 402 | |
| Ted Kremenek | 004e823 | 2013-04-26 00:01:34 +0000 | [diff] [blame] | 403 | Core Analysis Improvements |
| 404 | ========================== |
| 405 | |
| Bill Wendling | 61f44cc | 2013-06-04 06:17:46 +0000 | [diff] [blame] | 406 | - ... |
| Ted Kremenek | 004e823 | 2013-04-26 00:01:34 +0000 | [diff] [blame] | 407 | |
| 408 | New Issues Found |
| 409 | ================ |
| 410 | |
| Bill Wendling | 61f44cc | 2013-06-04 06:17:46 +0000 | [diff] [blame] | 411 | - ... |
| Anna Zaks | b6219a9 | 2013-04-25 23:14:38 +0000 | [diff] [blame] | 412 | |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 413 | Python Binding Changes |
| 414 | ---------------------- |
| 415 | |
| 416 | The following methods have been added: |
| 417 | |
| 418 | - ... |
| 419 | |
| 420 | Significant Known Problems |
| 421 | ========================== |
| 422 | |
| 423 | Additional Information |
| 424 | ====================== |
| 425 | |
| 426 | A wide variety of additional information is available on the `Clang web |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 427 | page <https://clang.llvm.org/>`_. The web page contains versions of the |
| Sean Silva | fe25144 | 2012-12-23 01:19:35 +0000 | [diff] [blame] | 428 | API documentation which are up-to-date with the Subversion version of |
| 429 | the source code. You can access versions of these documents specific to |
| 430 | this release by going into the "``clang/docs/``" directory in the Clang |
| 431 | tree. |
| 432 | |
| 433 | If you have any questions or comments about Clang, please feel free to |
| 434 | contact us via the `mailing |
| Hans Wennborg | 0aa0d91 | 2018-09-10 08:51:25 +0000 | [diff] [blame] | 435 | list <https://lists.llvm.org/mailman/listinfo/cfe-dev>`_. |