blob: d6b128f7321c631eeecae03de59e51219910e851 [file] [log] [blame]
Sean Silva28c1f752013-01-02 22:05:33 +00001=====================================
Bill Wendlinga03209e2013-06-04 06:17:46 +00002Clang 3.4 (In-Progress) Release Notes
Sean Silva28c1f752013-01-02 22:05:33 +00003=====================================
Sean Silvadebc0182012-12-23 01:19:35 +00004
5.. contents::
6 :local:
7 :depth: 2
8
Sean Silvadebc0182012-12-23 01:19:35 +00009Introduction
10============
11
12This document contains the release notes for the Clang C/C++/Objective-C
Bill Wendlinga03209e2013-06-04 06:17:46 +000013frontend, part of the LLVM Compiler Infrastructure, release 3.4. Here we
Sean Silvadebc0182012-12-23 01:19:35 +000014describe the status of Clang in some detail, including major
15improvements from the previous release and new feature work. For the
16general LLVM release notes, see `the LLVM
17documentation <http://llvm.org/docs/ReleaseNotes.html>`_. All LLVM
18releases may be downloaded from the `LLVM releases web
19site <http://llvm.org/releases/>`_.
20
21For more information about Clang or LLVM, including information about
22the latest release, please check out the main please see the `Clang Web
23Site <http://clang.llvm.org>`_ or the `LLVM Web
24Site <http://llvm.org>`_.
25
26Note that if you are reading this file from a Subversion checkout or the
27main Clang web page, this document applies to the *next* release, not
28the current one. To see the release notes for a specific release, please
29see the `releases page <http://llvm.org/releases/>`_.
30
Bill Wendlinga03209e2013-06-04 06:17:46 +000031What's New in Clang 3.4?
Sean Silvadebc0182012-12-23 01:19:35 +000032========================
33
34Some of the major new features and improvements to Clang are listed
35here. Generic improvements to Clang as a whole or to its underlying
36infrastructure are described first, followed by language-specific
37sections with improvements to Clang's support for those languages.
38
Chandler Carruthfe1088d2013-11-07 00:26:32 +000039Last release which will build as C++98
40--------------------------------------
41
42This is expected to be the last release of Clang which compiles using a C++98
43toolchain. We expect to start using some C++11 features in Clang starting after
44this release. That said, we are committed to supporting a reasonable set of
45modern C++ toolchains as the host compiler on all of the platforms. This will
46at least include Visual Studio 2012 on Windows, and Clang 3.1 or GCC 4.7.x on
47Mac and Linux. The final set of compilers (and the C++11 features they support)
48is not set in stone, but we wanted users of Clang to have a heads up that the
49next release will involve a substantial change in the host toolchain
50requirements.
51
52Note that this change is part of a change for the entire LLVM project, not just
53Clang.
54
Sean Silvadebc0182012-12-23 01:19:35 +000055Major New Features
56------------------
57
58Improvements to Clang's diagnostics
59^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60
61Clang's diagnostics are constantly being improved to catch more issues,
62explain them more clearly, and provide more accurate source information
Bill Wendlinga03209e2013-06-04 06:17:46 +000063about them. The improvements since the 3.3 release include:
Sean Silvadebc0182012-12-23 01:19:35 +000064
Richard Trieu06907e12013-12-03 01:35:18 +000065- -Wheader-guard warns on mismatches between the #ifndef and #define lines
66 in a header guard.
67- -Wlogical-not-parentheses warns when a logical not ('!') only applies to the
68 left-hand side of a comparison. This warning is part of -Wparentheses.
69- Boolean increment, a deprecated feature, has own warning flag
70 -Wdeprecated-increment-bool, and is still part of -Wdeprecated.
71- Clang errors on builtin enum increments and decrements.
Sylvestre Ledruaa7fc192013-12-13 11:30:23 +000072- -Wloop-analysis now warns on for-loops which have the same increment or
Richard Trieu06907e12013-12-03 01:35:18 +000073 decrement in the loop header as the last statement in the loop.
74- -Wuninitialized now performs checking across field initializers to detect
75 when one field in used uninitialized in another field initialization.
76- Clang can detect initializer list use inside a macro and suggest parentheses
77 if possible to fix.
Kaelyn Uhrainb4ec8b12013-12-04 02:25:41 +000078- Many improvements to Clang's typo correction facilities, such as:
Richard Smithf1a28372013-12-12 02:26:06 +000079
Kaelyn Uhrainb4ec8b12013-12-04 02:25:41 +000080 + Adding global namespace qualifiers so that corrections can refer to shadowed
81 or otherwise ambiguous or unreachable namespaces.
82 + Including accessible class members in the set of typo correction candidates,
83 so that corrections requiring a class name in the name specifier are now
84 possible.
85 + Allowing typo corrections that involve removing a name specifier.
86 + In some situations, correcting function names when a function was given the
87 wrong number of arguments, including situations where the original function
88 name was correct but was shadowed by a lexically closer function with the
89 same name yet took a different number of arguments.
90 + Offering typo suggestions for 'using' declarations.
91 + Providing better diagnostics and fixit suggestions in more situations when
92 a '->' was used instead of '.' or vice versa.
93 + Providing more relevant suggestions for typos followed by '.' or '='.
94 + Various performance improvements when searching for typo correction
95 candidates.
Sean Silvadebc0182012-12-23 01:19:35 +000096
Sean Silvadebc0182012-12-23 01:19:35 +000097New Compiler Flags
98------------------
99
Rafael Espindola3b0f62b2013-08-23 21:49:00 +0000100- Clang no longer special cases -O4 to enable lto. Explicitly pass -flto to
101 enable it.
Richard Smith22540da2013-12-12 02:20:54 +0000102- Clang no longer fails on >= -O5. These flags are mapped to -O3 instead.
Sylvestre Ledru762e5672013-11-18 13:23:07 +0000103- Command line "clang -O3 -flto a.c -c" and "clang -emit-llvm a.c -c"
Shuxin Yang8b498542013-08-23 22:01:03 +0000104 are no longer equivalent.
Rafael Espindola3dd4dd62013-10-16 16:32:17 +0000105- Clang now errors on unknown -m flags (``-munknown-to-clang``),
106 unknown -f flags (``-funknown-to-clang``) and unknown
107 options (``-what-is-this``).
Sean Silvadebc0182012-12-23 01:19:35 +0000108
109C Language Changes in Clang
110---------------------------
111
Michael Gottesman98d1ec12013-06-20 23:28:10 +0000112- Added new checked arithmetic builtins for security critical applications.
113
Sean Silvadebc0182012-12-23 01:19:35 +0000114C11 Feature Support
115^^^^^^^^^^^^^^^^^^^
116
117...
118
119C++ Language Changes in Clang
120-----------------------------
121
Eli Friedman65400522013-07-20 01:06:31 +0000122- Fixed an ABI regression, introduced in Clang 3.2, which affected
123 member offsets for classes inheriting from certain classes with tail padding.
124 See PR16537.
125
Richard Smith22540da2013-12-12 02:20:54 +0000126- Clang 3.4 supports the 2013-08-28 draft of the ISO WG21 SG10 feature test
127 macro recommendations. These aim to provide a portable method to determine
128 whether a compiler supports a language feature, much like Clang's
Richard Smithf1a28372013-12-12 02:26:06 +0000129 |has_feature macro|_.
Rafael Espindola40db5152013-04-09 12:51:24 +0000130
Richard Smithf1a28372013-12-12 02:26:06 +0000131.. |has_feature macro| replace:: ``__has_feature`` macro
132.. _has_feature macro: LanguageExtensions.html#has-feature-and-has-extension
Richard Smith22540da2013-12-12 02:20:54 +0000133
134C++1y Feature Support
Sean Silvadebc0182012-12-23 01:19:35 +0000135^^^^^^^^^^^^^^^^^^^^^
136
Richard Smith22540da2013-12-12 02:20:54 +0000137Clang 3.4 supports all the features in the current working draft of the
138upcoming C++ standard, provisionally named C++1y. Support for the following
139major new features has been added since Clang 3.3:
140
141- Generic lambdas and initialized lambda captures.
142- Deduced function return types (``auto f() { return 0; }``).
143- Generalized ``constexpr`` support (variable mutation and loops).
144- Variable templates and static data member templates.
145- Use of ``'`` as a digit separator in numeric literals.
146- Support for sized ``::operator delete`` functions.
147
148In addition, ``[[deprecated]]`` is now accepted as a synonym for Clang's
149existing ``deprecated`` attribute.
150
151Use ``-std=c++1y`` to enable C++1y mode.
Sean Silvadebc0182012-12-23 01:19:35 +0000152
153Objective-C Language Changes in Clang
154-------------------------------------
155
156...
157
Erik Schnettera87219b2013-11-11 06:36:33 +0000158OpenCL C Language Changes in Clang
159----------------------------------
160
161- OpenCL C "long" now always has a size of 64 bit, and all OpenCL C
162 types are aligned as specified in the OpenCL C standard. Also,
163 "char" is now always signed.
164
Sean Silvadebc0182012-12-23 01:19:35 +0000165Internal API Changes
166--------------------
167
Bill Wendlinga03209e2013-06-04 06:17:46 +0000168These are major API changes that have happened since the 3.3 release of
Sean Silvadebc0182012-12-23 01:19:35 +0000169Clang. If upgrading an external codebase that uses Clang as a library,
170this section should help get you past the largest hurdles of upgrading.
171
Hans Wennborg0437e0d2013-05-20 14:53:06 +0000172Wide Character Types
173^^^^^^^^^^^^^^^^^^^^
174
175The ASTContext class now keeps track of two different types for wide character
176types: WCharTy and WideCharTy. WCharTy represents the built-in wchar_t type
177available in C++. WideCharTy is the type used for wide character literals; in
178C++ it is the same as WCharTy, but in C99, where wchar_t is a typedef, it is an
179integer type.
180
Sean Silvadebc0182012-12-23 01:19:35 +0000181...
182
Ted Kremenek230fc372013-04-24 07:33:52 +0000183libclang
184--------
185
Bill Wendlinga03209e2013-06-04 06:17:46 +0000186...
Ted Kremenek230fc372013-04-24 07:33:52 +0000187
Anna Zaks08741a02013-04-25 23:14:38 +0000188Static Analyzer
Ted Kremenek1377a462013-04-26 00:01:34 +0000189---------------
Anna Zaks08741a02013-04-25 23:14:38 +0000190
Ted Kremenek1377a462013-04-26 00:01:34 +0000191The static analyzer (which contains additional code checking beyond compiler
Sylvestre Ledruaa7fc192013-12-13 11:30:23 +0000192warnings) has improved significantly in both in the core analysis engine and
Ted Kremenek1377a462013-04-26 00:01:34 +0000193also in the kinds of issues it can find.
194
Sylvestre Ledruaa7fc192013-12-13 11:30:23 +0000195For example, the static analyzer now manages the following cases:
196
197- Missing return after function pointer null check.
198
199.. code-block:: c
200
201 void foo(void (*f)(void)) {
202 if (f)
203 return;
204 f();
205 }
206
207- Detect when ``delete`` is used on an uninitialized variable.
208
209.. code-block:: c++
210
211 void foo() {
212 int *x;
213 delete[] x;
214 }
215
216- Handle destructors for the argument to C++ ``delete``.
217
218.. code-block:: c++
219
220 class DerefClass{
221 public:
222 int *x;
223 DerefClass() {}
224 ~DerefClass() {*x = 1;}
225 };
226
227 void testDoubleDeleteClassInstance() {
228 DerefClass *foo = new DerefClass();
229 delete foo;
230 delete foo;
231 }
232
233
Daniel Jasper87ddfdd2013-12-11 14:41:33 +0000234Clang Format
235------------
236
237Clang now includes a new tool ``clang-format`` which can be used to
238automatically format C, C++ and Objective-C source code. ``clang-format``
239automatically chooses linebreaks and indentation and can be easily integrated
240into editors, IDEs and version control systems. It supports several pre-defined
241styles as well as precise style control using a multitude of formatting
242options. ``clang-format`` itself is just a thin wrapper around a library which
243can also be used directly from code refactoring and code translation tools.
244More information can be found on `Clang Format's
245site <http://clang.llvm.org/docs/ClangFormat.html>`_.
246
Hans Wennborga6c18502013-12-02 22:38:55 +0000247Windows Support
248---------------
249
Richard Smith94aaee22013-12-12 02:30:46 +0000250- `clang-cl <UsersManual.html#clang-cl>`_ provides a new driver mode that is
Hans Wennborga6c18502013-12-02 22:38:55 +0000251 designed for compatibility with Visual Studio's compiler, cl.exe. This driver
Hans Wennborg70cb8382013-12-09 20:00:25 +0000252 mode makes Clang accept the same kind of command-line options as cl.exe. The
253 installer will attempt to expose clang-cl in any Visual Studio installations
254 on the system as a Platform Toolset, e.g. "LLVM-vs2012". clang-cl targets the
255 Microsoft ABI by default. Please note that this driver mode and compatibility
256 with the MS ABI is highly experimental.
Hans Wennborga6c18502013-12-02 22:38:55 +0000257
Ted Kremenek1377a462013-04-26 00:01:34 +0000258Core Analysis Improvements
259==========================
260
Bill Wendlinga03209e2013-06-04 06:17:46 +0000261- ...
Ted Kremenek1377a462013-04-26 00:01:34 +0000262
263New Issues Found
264================
265
Bill Wendlinga03209e2013-06-04 06:17:46 +0000266- ...
Anna Zaks08741a02013-04-25 23:14:38 +0000267
Sean Silvadebc0182012-12-23 01:19:35 +0000268Python Binding Changes
269----------------------
270
271The following methods have been added:
272
273- ...
274
275Significant Known Problems
276==========================
277
278Additional Information
279======================
280
281A wide variety of additional information is available on the `Clang web
282page <http://clang.llvm.org/>`_. The web page contains versions of the
283API documentation which are up-to-date with the Subversion version of
284the source code. You can access versions of these documents specific to
285this release by going into the "``clang/docs/``" directory in the Clang
286tree.
287
288If you have any questions or comments about Clang, please feel free to
289contact us via the `mailing
290list <http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev>`_.