blob: b6a405dbc78b2edbd55ca08256ea93be6fe2e1f4 [file] [log] [blame]
Hans Wennborg60d06bf2016-07-18 18:05:19 +00001=======================================
Hans Wennborg3d0d25d2018-08-01 14:01:27 +00002Clang 8.0.0 (In-Progress) Release Notes
Hans Wennborg60d06bf2016-07-18 18:05:19 +00003=======================================
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 Wennborg3d0d25d2018-08-01 14:01:27 +000013 These are in-progress notes for the upcoming Clang 8 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 Wennborg3d0d25d2018-08-01 14:01:27 +000021frontend, part of the LLVM Compiler Infrastructure, release 8.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 Wennborg3d0d25d2018-08-01 14:01:27 +000038What's New in Clang 8.0.0?
Hans Wennborg60d06bf2016-07-18 18:05:19 +000039==========================
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
Richard Smith8654ae52018-10-10 23:13:35 +000049- Clang supports use of a profile remapping file, which permits
50 profile data captured for one version of a program to be applied
51 when building another version where symbols have changed (for
52 example, due to renaming a class or namespace).
53 See the :doc:`UsersManual` for details.
Rafael Espindola34970692013-12-12 16:07:11 +000054
Sean Silvafe251442012-12-23 01:19:35 +000055Improvements to Clang's diagnostics
56^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57
Roman Lebedev377748f2018-11-20 18:59:05 +000058- ``-Wextra-semi-stmt`` is a new diagnostic that diagnoses extra semicolons,
59 much like ``-Wextra-semi``. This new diagnostic diagnoses all *unnecessary*
60 null statements (expression statements without an expression), unless: the
61 semicolon directly follows a macro that was expanded to nothing or if the
62 semicolon is within the macro itself. This applies to macros defined in system
63 headers as well as user-defined macros.
64
65 .. code-block:: c++
66
67 #define MACRO(x) int x;
68 #define NULLMACRO(varname)
69
70 void test() {
71 ; // <- warning: ';' with no preceding expression is a null statement
72
73 while (true)
74 ; // OK, it is needed.
75
76 switch (my_enum) {
77 case E1:
78 // stuff
79 break;
80 case E2:
81 ; // OK, it is needed.
82 }
83
84 MACRO(v0;) // Extra semicolon, but within macro, so ignored.
85
86 MACRO(v1); // <- warning: ';' with no preceding expression is a null statement
87
88 NULLMACRO(v2); // ignored, NULLMACRO expanded to nothing.
89 }
90
91- ``-Wempty-init-stmt`` is a new diagnostic that diagnoses empty init-statements
92 of ``if``, ``switch``, ``range-based for``, unless: the semicolon directly
93 follows a macro that was expanded to nothing or if the semicolon is within the
94 macro itself (both macros from system headers, and normal macros). This
95 diagnostic is in the ``-Wextra-semi-stmt`` group and is enabled in
96 ``-Wextra``.
97
98 .. code-block:: c++
99
100 void test() {
101 if(; // <- warning: init-statement of 'if' is a null statement
102 true)
103 ;
104
105 switch (; // <- warning: init-statement of 'switch' is a null statement
106 x) {
107 ...
108 }
109
110 for (; // <- warning: init-statement of 'range-based for' is a null statement
111 int y : S())
112 ;
113 }
114
Roman Lebedev61061d62018-04-07 10:39:21 +0000115
Erich Keaneb0c78092017-07-26 18:04:45 +0000116Non-comprehensive list of changes in this release
117-------------------------------------------------
118
Erich Keane0a6b5b62018-12-04 14:34:09 +0000119- The experimental feature Pretokenized Headers (PTH) was removed in its
120 entirely from Clang. The feature did not properly work with about 1/3 of the
121 possible tokens available and was unmaintained.
Alex Lorenzd8ec4312017-12-14 19:22:02 +0000122
Ilya Biryukov88aef522018-12-05 18:32:05 +0000123- The internals of libc++ include directory detection on MacOS have changed.
124 Instead of running a search based on the ``-resource-dir`` flag, the search
125 is now based on the path of the compiler in the filesystem. The default
126 behaviour should not change. However, if you override ``-resource-dir``
127 manually and rely on the old behaviour you will need to add appropriate
128 compiler flags for finding the corresponding libc++ include directory.
129
Sean Silvafe251442012-12-23 01:19:35 +0000130New Compiler Flags
131------------------
132
Calixte Denizetf4bf6712018-11-17 19:41:39 +0000133- ``-fprofile-filter-files=[regexes]`` and ``-fprofile-exclude-files=[regexes]``.
134
135 Clang has now options to filter or exclude some files when
136 instrumenting for gcov-based profiling.
137 See the :doc:`UsersManual` for details.
138
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000139- ...
Aaron Ballman2b3bc4c2017-10-21 16:45:08 +0000140
Joerg Sonnenbergerc9199682017-07-01 21:36:21 +0000141Deprecated Compiler Flags
142-------------------------
143
144The following options are deprecated and ignored. They will be removed in
145future versions of Clang.
146
Hans Wennborgfbb21e02017-07-19 14:14:07 +0000147- ...
Joerg Sonnenbergerc9199682017-07-01 21:36:21 +0000148
Yuka Takahashiba900ab2018-03-07 11:34:02 +0000149Modified Compiler Flags
150-----------------------
151
Richard Smith6822bd72018-10-26 19:26:45 +0000152- As of clang 8, `alignof` and `_Alignof` return the ABI alignment of a type,
153 as opposed to the preferred alignment. `__alignof` still returns the
154 preferred alignment. `-fclang-abi-compat=7` (and previous) will make
155 `alignof` and `_Alignof` return preferred alignment again.
156
Yuka Takahashiba900ab2018-03-07 11:34:02 +0000157
Tyler Nowickidb2668a2014-06-18 00:51:32 +0000158New Pragmas in Clang
Eugene Zelenkoad5684a2018-05-15 21:45:01 +0000159--------------------
Tyler Nowickidb2668a2014-06-18 00:51:32 +0000160
Erik Pilkington7d180942018-10-29 17:38:42 +0000161- Clang now supports adding multiple `#pragma clang attribute` attributes into
162 a scope of pushed attributes.
Paul Robinsonf9ede1c2016-07-18 17:19:12 +0000163
164Attribute Changes in Clang
165--------------------------
166
Hans Wennborgfbb21e02017-07-19 14:14:07 +0000167- ...
Paul Robinsonf9ede1c2016-07-18 17:19:12 +0000168
Hans Wennborg02dc0002014-08-05 00:21:23 +0000169Windows Support
170---------------
171
Mike Rice58df1af2018-09-11 17:10:44 +0000172- clang-cl now supports the use of the precompiled header options /Yc and /Yu
173 without the filename argument. When these options are used without the
174 filename, a `#pragma hdrstop` inside the source marks the end of the
175 precompiled code.
176
Hans Wennborga97c4e32018-11-12 08:42:21 +0000177- clang-cl has a new command-line option, ``/Zc:dllexportInlines-``, similar to
178 ``-fvisibility-inlines-hidden`` on non-Windows, that makes class-level
179 `dllexport` and `dllimport` attributes not apply to inline member functions.
180 This can significantly reduce compile and link times. See the `User's Manual
181 <UsersManual.html#the-zc-dllexportinlines-option>`_ for more info.
Nico Weber1dbff9a2018-07-18 11:55:03 +0000182- ...
Hans Wennborg02dc0002014-08-05 00:21:23 +0000183
184
Renato Golinf2fcddb2013-12-13 09:27:34 +0000185C Language Changes in Clang
186---------------------------
187
Hans Wennborg60d06bf2016-07-18 18:05:19 +0000188- ...
Pirama Arumuga Nainarc85c8532016-06-21 16:09:30 +0000189
Renato Golinf2fcddb2013-12-13 09:27:34 +0000190...
191
Sean Silvafe251442012-12-23 01:19:35 +0000192C11 Feature Support
193^^^^^^^^^^^^^^^^^^^
194
195...
196
197C++ Language Changes in Clang
198-----------------------------
199
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000200- ...
Richard Smith8eb53c82016-05-05 18:40:37 +0000201
202C++1z Feature Support
Sean Silvafe251442012-12-23 01:19:35 +0000203^^^^^^^^^^^^^^^^^^^^^
204
205...
206
207Objective-C Language Changes in Clang
208-------------------------------------
209
210...
211
Erik Schnetter489700d2013-11-11 06:36:33 +0000212OpenCL C Language Changes in Clang
213----------------------------------
214
Bill Wendling0a794a4b2013-11-20 10:13:37 +0000215...
Erik Schnetter489700d2013-11-11 06:36:33 +0000216
Richard Smith6822bd72018-10-26 19:26:45 +0000217ABI Changes in Clang
218--------------------
219
220- `_Alignof` and `alignof` now return the ABI alignment of a type, as opposed
221 to the preferred alignment.
Jonas Tothaa51ef12018-10-31 17:00:50 +0000222
Richard Smith6822bd72018-10-26 19:26:45 +0000223 - This is more in keeping with the language of the standards, as well as
224 being compatible with gcc
225 - `__alignof` and `__alignof__` still return the preferred alignment of
226 a type
227 - This shouldn't break any ABI except for things that explicitly ask for
228 `alignas(alignof(T))`.
229 - If you have interfaces that break with this change, you may wish to switch
230 to `alignas(__alignof(T))`, instead of using the `-fclang-abi-compat`
231 switch.
232
Alexey Bataev44b67502016-05-31 11:17:08 +0000233OpenMP Support in Clang
234----------------------------------
235
Alexey Bataev2819d4d2019-01-09 20:32:56 +0000236- Support relational-op != (not-equal) as one of the canonical forms of random
237 access iterator.
238
239- Added support for mapping of the lambdas in target regions.
240
241- Added parsing/sema analysis for OpenMP 5.0 requires directive.
242
243- Various bugfixes and improvements.
244
245New features supported for Cuda devices:
246
247- Added support for the reductions across the teams.
248
249- Extended number of constructs that can be executed in SPMD mode.
250
251- Fixed support for lastprivate/reduction variables in SPMD constructs.
252
253- General performance improvement.
Alexey Bataev44b67502016-05-31 11:17:08 +0000254
Jonas Hahnfeld8da9c2a2018-04-20 13:04:54 +0000255CUDA Support in Clang
256---------------------
257
Jonas Hahnfeld8da9c2a2018-04-20 13:04:54 +0000258
Sean Silvafe251442012-12-23 01:19:35 +0000259Internal API Changes
260--------------------
261
Hans Wennborg3d0d25d2018-08-01 14:01:27 +0000262These are major API changes that have happened since the 7.0.0 release of
Sean Silvafe251442012-12-23 01:19:35 +0000263Clang. If upgrading an external codebase that uses Clang as a library,
264this section should help get you past the largest hurdles of upgrading.
265
Vedant Kumar5fb00e42016-07-27 23:01:55 +0000266- ...
Richard Smitha0334a92015-05-14 00:22:12 +0000267
Aaron Ballmancdc43af2015-09-17 13:47:22 +0000268AST Matchers
269------------
Aaron Ballmancdc43af2015-09-17 13:47:22 +0000270
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000271- ...
Sylvestre Ledru72e3fa72017-03-14 09:43:55 +0000272
273clang-format
274------------
275
Krasimir Georgievf2ca41d2018-05-08 09:25:12 +0000276
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000277- ...
Sylvestre Ledruc9410392017-12-05 09:23:47 +0000278
Ted Kremenek3a2291b2013-04-24 07:33:52 +0000279libclang
280--------
281
Bill Wendling61f44cc2013-06-04 06:17:46 +0000282...
Ted Kremenek3a2291b2013-04-24 07:33:52 +0000283
Sylvestre Ledruea49d3a2016-08-06 20:23:54 +0000284
Anna Zaksb6219a92013-04-25 23:14:38 +0000285Static Analyzer
Ted Kremenek004e8232013-04-26 00:01:34 +0000286---------------
Anna Zaksb6219a92013-04-25 23:14:38 +0000287
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000288- ...
Roman Lebedev88b56ca2017-11-30 09:18:35 +0000289
Bill Wendling0a794a4b2013-11-20 10:13:37 +0000290...
Ted Kremenek004e8232013-04-26 00:01:34 +0000291
Roman Lebedevb69ba222018-07-30 18:58:30 +0000292.. _release-notes-ubsan:
293
Vedant Kumar840c2c72017-06-13 02:52:31 +0000294Undefined Behavior Sanitizer (UBSan)
295------------------------------------
296
Roman Lebedev62debd802018-10-30 21:58:56 +0000297* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group
298 was extended. One more type of issues is caught - implicit integer sign change.
299 (``-fsanitize=implicit-integer-sign-change``).
300 This makes the Implicit Conversion Sanitizer feature-complete,
301 with only missing piece being bitfield handling.
302 While there is a ``-Wsign-conversion`` diagnostic group that catches this kind
303 of issues, it is both noisy, and does not catch **all** the cases.
304
305 .. code-block:: c++
306
307 bool consume(unsigned int val);
308
309 void test(int val) {
310 (void)consume(val); // If the value was negative, it is now large positive.
311 (void)consume((unsigned int)val); // OK, the conversion is explicit.
312 }
313
314 Like some other ``-fsanitize=integer`` checks, these issues are **not**
315 undefined behaviour. But they are not *always* intentional, and are somewhat
316 hard to track down. This group is **not** enabled by ``-fsanitize=undefined``,
317 but the ``-fsanitize=implicit-integer-sign-change`` check
318 is enabled by ``-fsanitize=integer``.
319 (as is ``-fsanitize=implicit-integer-truncation`` check)
Vedant Kumar840c2c72017-06-13 02:52:31 +0000320
Roman Lebedevd677c3f2018-11-19 19:56:43 +0000321* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
322 learned to sanitize compound assignment operators.
323
Roman Lebedevbd1c0872019-01-15 09:44:25 +0000324* ``alignment`` check has learned to sanitize the assume_aligned-like attributes:
325
326 .. code-block:: c++
327
328 typedef char **__attribute__((align_value(1024))) aligned_char;
329 struct ac_struct {
330 aligned_char a;
331 };
332 char **load_from_ac_struct(struct ac_struct *x) {
333 return x->a; // <- check that loaded 'a' is aligned
334 }
335
336 char **passthrough(__attribute__((align_value(1024))) char **x) {
337 return x; // <- check the pointer passed as function argument
338 }
339
340 char **__attribute__((alloc_align(2)))
341 alloc_align(int size, unsigned long alignment);
342
343 char **caller(int size) {
344 return alloc_align(size, 1024); // <- check returned pointer
345 }
346
347 char **__attribute__((assume_aligned(1024))) get_ptr();
348
349 char **caller2() {
350 return get_ptr(); // <- check returned pointer
351 }
352
353 void *caller3(char **x) {
354 return __builtin_assume_aligned(x, 1024); // <- check returned pointer
355 }
356
357 void *caller4(char **x, unsigned long offset) {
358 return __builtin_assume_aligned(x, 1024, offset); // <- check returned pointer accounting for the offest
359 }
360
361 void process(char *data, int width) {
362 #pragma omp for simd aligned(data : 1024) // <- aligned clause will be checked.
363 for (int x = 0; x < width; x++)
364 data[x] *= data[x];
365 }
366
Ted Kremenek004e8232013-04-26 00:01:34 +0000367Core Analysis Improvements
368==========================
369
Bill Wendling61f44cc2013-06-04 06:17:46 +0000370- ...
Ted Kremenek004e8232013-04-26 00:01:34 +0000371
372New Issues Found
373================
374
Bill Wendling61f44cc2013-06-04 06:17:46 +0000375- ...
Anna Zaksb6219a92013-04-25 23:14:38 +0000376
Sean Silvafe251442012-12-23 01:19:35 +0000377Python Binding Changes
378----------------------
379
380The following methods have been added:
381
382- ...
383
384Significant Known Problems
385==========================
386
387Additional Information
388======================
389
390A wide variety of additional information is available on the `Clang web
Hans Wennborg0aa0d912018-09-10 08:51:25 +0000391page <https://clang.llvm.org/>`_. The web page contains versions of the
Sean Silvafe251442012-12-23 01:19:35 +0000392API documentation which are up-to-date with the Subversion version of
393the source code. You can access versions of these documents specific to
394this release by going into the "``clang/docs/``" directory in the Clang
395tree.
396
397If you have any questions or comments about Clang, please feel free to
398contact us via the `mailing
Hans Wennborg0aa0d912018-09-10 08:51:25 +0000399list <https://lists.llvm.org/mailman/listinfo/cfe-dev>`_.