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