blob: bd717b842272084ed9eeaf387aed6b05c5e8a80e [file] [log] [blame]
Benjamin Kramer665a8dc2012-01-15 15:26:07 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
Chandler Carruthc00c0c32011-11-28 07:16:19 +00003<html>
4<head>
5<title>Clang 3.0 Release Notes</title>
Benjamin Kramer665a8dc2012-01-15 15:26:07 +00006<link type="text/css" rel="stylesheet" href="../menu.css">
7<link type="text/css" rel="stylesheet" href="../content.css">
Chandler Carruthc00c0c32011-11-28 07:16:19 +00008<style type="text/css">
9td {
10 vertical-align: top;
11}
12</style>
13</head>
14<body>
15
16<!--#include virtual="../menu.html.incl"-->
17
18<div id="content">
19
20<h1>Clang 3.0 Release Notes</h1>
21
Benjamin Kramer665a8dc2012-01-15 15:26:07 +000022<img style="float:right" src="http://llvm.org/img/DragonSmall.png"
Chandler Carruthc00c0c32011-11-28 07:16:19 +000023 width="136" height="136" alt="LLVM Dragon Logo">
24
25<ul>
26 <li><a href="#intro">Introduction</a></li>
27 <li><a href="#whatsnew">What's New in Clang 3.0?</a>
28 <ul>
29 <li><a href="#majorfeatures">Major New Features</a></li>
30 <li><a href="#cchanges">C Language Changes</a></li>
31 <li><a href="#cxxhanges">C++ Language Changes</a></li>
32 <li><a href="#objchanges">Objective-C Language Changes</a></li>
33 <li><a href="#apichanges">Internal API Changes</a></li>
Richard Smith855746b2011-11-28 20:02:05 +000034 </ul>
Chandler Carruthc00c0c32011-11-28 07:16:19 +000035 </li>
36 <li><a href="#knownproblems">Known Problems</a></li>
37 <li><a href="#additionalinfo">Additional Information</a></li>
38</ul>
39
40<div class="doc_author">
41 <p>Written by the <a href="http://llvm.org/">LLVM Team</a></p>
42</div>
43
44<!--
45<h1 style="color:red">These are in-progress notes for the upcoming LLVM 3.0
46release.<br>
47You may prefer the
48<a href="http://llvm.org/releases/2.9/docs/ReleaseNotes.html">LLVM 2.9
49Release Notes</a>.</h1>
50 -->
51
52<!-- ======================================================================= -->
53<h2 id="intro">Introduction</h2>
54<!-- ======================================================================= -->
55
56<p>This document contains the release notes for the Clang C/C++/Objective-C
57frontend, part of the LLVM Compiler Infrastructure, release 3.0. Here we
58describe the status of Clang in some detail, including major improvements from
59the previous release and new feature work. For the general LLVM release notes,
Peter Collingbourne5cc989e2011-11-29 02:03:03 +000060see <a href="http://llvm.org/docs/ReleaseNotes.html">the LLVM
Chandler Carruthc00c0c32011-11-28 07:16:19 +000061 documentation</a>. All LLVM releases may be downloaded from the
62<a href="http://llvm.org/releases/">LLVM releases web site</a>.</p>
63
64<p>For more information about Clang or LLVM, including information about the
65latest release, please check out the main please see the
66<a href="http://clang.llvm.org">Clang Web Site</a> or the
67<a href="http://llvm.org">LLVM Web Site</a>.
68
69<p>Note that if you are reading this file from a Subversion checkout or the main
70Clang web page, this document applies to the <i>next</i> release, not the
71current one. To see the release notes for a specific release, please see the
72<a href="http://llvm.org/releases/">releases page</a>.</p>
73
74<!-- ======================================================================= -->
75<h2 id="whatsnew">What's New in Clang 3.0?</h2>
76<!-- ======================================================================= -->
77
78<p>Some of the major new features and improvements to Clang are listed here.
79Generic improvements to Clang as a whole or two its underlying infrastructure
80are described first, followed by language-specific sections with improvements to
81Clang's support for those languages.</p>
82
83<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
84<h3 id="majorfeatures">Major New Features</h3>
85<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
86
Chandler Carruth58f2cbc2011-11-28 22:34:59 +000087<h4 id="diagnostics">A multitude of improvements to Clang's diagnostics</h4>
88Clang's diagnostics are constantly being improved to catch more issues, explain
89them more clearly, and provide more accurate source information about them.
90A few improvements since the 2.9 release that have a particularly high impact:
91<ul>
92 <li>Substantially shorter messages due to better recovery, fewer include
93 stacks, and tuning verbose features such as 'a.k.a.' type printing.</li>
94 <li>
Chandler Carruthee77d3d2011-11-29 00:24:20 +000095 Able to recover and correct from misspelled type names at the beging of
96 statements. For example, Clang now emits:
97<pre><b>t.c:6:3: <span class="error">error:</span> use of undeclared identifier 'integer'; did you mean 'Integer'?</b>
Chandler Carruth58f2cbc2011-11-28 22:34:59 +000098 integer *i = 0;
Richard Smithad5459a2011-11-28 23:16:15 +000099 <span class="caret">^~~~~~~</span>
Chandler Carruth58f2cbc2011-11-28 22:34:59 +0000100 Integer
Richard Smithad5459a2011-11-28 23:16:15 +0000101<b>t.c:1:13: note:</b> 'Integer' declared here
Chandler Carruth58f2cbc2011-11-28 22:34:59 +0000102typedef int Integer;
Richard Smithad5459a2011-11-28 23:16:15 +0000103 <span class="caret">^</span></pre>
Chandler Carruth58f2cbc2011-11-28 22:34:59 +0000104 </li>
105 <li>Expanded typo correction to (among other improvements) look across
106 namespaces and suggest namespace qualifiers in addition to misspellings of the
107 identifier itself.</li>
108 <li>More rich macro expansion backtraces and some (limited) fix-it hints when
109 diagnostics stem from macro arguments.</li>
Chandler Carruth2f376852011-11-28 22:54:33 +0000110 <li>Many new warnings have been added to catch common, bug-prone code
111 patterns.</li>
112 <li>Uninitialized values Clang warning was rewritten to be more accurate,
113 faster, and able to differentiate between the <em>possibility</em> of an
114 uninitialized use and the <em>certainty</em> of an uninitialized use.</li>
Chandler Carruth58f2cbc2011-11-28 22:34:59 +0000115</ul>
116
Chandler Carruth9a167122011-11-28 22:43:32 +0000117<h4 id="libclang">This release saw significant improvements to <code>libclang</code></h4>
118<ul>
119 <li>A broader set of the <code>libclang</code> API is exposed in the Python
120 bindings.</li>
121 <li>Much more of the Clang AST is exposed through <code>libclang</code>'s APIs
122 and cursors.</li>
123 <li>Cursors can now walk more effectively through macros, especially arguments
124 to function-style macros, and resolve to the underlying AST.</li>
125 <li>Improved code completion surrounding macros, macro arguments, and
126 token pasting.</li>
127 <li>Improved code completion for in-class member functions.</li>
128 <li>Crash recovery for <code>libclang</code> clients.</li>
129 <!-- Doug or Ted may want to flesh this out if there are relevant details I'm
130 glossing over... -->
131</ul>
132
Chandler Carruthb882a1d2011-11-28 21:56:30 +0000133<h4 id="driver">The Clang GCC-compatible command-line driver improved dramatically</h4>
134A great deal of work went into the GCC-compatible driver for the 3.0 release
135making it support more operating systems, emulate GCC behavior more accurately,
136and support a much broader range of Linux distributions out of the box.
137<ul>
138 <li>More accurate support for hardware architecture pre-defined macros (e.g.,
139 __i686__).</li>
140 <li>Robust library and header search paths for the vast majority of x86 and
141 x86-64 Linux distributions.</li>
142 <li>Improved support for newer Darwin platforms.</li>
143 <li>Partial support for <code>--sysroot=...</code> based cross-compiling on
144 Linux (and similar) host systems.</li>
145 <li>Improved support for locating and using libcxx when installed, especially
146 on Darwin.</li>
147 <!-- There are likely more Darwin-specific improvements to mention here? -->
148 <!-- What support was added for FreeBSD? NetBSD? Anything noteworthy? -->
Chandler Carruth2f376852011-11-28 22:54:33 +0000149 <li>Automatic detection of Clang crashes in the driver and preparation of
150 reproduction steps for filing bug reports.</li><!-- Chad, feel free to add
151 more details here. -->
Chandler Carruthb882a1d2011-11-28 21:56:30 +0000152</ul>
153
Chandler Carruthc6f2af32011-11-28 19:17:25 +0000154<h4 id="ppcallbacks">Expanded support for instrumenting the preprocessor through
155 callbacks</h4>
Chandler Carruthf16d7252011-11-28 21:47:51 +0000156Several enhancements were made to the <code>PPCallbacks</code> interface to
157expand the information available to tools and library users of Clang that wish
158to introspect the preprocessing.
Chandler Carruthc6f2af32011-11-28 19:17:25 +0000159<ul>
160 <li>The exact text used between the <code>""</code>s or <code>&lt;&gt;</code>s is reported.</li>
161 <li>The header search path used to locate the header is reported.</li>
162 <li>Missing files during including headers reported.</li>
163 <li>The exact source range for expanded macros can be retrieved.</li>
164</ul>
165
Chandler Carruth185e9302011-11-28 23:11:27 +0000166<h4 id="windows">Clang is building and tested regularly on Windows and can
167 compile limited subsets of code on Windows</h4>
168Clang is regularly built and tested on a variety of Windows platforms including
169MinGW 32-bit and 64-bit, Cygwin, and natively with MSVC. In addition, Clang can
170be used as a compiler in a few Windows contexts.
171<ul>
172 <li>Normal compilation supported for the MinGW target platform, in both 32-bit
173 and 64-bit, and the Cygwin target platform.</li>
174 <li>Parsing and AST support for Windows Structured Exception Handling.</li>
Francois Pichet551988f2011-11-28 23:30:46 +0000175 <li>New -fms-compatibility flag to handle MSVC constructs that could change
176 the meaning of an otherwise well formed program</li>
177 <li>clang can now parse all the MSVC 2010 standard C++ header files
178 in the nominal case, (still need to specifiy -nobuiltininc for some headers).</li>
179 <li>Improved support for MFC code parsing, (still a work in progress).</li>
Francois Pichet0c2198a2011-11-28 23:46:15 +0000180 <li>Add support for function template specialization at class scope (-fms-extensions mode).</li>
181 <li>Add support for Microsoft __if_exists/__if_not_exists statements (-fms-extensions mode).</li>
Chandler Carruth185e9302011-11-28 23:11:27 +0000182</ul>
183
Chandler Carruth45901b32011-11-29 00:15:26 +0000184<h4 id="availability">New availability attribute to detect and warn about API
185usage across OS X and iOS versions</h4>
186Clang now supports an attribute which documents the availability of an API
187across various platforms and releases, allowing interfaces to include
188information about what OS versions support the relevant features. Based on the
189targeted version of a compile, warnings for deprecated and unavailable
190interfaces will automatically be provided by Clang.
191
192<h4 id="threadsafety">Thread Safety annotations and analysis-based warnings</h4>
193A set of annotations were introduced to Clang to describe the various
194thread-safety concerns of a program, and an accompanying set of analysis based
195warnings will diagnose clearly unsafe code patterns. The annotations are
196described in the
197<a href="http://clang.llvm.org/docs/LanguageExtensions.html#threadsafety">extension specification</a>,
198and the warnings currently supported include:
199<ul>
200 <li>Calling functions without the required locks</li>
201 <li>Reading variables without the required locks</li>
202 <li>Writing to variables without an exclusive lock (even if holding a shared
203 lock)</li>
204 <li>Imbalance between locks and unlocks across loop entries and exits</li>
205 <li>Acquiring or releasing locks out of order</li>
206</ul>
207
208<h4 id="incompleteast">Improved support for partially constructed and/or
209incomplete ASTs</h4>
210For users such as LLDB that are dynamically forming C++ ASTs, sometimes it is
211either necessary or useful to form a partial or incomplete AST. Support for
212these use cases have improved through the introduction of "unknown" types and
213other AST constructs designed specifically for use cases without complete
214information about the C++ construct being formed.
215
Peter Collingbourne375f7c42011-11-29 02:03:07 +0000216<h4 id="opencl">Initial work to support compiling OpenCL C with Clang</h4>
217<p>Clang has some (limited) support for compiling OpenCL C. The 3.0
218release adds support for the <tt>vec_step</tt> operator, address space
219qualifiers (<tt>__private</tt>, <tt>__global</tt>, <tt>__local</tt> and
220<tt>__constant</tt>), improved vector literal support and code generation
221support for the <a href="http://llvm.org/docs/ReleaseNotes.html#PTX">PTX
222target</a>.</p>
Chandler Carrutha0df07d2011-11-28 22:17:58 +0000223
Peter Collingbourne375f7c42011-11-29 02:03:07 +0000224<p>Using the <a href="http://www.pcc.me.uk/~peter/libclc/">libclc library</a>
225to supply OpenCL C built-ins, you can use Clang to compile OpenCL C code
226into PTX and execute it by loading the resulting PTX as a binary blob using
227the nVidia OpenCL library. It has been tested with several OpenCL programs,
228including some from the nVidia GPU Computing SDK, and the performance is on
229par with the nVidia compiler.</p>
Chandler Carrutha0df07d2011-11-28 22:17:58 +0000230
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000231<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
232<h3 id="cchanges">C Language Changes in Clang</h3>
233<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
234
Richard Smith62d730f2011-11-28 22:48:25 +0000235<h4 id="c1xchanges">C1X Feature Support</h4>
236
237<p>Clang 3.0 adds support for the
238<a href="http://clang.llvm.org/docs/LanguageExtensions.html#c1x">
239<code>_Alignas</code>, <code>_Generic</code>, and <code>_Static_assert</code>
240keywords</a>, drafted for inclusion in the next C standard, which is
241provisionally known as C1X. Use <code>-std=c1x</code> or <code>-std=gnu1x</code>
242to enable support for the new language standard. These features are
243backwards-compatible and are available as an extension in all language
244modes.</p>
245
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000246<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
247<h3 id="cxxchanges">C++ Language Changes in Clang</h3>
248<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
249
Richard Smith855746b2011-11-28 20:02:05 +0000250<h4 id="cxx11changes">C++11 Feature Support</h4>
Richard Smith855746b2011-11-28 20:02:05 +0000251<p>Clang 3.0 adds support for
252<a href="http://clang.llvm.org/cxx_status.html#cxx11">more of the language
Richard Smith47931382011-11-28 23:35:03 +0000253features</a> added in the latest ISO C++ standard,
254<a href="http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=50372">C++ 2011</a>.
255Use <code>-std=c++11</code> or <code>-std=gnu++11</code> to enable support for
256these features. The following are now considered to be of production quality:
Richard Smith855746b2011-11-28 20:02:05 +0000257<ul>
Chandler Carruthf16d7252011-11-28 21:47:51 +0000258 <li>Range-based <code>for</code> loops</li>
259 <li>Alias declarations (a new syntax for <code>typedef</code> declarations),
260 including their <code>template</code> forms</li>
Richard Smith855746b2011-11-28 20:02:05 +0000261 <li>Specifying default values for class data members within a class
262 definition</li>
263 <li>Constructors delegating to other constructors of the same class</li>
Chandler Carruthf16d7252011-11-28 21:47:51 +0000264 <li>The <code>override</code> context-sensitive keyword for virtual member
Richard Smith855746b2011-11-28 20:02:05 +0000265 function declarations</li>
Chandler Carruthf16d7252011-11-28 21:47:51 +0000266 <li>Explicitly generating default function definitions with
267 <code>= default</code></li>
268 <li>The <code>nullptr</code> keyword, and the corresponding type</li>
Richard Smith855746b2011-11-28 20:02:05 +0000269 <li>Raw string literals with arbitary delimiters (for instance,
Chandler Carruthf16d7252011-11-28 21:47:51 +0000270 <code>R"delim(str"ing)delim"</code>)</li>
271 <li>Unicode string literals (for instance, <code>U"\u1234"</code>) and the
272 <code>char16_t</code> and <code>char32_t</code> built-in types
273 <li><code>noexcept</code> expressions and the <code>noexcept</code> specifier
274 on function declarations</li>
275 <li><code>alignof</code> expressions and the <code>alignas</code> specifier on
Richard Smith855746b2011-11-28 20:02:05 +0000276 variable declarations</li>
277 <li>A full set of <a href="http://clang.llvm.org/docs/LanguageExtensions.html#checking_type_traits">type traits</a>,
278 sufficient to support C++11 standard libraries</li>
279</ul>
Chandler Carruthbc02a042011-11-28 21:55:34 +0000280All warning and language selection flags which previously accepted
281<code>c++0x</code> now accept <code>c++11</code>. The old <code>c++0x</code>
282form remains as an alias.
Richard Smith855746b2011-11-28 20:02:05 +0000283
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000284<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
285<h3 id="objcchanges">Objective-C Language Changes in Clang</h3>
286<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
Chandler Carruth4d582122011-11-29 00:15:23 +0000287Clang 3.0 introduces several new Objective-C language features and improvements.
288
289<h4 id="objc_arc">Objective-C Automatic Reference Counting</h4>
290<!-- This is really just a stub for John to flesh out regarding ARC. -->
291ARC provides automated memory management for Objective-C programs that is
292compatible with existing retain/release code. ARC is carefully built to
293be a reliable programming model that errs on the side of producing a
294compiler error instead of silently producing a runtime memory problem.
295ARC automates Objective-C objects, not malloc data, file descriptors,
296CoreFoundation datatypes or anything else. For more details, see the
297<a href="http://clang.llvm.org/docs/AutomaticReferenceCounting.html">full specification</a>.
298
299<h4 id="objc_instancetype">Objective-C Related Result Types / Instance
300Types</h4>
301Allows declaring new methods which follow the Cocoa conventions for methods
302such as <code>init</code> which always return objects that are an instance of
303the receiving class's type. For more details, see the
304<a href="http://clang.llvm.org/docs/LanguageExtensions.html#objc_instancetype">language extension documentation</a>.
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000305
Chandler Carruth52e375e2011-11-29 00:15:25 +0000306<!--
307This is a stub for David Chisnall to fill out.
308
309<h4 id="objc_gnuruntime">Improved support for the GNU Runtime</h4>
310....
311-->
312
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000313<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
314<h3 id="apichanges">Internal API Changes</h3>
315<!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
316
Chandler Carruthc4dbffa2011-11-28 18:55:47 +0000317These are major API changes that have happened since the 2.9 release of Clang.
318If upgrading an external codebase that uses Clang as a library, this section
319should help get you past the largest hurdles of upgrading.
320
Chandler Carruth7d727b72011-11-28 19:06:34 +0000321<h4 id="macroexpansion">Switched terminology from "instantiation" to "expansion"
322 for macros</h4>
323A great deal of comments and code changes fell out of this, but also every API
324relating to macros with the word "instantiation" (or some variant thereof) was
325renamed. An incomplete list of the most note-worthy ones is here:
326<ul>
327 <li><code>MacroInstantiation</code> became <code>MacroExpansion</code></li>
328 <li><code>SourceManager::getInstantiationLoc</code> became
329 <code>SourceManager::getExpansionLoc</code></li>
330 <li><code>SourceManager::getInstantiationRange</code> became
331 <code>SourceManager::getExpansionRange</code></li>
332 <li><code>SourceManager::getImmediateInstantiationRange</code> became
333 <code>SourceManager::getImmediateExpansionRange</code></li>
334 <li><code>SourceManager::getDecomposedInstantiationLoc</code> became
335 <code>SourceManager::getDecomposedExpansionLoc</code></li>
336 <li><code>SourceManager::getInstantiationColumnNumber</code> became
337 <code>SourceManager::getExpansionColumnNumber</code></li>
338 <li><code>SourceManager::getInstantiationLineNumber</code> became
339 <code>SourceManager::getExpansionLineNumber</code></li>
340 <!-- TODO: Make this more complete! -->
341</ul>
342
Chandler Carruthc4dbffa2011-11-28 18:55:47 +0000343<h4 id="diagnosticrename">Diagnostic class names were shuffled</h4>
344<ul>
345 <li><code>Diagnostic</code> became <code>DiagnosticEngine</code></li>
346 <li><code>DiagnosticClient</code> became <code>DiagnosticConsumer</code></li>
347 <li><code>DiagnosticInfo</code> became <code>Diagnostic</code></li>
348</ul>
349Subclasses of <code>DiagnosticConsumer</code> were also then renamed to end with
350<code>Consumer</code>.
351
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000352<!-- ======================================================================= -->
353<h2 id="knownproblems">Significant Known Problems</h2>
354<!-- ======================================================================= -->
355
356<!-- ======================================================================= -->
357<h2 id="additionalinfo">Additional Information</h2>
358<!-- ======================================================================= -->
359
360<p>A wide variety of additional information is available on the
361<a href="http://clang.llvm.org/">Clang web page</a>. The web page contains
362versions of the API documentation which are up-to-date with the Subversion
363version of the source code. You can access versions of these documents specific
364to this release by going into the "<tt>clang/doc/</tt>" directory in the Clang
365tree.</p>
366
367<p>If you have any questions or comments about Clang, please feel free to
368contact us via the <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">
369mailing list</a>.</p>
370
Chandler Carruth59abf062011-11-28 22:12:44 +0000371
372<!-- ======================================================================= -->
373<!-- Likely 3.1 release notes -->
374<!-- ======================================================================= -->
375<!--
376This is just a section to hold things that have already gotten started and
377should likely pick up proper release notes in 3.1.
378
379- C1X and C++11 atomics infrastructure and support
380- CUDA support?
381
382-->
383
Benjamin Kramer665a8dc2012-01-15 15:26:07 +0000384</div>
Chandler Carruthc00c0c32011-11-28 07:16:19 +0000385</body>
386</html>