blob: 1e45a13ef916133b3cc04080555ab010fdabc23c [file] [log] [blame]
Hans Wennborg60d06bf2016-07-18 18:05:19 +00001=======================================
Hans Wennborg7b852ea2018-01-03 15:49:39 +00002Clang 7.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
9Written by the `LLVM Team <http://llvm.org/>`_
10
11.. warning::
12
Hans Wennborg7b852ea2018-01-03 15:49:39 +000013 These are in-progress notes for the upcoming Clang 7 release.
Hans Wennborg189f1f32017-02-09 23:26:34 +000014 Release notes for previous releases can be found on
15 `the Download Page <http://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 Wennborg7b852ea2018-01-03 15:49:39 +000021frontend, part of the LLVM Compiler Infrastructure, release 7.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
25documentation <http://llvm.org/docs/ReleaseNotes.html>`_. All LLVM
26releases may be downloaded from the `LLVM releases web
27site <http://llvm.org/releases/>`_.
28
Hans Wennborgd878ca82017-08-30 18:35:44 +000029For more information about Clang or LLVM, including information about the
30latest release, please see the `Clang Web Site <http://clang.llvm.org>`_ or the
31`LLVM Web Site <http://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
36see the `releases page <http://llvm.org/releases/>`_.
37
Hans Wennborg7b852ea2018-01-03 15:49:39 +000038What's New in Clang 7.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
Roman Lebedevb69ba222018-07-30 18:58:30 +000049- A new Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group
50 was added. Please refer to the :ref:`release-notes-ubsan` section of the
51 release notes for the details.
Rafael Espindola34970692013-12-12 16:07:11 +000052
Sean Silvafe251442012-12-23 01:19:35 +000053Improvements to Clang's diagnostics
54^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55
Roman Lebedevc9977f32018-03-16 18:01:07 +000056- ``-Wc++98-compat-extra-semi`` is a new flag, which was previously inseparable
57 from ``-Wc++98-compat-pedantic``. The latter still controls the new flag.
58
59- ``-Wextra-semi`` now also controls ``-Wc++98-compat-extra-semi``.
60 Please do note that if you pass ``-Wno-c++98-compat-pedantic``, it implies
61 ``-Wno-c++98-compat-extra-semi``, so if you want that diagnostic, you need
62 to explicitly re-enable it (e.g. by appending ``-Wextra-semi``).
Roman Lebedev809df342017-10-26 13:18:14 +000063
Roman Lebedev61061d62018-04-07 10:39:21 +000064- ``-Wself-assign`` and ``-Wself-assign-field`` were extended to diagnose
65 self-assignment operations using overloaded operators (i.e. classes).
66 If you are doing such an assignment intentionally, e.g. in a unit test for
Roman Lebedev6ed0fad2018-04-23 21:35:21 +000067 a data structure, the first warning can be disabled by passing
68 ``-Wno-self-assign-overloaded``, also the warning can be suppressed by adding
69 ``*&`` to the right-hand side or casting it to the appropriate reference type.
Roman Lebedev61061d62018-04-07 10:39:21 +000070
Erich Keaneb0c78092017-07-26 18:04:45 +000071Non-comprehensive list of changes in this release
72-------------------------------------------------
73
Richard Smithbb0ad1e2018-04-03 18:28:13 +000074- Clang binary and libraries have been renamed from 7.0 to 7.
75 For example, the ``clang`` binary will be called ``clang-7``
76 instead of ``clang-7.0``.
Sylvestre Ledrua8b717f2018-03-29 10:05:46 +000077
Richard Smithb6070db2018-04-05 18:55:37 +000078- Clang implements a collection of recent fixes to the C++ standard's definition
79 of "standard-layout". In particular, a class is only considered to be
80 standard-layout if all base classes and the first data member (or bit-field)
81 can be laid out at offset zero.
82
Richard Smith4ae767b2018-04-29 04:55:46 +000083- Clang's handling of the GCC ``packed`` class attribute in C++ has been fixed
84 to apply only to non-static data members and not to base classes. This fixes
85 an ABI difference between Clang and GCC, but creates an ABI difference between
86 Clang 7 and earlier versions. The old behavior can be restored by setting
87 ``-fclang-abi-compat`` to ``6`` or earlier.
88
Richard Smithb5a317f2018-05-07 06:43:30 +000089- Clang implements the proposed resolution of LWG issue 2358, along with the
90 `corresponding change to the Itanium C++ ABI
91 <https://github.com/itanium-cxx-abi/cxx-abi/pull/51>`_, which make classes
92 containing only unnamed non-zero-length bit-fields be considered non-empty.
93 This is an ABI break compared to prior Clang releases, but makes Clang
94 generate code that is ABI-compatible with other compilers. The old
95 behavior can be restored by setting ``-fclang-abi-compat`` to ``6`` or
96 lower.
97
Jonas Devlieghereb48447a2018-05-16 10:23:25 +000098- An existing tool named ``diagtool`` has been added to the release. As the
99 name suggests, it helps with dealing with diagnostics in ``clang``, such as
100 finding out the warning hierarchy, and which of them are enabled by default
101 or for a particular compiler invocation.
102
Peter Collingbourne14b468b2018-07-18 00:27:07 +0000103- By default, Clang emits an address-significance table into
104 every ELF object file when using the integrated assembler.
105 Address-significance tables allow linkers to implement `safe ICF
106 <https://research.google.com/pubs/archive/36912.pdf>`_ without the false
107 positives that can result from other implementation techniques such as
108 relocation scanning. The ``-faddrsig`` and ``-fno-addrsig`` flags can be
109 used to control whether to emit the address-significance table.
110
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000111- ...
Alex Lorenzd8ec4312017-12-14 19:22:02 +0000112
Sean Silvafe251442012-12-23 01:19:35 +0000113New Compiler Flags
114------------------
115
Aaron Ballman00504662018-06-28 12:05:40 +0000116- ``-fstrict-float-cast-overflow`` and ``-fno-strict-float-cast-overflow``.
Eugene Zelenkoad5684a2018-05-15 21:45:01 +0000117
118 When a floating-point value is not representable in a destination integer
119 type, the code has undefined behavior according to the language standard. By
120 default, Clang will not guarantee any particular result in that case. With the
121 'no-strict' option, Clang attempts to match the overflowing behavior of the
122 target's native float-to-int conversion instructions.
Sanjay Patelcee47be2018-04-27 16:21:22 +0000123
Aaron Ballman00504662018-06-28 12:05:40 +0000124- ``-fforce-emit-vtables`` and ``-fno-force-emit-vtables``.
Piotr Padlewskie368de32018-06-13 13:55:42 +0000125
126 In order to improve devirtualization, forces emitting of vtables even in
127 modules where it isn't necessary. It causes more inline virtual functions
128 to be emitted.
129
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000130- ...
Aaron Ballman2b3bc4c2017-10-21 16:45:08 +0000131
Joerg Sonnenbergerc9199682017-07-01 21:36:21 +0000132Deprecated Compiler Flags
133-------------------------
134
135The following options are deprecated and ignored. They will be removed in
136future versions of Clang.
137
Hans Wennborgfbb21e02017-07-19 14:14:07 +0000138- ...
Joerg Sonnenbergerc9199682017-07-01 21:36:21 +0000139
Yuka Takahashiba900ab2018-03-07 11:34:02 +0000140Modified Compiler Flags
141-----------------------
142
Sylvestre Ledrue0b46382018-04-04 09:38:22 +0000143- Before Clang 7, we prepended the `#` character to the `--autocomplete`
Eugene Zelenkod02f3e92018-03-08 01:37:39 +0000144 argument to enable cc1 flags. For example, when the `-cc1` or `-Xclang` flag
145 is in the :program:`clang` invocation, the shell executed
Sylvestre Ledrue0b46382018-04-04 09:38:22 +0000146 `clang --autocomplete=#-<flag to be completed>`. Clang 7 now requires the
Eugene Zelenkod02f3e92018-03-08 01:37:39 +0000147 whole invocation including all flags to be passed to the `--autocomplete` like
148 this: `clang --autocomplete=-cc1,-xc++,-fsyn`.
Yuka Takahashiba900ab2018-03-07 11:34:02 +0000149
Tyler Nowickidb2668a2014-06-18 00:51:32 +0000150New Pragmas in Clang
Eugene Zelenkoad5684a2018-05-15 21:45:01 +0000151--------------------
Tyler Nowickidb2668a2014-06-18 00:51:32 +0000152
Rafael Espindolaaf742502014-08-22 21:59:11 +0000153Clang now supports the ...
Mark Heffernanbd26f5e2014-07-21 18:08:34 +0000154
Paul Robinsonf9ede1c2016-07-18 17:19:12 +0000155
156Attribute Changes in Clang
157--------------------------
158
Erich Keaneace10a22018-01-08 23:36:29 +0000159- Clang now supports function multiversioning with attribute 'target' on ELF
160 based x86/x86-64 environments by using indirect functions. This implementation
161 has a few minor limitations over the GCC implementation for the sake of AST
162 sanity, however it is otherwise compatible with existing code using this
163 feature for GCC. Consult the documentation for the target attribute for more
164 information.
Eugene Zelenkod02f3e92018-03-08 01:37:39 +0000165
Hans Wennborgfbb21e02017-07-19 14:14:07 +0000166- ...
Paul Robinsonf9ede1c2016-07-18 17:19:12 +0000167
Hans Wennborg02dc0002014-08-05 00:21:23 +0000168Windows Support
169---------------
170
Nico Weber1dbff9a2018-07-18 11:55:03 +0000171- clang-cl's support for precompiled headers has been much improved:
172
173 - When using a pch file, clang-cl now no longer redundantly emits inline
174 methods that are already stored in the obj that was built together with
175 the pch file (matching cl.exe). This speeds up builds using pch files
176 by around 30%.
177
Nico Weberf925b332018-07-20 21:06:41 +0000178 - The /Ycfoo.h and /Yufoo.h flags can now be used without /FIfoo.h when
Nico Weber1dbff9a2018-07-18 11:55:03 +0000179 foo.h is instead included by an explicit `#include` directive. This means
180 Visual Studio's default stdafx.h setup now uses precompiled headers with
181 clang-cl.
182
183- ...
Hans Wennborg02dc0002014-08-05 00:21:23 +0000184
185
Renato Golinf2fcddb2013-12-13 09:27:34 +0000186C Language Changes in Clang
187---------------------------
188
Hans Wennborg60d06bf2016-07-18 18:05:19 +0000189- ...
Pirama Arumuga Nainarc85c8532016-06-21 16:09:30 +0000190
Renato Golinf2fcddb2013-12-13 09:27:34 +0000191...
192
Sean Silvafe251442012-12-23 01:19:35 +0000193C11 Feature Support
194^^^^^^^^^^^^^^^^^^^
195
196...
197
198C++ Language Changes in Clang
199-----------------------------
200
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000201- ...
Richard Smith8eb53c82016-05-05 18:40:37 +0000202
203C++1z Feature Support
Sean Silvafe251442012-12-23 01:19:35 +0000204^^^^^^^^^^^^^^^^^^^^^
205
206...
207
208Objective-C Language Changes in Clang
209-------------------------------------
210
211...
212
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
Alexey Bataev44b67502016-05-31 11:17:08 +0000218OpenMP Support in Clang
219----------------------------------
220
Alexey Bataev3bdd6002018-07-26 17:53:45 +0000221- Clang gained basic support for OpenMP 4.5 offloading for NVPTX target.
222 To compile your program for NVPTX target use the following options:
223 `-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda` for 64 bit platforms or
224 `-fopenmp -fopenmp-targets=nvptx-nvidia-cuda` for 32 bit platform.
225
226- Passing options to the OpenMP device offloading toolchain can be done using
227 the `-Xopenmp-target=<triple> -opt=val` flag. In this way the `-opt=val`
228 option will be forwarded to the respective OpenMP device offloading toolchain
229 described by the triple. For example passing the compute capability to
230 the OpenMP NVPTX offloading toolchain can be done as follows:
Alexey Bataevc5982fb2018-07-26 18:40:41 +0000231 `-Xopenmp-target=nvptx64-nvidia-cuda -march=sm_60`. For the case when only one
Alexey Bataev3bdd6002018-07-26 17:53:45 +0000232 target offload toolchain is specified under the `-fopenmp-targets=<triples>`
233 option, then the triple can be skipped: `-Xopenmp-target -march=sm_60`.
234
235- Other bugfixes.
Alexey Bataev44b67502016-05-31 11:17:08 +0000236
Jonas Hahnfeld8da9c2a2018-04-20 13:04:54 +0000237CUDA Support in Clang
238---------------------
239
240- Clang will now try to locate the CUDA installation next to :program:`ptxas`
241 in the `PATH` environment variable. This behavior can be turned off by passing
242 the new flag `--cuda-path-ignore-env`.
243
244- Clang now supports generating object files with relocatable device code. This
245 feature needs to be enabled with `-fcuda-rdc` and my result in performance
246 penalties compared to whole program compilation. Please note that NVIDIA's
247 :program:`nvcc` must be used for linking.
248
Sean Silvafe251442012-12-23 01:19:35 +0000249Internal API Changes
250--------------------
251
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000252These are major API changes that have happened since the 6.0.0 release of
Sean Silvafe251442012-12-23 01:19:35 +0000253Clang. If upgrading an external codebase that uses Clang as a library,
254this section should help get you past the largest hurdles of upgrading.
255
Vedant Kumar5fb00e42016-07-27 23:01:55 +0000256- ...
Richard Smitha0334a92015-05-14 00:22:12 +0000257
Aaron Ballmancdc43af2015-09-17 13:47:22 +0000258AST Matchers
259------------
Aaron Ballmancdc43af2015-09-17 13:47:22 +0000260
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000261- ...
Sylvestre Ledru72e3fa72017-03-14 09:43:55 +0000262
263clang-format
264------------
265
Krasimir Georgievf2ca41d2018-05-08 09:25:12 +0000266- Clang-format will now support detecting and formatting code snippets in raw
267 string literals. This is configured through the `RawStringFormats` style
268 option.
269
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000270- ...
Sylvestre Ledruc9410392017-12-05 09:23:47 +0000271
Ted Kremenek3a2291b2013-04-24 07:33:52 +0000272libclang
273--------
274
Bill Wendling61f44cc2013-06-04 06:17:46 +0000275...
Ted Kremenek3a2291b2013-04-24 07:33:52 +0000276
Sylvestre Ledruea49d3a2016-08-06 20:23:54 +0000277
Anna Zaksb6219a92013-04-25 23:14:38 +0000278Static Analyzer
Ted Kremenek004e8232013-04-26 00:01:34 +0000279---------------
Anna Zaksb6219a92013-04-25 23:14:38 +0000280
Hans Wennborg7b852ea2018-01-03 15:49:39 +0000281- ...
Roman Lebedev88b56ca2017-11-30 09:18:35 +0000282
Bill Wendling0a794a4b2013-11-20 10:13:37 +0000283...
Ted Kremenek004e8232013-04-26 00:01:34 +0000284
Roman Lebedevb69ba222018-07-30 18:58:30 +0000285.. _release-notes-ubsan:
286
Vedant Kumar840c2c72017-06-13 02:52:31 +0000287Undefined Behavior Sanitizer (UBSan)
288------------------------------------
289
Roman Lebedevb69ba222018-07-30 18:58:30 +0000290* A new Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) group
291 was added.
292
293 Currently, only one type of issues is caught - implicit integer truncation
294 (``-fsanitize=implicit-integer-truncation``), also known as integer demotion.
295 While there is a ``-Wconversion`` diagnostic group that catches this kind of
296 issues, it is both noisy, and does not catch **all** the cases.
297
298 .. code-block:: c++
299
300 unsigned char store = 0;
301
302 bool consume(unsigned int val);
303
304 void test(unsigned long val) {
305 if (consume(val)) // the value may have been silently truncated.
306 store = store + 768; // before addition, 'store' was promoted to int.
307 (void)consume((unsigned int)val); // OK, the truncation is explicit.
308 }
309
310 Just like other ``-fsanitize=integer`` checks, these issues are **not**
311 undefined behaviour. But they are not *always* intentional, and are somewhat
312 hard to track down. This group is **not** enabled by ``-fsanitize=undefined``,
313 but the ``-fsanitize=implicit-integer-truncation`` check
314 is enabled by ``-fsanitize=integer``.
Vedant Kumar840c2c72017-06-13 02:52:31 +0000315
Ted Kremenek004e8232013-04-26 00:01:34 +0000316Core Analysis Improvements
317==========================
318
Bill Wendling61f44cc2013-06-04 06:17:46 +0000319- ...
Ted Kremenek004e8232013-04-26 00:01:34 +0000320
321New Issues Found
322================
323
Bill Wendling61f44cc2013-06-04 06:17:46 +0000324- ...
Anna Zaksb6219a92013-04-25 23:14:38 +0000325
Sean Silvafe251442012-12-23 01:19:35 +0000326Python Binding Changes
327----------------------
328
329The following methods have been added:
330
331- ...
332
333Significant Known Problems
334==========================
335
336Additional Information
337======================
338
339A wide variety of additional information is available on the `Clang web
340page <http://clang.llvm.org/>`_. The web page contains versions of the
341API documentation which are up-to-date with the Subversion version of
342the source code. You can access versions of these documents specific to
343this release by going into the "``clang/docs/``" directory in the Clang
344tree.
345
346If you have any questions or comments about Clang, please feel free to
347contact us via the `mailing
Tanya Lattner4a08e932015-08-05 03:55:23 +0000348list <http://lists.llvm.org/mailman/listinfo/cfe-dev>`_.