blob: 3db1603e063117cb29f2e444c3e4d4942175e507 [file] [log] [blame]
Hans Wennborg8f5b44a2019-07-18 11:51:05 +00001========================================
2Clang 10.0.0 (In-Progress) Release Notes
3========================================
Sean Silvafe251442012-12-23 01:19:35 +00004
5.. contents::
6 :local:
7 :depth: 2
8
Hans Wennborg0aa0d912018-09-10 08:51:25 +00009Written by the `LLVM Team <https://llvm.org/>`_
Sean Silvafe251442012-12-23 01:19:35 +000010
11.. warning::
12
Hans Wennborg8f5b44a2019-07-18 11:51:05 +000013 These are in-progress notes for the upcoming Clang 10 release.
Hans Wennborg189f1f32017-02-09 23:26:34 +000014 Release notes for previous releases can be found on
Hans Wennborg0aa0d912018-09-10 08:51:25 +000015 `the Download Page <https://releases.llvm.org/download.html>`_.
Sean Silvafe251442012-12-23 01:19:35 +000016
17Introduction
18============
19
20This document contains the release notes for the Clang C/C++/Objective-C
Hans Wennborg8f5b44a2019-07-18 11:51:05 +000021frontend, part of the LLVM Compiler Infrastructure, release 10.0.0. Here we
Sean Silvafe251442012-12-23 01:19:35 +000022describe the status of Clang in some detail, including major
23improvements from the previous release and new feature work. For the
24general LLVM release notes, see `the LLVM
Hans Wennborg0aa0d912018-09-10 08:51:25 +000025documentation <https://llvm.org/docs/ReleaseNotes.html>`_. All LLVM
Sean Silvafe251442012-12-23 01:19:35 +000026releases may be downloaded from the `LLVM releases web
Hans Wennborg0aa0d912018-09-10 08:51:25 +000027site <https://llvm.org/releases/>`_.
Sean Silvafe251442012-12-23 01:19:35 +000028
Hans Wennborgd878ca82017-08-30 18:35:44 +000029For more information about Clang or LLVM, including information about the
Hans Wennborg0aa0d912018-09-10 08:51:25 +000030latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
31`LLVM Web Site <https://llvm.org>`_.
Sean Silvafe251442012-12-23 01:19:35 +000032
33Note that if you are reading this file from a Subversion checkout or the
34main Clang web page, this document applies to the *next* release, not
35the current one. To see the release notes for a specific release, please
Hans Wennborg0aa0d912018-09-10 08:51:25 +000036see the `releases page <https://llvm.org/releases/>`_.
Sean Silvafe251442012-12-23 01:19:35 +000037
Hans Wennborg8f5b44a2019-07-18 11:51:05 +000038What's New in Clang 10.0.0?
39===========================
Sean Silvafe251442012-12-23 01:19:35 +000040
41Some of the major new features and improvements to Clang are listed
42here. Generic improvements to Clang as a whole or to its underlying
43infrastructure are described first, followed by language-specific
44sections with improvements to Clang's support for those languages.
45
46Major New Features
47------------------
48
Hans Wennborg1fe469a2019-01-16 10:57:02 +000049- ...
Rafael Espindola34970692013-12-12 16:07:11 +000050
Sean Silvafe251442012-12-23 01:19:35 +000051Improvements to Clang's diagnostics
52^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
53
Richard Trieu6541c792019-09-21 02:37:10 +000054- -Wtautological-overlap-compare will warn on negative numbers and non-int
55 types.
Richard Trieu4c05de82019-09-21 03:02:26 +000056- -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 Trieu8b0d14a2019-10-19 00:57:23 +000059- -Wtautological-bitwise-compare is a new warning group. This group has the
60 current warning which diagnoses the tautological comparison of a bitwise
61 operation and a constant. The group also has the new warning which diagnoses
62 when a bitwise-or with a non-negative value is converted to a bool, since
63 that bool will always be true.
Richard Trieu637af4c2019-10-19 01:47:49 +000064- -Wbitwise-conditional-parentheses will warn on operator precedence issues
65 when mixing bitwise-and (&) and bitwise-or (|) operator with the
66 conditional operator (?:).
Roman Lebedev61061d62018-04-07 10:39:21 +000067
Erich Keaneb0c78092017-07-26 18:04:45 +000068Non-comprehensive list of changes in this release
69-------------------------------------------------
70
Roman Lebedev536b0ee2019-10-10 09:25:02 +000071* 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
Craig Topper635d3832019-09-11 23:54:36 +000081- For X86 target, -march=skylake-avx512, -march=icelake-client,
82 -march=icelake-server, -march=cascadelake, -march=cooperlake will default to
83 not using 512-bit zmm registers in vectorized code unless 512-bit intrinsics
84 are used in the source code. 512-bit operations are known to cause the CPUs
85 to run at a lower frequency which can impact performance. This behavior can be
86 changed by passing -mprefer-vector-width=512 on the command line.
Ilya Biryukov88aef522018-12-05 18:32:05 +000087
Sean Silvafe251442012-12-23 01:19:35 +000088New Compiler Flags
89------------------
90
Reid Kleckner5e866e42019-10-10 21:04:25 +000091- The -fgnuc-version= flag now controls the value of ``__GNUC__`` and related
92 macros. This flag does not enable or disable any GCC extensions implemented in
93 Clang. Setting the version to zero causes Clang to leave ``__GNUC__`` and
94 other GNU-namespaced macros, such as ``__GXX_WEAK__``, undefined.
Aaron Ballman2b3bc4c2017-10-21 16:45:08 +000095
Craig Topperb2b6a542019-11-04 10:20:00 -080096- vzeroupper insertion on X86 targets can now be disabled with -mno-vzeroupper.
97 You can also force vzeroupper insertion to be used on CPUs that normally
98 wouldn't with -mvzeroupper.
99
Joerg Sonnenbergerc9199682017-07-01 21:36:21 +0000100Deprecated Compiler Flags
101-------------------------
102
103The following options are deprecated and ignored. They will be removed in
104future versions of Clang.
105
Craig Topper5a43fdd2019-08-29 18:09:02 +0000106- -mmpx used to enable the __MPX__ preprocessor define for the Intel MPX
107 instructions. There were no MPX intrinsics.
108- -mno-mpx used to disable -mmpx and is the default behavior.
109
Hans Wennborgfbb21e02017-07-19 14:14:07 +0000110- ...
Joerg Sonnenbergerc9199682017-07-01 21:36:21 +0000111
Yuka Takahashiba900ab2018-03-07 11:34:02 +0000112Modified Compiler Flags
113-----------------------
114
Eric Christopher030b17d2019-05-14 19:40:42 +0000115- ...
Yuka Takahashiba900ab2018-03-07 11:34:02 +0000116
Tyler Nowickidb2668a2014-06-18 00:51:32 +0000117New Pragmas in Clang
Eugene Zelenkoad5684a2018-05-15 21:45:01 +0000118--------------------
Tyler Nowickidb2668a2014-06-18 00:51:32 +0000119
Hans Wennborg1fe469a2019-01-16 10:57:02 +0000120- ...
Paul Robinsonf9ede1c2016-07-18 17:19:12 +0000121
122Attribute Changes in Clang
123--------------------------
124
Hans Wennborgfbb21e02017-07-19 14:14:07 +0000125- ...
Paul Robinsonf9ede1c2016-07-18 17:19:12 +0000126
Hans Wennborg02dc0002014-08-05 00:21:23 +0000127Windows Support
128---------------
129
Hans Wennborg99c86512019-09-25 11:53:17 +0000130- Previous Clang versions contained a work-around to avoid an issue with the
131 standard library headers in Visual Studio 2019 versions prior to 16.3. This
132 work-around has now been removed, and users of Visual Studio 2019 are
133 encouraged to upgrade to 16.3 or later, otherwise they may see link errors as
134 below:
135
136 .. code-block:: console
137
138 error LNK2005: "bool const std::_Is_integral<int>" (??$_Is_integral@H@std@@3_NB) already defined
139
140
141
Hans Wennborg02dc0002014-08-05 00:21:23 +0000142
Renato Golinf2fcddb2013-12-13 09:27:34 +0000143C Language Changes in Clang
144---------------------------
145
Kristina Brooksc0eb8a92019-06-05 03:47:02 +0000146- ...
Renato Golinf2fcddb2013-12-13 09:27:34 +0000147
Sean Silvafe251442012-12-23 01:19:35 +0000148C11 Feature Support
149^^^^^^^^^^^^^^^^^^^
150
151...
152
153C++ Language Changes in Clang
154-----------------------------
155
Martin Storsjo71decf82019-09-27 12:25:19 +0000156- The behaviour of the `gnu_inline` attribute now matches GCC, for cases
157 where used without the `extern` keyword. As this is a change compared to
158 how it behaved in previous Clang versions, a warning is emitted for this
159 combination.
Richard Smith8eb53c82016-05-05 18:40:37 +0000160
161C++1z Feature Support
Sean Silvafe251442012-12-23 01:19:35 +0000162^^^^^^^^^^^^^^^^^^^^^
163
164...
165
166Objective-C Language Changes in Clang
167-------------------------------------
168
James Y Knightd11a9012019-11-04 12:44:31 -0500169- In both Objective-C and
170 Objective-C++, ``-Wcompare-distinct-pointer-types`` will now warn when
171 comparing ObjC ``Class`` with an ObjC instance type pointer.
172
173 .. code-block:: objc
174
175 Class clz = ...;
176 MyType *instance = ...;
177 bool eq = (clz == instance); // Previously undiagnosed, now warns.
178
179- Objective-C++ now diagnoses conversions between ``Class`` and ObjC
180 instance type pointers. Such conversions already emitted an
181 on-by-default ``-Wincompatible-pointer-types`` warning in Objective-C
182 mode, but had inadvertently been missed entirely in
183 Objective-C++. This has been fixed, and they are now diagnosed as
184 errors, consistent with the usual C++ treatment for conversions
185 between unrelated pointer types.
186
187 .. code-block:: objc
188
189 Class clz = ...;
190 MyType *instance = ...;
191 clz = instance; // Previously undiagnosed, now an error.
192 instance = clz; // Previously undiagnosed, now an error.
193
194 One particular issue you may run into is attempting to use a class
195 as a key in a dictionary literal. This will now result in an error,
196 because ``Class`` is not convertable to ``id<NSCopying>``. (Note that
197 this was already a warning in Objective-C mode.) While an arbitrary
198 ``Class`` object is not guaranteed to implement ``NSCopying``, the
199 default metaclass implementation does. Therefore, the recommended
200 solution is to insert an explicit cast to ``id``, which disables the
201 type-checking here.
202
203 .. code-block:: objc
204
205 Class cls = ...;
206
207 // Error: cannot convert from Class to id<NSCoding>.
208 NSDictionary* d = @{cls : @"Hello"};
209
210 // Fix: add an explicit cast to 'id'.
211 NSDictionary* d = @{(id)cls : @"Hello"};
Sean Silvafe251442012-12-23 01:19:35 +0000212
Erik Schnetter489700d2013-11-11 06:36:33 +0000213OpenCL C Language Changes in Clang
214----------------------------------
215
Bill Wendling0a794a4b2013-11-20 10:13:37 +0000216...
Erik Schnetter489700d2013-11-11 06:36:33 +0000217
Richard Smith6822bd72018-10-26 19:26:45 +0000218ABI Changes in Clang
219--------------------
220
Craig Topper6c8a34e2019-09-06 06:02:13 +0000221- gcc passes vectors of __int128 in memory on X86-64. Clang historically
222 broke the vectors into multiple scalars using two 64-bit values for each
223 element. Clang now matches the gcc behavior on Linux and NetBSD. You can
224 switch back to old API behavior with flag: -fclang-abi-compat=9.0.
Richard Smith6822bd72018-10-26 19:26:45 +0000225
Alexey Bataev44b67502016-05-31 11:17:08 +0000226OpenMP Support in Clang
Shoaib Meenai5be71fa2019-03-04 21:19:53 +0000227-----------------------
Alexey Bataev44b67502016-05-31 11:17:08 +0000228
Hans Wennborg8f5b44a2019-07-18 11:51:05 +0000229- ...
Alexey Bataev44b67502016-05-31 11:17:08 +0000230
Jonas Hahnfeld8da9c2a2018-04-20 13:04:54 +0000231CUDA Support in Clang
232---------------------
233
Hans Wennborg8f5b44a2019-07-18 11:51:05 +0000234- ...
Jonas Hahnfeld8da9c2a2018-04-20 13:04:54 +0000235
Sean Silvafe251442012-12-23 01:19:35 +0000236Internal API Changes
237--------------------
238
Hans Wennborg8f5b44a2019-07-18 11:51:05 +0000239These are major API changes that have happened since the 9.0.0 release of
Sean Silvafe251442012-12-23 01:19:35 +0000240Clang. If upgrading an external codebase that uses Clang as a library,
241this section should help get you past the largest hurdles of upgrading.
242
Dmitri Gribenkob22804b2019-08-30 09:29:34 +0000243- libTooling APIs that transfer ownership of `FrontendAction` objects now pass
244 them by `unique_ptr`, making the ownership transfer obvious in the type
245 system. `FrontendActionFactory::create()` now returns a
246 `unique_ptr<FrontendAction>`. `runToolOnCode`, `runToolOnCodeWithArgs`,
247 `ToolInvocation::ToolInvocation()` now take a `unique_ptr<FrontendAction>`.
248
Shoaib Meenai5be71fa2019-03-04 21:19:53 +0000249Build System Changes
250--------------------
251
Hans Wennborg8f5b44a2019-07-18 11:51:05 +0000252These are major changes to the build system that have happened since the 9.0.0
Shoaib Meenai5be71fa2019-03-04 21:19:53 +0000253release of Clang. Users of the build system should adjust accordingly.
254
255- In 8.0.0 and below, the install-clang-headers target would install clang's
256 resource directory headers. This installation is now performed by the
257 install-clang-resource-headers target. Users of the old install-clang-headers
Shoaib Meenai20e7c0c2019-03-11 18:53:57 +0000258 target should switch to the new install-clang-resource-headers target. The
259 install-clang-headers target now installs clang's API headers (corresponding
260 to its libraries), which is consistent with the install-llvm-headers target.
Shoaib Meenai5be71fa2019-03-04 21:19:53 +0000261
Chris Bienemana80a3a2b2019-08-14 16:49:52 +0000262- In 9.0.0 and later Clang added a new target, clang-cpp, which generates a
263 shared library comprised of all the clang component libraries and exporting
264 the clang C++ APIs. Additionally the build system gained the new
265 "CLANG_LINK_CLANG_DYLIB" option, which defaults Off, and when set to On, will
266 force clang (and clang-based tools) to link the clang-cpp library instead of
267 statically linking clang's components. This option will reduce the size of
268 binary distributions at the expense of compiler performance.
269
270- ...
Richard Smitha0334a92015-05-14 00:22:12 +0000271
Aaron Ballmancdc43af2015-09-17 13:47:22 +0000272AST Matchers
273------------
Aaron Ballmancdc43af2015-09-17 13:47:22 +0000274
Paul Hoadccc6f832019-03-22 22:47:34 +0000275- ...
Sylvestre Ledru72e3fa72017-03-14 09:43:55 +0000276
277clang-format
278------------
279
Sam McCall08bfd9e2019-10-02 09:52:52 +0000280- The ``Standard`` style option specifies which version of C++ should be used
281 when parsing and formatting C++ code. The set of allowed values has changed:
Simon Pilgrim68f21b32019-10-05 16:08:17 +0000282
Sam McCall08bfd9e2019-10-02 09:52:52 +0000283 - ``Latest`` will always enable new C++ language features.
284 - ``c++03``, ``c++11``, ``c++14``, ``c++17``, ``c++20`` will pin to exactly
285 that language version.
286 - ``Auto`` is the default and detects style from the code (this is unchanged).
Simon Pilgrim68f21b32019-10-05 16:08:17 +0000287
288 The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that
289 ``Cpp11`` is treated as ``Latest``, as this was always clang-format's behavior.
290 (One motivation for this change is the new name describes the behavior better).
Sylvestre Ledruc9410392017-12-05 09:23:47 +0000291
Sylvestre Ledru4c44fd32019-11-08 23:26:29 +0100292- clang-format gets a new option called ``--dry-run`` or ``-n`` to emit a
293 warning.
294
Ted Kremenek3a2291b2013-04-24 07:33:52 +0000295libclang
296--------
297
Hans Wennborg8f5b44a2019-07-18 11:51:05 +0000298- ...
Ted Kremenek3a2291b2013-04-24 07:33:52 +0000299
Sylvestre Ledruea49d3a2016-08-06 20:23:54 +0000300
Anna Zaksb6219a92013-04-25 23:14:38 +0000301Static Analyzer
Ted Kremenek004e8232013-04-26 00:01:34 +0000302---------------
Anna Zaksb6219a92013-04-25 23:14:38 +0000303
Sylvestre Ledru9bea4ec2019-10-11 20:33:43 +0000304- The Clang analyzer checker ``DeadStores`` gets a new option called
305 ``WarnForDeadNestedAssignments`` to detect nested dead assignments
306 (enabled by default).
Hans Wennborg8f5b44a2019-07-18 11:51:05 +0000307- ...
Ted Kremenek004e8232013-04-26 00:01:34 +0000308
Roman Lebedevb69ba222018-07-30 18:58:30 +0000309.. _release-notes-ubsan:
310
Vedant Kumar840c2c72017-06-13 02:52:31 +0000311Undefined Behavior Sanitizer (UBSan)
312------------------------------------
313
Roman Lebedev536b0ee2019-10-10 09:25:02 +0000314- * The ``pointer-overflow`` check was extended added to catch the cases where
315 a non-zero offset is applied to a null pointer, or the result of
316 applying the offset is a null pointer.
317
318 .. code-block:: c++
319
320 #include <cstdint> // for intptr_t
321
322 static char *getelementpointer_inbounds(char *base, unsigned long offset) {
323 // Potentially UB.
324 return base + offset;
325 }
326
327 char *getelementpointer_unsafe(char *base, unsigned long offset) {
328 // Always apply offset. UB if base is ``nullptr`` and ``offset`` is not
329 // zero, or if ``base`` is non-``nullptr`` and ``offset`` is
330 // ``-reinterpret_cast<intptr_t>(base)``.
331 return getelementpointer_inbounds(base, offset);
332 }
333
334 char *getelementpointer_safe(char *base, unsigned long offset) {
335 // Cast pointer to integer, perform usual arithmetic addition,
336 // and cast to pointer. This is legal.
337 char *computed =
338 reinterpret_cast<char *>(reinterpret_cast<intptr_t>(base) + offset);
339 // If either the pointer becomes non-``nullptr``, or becomes
340 // ``nullptr``, we must use ``computed`` result.
341 if (((base == nullptr) && (computed != nullptr)) ||
342 ((base != nullptr) && (computed == nullptr)))
343 return computed;
344 // Else we can use ``getelementpointer_inbounds()``.
345 return getelementpointer_inbounds(base, offset);
346 }
347
Roman Lebedevbd1c0872019-01-15 09:44:25 +0000348
Ted Kremenek004e8232013-04-26 00:01:34 +0000349Core Analysis Improvements
350==========================
351
Bill Wendling61f44cc2013-06-04 06:17:46 +0000352- ...
Ted Kremenek004e8232013-04-26 00:01:34 +0000353
354New Issues Found
355================
356
Bill Wendling61f44cc2013-06-04 06:17:46 +0000357- ...
Anna Zaksb6219a92013-04-25 23:14:38 +0000358
Sean Silvafe251442012-12-23 01:19:35 +0000359Python Binding Changes
360----------------------
361
362The following methods have been added:
363
364- ...
365
366Significant Known Problems
367==========================
368
369Additional Information
370======================
371
372A wide variety of additional information is available on the `Clang web
Hans Wennborg0aa0d912018-09-10 08:51:25 +0000373page <https://clang.llvm.org/>`_. The web page contains versions of the
Sean Silvafe251442012-12-23 01:19:35 +0000374API documentation which are up-to-date with the Subversion version of
375the source code. You can access versions of these documents specific to
376this release by going into the "``clang/docs/``" directory in the Clang
377tree.
378
379If you have any questions or comments about Clang, please feel free to
380contact us via the `mailing
Hans Wennborg0aa0d912018-09-10 08:51:25 +0000381list <https://lists.llvm.org/mailman/listinfo/cfe-dev>`_.