[www-releases] r230777 - Upload 3.6.0

Hans Wennborg hans at hanshq.net
Fri Feb 27 10:44:12 PST 2015


Added: www-releases/trunk/3.6.0/tools/clang/docs/InternalsManual.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/InternalsManual.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/InternalsManual.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/InternalsManual.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,1879 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>“Clang” CFE Internals Manual — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Driver Design & Internals" href="DriverInternals.html" />
+    <link rel="prev" title="Clang-Format Style Options" href="ClangFormatStyleOptions.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>“Clang” CFE Internals Manual</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="ClangFormatStyleOptions.html">Clang-Format Style Options</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="DriverInternals.html">Driver Design & Internals</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="clang-cfe-internals-manual">
+<h1>“Clang” CFE Internals Manual<a class="headerlink" href="#clang-cfe-internals-manual" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id2">Introduction</a></li>
+<li><a class="reference internal" href="#llvm-support-library" id="id3">LLVM Support Library</a></li>
+<li><a class="reference internal" href="#the-clang-basic-library" id="id4">The Clang “Basic” Library</a><ul>
+<li><a class="reference internal" href="#the-diagnostics-subsystem" id="id5">The Diagnostics Subsystem</a><ul>
+<li><a class="reference internal" href="#the-diagnostic-kinds-td-files" id="id6">The <tt class="docutils literal"><span class="pre">Diagnostic*Kinds.td</span></tt> files</a></li>
+<li><a class="reference internal" href="#the-format-string" id="id7">The Format String</a></li>
+<li><a class="reference internal" href="#formatting-a-diagnostic-argument" id="id8">Formatting a Diagnostic Argument</a></li>
+<li><a class="reference internal" href="#producing-the-diagnostic" id="id9">Producing the Diagnostic</a></li>
+<li><a class="reference internal" href="#fix-it-hints" id="id10">Fix-It Hints</a></li>
+<li><a class="reference internal" href="#the-diagnosticclient-interface" id="id11">The <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt> Interface</a></li>
+<li><a class="reference internal" href="#adding-translations-to-clang" id="id12">Adding Translations to Clang</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#the-sourcelocation-and-sourcemanager-classes" id="id13">The <tt class="docutils literal"><span class="pre">SourceLocation</span></tt> and <tt class="docutils literal"><span class="pre">SourceManager</span></tt> classes</a></li>
+<li><a class="reference internal" href="#sourcerange-and-charsourcerange" id="id14"><tt class="docutils literal"><span class="pre">SourceRange</span></tt> and <tt class="docutils literal"><span class="pre">CharSourceRange</span></tt></a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#the-driver-library" id="id15">The Driver Library</a></li>
+<li><a class="reference internal" href="#precompiled-headers" id="id16">Precompiled Headers</a></li>
+<li><a class="reference internal" href="#the-frontend-library" id="id17">The Frontend Library</a></li>
+<li><a class="reference internal" href="#the-lexer-and-preprocessor-library" id="id18">The Lexer and Preprocessor Library</a><ul>
+<li><a class="reference internal" href="#the-token-class" id="id19">The Token class</a></li>
+<li><a class="reference internal" href="#annotation-tokens" id="id20">Annotation Tokens</a></li>
+<li><a class="reference internal" href="#the-lexer-class" id="id21">The <tt class="docutils literal"><span class="pre">Lexer</span></tt> class</a></li>
+<li><a class="reference internal" href="#the-tokenlexer-class" id="id22">The <tt class="docutils literal"><span class="pre">TokenLexer</span></tt> class</a></li>
+<li><a class="reference internal" href="#the-multipleincludeopt-class" id="id23">The <tt class="docutils literal"><span class="pre">MultipleIncludeOpt</span></tt> class</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#the-parser-library" id="id24">The Parser Library</a></li>
+<li><a class="reference internal" href="#the-ast-library" id="id25">The AST Library</a><ul>
+<li><a class="reference internal" href="#the-type-class-and-its-subclasses" id="id26">The <tt class="docutils literal"><span class="pre">Type</span></tt> class and its subclasses</a><ul>
+<li><a class="reference internal" href="#canonical-types" id="id27">Canonical Types</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#the-qualtype-class" id="id28">The <tt class="docutils literal"><span class="pre">QualType</span></tt> class</a></li>
+<li><a class="reference internal" href="#declaration-names" id="id29">Declaration names</a></li>
+<li><a class="reference internal" href="#declaration-contexts" id="id30">Declaration contexts</a><ul>
+<li><a class="reference internal" href="#redeclarations-and-overloads" id="id31">Redeclarations and Overloads</a></li>
+<li><a class="reference internal" href="#lexical-and-semantic-contexts" id="id32">Lexical and Semantic Contexts</a></li>
+<li><a class="reference internal" href="#transparent-declaration-contexts" id="id33">Transparent Declaration Contexts</a></li>
+<li><a class="reference internal" href="#multiply-defined-declaration-contexts" id="id34">Multiply-Defined Declaration Contexts</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#the-cfg-class" id="id35">The <tt class="docutils literal"><span class="pre">CFG</span></tt> class</a><ul>
+<li><a class="reference internal" href="#basic-blocks" id="id36">Basic Blocks</a></li>
+<li><a class="reference internal" href="#entry-and-exit-blocks" id="id37">Entry and Exit Blocks</a></li>
+<li><a class="reference internal" href="#conditional-control-flow" id="id38">Conditional Control-Flow</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#constant-folding-in-the-clang-ast" id="id39">Constant Folding in the Clang AST</a><ul>
+<li><a class="reference internal" href="#implementation-approach" id="id40">Implementation Approach</a></li>
+<li><a class="reference internal" href="#extensions" id="id41">Extensions</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li><a class="reference internal" href="#the-sema-library" id="id42">The Sema Library</a></li>
+<li><a class="reference internal" href="#the-codegen-library" id="id43">The CodeGen Library</a></li>
+<li><a class="reference internal" href="#how-to-change-clang" id="id44">How to change Clang</a><ul>
+<li><a class="reference internal" href="#how-to-add-an-attribute" id="id45">How to add an attribute</a><ul>
+<li><a class="reference internal" href="#attribute-basics" id="id46">Attribute Basics</a></li>
+<li><a class="reference internal" href="#include-clang-basic-attr-td" id="id47"><tt class="docutils literal"><span class="pre">include/clang/Basic/Attr.td</span></tt></a></li>
+<li><a class="reference internal" href="#boilerplate" id="id48">Boilerplate</a></li>
+<li><a class="reference internal" href="#the-meat-of-your-attribute" id="id49">The meat of your attribute</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#how-to-add-an-expression-or-statement" id="id50">How to add an expression or statement</a></li>
+</ul>
+</li>
+</ul>
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id2">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>This document describes some of the more important APIs and internal design
+decisions made in the Clang C front-end.  The purpose of this document is to
+both capture some of this high level information and also describe some of the
+design decisions behind it.  This is meant for people interested in hacking on
+Clang, not for end-users.  The description below is categorized by libraries,
+and does not describe any of the clients of the libraries.</p>
+</div>
+<div class="section" id="llvm-support-library">
+<h2><a class="toc-backref" href="#id3">LLVM Support Library</a><a class="headerlink" href="#llvm-support-library" title="Permalink to this headline">¶</a></h2>
+<p>The LLVM <tt class="docutils literal"><span class="pre">libSupport</span></tt> library provides many underlying libraries and
+<a class="reference external" href="http://llvm.org/docs/ProgrammersManual.html">data-structures</a>, including
+command line option processing, various containers and a system abstraction
+layer, which is used for file system access.</p>
+</div>
+<div class="section" id="the-clang-basic-library">
+<h2><a class="toc-backref" href="#id4">The Clang “Basic” Library</a><a class="headerlink" href="#the-clang-basic-library" title="Permalink to this headline">¶</a></h2>
+<p>This library certainly needs a better name.  The “basic” library contains a
+number of low-level utilities for tracking and manipulating source buffers,
+locations within the source buffers, diagnostics, tokens, target abstraction,
+and information about the subset of the language being compiled for.</p>
+<p>Part of this infrastructure is specific to C (such as the <tt class="docutils literal"><span class="pre">TargetInfo</span></tt>
+class), other parts could be reused for other non-C-based languages
+(<tt class="docutils literal"><span class="pre">SourceLocation</span></tt>, <tt class="docutils literal"><span class="pre">SourceManager</span></tt>, <tt class="docutils literal"><span class="pre">Diagnostics</span></tt>, <tt class="docutils literal"><span class="pre">FileManager</span></tt>).
+When and if there is future demand we can figure out if it makes sense to
+introduce a new library, move the general classes somewhere else, or introduce
+some other solution.</p>
+<p>We describe the roles of these classes in order of their dependencies.</p>
+<div class="section" id="the-diagnostics-subsystem">
+<h3><a class="toc-backref" href="#id5">The Diagnostics Subsystem</a><a class="headerlink" href="#the-diagnostics-subsystem" title="Permalink to this headline">¶</a></h3>
+<p>The Clang Diagnostics subsystem is an important part of how the compiler
+communicates with the human.  Diagnostics are the warnings and errors produced
+when the code is incorrect or dubious.  In Clang, each diagnostic produced has
+(at the minimum) a unique ID, an English translation associated with it, a
+<a class="reference internal" href="#sourcelocation"><em>SourceLocation</em></a> to “put the caret”, and a severity
+(e.g., <tt class="docutils literal"><span class="pre">WARNING</span></tt> or <tt class="docutils literal"><span class="pre">ERROR</span></tt>).  They can also optionally include a number of
+arguments to the dianostic (which fill in “%0“‘s in the string) as well as a
+number of source ranges that related to the diagnostic.</p>
+<p>In this section, we’ll be giving examples produced by the Clang command line
+driver, but diagnostics can be <a class="reference internal" href="#diagnosticclient"><em>rendered in many different ways</em></a> depending on how the <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt> interface is
+implemented.  A representative example of a diagnostic is:</p>
+<div class="highlight-c++"><div class="highlight"><pre>t.c:38:15: error: invalid operands to binary expression ('int *' and '_Complex float')
+P = (P-42) + Gamma*4;
+    ~~~~~~ ^ ~~~~~~~
+</pre></div>
+</div>
+<p>In this example, you can see the English translation, the severity (error), you
+can see the source location (the caret (“<tt class="docutils literal"><span class="pre">^</span></tt>”) and file/line/column info),
+the source ranges “<tt class="docutils literal"><span class="pre">~~~~</span></tt>”, arguments to the diagnostic (“<tt class="docutils literal"><span class="pre">int*</span></tt>” and
+“<tt class="docutils literal"><span class="pre">_Complex</span> <span class="pre">float</span></tt>”).  You’ll have to believe me that there is a unique ID
+backing the diagnostic :).</p>
+<p>Getting all of this to happen has several steps and involves many moving
+pieces, this section describes them and talks about best practices when adding
+a new diagnostic.</p>
+<div class="section" id="the-diagnostic-kinds-td-files">
+<h4><a class="toc-backref" href="#id6">The <tt class="docutils literal"><span class="pre">Diagnostic*Kinds.td</span></tt> files</a><a class="headerlink" href="#the-diagnostic-kinds-td-files" title="Permalink to this headline">¶</a></h4>
+<p>Diagnostics are created by adding an entry to one of the
+<tt class="docutils literal"><span class="pre">clang/Basic/Diagnostic*Kinds.td</span></tt> files, depending on what library will be
+using it.  From this file, <strong class="program">tblgen</strong> generates the unique ID of the
+diagnostic, the severity of the diagnostic and the English translation + format
+string.</p>
+<p>There is little sanity with the naming of the unique ID’s right now.  Some
+start with <tt class="docutils literal"><span class="pre">err_</span></tt>, <tt class="docutils literal"><span class="pre">warn_</span></tt>, <tt class="docutils literal"><span class="pre">ext_</span></tt> to encode the severity into the name.
+Since the enum is referenced in the C++ code that produces the diagnostic, it
+is somewhat useful for it to be reasonably short.</p>
+<p>The severity of the diagnostic comes from the set {<tt class="docutils literal"><span class="pre">NOTE</span></tt>, <tt class="docutils literal"><span class="pre">REMARK</span></tt>,
+<tt class="docutils literal"><span class="pre">WARNING</span></tt>,
+<tt class="docutils literal"><span class="pre">EXTENSION</span></tt>, <tt class="docutils literal"><span class="pre">EXTWARN</span></tt>, <tt class="docutils literal"><span class="pre">ERROR</span></tt>}.  The <tt class="docutils literal"><span class="pre">ERROR</span></tt> severity is used for
+diagnostics indicating the program is never acceptable under any circumstances.
+When an error is emitted, the AST for the input code may not be fully built.
+The <tt class="docutils literal"><span class="pre">EXTENSION</span></tt> and <tt class="docutils literal"><span class="pre">EXTWARN</span></tt> severities are used for extensions to the
+language that Clang accepts.  This means that Clang fully understands and can
+represent them in the AST, but we produce diagnostics to tell the user their
+code is non-portable.  The difference is that the former are ignored by
+default, and the later warn by default.  The <tt class="docutils literal"><span class="pre">WARNING</span></tt> severity is used for
+constructs that are valid in the currently selected source language but that
+are dubious in some way.  The <tt class="docutils literal"><span class="pre">REMARK</span></tt> severity provides generic information
+about the compilation that is not necessarily related to any dubious code.  The
+<tt class="docutils literal"><span class="pre">NOTE</span></tt> level is used to staple more information onto previous diagnostics.</p>
+<p>These <em>severities</em> are mapped into a smaller set (the <tt class="docutils literal"><span class="pre">Diagnostic::Level</span></tt>
+enum, {<tt class="docutils literal"><span class="pre">Ignored</span></tt>, <tt class="docutils literal"><span class="pre">Note</span></tt>, <tt class="docutils literal"><span class="pre">Remark</span></tt>, <tt class="docutils literal"><span class="pre">Warning</span></tt>, <tt class="docutils literal"><span class="pre">Error</span></tt>, <tt class="docutils literal"><span class="pre">Fatal</span></tt>}) of
+output
+<em>levels</em> by the diagnostics subsystem based on various configuration options.
+Clang internally supports a fully fine grained mapping mechanism that allows
+you to map almost any diagnostic to the output level that you want.  The only
+diagnostics that cannot be mapped are <tt class="docutils literal"><span class="pre">NOTE</span></tt>s, which always follow the
+severity of the previously emitted diagnostic and <tt class="docutils literal"><span class="pre">ERROR</span></tt>s, which can only
+be mapped to <tt class="docutils literal"><span class="pre">Fatal</span></tt> (it is not possible to turn an error into a warning, for
+example).</p>
+<p>Diagnostic mappings are used in many ways.  For example, if the user specifies
+<tt class="docutils literal"><span class="pre">-pedantic</span></tt>, <tt class="docutils literal"><span class="pre">EXTENSION</span></tt> maps to <tt class="docutils literal"><span class="pre">Warning</span></tt>, if they specify
+<tt class="docutils literal"><span class="pre">-pedantic-errors</span></tt>, it turns into <tt class="docutils literal"><span class="pre">Error</span></tt>.  This is used to implement
+options like <tt class="docutils literal"><span class="pre">-Wunused_macros</span></tt>, <tt class="docutils literal"><span class="pre">-Wundef</span></tt> etc.</p>
+<p>Mapping to <tt class="docutils literal"><span class="pre">Fatal</span></tt> should only be used for diagnostics that are considered so
+severe that error recovery won’t be able to recover sensibly from them (thus
+spewing a ton of bogus errors).  One example of this class of error are failure
+to <tt class="docutils literal"><span class="pre">#include</span></tt> a file.</p>
+</div>
+<div class="section" id="the-format-string">
+<h4><a class="toc-backref" href="#id7">The Format String</a><a class="headerlink" href="#the-format-string" title="Permalink to this headline">¶</a></h4>
+<p>The format string for the diagnostic is very simple, but it has some power.  It
+takes the form of a string in English with markers that indicate where and how
+arguments to the diagnostic are inserted and formatted.  For example, here are
+some simple format strings:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="s">"binary integer literals are an extension"</span>
+<span class="s">"format string contains '</span><span class="se">\\</span><span class="s">0' within the string body"</span>
+<span class="s">"more '%%' conversions than data arguments"</span>
+<span class="s">"invalid operands to binary expression (%0 and %1)"</span>
+<span class="s">"overloaded '%0' must be a %select{unary|binary|unary or binary}2 operator"</span>
+     <span class="s">" (has %1 parameter%s1)"</span>
+</pre></div>
+</div>
+<p>These examples show some important points of format strings.  You can use any
+plain ASCII character in the diagnostic string except “<tt class="docutils literal"><span class="pre">%</span></tt>” without a
+problem, but these are C strings, so you have to use and be aware of all the C
+escape sequences (as in the second example).  If you want to produce a “<tt class="docutils literal"><span class="pre">%</span></tt>”
+in the output, use the “<tt class="docutils literal"><span class="pre">%%</span></tt>” escape sequence, like the third diagnostic.
+Finally, Clang uses the “<tt class="docutils literal"><span class="pre">%...[digit]</span></tt>” sequences to specify where and how
+arguments to the diagnostic are formatted.</p>
+<p>Arguments to the diagnostic are numbered according to how they are specified by
+the C++ code that <a class="reference internal" href="#internals-producing-diag"><em>produces them</em></a>, and are
+referenced by <tt class="docutils literal"><span class="pre">%0</span></tt> .. <tt class="docutils literal"><span class="pre">%9</span></tt>.  If you have more than 10 arguments to your
+diagnostic, you are doing something wrong :).  Unlike <tt class="docutils literal"><span class="pre">printf</span></tt>, there is no
+requirement that arguments to the diagnostic end up in the output in the same
+order as they are specified, you could have a format string with “<tt class="docutils literal"><span class="pre">%1</span> <span class="pre">%0</span></tt>”
+that swaps them, for example.  The text in between the percent and digit are
+formatting instructions.  If there are no instructions, the argument is just
+turned into a string and substituted in.</p>
+<p>Here are some “best practices” for writing the English format string:</p>
+<ul class="simple">
+<li>Keep the string short.  It should ideally fit in the 80 column limit of the
+<tt class="docutils literal"><span class="pre">DiagnosticKinds.td</span></tt> file.  This avoids the diagnostic wrapping when
+printed, and forces you to think about the important point you are conveying
+with the diagnostic.</li>
+<li>Take advantage of location information.  The user will be able to see the
+line and location of the caret, so you don’t need to tell them that the
+problem is with the 4th argument to the function: just point to it.</li>
+<li>Do not capitalize the diagnostic string, and do not end it with a period.</li>
+<li>If you need to quote something in the diagnostic string, use single quotes.</li>
+</ul>
+<p>Diagnostics should never take random English strings as arguments: you
+shouldn’t use “<tt class="docutils literal"><span class="pre">you</span> <span class="pre">have</span> <span class="pre">a</span> <span class="pre">problem</span> <span class="pre">with</span> <span class="pre">%0</span></tt>” and pass in things like “<tt class="docutils literal"><span class="pre">your</span>
+<span class="pre">argument</span></tt>” or “<tt class="docutils literal"><span class="pre">your</span> <span class="pre">return</span> <span class="pre">value</span></tt>” as arguments.  Doing this prevents
+<a class="reference internal" href="#internals-diag-translation"><em>translating</em></a> the Clang diagnostics to other
+languages (because they’ll get random English words in their otherwise
+localized diagnostic).  The exceptions to this are C/C++ language keywords
+(e.g., <tt class="docutils literal"><span class="pre">auto</span></tt>, <tt class="docutils literal"><span class="pre">const</span></tt>, <tt class="docutils literal"><span class="pre">mutable</span></tt>, etc) and C/C++ operators (<tt class="docutils literal"><span class="pre">/=</span></tt>).
+Note that things like “pointer” and “reference” are not keywords.  On the other
+hand, you <em>can</em> include anything that comes from the user’s source code,
+including variable names, types, labels, etc.  The “<tt class="docutils literal"><span class="pre">select</span></tt>” format can be
+used to achieve this sort of thing in a localizable way, see below.</p>
+</div>
+<div class="section" id="formatting-a-diagnostic-argument">
+<h4><a class="toc-backref" href="#id8">Formatting a Diagnostic Argument</a><a class="headerlink" href="#formatting-a-diagnostic-argument" title="Permalink to this headline">¶</a></h4>
+<p>Arguments to diagnostics are fully typed internally, and come from a couple
+different classes: integers, types, names, and random strings.  Depending on
+the class of the argument, it can be optionally formatted in different ways.
+This gives the <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt> information about what the argument means
+without requiring it to use a specific presentation (consider this MVC for
+Clang :).</p>
+<p>Here are the different diagnostic argument formats currently supported by
+Clang:</p>
+<p><strong>“s” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"requires</span> <span class="pre">%1</span> <span class="pre">parameter%s1"</span></tt></dd>
+<dt>Class:</dt>
+<dd>Integers</dd>
+<dt>Description:</dt>
+<dd>This is a simple formatter for integers that is useful when producing English
+diagnostics.  When the integer is 1, it prints as nothing.  When the integer
+is not 1, it prints as “<tt class="docutils literal"><span class="pre">s</span></tt>”.  This allows some simple grammatical forms to
+be to be handled correctly, and eliminates the need to use gross things like
+<tt class="docutils literal"><span class="pre">"requires</span> <span class="pre">%1</span> <span class="pre">parameter(s)"</span></tt>.</dd>
+</dl>
+<p><strong>“select” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"must</span> <span class="pre">be</span> <span class="pre">a</span> <span class="pre">%select{unary|binary|unary</span> <span class="pre">or</span> <span class="pre">binary}2</span> <span class="pre">operator"</span></tt></dd>
+<dt>Class:</dt>
+<dd>Integers</dd>
+<dt>Description:</dt>
+<dd>This format specifier is used to merge multiple related diagnostics together
+into one common one, without requiring the difference to be specified as an
+English string argument.  Instead of specifying the string, the diagnostic
+gets an integer argument and the format string selects the numbered option.
+In this case, the “<tt class="docutils literal"><span class="pre">%2</span></tt>” value must be an integer in the range [0..2].  If
+it is 0, it prints “unary”, if it is 1 it prints “binary” if it is 2, it
+prints “unary or binary”.  This allows other language translations to
+substitute reasonable words (or entire phrases) based on the semantics of the
+diagnostic instead of having to do things textually.  The selected string
+does undergo formatting.</dd>
+</dl>
+<p><strong>“plural” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"you</span> <span class="pre">have</span> <span class="pre">%1</span> <span class="pre">%plural{1:mouse|:mice}1</span> <span class="pre">connected</span> <span class="pre">to</span> <span class="pre">your</span> <span class="pre">computer"</span></tt></dd>
+<dt>Class:</dt>
+<dd>Integers</dd>
+<dt>Description:</dt>
+<dd><p class="first">This is a formatter for complex plural forms.  It is designed to handle even
+the requirements of languages with very complex plural forms, as many Baltic
+languages have.  The argument consists of a series of expression/form pairs,
+separated by ”:”, where the first form whose expression evaluates to true is
+the result of the modifier.</p>
+<p>An expression can be empty, in which case it is always true.  See the example
+at the top.  Otherwise, it is a series of one or more numeric conditions,
+separated by ”,”.  If any condition matches, the expression matches.  Each
+numeric condition can take one of three forms.</p>
+<ul class="simple">
+<li>number: A simple decimal number matches if the argument is the same as the
+number.  Example: <tt class="docutils literal"><span class="pre">"%plural{1:mouse|:mice}4"</span></tt></li>
+<li>range: A range in square brackets matches if the argument is within the
+range.  Then range is inclusive on both ends.  Example:
+<tt class="docutils literal"><span class="pre">"%plural{0:none|1:one|[2,5]:some|:many}2"</span></tt></li>
+<li>modulo: A modulo operator is followed by a number, and equals sign and
+either a number or a range.  The tests are the same as for plain numbers
+and ranges, but the argument is taken modulo the number first.  Example:
+<tt class="docutils literal"><span class="pre">"%plural{%100=0:even</span> <span class="pre">hundred|%100=[1,50]:lower</span> <span class="pre">half|:everything</span> <span class="pre">else}1"</span></tt></li>
+</ul>
+<p class="last">The parser is very unforgiving.  A syntax error, even whitespace, will abort,
+as will a failure to match the argument against any expression.</p>
+</dd>
+</dl>
+<p><strong>“ordinal” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"ambiguity</span> <span class="pre">in</span> <span class="pre">%ordinal0</span> <span class="pre">argument"</span></tt></dd>
+<dt>Class:</dt>
+<dd>Integers</dd>
+<dt>Description:</dt>
+<dd>This is a formatter which represents the argument number as an ordinal: the
+value <tt class="docutils literal"><span class="pre">1</span></tt> becomes <tt class="docutils literal"><span class="pre">1st</span></tt>, <tt class="docutils literal"><span class="pre">3</span></tt> becomes <tt class="docutils literal"><span class="pre">3rd</span></tt>, and so on.  Values less
+than <tt class="docutils literal"><span class="pre">1</span></tt> are not supported.  This formatter is currently hard-coded to use
+English ordinals.</dd>
+</dl>
+<p><strong>“objcclass” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"method</span> <span class="pre">%objcclass0</span> <span class="pre">not</span> <span class="pre">found"</span></tt></dd>
+<dt>Class:</dt>
+<dd><tt class="docutils literal"><span class="pre">DeclarationName</span></tt></dd>
+<dt>Description:</dt>
+<dd>This is a simple formatter that indicates the <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> corresponds
+to an Objective-C class method selector.  As such, it prints the selector
+with a leading “<tt class="docutils literal"><span class="pre">+</span></tt>”.</dd>
+</dl>
+<p><strong>“objcinstance” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"method</span> <span class="pre">%objcinstance0</span> <span class="pre">not</span> <span class="pre">found"</span></tt></dd>
+<dt>Class:</dt>
+<dd><tt class="docutils literal"><span class="pre">DeclarationName</span></tt></dd>
+<dt>Description:</dt>
+<dd>This is a simple formatter that indicates the <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> corresponds
+to an Objective-C instance method selector.  As such, it prints the selector
+with a leading “<tt class="docutils literal"><span class="pre">-</span></tt>”.</dd>
+</dl>
+<p><strong>“q” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"candidate</span> <span class="pre">found</span> <span class="pre">by</span> <span class="pre">name</span> <span class="pre">lookup</span> <span class="pre">is</span> <span class="pre">%q0"</span></tt></dd>
+<dt>Class:</dt>
+<dd><tt class="docutils literal"><span class="pre">NamedDecl</span> <span class="pre">*</span></tt></dd>
+<dt>Description:</dt>
+<dd>This formatter indicates that the fully-qualified name of the declaration
+should be printed, e.g., “<tt class="docutils literal"><span class="pre">std::vector</span></tt>” rather than “<tt class="docutils literal"><span class="pre">vector</span></tt>”.</dd>
+</dl>
+<p><strong>“diff” format</strong></p>
+<dl class="docutils">
+<dt>Example:</dt>
+<dd><tt class="docutils literal"><span class="pre">"no</span> <span class="pre">known</span> <span class="pre">conversion</span> <span class="pre">%diff{from</span> <span class="pre">$</span> <span class="pre">to</span> <span class="pre">$|from</span> <span class="pre">argument</span> <span class="pre">type</span> <span class="pre">to</span> <span class="pre">parameter</span> <span class="pre">type}1,2"</span></tt></dd>
+<dt>Class:</dt>
+<dd><tt class="docutils literal"><span class="pre">QualType</span></tt></dd>
+<dt>Description:</dt>
+<dd>This formatter takes two <tt class="docutils literal"><span class="pre">QualType</span></tt>s and attempts to print a template
+difference between the two.  If tree printing is off, the text inside the
+braces before the pipe is printed, with the formatted text replacing the $.
+If tree printing is on, the text after the pipe is printed and a type tree is
+printed after the diagnostic message.</dd>
+</dl>
+<p>It is really easy to add format specifiers to the Clang diagnostics system, but
+they should be discussed before they are added.  If you are creating a lot of
+repetitive diagnostics and/or have an idea for a useful formatter, please bring
+it up on the cfe-dev mailing list.</p>
+</div>
+<div class="section" id="producing-the-diagnostic">
+<span id="internals-producing-diag"></span><h4><a class="toc-backref" href="#id9">Producing the Diagnostic</a><a class="headerlink" href="#producing-the-diagnostic" title="Permalink to this headline">¶</a></h4>
+<p>Now that you’ve created the diagnostic in the <tt class="docutils literal"><span class="pre">Diagnostic*Kinds.td</span></tt> file, you
+need to write the code that detects the condition in question and emits the new
+diagnostic.  Various components of Clang (e.g., the preprocessor, <tt class="docutils literal"><span class="pre">Sema</span></tt>,
+etc.) provide a helper function named “<tt class="docutils literal"><span class="pre">Diag</span></tt>”.  It creates a diagnostic and
+accepts the arguments, ranges, and other information that goes along with it.</p>
+<p>For example, the binary expression error comes from code like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">if</span> <span class="p">(</span><span class="n">various</span> <span class="n">things</span> <span class="n">that</span> <span class="n">are</span> <span class="n">bad</span><span class="p">)</span>
+  <span class="n">Diag</span><span class="p">(</span><span class="n">Loc</span><span class="p">,</span> <span class="n">diag</span><span class="o">::</span><span class="n">err_typecheck_invalid_operands</span><span class="p">)</span>
+    <span class="o"><<</span> <span class="n">lex</span><span class="o">-></span><span class="n">getType</span><span class="p">()</span> <span class="o"><<</span> <span class="n">rex</span><span class="o">-></span><span class="n">getType</span><span class="p">()</span>
+    <span class="o"><<</span> <span class="n">lex</span><span class="o">-></span><span class="n">getSourceRange</span><span class="p">()</span> <span class="o"><<</span> <span class="n">rex</span><span class="o">-></span><span class="n">getSourceRange</span><span class="p">();</span>
+</pre></div>
+</div>
+<p>This shows that use of the <tt class="docutils literal"><span class="pre">Diag</span></tt> method: it takes a location (a
+<a class="reference internal" href="#sourcelocation"><em>SourceLocation</em></a> object) and a diagnostic enum value
+(which matches the name from <tt class="docutils literal"><span class="pre">Diagnostic*Kinds.td</span></tt>).  If the diagnostic takes
+arguments, they are specified with the <tt class="docutils literal"><span class="pre"><<</span></tt> operator: the first argument
+becomes <tt class="docutils literal"><span class="pre">%0</span></tt>, the second becomes <tt class="docutils literal"><span class="pre">%1</span></tt>, etc.  The diagnostic interface
+allows you to specify arguments of many different types, including <tt class="docutils literal"><span class="pre">int</span></tt> and
+<tt class="docutils literal"><span class="pre">unsigned</span></tt> for integer arguments, <tt class="docutils literal"><span class="pre">const</span> <span class="pre">char*</span></tt> and <tt class="docutils literal"><span class="pre">std::string</span></tt> for
+string arguments, <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> and <tt class="docutils literal"><span class="pre">const</span> <span class="pre">IdentifierInfo</span> <span class="pre">*</span></tt> for names,
+<tt class="docutils literal"><span class="pre">QualType</span></tt> for types, etc.  <tt class="docutils literal"><span class="pre">SourceRange</span></tt>s are also specified with the
+<tt class="docutils literal"><span class="pre"><<</span></tt> operator, but do not have a specific ordering requirement.</p>
+<p>As you can see, adding and producing a diagnostic is pretty straightforward.
+The hard part is deciding exactly what you need to say to help the user,
+picking a suitable wording, and providing the information needed to format it
+correctly.  The good news is that the call site that issues a diagnostic should
+be completely independent of how the diagnostic is formatted and in what
+language it is rendered.</p>
+</div>
+<div class="section" id="fix-it-hints">
+<h4><a class="toc-backref" href="#id10">Fix-It Hints</a><a class="headerlink" href="#fix-it-hints" title="Permalink to this headline">¶</a></h4>
+<p>In some cases, the front end emits diagnostics when it is clear that some small
+change to the source code would fix the problem.  For example, a missing
+semicolon at the end of a statement or a use of deprecated syntax that is
+easily rewritten into a more modern form.  Clang tries very hard to emit the
+diagnostic and recover gracefully in these and other cases.</p>
+<p>However, for these cases where the fix is obvious, the diagnostic can be
+annotated with a hint (referred to as a “fix-it hint”) that describes how to
+change the code referenced by the diagnostic to fix the problem.  For example,
+it might add the missing semicolon at the end of the statement or rewrite the
+use of a deprecated construct into something more palatable.  Here is one such
+example from the C++ front end, where we warn about the right-shift operator
+changing meaning from C++98 to C++11:</p>
+<div class="highlight-c++"><div class="highlight"><pre>test.cpp:3:7: warning: use of right-shift operator ('>>') in template argument
+                       will require parentheses in C++11
+A<100 >> 2> *a;
+      ^
+  (       )
+</pre></div>
+</div>
+<p>Here, the fix-it hint is suggesting that parentheses be added, and showing
+exactly where those parentheses would be inserted into the source code.  The
+fix-it hints themselves describe what changes to make to the source code in an
+abstract manner, which the text diagnostic printer renders as a line of
+“insertions” below the caret line.  <a class="reference internal" href="#diagnosticclient"><em>Other diagnostic clients</em></a> might choose to render the code differently (e.g., as
+markup inline) or even give the user the ability to automatically fix the
+problem.</p>
+<p>Fix-it hints on errors and warnings need to obey these rules:</p>
+<ul class="simple">
+<li>Since they are automatically applied if <tt class="docutils literal"><span class="pre">-Xclang</span> <span class="pre">-fixit</span></tt> is passed to the
+driver, they should only be used when it’s very likely they match the user’s
+intent.</li>
+<li>Clang must recover from errors as if the fix-it had been applied.</li>
+</ul>
+<p>If a fix-it can’t obey these rules, put the fix-it on a note.  Fix-its on notes
+are not applied automatically.</p>
+<p>All fix-it hints are described by the <tt class="docutils literal"><span class="pre">FixItHint</span></tt> class, instances of which
+should be attached to the diagnostic using the <tt class="docutils literal"><span class="pre"><<</span></tt> operator in the same way
+that highlighted source ranges and arguments are passed to the diagnostic.
+Fix-it hints can be created with one of three constructors:</p>
+<ul>
+<li><p class="first"><tt class="docutils literal"><span class="pre">FixItHint::CreateInsertion(Loc,</span> <span class="pre">Code)</span></tt></p>
+<blockquote>
+<div><p>Specifies that the given <tt class="docutils literal"><span class="pre">Code</span></tt> (a string) should be inserted before the
+source location <tt class="docutils literal"><span class="pre">Loc</span></tt>.</p>
+</div></blockquote>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">FixItHint::CreateRemoval(Range)</span></tt></p>
+<blockquote>
+<div><p>Specifies that the code in the given source <tt class="docutils literal"><span class="pre">Range</span></tt> should be removed.</p>
+</div></blockquote>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">FixItHint::CreateReplacement(Range,</span> <span class="pre">Code)</span></tt></p>
+<blockquote>
+<div><p>Specifies that the code in the given source <tt class="docutils literal"><span class="pre">Range</span></tt> should be removed,
+and replaced with the given <tt class="docutils literal"><span class="pre">Code</span></tt> string.</p>
+</div></blockquote>
+</li>
+</ul>
+</div>
+<div class="section" id="the-diagnosticclient-interface">
+<span id="diagnosticclient"></span><h4><a class="toc-backref" href="#id11">The <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt> Interface</a><a class="headerlink" href="#the-diagnosticclient-interface" title="Permalink to this headline">¶</a></h4>
+<p>Once code generates a diagnostic with all of the arguments and the rest of the
+relevant information, Clang needs to know what to do with it.  As previously
+mentioned, the diagnostic machinery goes through some filtering to map a
+severity onto a diagnostic level, then (assuming the diagnostic is not mapped
+to “<tt class="docutils literal"><span class="pre">Ignore</span></tt>”) it invokes an object that implements the <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt>
+interface with the information.</p>
+<p>It is possible to implement this interface in many different ways.  For
+example, the normal Clang <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt> (named
+<tt class="docutils literal"><span class="pre">TextDiagnosticPrinter</span></tt>) turns the arguments into strings (according to the
+various formatting rules), prints out the file/line/column information and the
+string, then prints out the line of code, the source ranges, and the caret.
+However, this behavior isn’t required.</p>
+<p>Another implementation of the <tt class="docutils literal"><span class="pre">DiagnosticClient</span></tt> interface is the
+<tt class="docutils literal"><span class="pre">TextDiagnosticBuffer</span></tt> class, which is used when Clang is in <tt class="docutils literal"><span class="pre">-verify</span></tt>
+mode.  Instead of formatting and printing out the diagnostics, this
+implementation just captures and remembers the diagnostics as they fly by.
+Then <tt class="docutils literal"><span class="pre">-verify</span></tt> compares the list of produced diagnostics to the list of
+expected ones.  If they disagree, it prints out its own output.  Full
+documentation for the <tt class="docutils literal"><span class="pre">-verify</span></tt> mode can be found in the Clang API
+documentation for <a class="reference external" href="/doxygen/classclang_1_1VerifyDiagnosticConsumer.html#details">VerifyDiagnosticConsumer</a>.</p>
+<p>There are many other possible implementations of this interface, and this is
+why we prefer diagnostics to pass down rich structured information in
+arguments.  For example, an HTML output might want declaration names be
+linkified to where they come from in the source.  Another example is that a GUI
+might let you click on typedefs to expand them.  This application would want to
+pass significantly more information about types through to the GUI than a
+simple flat string.  The interface allows this to happen.</p>
+</div>
+<div class="section" id="adding-translations-to-clang">
+<span id="internals-diag-translation"></span><h4><a class="toc-backref" href="#id12">Adding Translations to Clang</a><a class="headerlink" href="#adding-translations-to-clang" title="Permalink to this headline">¶</a></h4>
+<p>Not possible yet! Diagnostic strings should be written in UTF-8, the client can
+translate to the relevant code page if needed.  Each translation completely
+replaces the format string for the diagnostic.</p>
+</div>
+</div>
+<div class="section" id="the-sourcelocation-and-sourcemanager-classes">
+<span id="sourcemanager"></span><span id="sourcelocation"></span><h3><a class="toc-backref" href="#id13">The <tt class="docutils literal"><span class="pre">SourceLocation</span></tt> and <tt class="docutils literal"><span class="pre">SourceManager</span></tt> classes</a><a class="headerlink" href="#the-sourcelocation-and-sourcemanager-classes" title="Permalink to this headline">¶</a></h3>
+<p>Strangely enough, the <tt class="docutils literal"><span class="pre">SourceLocation</span></tt> class represents a location within the
+source code of the program.  Important design points include:</p>
+<ol class="arabic simple">
+<li><tt class="docutils literal"><span class="pre">sizeof(SourceLocation)</span></tt> must be extremely small, as these are embedded
+into many AST nodes and are passed around often.  Currently it is 32 bits.</li>
+<li><tt class="docutils literal"><span class="pre">SourceLocation</span></tt> must be a simple value object that can be efficiently
+copied.</li>
+<li>We should be able to represent a source location for any byte of any input
+file.  This includes in the middle of tokens, in whitespace, in trigraphs,
+etc.</li>
+<li>A <tt class="docutils literal"><span class="pre">SourceLocation</span></tt> must encode the current <tt class="docutils literal"><span class="pre">#include</span></tt> stack that was
+active when the location was processed.  For example, if the location
+corresponds to a token, it should contain the set of <tt class="docutils literal"><span class="pre">#include</span></tt>s active
+when the token was lexed.  This allows us to print the <tt class="docutils literal"><span class="pre">#include</span></tt> stack
+for a diagnostic.</li>
+<li><tt class="docutils literal"><span class="pre">SourceLocation</span></tt> must be able to describe macro expansions, capturing both
+the ultimate instantiation point and the source of the original character
+data.</li>
+</ol>
+<p>In practice, the <tt class="docutils literal"><span class="pre">SourceLocation</span></tt> works together with the <tt class="docutils literal"><span class="pre">SourceManager</span></tt>
+class to encode two pieces of information about a location: its spelling
+location and its instantiation location.  For most tokens, these will be the
+same.  However, for a macro expansion (or tokens that came from a <tt class="docutils literal"><span class="pre">_Pragma</span></tt>
+directive) these will describe the location of the characters corresponding to
+the token and the location where the token was used (i.e., the macro
+instantiation point or the location of the <tt class="docutils literal"><span class="pre">_Pragma</span></tt> itself).</p>
+<p>The Clang front-end inherently depends on the location of a token being tracked
+correctly.  If it is ever incorrect, the front-end may get confused and die.
+The reason for this is that the notion of the “spelling” of a <tt class="docutils literal"><span class="pre">Token</span></tt> in
+Clang depends on being able to find the original input characters for the
+token.  This concept maps directly to the “spelling location” for the token.</p>
+</div>
+<div class="section" id="sourcerange-and-charsourcerange">
+<h3><a class="toc-backref" href="#id14"><tt class="docutils literal"><span class="pre">SourceRange</span></tt> and <tt class="docutils literal"><span class="pre">CharSourceRange</span></tt></a><a class="headerlink" href="#sourcerange-and-charsourcerange" title="Permalink to this headline">¶</a></h3>
+<p>Clang represents most source ranges by [first, last], where “first” and “last”
+each point to the beginning of their respective tokens.  For example consider
+the <tt class="docutils literal"><span class="pre">SourceRange</span></tt> of the following statement:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">x</span> <span class="o">=</span> <span class="n">foo</span> <span class="o">+</span> <span class="n">bar</span><span class="p">;</span>
+<span class="o">^</span><span class="n">first</span>    <span class="o">^</span><span class="n">last</span>
+</pre></div>
+</div>
+<p>To map from this representation to a character-based representation, the “last”
+location needs to be adjusted to point to (or past) the end of that token with
+either <tt class="docutils literal"><span class="pre">Lexer::MeasureTokenLength()</span></tt> or <tt class="docutils literal"><span class="pre">Lexer::getLocForEndOfToken()</span></tt>.  For
+the rare cases where character-level source ranges information is needed we use
+the <tt class="docutils literal"><span class="pre">CharSourceRange</span></tt> class.</p>
+</div>
+</div>
+<div class="section" id="the-driver-library">
+<h2><a class="toc-backref" href="#id15">The Driver Library</a><a class="headerlink" href="#the-driver-library" title="Permalink to this headline">¶</a></h2>
+<p>The clang Driver and library are documented <a class="reference internal" href="DriverInternals.html"><em>here</em></a>.</p>
+</div>
+<div class="section" id="precompiled-headers">
+<h2><a class="toc-backref" href="#id16">Precompiled Headers</a><a class="headerlink" href="#precompiled-headers" title="Permalink to this headline">¶</a></h2>
+<p>Clang supports two implementations of precompiled headers.  The default
+implementation, precompiled headers (<a class="reference internal" href="PCHInternals.html"><em>PCH</em></a>) uses a
+serialized representation of Clang’s internal data structures, encoded with the
+<a class="reference external" href="http://llvm.org/docs/BitCodeFormat.html">LLVM bitstream format</a>.
+Pretokenized headers (<a class="reference internal" href="PTHInternals.html"><em>PTH</em></a>), on the other hand, contain a
+serialized representation of the tokens encountered when preprocessing a header
+(and anything that header includes).</p>
+</div>
+<div class="section" id="the-frontend-library">
+<h2><a class="toc-backref" href="#id17">The Frontend Library</a><a class="headerlink" href="#the-frontend-library" title="Permalink to this headline">¶</a></h2>
+<p>The Frontend library contains functionality useful for building tools on top of
+the Clang libraries, for example several methods for outputting diagnostics.</p>
+</div>
+<div class="section" id="the-lexer-and-preprocessor-library">
+<h2><a class="toc-backref" href="#id18">The Lexer and Preprocessor Library</a><a class="headerlink" href="#the-lexer-and-preprocessor-library" title="Permalink to this headline">¶</a></h2>
+<p>The Lexer library contains several tightly-connected classes that are involved
+with the nasty process of lexing and preprocessing C source code.  The main
+interface to this library for outside clients is the large <tt class="docutils literal"><span class="pre">Preprocessor</span></tt>
+class.  It contains the various pieces of state that are required to coherently
+read tokens out of a translation unit.</p>
+<p>The core interface to the <tt class="docutils literal"><span class="pre">Preprocessor</span></tt> object (once it is set up) is the
+<tt class="docutils literal"><span class="pre">Preprocessor::Lex</span></tt> method, which returns the next <a class="reference internal" href="#token"><em>Token</em></a> from
+the preprocessor stream.  There are two types of token providers that the
+preprocessor is capable of reading from: a buffer lexer (provided by the
+<a class="reference internal" href="#lexer"><em>Lexer</em></a> class) and a buffered token stream (provided by the
+<a class="reference internal" href="#tokenlexer"><em>TokenLexer</em></a> class).</p>
+<div class="section" id="the-token-class">
+<span id="token"></span><h3><a class="toc-backref" href="#id19">The Token class</a><a class="headerlink" href="#the-token-class" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">Token</span></tt> class is used to represent a single lexed token.  Tokens are
+intended to be used by the lexer/preprocess and parser libraries, but are not
+intended to live beyond them (for example, they should not live in the ASTs).</p>
+<p>Tokens most often live on the stack (or some other location that is efficient
+to access) as the parser is running, but occasionally do get buffered up.  For
+example, macro definitions are stored as a series of tokens, and the C++
+front-end periodically needs to buffer tokens up for tentative parsing and
+various pieces of look-ahead.  As such, the size of a <tt class="docutils literal"><span class="pre">Token</span></tt> matters.  On a
+32-bit system, <tt class="docutils literal"><span class="pre">sizeof(Token)</span></tt> is currently 16 bytes.</p>
+<p>Tokens occur in two forms: <a class="reference internal" href="#annotationtoken"><em>annotation tokens</em></a> and
+normal tokens.  Normal tokens are those returned by the lexer, annotation
+tokens represent semantic information and are produced by the parser, replacing
+normal tokens in the token stream.  Normal tokens contain the following
+information:</p>
+<ul class="simple">
+<li><strong>A SourceLocation</strong> — This indicates the location of the start of the
+token.</li>
+<li><strong>A length</strong> — This stores the length of the token as stored in the
+<tt class="docutils literal"><span class="pre">SourceBuffer</span></tt>.  For tokens that include them, this length includes
+trigraphs and escaped newlines which are ignored by later phases of the
+compiler.  By pointing into the original source buffer, it is always possible
+to get the original spelling of a token completely accurately.</li>
+<li><strong>IdentifierInfo</strong> — If a token takes the form of an identifier, and if
+identifier lookup was enabled when the token was lexed (e.g., the lexer was
+not reading in “raw” mode) this contains a pointer to the unique hash value
+for the identifier.  Because the lookup happens before keyword
+identification, this field is set even for language keywords like “<tt class="docutils literal"><span class="pre">for</span></tt>”.</li>
+<li><strong>TokenKind</strong> — This indicates the kind of token as classified by the
+lexer.  This includes things like <tt class="docutils literal"><span class="pre">tok::starequal</span></tt> (for the “<tt class="docutils literal"><span class="pre">*=</span></tt>”
+operator), <tt class="docutils literal"><span class="pre">tok::ampamp</span></tt> for the “<tt class="docutils literal"><span class="pre">&&</span></tt>” token, and keyword values (e.g.,
+<tt class="docutils literal"><span class="pre">tok::kw_for</span></tt>) for identifiers that correspond to keywords.  Note that
+some tokens can be spelled multiple ways.  For example, C++ supports
+“operator keywords”, where things like “<tt class="docutils literal"><span class="pre">and</span></tt>” are treated exactly like the
+“<tt class="docutils literal"><span class="pre">&&</span></tt>” operator.  In these cases, the kind value is set to <tt class="docutils literal"><span class="pre">tok::ampamp</span></tt>,
+which is good for the parser, which doesn’t have to consider both forms.  For
+something that cares about which form is used (e.g., the preprocessor
+“stringize” operator) the spelling indicates the original form.</li>
+<li><strong>Flags</strong> — There are currently four flags tracked by the
+lexer/preprocessor system on a per-token basis:<ol class="arabic">
+<li><strong>StartOfLine</strong> — This was the first token that occurred on its input
+source line.</li>
+<li><strong>LeadingSpace</strong> — There was a space character either immediately before
+the token or transitively before the token as it was expanded through a
+macro.  The definition of this flag is very closely defined by the
+stringizing requirements of the preprocessor.</li>
+<li><strong>DisableExpand</strong> — This flag is used internally to the preprocessor to
+represent identifier tokens which have macro expansion disabled.  This
+prevents them from being considered as candidates for macro expansion ever
+in the future.</li>
+<li><strong>NeedsCleaning</strong> — This flag is set if the original spelling for the
+token includes a trigraph or escaped newline.  Since this is uncommon,
+many pieces of code can fast-path on tokens that did not need cleaning.</li>
+</ol>
+</li>
+</ul>
+<p>One interesting (and somewhat unusual) aspect of normal tokens is that they
+don’t contain any semantic information about the lexed value.  For example, if
+the token was a pp-number token, we do not represent the value of the number
+that was lexed (this is left for later pieces of code to decide).
+Additionally, the lexer library has no notion of typedef names vs variable
+names: both are returned as identifiers, and the parser is left to decide
+whether a specific identifier is a typedef or a variable (tracking this
+requires scope information among other things).  The parser can do this
+translation by replacing tokens returned by the preprocessor with “Annotation
+Tokens”.</p>
+</div>
+<div class="section" id="annotation-tokens">
+<span id="annotationtoken"></span><h3><a class="toc-backref" href="#id20">Annotation Tokens</a><a class="headerlink" href="#annotation-tokens" title="Permalink to this headline">¶</a></h3>
+<p>Annotation tokens are tokens that are synthesized by the parser and injected
+into the preprocessor’s token stream (replacing existing tokens) to record
+semantic information found by the parser.  For example, if “<tt class="docutils literal"><span class="pre">foo</span></tt>” is found
+to be a typedef, the “<tt class="docutils literal"><span class="pre">foo</span></tt>” <tt class="docutils literal"><span class="pre">tok::identifier</span></tt> token is replaced with an
+<tt class="docutils literal"><span class="pre">tok::annot_typename</span></tt>.  This is useful for a couple of reasons: 1) this makes
+it easy to handle qualified type names (e.g., “<tt class="docutils literal"><span class="pre">foo::bar::baz<42>::t</span></tt>”) in
+C++ as a single “token” in the parser.  2) if the parser backtracks, the
+reparse does not need to redo semantic analysis to determine whether a token
+sequence is a variable, type, template, etc.</p>
+<p>Annotation tokens are created by the parser and reinjected into the parser’s
+token stream (when backtracking is enabled).  Because they can only exist in
+tokens that the preprocessor-proper is done with, it doesn’t need to keep
+around flags like “start of line” that the preprocessor uses to do its job.
+Additionally, an annotation token may “cover” a sequence of preprocessor tokens
+(e.g., “<tt class="docutils literal"><span class="pre">a::b::c</span></tt>” is five preprocessor tokens).  As such, the valid fields
+of an annotation token are different than the fields for a normal token (but
+they are multiplexed into the normal <tt class="docutils literal"><span class="pre">Token</span></tt> fields):</p>
+<ul class="simple">
+<li><strong>SourceLocation “Location”</strong> — The <tt class="docutils literal"><span class="pre">SourceLocation</span></tt> for the annotation
+token indicates the first token replaced by the annotation token.  In the
+example above, it would be the location of the “<tt class="docutils literal"><span class="pre">a</span></tt>” identifier.</li>
+<li><strong>SourceLocation “AnnotationEndLoc”</strong> — This holds the location of the last
+token replaced with the annotation token.  In the example above, it would be
+the location of the “<tt class="docutils literal"><span class="pre">c</span></tt>” identifier.</li>
+<li><strong>void* “AnnotationValue”</strong> — This contains an opaque object that the
+parser gets from <tt class="docutils literal"><span class="pre">Sema</span></tt>.  The parser merely preserves the information for
+<tt class="docutils literal"><span class="pre">Sema</span></tt> to later interpret based on the annotation token kind.</li>
+<li><strong>TokenKind “Kind”</strong> — This indicates the kind of Annotation token this is.
+See below for the different valid kinds.</li>
+</ul>
+<p>Annotation tokens currently come in three kinds:</p>
+<ol class="arabic simple">
+<li><strong>tok::annot_typename</strong>: This annotation token represents a resolved
+typename token that is potentially qualified.  The <tt class="docutils literal"><span class="pre">AnnotationValue</span></tt> field
+contains the <tt class="docutils literal"><span class="pre">QualType</span></tt> returned by <tt class="docutils literal"><span class="pre">Sema::getTypeName()</span></tt>, possibly with
+source location information attached.</li>
+<li><strong>tok::annot_cxxscope</strong>: This annotation token represents a C++ scope
+specifier, such as “<tt class="docutils literal"><span class="pre">A::B::</span></tt>”.  This corresponds to the grammar
+productions “<em>::</em>” and “<em>:: [opt] nested-name-specifier</em>”.  The
+<tt class="docutils literal"><span class="pre">AnnotationValue</span></tt> pointer is a <tt class="docutils literal"><span class="pre">NestedNameSpecifier</span> <span class="pre">*</span></tt> returned by the
+<tt class="docutils literal"><span class="pre">Sema::ActOnCXXGlobalScopeSpecifier</span></tt> and
+<tt class="docutils literal"><span class="pre">Sema::ActOnCXXNestedNameSpecifier</span></tt> callbacks.</li>
+<li><strong>tok::annot_template_id</strong>: This annotation token represents a C++
+template-id such as “<tt class="docutils literal"><span class="pre">foo<int,</span> <span class="pre">4></span></tt>”, where “<tt class="docutils literal"><span class="pre">foo</span></tt>” is the name of a
+template.  The <tt class="docutils literal"><span class="pre">AnnotationValue</span></tt> pointer is a pointer to a <tt class="docutils literal"><span class="pre">malloc</span></tt>‘d
+<tt class="docutils literal"><span class="pre">TemplateIdAnnotation</span></tt> object.  Depending on the context, a parsed
+template-id that names a type might become a typename annotation token (if
+all we care about is the named type, e.g., because it occurs in a type
+specifier) or might remain a template-id token (if we want to retain more
+source location information or produce a new type, e.g., in a declaration of
+a class template specialization).  template-id annotation tokens that refer
+to a type can be “upgraded” to typename annotation tokens by the parser.</li>
+</ol>
+<p>As mentioned above, annotation tokens are not returned by the preprocessor,
+they are formed on demand by the parser.  This means that the parser has to be
+aware of cases where an annotation could occur and form it where appropriate.
+This is somewhat similar to how the parser handles Translation Phase 6 of C99:
+String Concatenation (see C99 5.1.1.2).  In the case of string concatenation,
+the preprocessor just returns distinct <tt class="docutils literal"><span class="pre">tok::string_literal</span></tt> and
+<tt class="docutils literal"><span class="pre">tok::wide_string_literal</span></tt> tokens and the parser eats a sequence of them
+wherever the grammar indicates that a string literal can occur.</p>
+<p>In order to do this, whenever the parser expects a <tt class="docutils literal"><span class="pre">tok::identifier</span></tt> or
+<tt class="docutils literal"><span class="pre">tok::coloncolon</span></tt>, it should call the <tt class="docutils literal"><span class="pre">TryAnnotateTypeOrScopeToken</span></tt> or
+<tt class="docutils literal"><span class="pre">TryAnnotateCXXScopeToken</span></tt> methods to form the annotation token.  These
+methods will maximally form the specified annotation tokens and replace the
+current token with them, if applicable.  If the current tokens is not valid for
+an annotation token, it will remain an identifier or “<tt class="docutils literal"><span class="pre">::</span></tt>” token.</p>
+</div>
+<div class="section" id="the-lexer-class">
+<span id="lexer"></span><h3><a class="toc-backref" href="#id21">The <tt class="docutils literal"><span class="pre">Lexer</span></tt> class</a><a class="headerlink" href="#the-lexer-class" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">Lexer</span></tt> class provides the mechanics of lexing tokens out of a source
+buffer and deciding what they mean.  The <tt class="docutils literal"><span class="pre">Lexer</span></tt> is complicated by the fact
+that it operates on raw buffers that have not had spelling eliminated (this is
+a necessity to get decent performance), but this is countered with careful
+coding as well as standard performance techniques (for example, the comment
+handling code is vectorized on X86 and PowerPC hosts).</p>
+<p>The lexer has a couple of interesting modal features:</p>
+<ul class="simple">
+<li>The lexer can operate in “raw” mode.  This mode has several features that
+make it possible to quickly lex the file (e.g., it stops identifier lookup,
+doesn’t specially handle preprocessor tokens, handles EOF differently, etc).
+This mode is used for lexing within an “<tt class="docutils literal"><span class="pre">#if</span> <span class="pre">0</span></tt>” block, for example.</li>
+<li>The lexer can capture and return comments as tokens.  This is required to
+support the <tt class="docutils literal"><span class="pre">-C</span></tt> preprocessor mode, which passes comments through, and is
+used by the diagnostic checker to identifier expect-error annotations.</li>
+<li>The lexer can be in <tt class="docutils literal"><span class="pre">ParsingFilename</span></tt> mode, which happens when
+preprocessing after reading a <tt class="docutils literal"><span class="pre">#include</span></tt> directive.  This mode changes the
+parsing of “<tt class="docutils literal"><span class="pre"><</span></tt>” to return an “angled string” instead of a bunch of tokens
+for each thing within the filename.</li>
+<li>When parsing a preprocessor directive (after “<tt class="docutils literal"><span class="pre">#</span></tt>”) the
+<tt class="docutils literal"><span class="pre">ParsingPreprocessorDirective</span></tt> mode is entered.  This changes the parser to
+return EOD at a newline.</li>
+<li>The <tt class="docutils literal"><span class="pre">Lexer</span></tt> uses a <tt class="docutils literal"><span class="pre">LangOptions</span></tt> object to know whether trigraphs are
+enabled, whether C++ or ObjC keywords are recognized, etc.</li>
+</ul>
+<p>In addition to these modes, the lexer keeps track of a couple of other features
+that are local to a lexed buffer, which change as the buffer is lexed:</p>
+<ul class="simple">
+<li>The <tt class="docutils literal"><span class="pre">Lexer</span></tt> uses <tt class="docutils literal"><span class="pre">BufferPtr</span></tt> to keep track of the current character being
+lexed.</li>
+<li>The <tt class="docutils literal"><span class="pre">Lexer</span></tt> uses <tt class="docutils literal"><span class="pre">IsAtStartOfLine</span></tt> to keep track of whether the next
+lexed token will start with its “start of line” bit set.</li>
+<li>The <tt class="docutils literal"><span class="pre">Lexer</span></tt> keeps track of the current “<tt class="docutils literal"><span class="pre">#if</span></tt>” directives that are active
+(which can be nested).</li>
+<li>The <tt class="docutils literal"><span class="pre">Lexer</span></tt> keeps track of an <a class="reference internal" href="#multipleincludeopt"><em>MultipleIncludeOpt</em></a> object, which is used to detect whether the buffer uses
+the standard “<tt class="docutils literal"><span class="pre">#ifndef</span> <span class="pre">XX</span></tt> / <tt class="docutils literal"><span class="pre">#define</span> <span class="pre">XX</span></tt>” idiom to prevent multiple
+inclusion.  If a buffer does, subsequent includes can be ignored if the
+“<tt class="docutils literal"><span class="pre">XX</span></tt>” macro is defined.</li>
+</ul>
+</div>
+<div class="section" id="the-tokenlexer-class">
+<span id="tokenlexer"></span><h3><a class="toc-backref" href="#id22">The <tt class="docutils literal"><span class="pre">TokenLexer</span></tt> class</a><a class="headerlink" href="#the-tokenlexer-class" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">TokenLexer</span></tt> class is a token provider that returns tokens from a list of
+tokens that came from somewhere else.  It typically used for two things: 1)
+returning tokens from a macro definition as it is being expanded 2) returning
+tokens from an arbitrary buffer of tokens.  The later use is used by
+<tt class="docutils literal"><span class="pre">_Pragma</span></tt> and will most likely be used to handle unbounded look-ahead for the
+C++ parser.</p>
+</div>
+<div class="section" id="the-multipleincludeopt-class">
+<span id="multipleincludeopt"></span><h3><a class="toc-backref" href="#id23">The <tt class="docutils literal"><span class="pre">MultipleIncludeOpt</span></tt> class</a><a class="headerlink" href="#the-multipleincludeopt-class" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">MultipleIncludeOpt</span></tt> class implements a really simple little state
+machine that is used to detect the standard “<tt class="docutils literal"><span class="pre">#ifndef</span> <span class="pre">XX</span></tt> / <tt class="docutils literal"><span class="pre">#define</span> <span class="pre">XX</span></tt>”
+idiom that people typically use to prevent multiple inclusion of headers.  If a
+buffer uses this idiom and is subsequently <tt class="docutils literal"><span class="pre">#include</span></tt>‘d, the preprocessor can
+simply check to see whether the guarding condition is defined or not.  If so,
+the preprocessor can completely ignore the include of the header.</p>
+</div>
+</div>
+<div class="section" id="the-parser-library">
+<span id="parser"></span><h2><a class="toc-backref" href="#id24">The Parser Library</a><a class="headerlink" href="#the-parser-library" title="Permalink to this headline">¶</a></h2>
+<p>This library contains a recursive-descent parser that polls tokens from the
+preprocessor and notifies a client of the parsing progress.</p>
+<p>Historically, the parser used to talk to an abstract <tt class="docutils literal"><span class="pre">Action</span></tt> interface that
+had virtual methods for parse events, for example <tt class="docutils literal"><span class="pre">ActOnBinOp()</span></tt>.  When Clang
+grew C++ support, the parser stopped supporting general <tt class="docutils literal"><span class="pre">Action</span></tt> clients –
+it now always talks to the <a class="reference internal" href="#sema"><em>Sema libray</em></a>.  However, the Parser
+still accesses AST objects only through opaque types like <tt class="docutils literal"><span class="pre">ExprResult</span></tt> and
+<tt class="docutils literal"><span class="pre">StmtResult</span></tt>.  Only <a class="reference internal" href="#sema"><em>Sema</em></a> looks at the AST node contents of these
+wrappers.</p>
+</div>
+<div class="section" id="the-ast-library">
+<span id="ast"></span><h2><a class="toc-backref" href="#id25">The AST Library</a><a class="headerlink" href="#the-ast-library" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="the-type-class-and-its-subclasses">
+<span id="type"></span><h3><a class="toc-backref" href="#id26">The <tt class="docutils literal"><span class="pre">Type</span></tt> class and its subclasses</a><a class="headerlink" href="#the-type-class-and-its-subclasses" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">Type</span></tt> class (and its subclasses) are an important part of the AST.
+Types are accessed through the <tt class="docutils literal"><span class="pre">ASTContext</span></tt> class, which implicitly creates
+and uniques them as they are needed.  Types have a couple of non-obvious
+features: 1) they do not capture type qualifiers like <tt class="docutils literal"><span class="pre">const</span></tt> or <tt class="docutils literal"><span class="pre">volatile</span></tt>
+(see <a class="reference internal" href="#qualtype"><em>QualType</em></a>), and 2) they implicitly capture typedef
+information.  Once created, types are immutable (unlike decls).</p>
+<p>Typedefs in C make semantic analysis a bit more complex than it would be without
+them.  The issue is that we want to capture typedef information and represent it
+in the AST perfectly, but the semantics of operations need to “see through”
+typedefs.  For example, consider this code:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">func</span><span class="p">()</span> <span class="p">{</span>
+  <span class="k">typedef</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">;</span>
+  <span class="n">foo</span> <span class="n">X</span><span class="p">,</span> <span class="o">*</span><span class="n">Y</span><span class="p">;</span>
+  <span class="k">typedef</span> <span class="n">foo</span> <span class="o">*</span><span class="n">bar</span><span class="p">;</span>
+  <span class="n">bar</span> <span class="n">Z</span><span class="p">;</span>
+  <span class="o">*</span><span class="n">X</span><span class="p">;</span> <span class="c1">// error</span>
+  <span class="o">**</span><span class="n">Y</span><span class="p">;</span> <span class="c1">// error</span>
+  <span class="o">**</span><span class="n">Z</span><span class="p">;</span> <span class="c1">// error</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>The code above is illegal, and thus we expect there to be diagnostics emitted
+on the annotated lines.  In this example, we expect to get:</p>
+<div class="highlight-c++"><div class="highlight"><pre>test.c:6:1: error: indirection requires pointer operand ('foo' invalid)
+  *X; // error
+  ^~
+test.c:7:1: error: indirection requires pointer operand ('foo' invalid)
+  **Y; // error
+  ^~~
+test.c:8:1: error: indirection requires pointer operand ('foo' invalid)
+  **Z; // error
+  ^~~
+</pre></div>
+</div>
+<p>While this example is somewhat silly, it illustrates the point: we want to
+retain typedef information where possible, so that we can emit errors about
+“<tt class="docutils literal"><span class="pre">std::string</span></tt>” instead of “<tt class="docutils literal"><span class="pre">std::basic_string<char,</span> <span class="pre">std:...</span></tt>”.  Doing this
+requires properly keeping typedef information (for example, the type of <tt class="docutils literal"><span class="pre">X</span></tt>
+is “<tt class="docutils literal"><span class="pre">foo</span></tt>”, not “<tt class="docutils literal"><span class="pre">int</span></tt>”), and requires properly propagating it through the
+various operators (for example, the type of <tt class="docutils literal"><span class="pre">*Y</span></tt> is “<tt class="docutils literal"><span class="pre">foo</span></tt>”, not
+“<tt class="docutils literal"><span class="pre">int</span></tt>”).  In order to retain this information, the type of these expressions
+is an instance of the <tt class="docutils literal"><span class="pre">TypedefType</span></tt> class, which indicates that the type of
+these expressions is a typedef for “<tt class="docutils literal"><span class="pre">foo</span></tt>”.</p>
+<p>Representing types like this is great for diagnostics, because the
+user-specified type is always immediately available.  There are two problems
+with this: first, various semantic checks need to make judgements about the
+<em>actual structure</em> of a type, ignoring typedefs.  Second, we need an efficient
+way to query whether two types are structurally identical to each other,
+ignoring typedefs.  The solution to both of these problems is the idea of
+canonical types.</p>
+<div class="section" id="canonical-types">
+<h4><a class="toc-backref" href="#id27">Canonical Types</a><a class="headerlink" href="#canonical-types" title="Permalink to this headline">¶</a></h4>
+<p>Every instance of the <tt class="docutils literal"><span class="pre">Type</span></tt> class contains a canonical type pointer.  For
+simple types with no typedefs involved (e.g., “<tt class="docutils literal"><span class="pre">int</span></tt>”, “<tt class="docutils literal"><span class="pre">int*</span></tt>”,
+“<tt class="docutils literal"><span class="pre">int**</span></tt>”), the type just points to itself.  For types that have a typedef
+somewhere in their structure (e.g., “<tt class="docutils literal"><span class="pre">foo</span></tt>”, “<tt class="docutils literal"><span class="pre">foo*</span></tt>”, “<tt class="docutils literal"><span class="pre">foo**</span></tt>”,
+“<tt class="docutils literal"><span class="pre">bar</span></tt>”), the canonical type pointer points to their structurally equivalent
+type without any typedefs (e.g., “<tt class="docutils literal"><span class="pre">int</span></tt>”, “<tt class="docutils literal"><span class="pre">int*</span></tt>”, “<tt class="docutils literal"><span class="pre">int**</span></tt>”, and
+“<tt class="docutils literal"><span class="pre">int*</span></tt>” respectively).</p>
+<p>This design provides a constant time operation (dereferencing the canonical type
+pointer) that gives us access to the structure of types.  For example, we can
+trivially tell that “<tt class="docutils literal"><span class="pre">bar</span></tt>” and “<tt class="docutils literal"><span class="pre">foo*</span></tt>” are the same type by dereferencing
+their canonical type pointers and doing a pointer comparison (they both point
+to the single “<tt class="docutils literal"><span class="pre">int*</span></tt>” type).</p>
+<p>Canonical types and typedef types bring up some complexities that must be
+carefully managed.  Specifically, the <tt class="docutils literal"><span class="pre">isa</span></tt>/<tt class="docutils literal"><span class="pre">cast</span></tt>/<tt class="docutils literal"><span class="pre">dyn_cast</span></tt> operators
+generally shouldn’t be used in code that is inspecting the AST.  For example,
+when type checking the indirection operator (unary “<tt class="docutils literal"><span class="pre">*</span></tt>” on a pointer), the
+type checker must verify that the operand has a pointer type.  It would not be
+correct to check that with “<tt class="docutils literal"><span class="pre">isa<PointerType>(SubExpr->getType())</span></tt>”, because
+this predicate would fail if the subexpression had a typedef type.</p>
+<p>The solution to this problem are a set of helper methods on <tt class="docutils literal"><span class="pre">Type</span></tt>, used to
+check their properties.  In this case, it would be correct to use
+“<tt class="docutils literal"><span class="pre">SubExpr->getType()->isPointerType()</span></tt>” to do the check.  This predicate will
+return true if the <em>canonical type is a pointer</em>, which is true any time the
+type is structurally a pointer type.  The only hard part here is remembering
+not to use the <tt class="docutils literal"><span class="pre">isa</span></tt>/<tt class="docutils literal"><span class="pre">cast</span></tt>/<tt class="docutils literal"><span class="pre">dyn_cast</span></tt> operations.</p>
+<p>The second problem we face is how to get access to the pointer type once we
+know it exists.  To continue the example, the result type of the indirection
+operator is the pointee type of the subexpression.  In order to determine the
+type, we need to get the instance of <tt class="docutils literal"><span class="pre">PointerType</span></tt> that best captures the
+typedef information in the program.  If the type of the expression is literally
+a <tt class="docutils literal"><span class="pre">PointerType</span></tt>, we can return that, otherwise we have to dig through the
+typedefs to find the pointer type.  For example, if the subexpression had type
+“<tt class="docutils literal"><span class="pre">foo*</span></tt>”, we could return that type as the result.  If the subexpression had
+type “<tt class="docutils literal"><span class="pre">bar</span></tt>”, we want to return “<tt class="docutils literal"><span class="pre">foo*</span></tt>” (note that we do <em>not</em> want
+“<tt class="docutils literal"><span class="pre">int*</span></tt>”).  In order to provide all of this, <tt class="docutils literal"><span class="pre">Type</span></tt> has a
+<tt class="docutils literal"><span class="pre">getAsPointerType()</span></tt> method that checks whether the type is structurally a
+<tt class="docutils literal"><span class="pre">PointerType</span></tt> and, if so, returns the best one.  If not, it returns a null
+pointer.</p>
+<p>This structure is somewhat mystical, but after meditating on it, it will make
+sense to you :).</p>
+</div>
+</div>
+<div class="section" id="the-qualtype-class">
+<span id="qualtype"></span><h3><a class="toc-backref" href="#id28">The <tt class="docutils literal"><span class="pre">QualType</span></tt> class</a><a class="headerlink" href="#the-qualtype-class" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">QualType</span></tt> class is designed as a trivial value class that is small,
+passed by-value and is efficient to query.  The idea of <tt class="docutils literal"><span class="pre">QualType</span></tt> is that it
+stores the type qualifiers (<tt class="docutils literal"><span class="pre">const</span></tt>, <tt class="docutils literal"><span class="pre">volatile</span></tt>, <tt class="docutils literal"><span class="pre">restrict</span></tt>, plus some
+extended qualifiers required by language extensions) separately from the types
+themselves.  <tt class="docutils literal"><span class="pre">QualType</span></tt> is conceptually a pair of “<tt class="docutils literal"><span class="pre">Type*</span></tt>” and the bits
+for these type qualifiers.</p>
+<p>By storing the type qualifiers as bits in the conceptual pair, it is extremely
+efficient to get the set of qualifiers on a <tt class="docutils literal"><span class="pre">QualType</span></tt> (just return the field
+of the pair), add a type qualifier (which is a trivial constant-time operation
+that sets a bit), and remove one or more type qualifiers (just return a
+<tt class="docutils literal"><span class="pre">QualType</span></tt> with the bitfield set to empty).</p>
+<p>Further, because the bits are stored outside of the type itself, we do not need
+to create duplicates of types with different sets of qualifiers (i.e. there is
+only a single heap allocated “<tt class="docutils literal"><span class="pre">int</span></tt>” type: “<tt class="docutils literal"><span class="pre">const</span> <span class="pre">int</span></tt>” and “<tt class="docutils literal"><span class="pre">volatile</span>
+<span class="pre">const</span> <span class="pre">int</span></tt>” both point to the same heap allocated “<tt class="docutils literal"><span class="pre">int</span></tt>” type).  This
+reduces the heap size used to represent bits and also means we do not have to
+consider qualifiers when uniquing types (<a class="reference internal" href="#type"><em>Type</em></a> does not even
+contain qualifiers).</p>
+<p>In practice, the two most common type qualifiers (<tt class="docutils literal"><span class="pre">const</span></tt> and <tt class="docutils literal"><span class="pre">restrict</span></tt>)
+are stored in the low bits of the pointer to the <tt class="docutils literal"><span class="pre">Type</span></tt> object, together with
+a flag indicating whether extended qualifiers are present (which must be
+heap-allocated).  This means that <tt class="docutils literal"><span class="pre">QualType</span></tt> is exactly the same size as a
+pointer.</p>
+</div>
+<div class="section" id="declaration-names">
+<span id="declarationname"></span><h3><a class="toc-backref" href="#id29">Declaration names</a><a class="headerlink" href="#declaration-names" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> class represents the name of a declaration in Clang.
+Declarations in the C family of languages can take several different forms.
+Most declarations are named by simple identifiers, e.g., “<tt class="docutils literal"><span class="pre">f</span></tt>” and “<tt class="docutils literal"><span class="pre">x</span></tt>” in
+the function declaration <tt class="docutils literal"><span class="pre">f(int</span> <span class="pre">x)</span></tt>.  In C++, declaration names can also name
+class constructors (“<tt class="docutils literal"><span class="pre">Class</span></tt>” in <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">Class</span> <span class="pre">{</span> <span class="pre">Class();</span> <span class="pre">}</span></tt>), class
+destructors (“<tt class="docutils literal"><span class="pre">~Class</span></tt>”), overloaded operator names (“<tt class="docutils literal"><span class="pre">operator+</span></tt>”), and
+conversion functions (“<tt class="docutils literal"><span class="pre">operator</span> <span class="pre">void</span> <span class="pre">const</span> <span class="pre">*</span></tt>”).  In Objective-C,
+declaration names can refer to the names of Objective-C methods, which involve
+the method name and the parameters, collectively called a <em>selector</em>, e.g.,
+“<tt class="docutils literal"><span class="pre">setWidth:height:</span></tt>”.  Since all of these kinds of entities — variables,
+functions, Objective-C methods, C++ constructors, destructors, and operators
+— are represented as subclasses of Clang’s common <tt class="docutils literal"><span class="pre">NamedDecl</span></tt> class,
+<tt class="docutils literal"><span class="pre">DeclarationName</span></tt> is designed to efficiently represent any kind of name.</p>
+<p>Given a <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> <tt class="docutils literal"><span class="pre">N</span></tt>, <tt class="docutils literal"><span class="pre">N.getNameKind()</span></tt> will produce a value
+that describes what kind of name <tt class="docutils literal"><span class="pre">N</span></tt> stores.  There are 10 options (all of
+the names are inside the <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> class).</p>
+<p><tt class="docutils literal"><span class="pre">Identifier</span></tt></p>
+<blockquote>
+<div>The name is a simple identifier.  Use <tt class="docutils literal"><span class="pre">N.getAsIdentifierInfo()</span></tt> to retrieve
+the corresponding <tt class="docutils literal"><span class="pre">IdentifierInfo*</span></tt> pointing to the actual identifier.</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">ObjCZeroArgSelector</span></tt>, <tt class="docutils literal"><span class="pre">ObjCOneArgSelector</span></tt>, <tt class="docutils literal"><span class="pre">ObjCMultiArgSelector</span></tt></p>
+<blockquote>
+<div>The name is an Objective-C selector, which can be retrieved as a <tt class="docutils literal"><span class="pre">Selector</span></tt>
+instance via <tt class="docutils literal"><span class="pre">N.getObjCSelector()</span></tt>.  The three possible name kinds for
+Objective-C reflect an optimization within the <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> class:
+both zero- and one-argument selectors are stored as a masked
+<tt class="docutils literal"><span class="pre">IdentifierInfo</span></tt> pointer, and therefore require very little space, since
+zero- and one-argument selectors are far more common than multi-argument
+selectors (which use a different structure).</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">CXXConstructorName</span></tt></p>
+<blockquote>
+<div>The name is a C++ constructor name.  Use <tt class="docutils literal"><span class="pre">N.getCXXNameType()</span></tt> to retrieve
+the <a class="reference internal" href="#qualtype"><em>type</em></a> that this constructor is meant to construct.  The
+type is always the canonical type, since all constructors for a given type
+have the same name.</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">CXXDestructorName</span></tt></p>
+<blockquote>
+<div>The name is a C++ destructor name.  Use <tt class="docutils literal"><span class="pre">N.getCXXNameType()</span></tt> to retrieve
+the <a class="reference internal" href="#qualtype"><em>type</em></a> whose destructor is being named.  This type is
+always a canonical type.</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">CXXConversionFunctionName</span></tt></p>
+<blockquote>
+<div>The name is a C++ conversion function.  Conversion functions are named
+according to the type they convert to, e.g., “<tt class="docutils literal"><span class="pre">operator</span> <span class="pre">void</span> <span class="pre">const</span> <span class="pre">*</span></tt>”.
+Use <tt class="docutils literal"><span class="pre">N.getCXXNameType()</span></tt> to retrieve the type that this conversion function
+converts to.  This type is always a canonical type.</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">CXXOperatorName</span></tt></p>
+<blockquote>
+<div>The name is a C++ overloaded operator name.  Overloaded operators are named
+according to their spelling, e.g., “<tt class="docutils literal"><span class="pre">operator+</span></tt>” or “<tt class="docutils literal"><span class="pre">operator</span> <span class="pre">new</span> <span class="pre">[]</span></tt>”.
+Use <tt class="docutils literal"><span class="pre">N.getCXXOverloadedOperator()</span></tt> to retrieve the overloaded operator (a
+value of type <tt class="docutils literal"><span class="pre">OverloadedOperatorKind</span></tt>).</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">CXXLiteralOperatorName</span></tt></p>
+<blockquote>
+<div>The name is a C++11 user defined literal operator.  User defined
+Literal operators are named according to the suffix they define,
+e.g., “<tt class="docutils literal"><span class="pre">_foo</span></tt>” for “<tt class="docutils literal"><span class="pre">operator</span> <span class="pre">""</span> <span class="pre">_foo</span></tt>”.  Use
+<tt class="docutils literal"><span class="pre">N.getCXXLiteralIdentifier()</span></tt> to retrieve the corresponding
+<tt class="docutils literal"><span class="pre">IdentifierInfo*</span></tt> pointing to the identifier.</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">CXXUsingDirective</span></tt></p>
+<blockquote>
+<div>The name is a C++ using directive.  Using directives are not really
+NamedDecls, in that they all have the same name, but they are
+implemented as such in order to store them in DeclContext
+effectively.</div></blockquote>
+<p><tt class="docutils literal"><span class="pre">DeclarationName</span></tt>s are cheap to create, copy, and compare.  They require
+only a single pointer’s worth of storage in the common cases (identifiers,
+zero- and one-argument Objective-C selectors) and use dense, uniqued storage
+for the other kinds of names.  Two <tt class="docutils literal"><span class="pre">DeclarationName</span></tt>s can be compared for
+equality (<tt class="docutils literal"><span class="pre">==</span></tt>, <tt class="docutils literal"><span class="pre">!=</span></tt>) using a simple bitwise comparison, can be ordered
+with <tt class="docutils literal"><span class="pre"><</span></tt>, <tt class="docutils literal"><span class="pre">></span></tt>, <tt class="docutils literal"><span class="pre"><=</span></tt>, and <tt class="docutils literal"><span class="pre">>=</span></tt> (which provide a lexicographical ordering
+for normal identifiers but an unspecified ordering for other kinds of names),
+and can be placed into LLVM <tt class="docutils literal"><span class="pre">DenseMap</span></tt>s and <tt class="docutils literal"><span class="pre">DenseSet</span></tt>s.</p>
+<p><tt class="docutils literal"><span class="pre">DeclarationName</span></tt> instances can be created in different ways depending on
+what kind of name the instance will store.  Normal identifiers
+(<tt class="docutils literal"><span class="pre">IdentifierInfo</span></tt> pointers) and Objective-C selectors (<tt class="docutils literal"><span class="pre">Selector</span></tt>) can be
+implicitly converted to <tt class="docutils literal"><span class="pre">DeclarationNames</span></tt>.  Names for C++ constructors,
+destructors, conversion functions, and overloaded operators can be retrieved
+from the <tt class="docutils literal"><span class="pre">DeclarationNameTable</span></tt>, an instance of which is available as
+<tt class="docutils literal"><span class="pre">ASTContext::DeclarationNames</span></tt>.  The member functions
+<tt class="docutils literal"><span class="pre">getCXXConstructorName</span></tt>, <tt class="docutils literal"><span class="pre">getCXXDestructorName</span></tt>,
+<tt class="docutils literal"><span class="pre">getCXXConversionFunctionName</span></tt>, and <tt class="docutils literal"><span class="pre">getCXXOperatorName</span></tt>, respectively,
+return <tt class="docutils literal"><span class="pre">DeclarationName</span></tt> instances for the four kinds of C++ special function
+names.</p>
+</div>
+<div class="section" id="declaration-contexts">
+<span id="declcontext"></span><h3><a class="toc-backref" href="#id30">Declaration contexts</a><a class="headerlink" href="#declaration-contexts" title="Permalink to this headline">¶</a></h3>
+<p>Every declaration in a program exists within some <em>declaration context</em>, such
+as a translation unit, namespace, class, or function.  Declaration contexts in
+Clang are represented by the <tt class="docutils literal"><span class="pre">DeclContext</span></tt> class, from which the various
+declaration-context AST nodes (<tt class="docutils literal"><span class="pre">TranslationUnitDecl</span></tt>, <tt class="docutils literal"><span class="pre">NamespaceDecl</span></tt>,
+<tt class="docutils literal"><span class="pre">RecordDecl</span></tt>, <tt class="docutils literal"><span class="pre">FunctionDecl</span></tt>, etc.) will derive.  The <tt class="docutils literal"><span class="pre">DeclContext</span></tt> class
+provides several facilities common to each declaration context:</p>
+<p>Source-centric vs. Semantics-centric View of Declarations</p>
+<blockquote>
+<div><tt class="docutils literal"><span class="pre">DeclContext</span></tt> provides two views of the declarations stored within a
+declaration context.  The source-centric view accurately represents the
+program source code as written, including multiple declarations of entities
+where present (see the section <a class="reference internal" href="#redeclarations"><em>Redeclarations and Overloads</em></a>), while the semantics-centric view represents the program
+semantics.  The two views are kept synchronized by semantic analysis while
+the ASTs are being constructed.</div></blockquote>
+<p>Storage of declarations within that context</p>
+<blockquote>
+<div>Every declaration context can contain some number of declarations.  For
+example, a C++ class (represented by <tt class="docutils literal"><span class="pre">RecordDecl</span></tt>) contains various member
+functions, fields, nested types, and so on.  All of these declarations will
+be stored within the <tt class="docutils literal"><span class="pre">DeclContext</span></tt>, and one can iterate over the
+declarations via [<tt class="docutils literal"><span class="pre">DeclContext::decls_begin()</span></tt>,
+<tt class="docutils literal"><span class="pre">DeclContext::decls_end()</span></tt>).  This mechanism provides the source-centric
+view of declarations in the context.</div></blockquote>
+<p>Lookup of declarations within that context</p>
+<blockquote>
+<div>The <tt class="docutils literal"><span class="pre">DeclContext</span></tt> structure provides efficient name lookup for names within
+that declaration context.  For example, if <tt class="docutils literal"><span class="pre">N</span></tt> is a namespace we can look
+for the name <tt class="docutils literal"><span class="pre">N::f</span></tt> using <tt class="docutils literal"><span class="pre">DeclContext::lookup</span></tt>.  The lookup itself is
+based on a lazily-constructed array (for declaration contexts with a small
+number of declarations) or hash table (for declaration contexts with more
+declarations).  The lookup operation provides the semantics-centric view of
+the declarations in the context.</div></blockquote>
+<p>Ownership of declarations</p>
+<blockquote>
+<div>The <tt class="docutils literal"><span class="pre">DeclContext</span></tt> owns all of the declarations that were declared within
+its declaration context, and is responsible for the management of their
+memory as well as their (de-)serialization.</div></blockquote>
+<p>All declarations are stored within a declaration context, and one can query
+information about the context in which each declaration lives.  One can
+retrieve the <tt class="docutils literal"><span class="pre">DeclContext</span></tt> that contains a particular <tt class="docutils literal"><span class="pre">Decl</span></tt> using
+<tt class="docutils literal"><span class="pre">Decl::getDeclContext</span></tt>.  However, see the section
+<a class="reference internal" href="#lexicalandsemanticcontexts"><em>Lexical and Semantic Contexts</em></a> for more information about how to interpret
+this context information.</p>
+<div class="section" id="redeclarations-and-overloads">
+<span id="redeclarations"></span><h4><a class="toc-backref" href="#id31">Redeclarations and Overloads</a><a class="headerlink" href="#redeclarations-and-overloads" title="Permalink to this headline">¶</a></h4>
+<p>Within a translation unit, it is common for an entity to be declared several
+times.  For example, we might declare a function “<tt class="docutils literal"><span class="pre">f</span></tt>” and then later
+re-declare it as part of an inlined definition:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">f</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">,</span> <span class="kt">int</span> <span class="n">z</span> <span class="o">=</span> <span class="mi">1</span><span class="p">);</span>
+
+<span class="kr">inline</span> <span class="kt">void</span> <span class="nf">f</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">,</span> <span class="kt">int</span> <span class="n">z</span><span class="p">)</span> <span class="p">{</span> <span class="cm">/* ...  */</span> <span class="p">}</span>
+</pre></div>
+</div>
+<p>The representation of “<tt class="docutils literal"><span class="pre">f</span></tt>” differs in the source-centric and
+semantics-centric views of a declaration context.  In the source-centric view,
+all redeclarations will be present, in the order they occurred in the source
+code, making this view suitable for clients that wish to see the structure of
+the source code.  In the semantics-centric view, only the most recent “<tt class="docutils literal"><span class="pre">f</span></tt>”
+will be found by the lookup, since it effectively replaces the first
+declaration of “<tt class="docutils literal"><span class="pre">f</span></tt>”.</p>
+<p>In the semantics-centric view, overloading of functions is represented
+explicitly.  For example, given two declarations of a function “<tt class="docutils literal"><span class="pre">g</span></tt>” that are
+overloaded, e.g.,</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">g</span><span class="p">();</span>
+<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>the <tt class="docutils literal"><span class="pre">DeclContext::lookup</span></tt> operation will return a
+<tt class="docutils literal"><span class="pre">DeclContext::lookup_result</span></tt> that contains a range of iterators over
+declarations of “<tt class="docutils literal"><span class="pre">g</span></tt>”.  Clients that perform semantic analysis on a program
+that is not concerned with the actual source code will primarily use this
+semantics-centric view.</p>
+</div>
+<div class="section" id="lexical-and-semantic-contexts">
+<span id="lexicalandsemanticcontexts"></span><h4><a class="toc-backref" href="#id32">Lexical and Semantic Contexts</a><a class="headerlink" href="#lexical-and-semantic-contexts" title="Permalink to this headline">¶</a></h4>
+<p>Each declaration has two potentially different declaration contexts: a
+<em>lexical</em> context, which corresponds to the source-centric view of the
+declaration context, and a <em>semantic</em> context, which corresponds to the
+semantics-centric view.  The lexical context is accessible via
+<tt class="docutils literal"><span class="pre">Decl::getLexicalDeclContext</span></tt> while the semantic context is accessible via
+<tt class="docutils literal"><span class="pre">Decl::getDeclContext</span></tt>, both of which return <tt class="docutils literal"><span class="pre">DeclContext</span></tt> pointers.  For
+most declarations, the two contexts are identical.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">X</span> <span class="p">{</span>
+<span class="nl">public:</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">);</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>Here, the semantic and lexical contexts of <tt class="docutils literal"><span class="pre">X::f</span></tt> are the <tt class="docutils literal"><span class="pre">DeclContext</span></tt>
+associated with the class <tt class="docutils literal"><span class="pre">X</span></tt> (itself stored as a <tt class="docutils literal"><span class="pre">RecordDecl</span></tt> AST node).
+However, we can now define <tt class="docutils literal"><span class="pre">X::f</span></tt> out-of-line:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="n">X</span><span class="o">::</span><span class="n">f</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span> <span class="o">=</span> <span class="mi">17</span><span class="p">)</span> <span class="p">{</span> <span class="cm">/* ...  */</span> <span class="p">}</span>
+</pre></div>
+</div>
+<p>This definition of “<tt class="docutils literal"><span class="pre">f</span></tt>” has different lexical and semantic contexts.  The
+lexical context corresponds to the declaration context in which the actual
+declaration occurred in the source code, e.g., the translation unit containing
+<tt class="docutils literal"><span class="pre">X</span></tt>.  Thus, this declaration of <tt class="docutils literal"><span class="pre">X::f</span></tt> can be found by traversing the
+declarations provided by [<tt class="docutils literal"><span class="pre">decls_begin()</span></tt>, <tt class="docutils literal"><span class="pre">decls_end()</span></tt>) in the
+translation unit.</p>
+<p>The semantic context of <tt class="docutils literal"><span class="pre">X::f</span></tt> corresponds to the class <tt class="docutils literal"><span class="pre">X</span></tt>, since this
+member function is (semantically) a member of <tt class="docutils literal"><span class="pre">X</span></tt>.  Lookup of the name <tt class="docutils literal"><span class="pre">f</span></tt>
+into the <tt class="docutils literal"><span class="pre">DeclContext</span></tt> associated with <tt class="docutils literal"><span class="pre">X</span></tt> will then return the definition
+of <tt class="docutils literal"><span class="pre">X::f</span></tt> (including information about the default argument).</p>
+</div>
+<div class="section" id="transparent-declaration-contexts">
+<h4><a class="toc-backref" href="#id33">Transparent Declaration Contexts</a><a class="headerlink" href="#transparent-declaration-contexts" title="Permalink to this headline">¶</a></h4>
+<p>In C and C++, there are several contexts in which names that are logically
+declared inside another declaration will actually “leak” out into the enclosing
+scope from the perspective of name lookup.  The most obvious instance of this
+behavior is in enumeration types, e.g.,</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">enum</span> <span class="n">Color</span> <span class="p">{</span>
+  <span class="n">Red</span><span class="p">,</span>
+  <span class="n">Green</span><span class="p">,</span>
+  <span class="n">Blue</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>Here, <tt class="docutils literal"><span class="pre">Color</span></tt> is an enumeration, which is a declaration context that contains
+the enumerators <tt class="docutils literal"><span class="pre">Red</span></tt>, <tt class="docutils literal"><span class="pre">Green</span></tt>, and <tt class="docutils literal"><span class="pre">Blue</span></tt>.  Thus, traversing the list of
+declarations contained in the enumeration <tt class="docutils literal"><span class="pre">Color</span></tt> will yield <tt class="docutils literal"><span class="pre">Red</span></tt>,
+<tt class="docutils literal"><span class="pre">Green</span></tt>, and <tt class="docutils literal"><span class="pre">Blue</span></tt>.  However, outside of the scope of <tt class="docutils literal"><span class="pre">Color</span></tt> one can
+name the enumerator <tt class="docutils literal"><span class="pre">Red</span></tt> without qualifying the name, e.g.,</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Color</span> <span class="n">c</span> <span class="o">=</span> <span class="n">Red</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>There are other entities in C++ that provide similar behavior.  For example,
+linkage specifications that use curly braces:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">extern</span> <span class="s">"C"</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+  <span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+<span class="p">}</span>
+<span class="c1">// f and g are visible here</span>
+</pre></div>
+</div>
+<p>For source-level accuracy, we treat the linkage specification and enumeration
+type as a declaration context in which its enclosed declarations (“<tt class="docutils literal"><span class="pre">Red</span></tt>”,
+“<tt class="docutils literal"><span class="pre">Green</span></tt>”, and “<tt class="docutils literal"><span class="pre">Blue</span></tt>”; “<tt class="docutils literal"><span class="pre">f</span></tt>” and “<tt class="docutils literal"><span class="pre">g</span></tt>”) are declared.  However, these
+declarations are visible outside of the scope of the declaration context.</p>
+<p>These language features (and several others, described below) have roughly the
+same set of requirements: declarations are declared within a particular lexical
+context, but the declarations are also found via name lookup in scopes
+enclosing the declaration itself.  This feature is implemented via
+<em>transparent</em> declaration contexts (see
+<tt class="docutils literal"><span class="pre">DeclContext::isTransparentContext()</span></tt>), whose declarations are visible in the
+nearest enclosing non-transparent declaration context.  This means that the
+lexical context of the declaration (e.g., an enumerator) will be the
+transparent <tt class="docutils literal"><span class="pre">DeclContext</span></tt> itself, as will the semantic context, but the
+declaration will be visible in every outer context up to and including the
+first non-transparent declaration context (since transparent declaration
+contexts can be nested).</p>
+<p>The transparent <tt class="docutils literal"><span class="pre">DeclContext</span></tt>s are:</p>
+<ul>
+<li><p class="first">Enumerations (but not C++11 “scoped enumerations”):</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">enum</span> <span class="n">Color</span> <span class="p">{</span>
+  <span class="n">Red</span><span class="p">,</span>
+  <span class="n">Green</span><span class="p">,</span>
+  <span class="n">Blue</span>
+<span class="p">};</span>
+<span class="c1">// Red, Green, and Blue are in scope</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">C++ linkage specifications:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">extern</span> <span class="s">"C"</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+  <span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+<span class="p">}</span>
+<span class="c1">// f and g are in scope</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">Anonymous unions and structs:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">LookupTable</span> <span class="p">{</span>
+  <span class="kt">bool</span> <span class="n">IsVector</span><span class="p">;</span>
+  <span class="k">union</span> <span class="p">{</span>
+    <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o"><</span><span class="n">Item</span><span class="o">></span> <span class="o">*</span><span class="n">Vector</span><span class="p">;</span>
+    <span class="n">std</span><span class="o">::</span><span class="n">set</span><span class="o"><</span><span class="n">Item</span><span class="o">></span> <span class="o">*</span><span class="n">Set</span><span class="p">;</span>
+  <span class="p">};</span>
+<span class="p">};</span>
+
+<span class="n">LookupTable</span> <span class="n">LT</span><span class="p">;</span>
+<span class="n">LT</span><span class="p">.</span><span class="n">Vector</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="c1">// Okay: finds Vector inside the unnamed union</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">C++11 inline namespaces:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">namespace</span> <span class="n">mylib</span> <span class="p">{</span>
+  <span class="kr">inline</span> <span class="k">namespace</span> <span class="n">debug</span> <span class="p">{</span>
+    <span class="k">class</span> <span class="nc">X</span><span class="p">;</span>
+  <span class="p">}</span>
+<span class="p">}</span>
+<span class="n">mylib</span><span class="o">::</span><span class="n">X</span> <span class="o">*</span><span class="n">xp</span><span class="p">;</span> <span class="c1">// okay: mylib::X refers to mylib::debug::X</span>
+</pre></div>
+</div>
+</li>
+</ul>
+</div>
+<div class="section" id="multiply-defined-declaration-contexts">
+<span id="multideclcontext"></span><h4><a class="toc-backref" href="#id34">Multiply-Defined Declaration Contexts</a><a class="headerlink" href="#multiply-defined-declaration-contexts" title="Permalink to this headline">¶</a></h4>
+<p>C++ namespaces have the interesting — and, so far, unique — property that
+the namespace can be defined multiple times, and the declarations provided by
+each namespace definition are effectively merged (from the semantic point of
+view).  For example, the following two code snippets are semantically
+indistinguishable:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// Snippet #1:</span>
+<span class="k">namespace</span> <span class="n">N</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">();</span>
+<span class="p">}</span>
+<span class="k">namespace</span> <span class="n">N</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+<span class="p">}</span>
+
+<span class="c1">// Snippet #2:</span>
+<span class="k">namespace</span> <span class="n">N</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">();</span>
+  <span class="kt">void</span> <span class="nf">f</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>In Clang’s representation, the source-centric view of declaration contexts will
+actually have two separate <tt class="docutils literal"><span class="pre">NamespaceDecl</span></tt> nodes in Snippet #1, each of which
+is a declaration context that contains a single declaration of “<tt class="docutils literal"><span class="pre">f</span></tt>”.
+However, the semantics-centric view provided by name lookup into the namespace
+<tt class="docutils literal"><span class="pre">N</span></tt> for “<tt class="docutils literal"><span class="pre">f</span></tt>” will return a <tt class="docutils literal"><span class="pre">DeclContext::lookup_result</span></tt> that contains a
+range of iterators over declarations of “<tt class="docutils literal"><span class="pre">f</span></tt>”.</p>
+<p><tt class="docutils literal"><span class="pre">DeclContext</span></tt> manages multiply-defined declaration contexts internally.  The
+function <tt class="docutils literal"><span class="pre">DeclContext::getPrimaryContext</span></tt> retrieves the “primary” context for
+a given <tt class="docutils literal"><span class="pre">DeclContext</span></tt> instance, which is the <tt class="docutils literal"><span class="pre">DeclContext</span></tt> responsible for
+maintaining the lookup table used for the semantics-centric view.  Given the
+primary context, one can follow the chain of <tt class="docutils literal"><span class="pre">DeclContext</span></tt> nodes that define
+additional declarations via <tt class="docutils literal"><span class="pre">DeclContext::getNextContext</span></tt>.  Note that these
+functions are used internally within the lookup and insertion methods of the
+<tt class="docutils literal"><span class="pre">DeclContext</span></tt>, so the vast majority of clients can ignore them.</p>
+</div>
+</div>
+<div class="section" id="the-cfg-class">
+<span id="cfg"></span><h3><a class="toc-backref" href="#id35">The <tt class="docutils literal"><span class="pre">CFG</span></tt> class</a><a class="headerlink" href="#the-cfg-class" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">CFG</span></tt> class is designed to represent a source-level control-flow graph
+for a single statement (<tt class="docutils literal"><span class="pre">Stmt*</span></tt>).  Typically instances of <tt class="docutils literal"><span class="pre">CFG</span></tt> are
+constructed for function bodies (usually an instance of <tt class="docutils literal"><span class="pre">CompoundStmt</span></tt>), but
+can also be instantiated to represent the control-flow of any class that
+subclasses <tt class="docutils literal"><span class="pre">Stmt</span></tt>, which includes simple expressions.  Control-flow graphs
+are especially useful for performing <a class="reference external" href="http://en.wikipedia.org/wiki/Data_flow_analysis#Sensitivities">flow- or path-sensitive</a> program
+analyses on a given function.</p>
+<div class="section" id="basic-blocks">
+<h4><a class="toc-backref" href="#id36">Basic Blocks</a><a class="headerlink" href="#basic-blocks" title="Permalink to this headline">¶</a></h4>
+<p>Concretely, an instance of <tt class="docutils literal"><span class="pre">CFG</span></tt> is a collection of basic blocks.  Each basic
+block is an instance of <tt class="docutils literal"><span class="pre">CFGBlock</span></tt>, which simply contains an ordered sequence
+of <tt class="docutils literal"><span class="pre">Stmt*</span></tt> (each referring to statements in the AST).  The ordering of
+statements within a block indicates unconditional flow of control from one
+statement to the next.  <a class="reference internal" href="#conditionalcontrolflow"><em>Conditional control-flow</em></a> is represented using edges between basic blocks.  The
+statements within a given <tt class="docutils literal"><span class="pre">CFGBlock</span></tt> can be traversed using the
+<tt class="docutils literal"><span class="pre">CFGBlock::*iterator</span></tt> interface.</p>
+<p>A <tt class="docutils literal"><span class="pre">CFG</span></tt> object owns the instances of <tt class="docutils literal"><span class="pre">CFGBlock</span></tt> within the control-flow
+graph it represents.  Each <tt class="docutils literal"><span class="pre">CFGBlock</span></tt> within a CFG is also uniquely numbered
+(accessible via <tt class="docutils literal"><span class="pre">CFGBlock::getBlockID()</span></tt>).  Currently the number is based on
+the ordering the blocks were created, but no assumptions should be made on how
+<tt class="docutils literal"><span class="pre">CFGBlocks</span></tt> are numbered other than their numbers are unique and that they
+are numbered from 0..N-1 (where N is the number of basic blocks in the CFG).</p>
+</div>
+<div class="section" id="entry-and-exit-blocks">
+<h4><a class="toc-backref" href="#id37">Entry and Exit Blocks</a><a class="headerlink" href="#entry-and-exit-blocks" title="Permalink to this headline">¶</a></h4>
+<p>Each instance of <tt class="docutils literal"><span class="pre">CFG</span></tt> contains two special blocks: an <em>entry</em> block
+(accessible via <tt class="docutils literal"><span class="pre">CFG::getEntry()</span></tt>), which has no incoming edges, and an
+<em>exit</em> block (accessible via <tt class="docutils literal"><span class="pre">CFG::getExit()</span></tt>), which has no outgoing edges.
+Neither block contains any statements, and they serve the role of providing a
+clear entrance and exit for a body of code such as a function body.  The
+presence of these empty blocks greatly simplifies the implementation of many
+analyses built on top of CFGs.</p>
+</div>
+<div class="section" id="conditional-control-flow">
+<span id="conditionalcontrolflow"></span><h4><a class="toc-backref" href="#id38">Conditional Control-Flow</a><a class="headerlink" href="#conditional-control-flow" title="Permalink to this headline">¶</a></h4>
+<p>Conditional control-flow (such as those induced by if-statements and loops) is
+represented as edges between <tt class="docutils literal"><span class="pre">CFGBlocks</span></tt>.  Because different C language
+constructs can induce control-flow, each <tt class="docutils literal"><span class="pre">CFGBlock</span></tt> also records an extra
+<tt class="docutils literal"><span class="pre">Stmt*</span></tt> that represents the <em>terminator</em> of the block.  A terminator is
+simply the statement that caused the control-flow, and is used to identify the
+nature of the conditional control-flow between blocks.  For example, in the
+case of an if-statement, the terminator refers to the <tt class="docutils literal"><span class="pre">IfStmt</span></tt> object in the
+AST that represented the given branch.</p>
+<p>To illustrate, consider the following code example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">x</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
+  <span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="mi">2</span><span class="p">)</span>
+    <span class="n">x</span><span class="o">++</span><span class="p">;</span>
+  <span class="k">else</span> <span class="p">{</span>
+    <span class="n">x</span> <span class="o">+=</span> <span class="mi">2</span><span class="p">;</span>
+    <span class="n">x</span> <span class="o">*=</span> <span class="mi">2</span><span class="p">;</span>
+  <span class="p">}</span>
+
+  <span class="k">return</span> <span class="n">x</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>After invoking the parser+semantic analyzer on this code fragment, the AST of
+the body of <tt class="docutils literal"><span class="pre">foo</span></tt> is referenced by a single <tt class="docutils literal"><span class="pre">Stmt*</span></tt>.  We can then construct
+an instance of <tt class="docutils literal"><span class="pre">CFG</span></tt> representing the control-flow graph of this function
+body by single call to a static class method:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Stmt</span> <span class="o">*</span><span class="n">FooBody</span> <span class="o">=</span> <span class="p">...</span>
+<span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o"><</span><span class="n">CFG</span><span class="o">></span> <span class="n">FooCFG</span> <span class="o">=</span> <span class="n">CFG</span><span class="o">::</span><span class="n">buildCFG</span><span class="p">(</span><span class="n">FooBody</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>Along with providing an interface to iterate over its <tt class="docutils literal"><span class="pre">CFGBlocks</span></tt>, the
+<tt class="docutils literal"><span class="pre">CFG</span></tt> class also provides methods that are useful for debugging and
+visualizing CFGs.  For example, the method <tt class="docutils literal"><span class="pre">CFG::dump()</span></tt> dumps a
+pretty-printed version of the CFG to standard error.  This is especially useful
+when one is using a debugger such as gdb.  For example, here is the output of
+<tt class="docutils literal"><span class="pre">FooCFG->dump()</span></tt>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="p">[</span> <span class="n">B5</span> <span class="p">(</span><span class="n">ENTRY</span><span class="p">)</span> <span class="p">]</span>
+   <span class="n">Predecessors</span> <span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">:</span>
+   <span class="n">Successors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B4</span>
+
+<span class="p">[</span> <span class="n">B4</span> <span class="p">]</span>
+   <span class="mi">1</span><span class="o">:</span> <span class="n">x</span> <span class="o">=</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span>
+   <span class="mi">2</span><span class="o">:</span> <span class="p">(</span><span class="n">x</span> <span class="o">></span> <span class="mi">2</span><span class="p">)</span>
+   <span class="nl">T:</span> <span class="k">if</span> <span class="p">[</span><span class="n">B4</span><span class="mf">.2</span><span class="p">]</span>
+   <span class="n">Predecessors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B5</span>
+   <span class="n">Successors</span> <span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">:</span> <span class="n">B3</span> <span class="n">B2</span>
+
+<span class="p">[</span> <span class="n">B3</span> <span class="p">]</span>
+   <span class="mi">1</span><span class="o">:</span> <span class="n">x</span><span class="o">++</span>
+   <span class="n">Predecessors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B4</span>
+   <span class="n">Successors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B1</span>
+
+<span class="p">[</span> <span class="n">B2</span> <span class="p">]</span>
+   <span class="mi">1</span><span class="o">:</span> <span class="n">x</span> <span class="o">+=</span> <span class="mi">2</span>
+   <span class="mi">2</span><span class="o">:</span> <span class="n">x</span> <span class="o">*=</span> <span class="mi">2</span>
+   <span class="n">Predecessors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B4</span>
+   <span class="n">Successors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B1</span>
+
+<span class="p">[</span> <span class="n">B1</span> <span class="p">]</span>
+   <span class="mi">1</span><span class="o">:</span> <span class="k">return</span> <span class="n">x</span><span class="p">;</span>
+   <span class="n">Predecessors</span> <span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">:</span> <span class="n">B2</span> <span class="n">B3</span>
+   <span class="n">Successors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B0</span>
+
+<span class="p">[</span> <span class="n">B0</span> <span class="p">(</span><span class="n">EXIT</span><span class="p">)</span> <span class="p">]</span>
+   <span class="n">Predecessors</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">:</span> <span class="n">B1</span>
+   <span class="n">Successors</span> <span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">:</span>
+</pre></div>
+</div>
+<p>For each block, the pretty-printed output displays for each block the number of
+<em>predecessor</em> blocks (blocks that have outgoing control-flow to the given
+block) and <em>successor</em> blocks (blocks that have control-flow that have incoming
+control-flow from the given block).  We can also clearly see the special entry
+and exit blocks at the beginning and end of the pretty-printed output.  For the
+entry block (block B5), the number of predecessor blocks is 0, while for the
+exit block (block B0) the number of successor blocks is 0.</p>
+<p>The most interesting block here is B4, whose outgoing control-flow represents
+the branching caused by the sole if-statement in <tt class="docutils literal"><span class="pre">foo</span></tt>.  Of particular
+interest is the second statement in the block, <tt class="docutils literal"><span class="pre">(x</span> <span class="pre">></span> <span class="pre">2)</span></tt>, and the terminator,
+printed as <tt class="docutils literal"><span class="pre">if</span> <span class="pre">[B4.2]</span></tt>.  The second statement represents the evaluation of
+the condition of the if-statement, which occurs before the actual branching of
+control-flow.  Within the <tt class="docutils literal"><span class="pre">CFGBlock</span></tt> for B4, the <tt class="docutils literal"><span class="pre">Stmt*</span></tt> for the second
+statement refers to the actual expression in the AST for <tt class="docutils literal"><span class="pre">(x</span> <span class="pre">></span> <span class="pre">2)</span></tt>.  Thus
+pointers to subclasses of <tt class="docutils literal"><span class="pre">Expr</span></tt> can appear in the list of statements in a
+block, and not just subclasses of <tt class="docutils literal"><span class="pre">Stmt</span></tt> that refer to proper C statements.</p>
+<p>The terminator of block B4 is a pointer to the <tt class="docutils literal"><span class="pre">IfStmt</span></tt> object in the AST.
+The pretty-printer outputs <tt class="docutils literal"><span class="pre">if</span> <span class="pre">[B4.2]</span></tt> because the condition expression of
+the if-statement has an actual place in the basic block, and thus the
+terminator is essentially <em>referring</em> to the expression that is the second
+statement of block B4 (i.e., B4.2).  In this manner, conditions for
+control-flow (which also includes conditions for loops and switch statements)
+are hoisted into the actual basic block.</p>
+</div>
+</div>
+<div class="section" id="constant-folding-in-the-clang-ast">
+<h3><a class="toc-backref" href="#id39">Constant Folding in the Clang AST</a><a class="headerlink" href="#constant-folding-in-the-clang-ast" title="Permalink to this headline">¶</a></h3>
+<p>There are several places where constants and constant folding matter a lot to
+the Clang front-end.  First, in general, we prefer the AST to retain the source
+code as close to how the user wrote it as possible.  This means that if they
+wrote “<tt class="docutils literal"><span class="pre">5+4</span></tt>”, we want to keep the addition and two constants in the AST, we
+don’t want to fold to “<tt class="docutils literal"><span class="pre">9</span></tt>”.  This means that constant folding in various
+ways turns into a tree walk that needs to handle the various cases.</p>
+<p>However, there are places in both C and C++ that require constants to be
+folded.  For example, the C standard defines what an “integer constant
+expression” (i-c-e) is with very precise and specific requirements.  The
+language then requires i-c-e’s in a lot of places (for example, the size of a
+bitfield, the value for a case statement, etc).  For these, we have to be able
+to constant fold the constants, to do semantic checks (e.g., verify bitfield
+size is non-negative and that case statements aren’t duplicated).  We aim for
+Clang to be very pedantic about this, diagnosing cases when the code does not
+use an i-c-e where one is required, but accepting the code unless running with
+<tt class="docutils literal"><span class="pre">-pedantic-errors</span></tt>.</p>
+<p>Things get a little bit more tricky when it comes to compatibility with
+real-world source code.  Specifically, GCC has historically accepted a huge
+superset of expressions as i-c-e’s, and a lot of real world code depends on
+this unfortuate accident of history (including, e.g., the glibc system
+headers).  GCC accepts anything its “fold” optimizer is capable of reducing to
+an integer constant, which means that the definition of what it accepts changes
+as its optimizer does.  One example is that GCC accepts things like “<tt class="docutils literal"><span class="pre">case</span>
+<span class="pre">X-X:</span></tt>” even when <tt class="docutils literal"><span class="pre">X</span></tt> is a variable, because it can fold this to 0.</p>
+<p>Another issue are how constants interact with the extensions we support, such
+as <tt class="docutils literal"><span class="pre">__builtin_constant_p</span></tt>, <tt class="docutils literal"><span class="pre">__builtin_inf</span></tt>, <tt class="docutils literal"><span class="pre">__extension__</span></tt> and many
+others.  C99 obviously does not specify the semantics of any of these
+extensions, and the definition of i-c-e does not include them.  However, these
+extensions are often used in real code, and we have to have a way to reason
+about them.</p>
+<p>Finally, this is not just a problem for semantic analysis.  The code generator
+and other clients have to be able to fold constants (e.g., to initialize global
+variables) and has to handle a superset of what C99 allows.  Further, these
+clients can benefit from extended information.  For example, we know that
+“<tt class="docutils literal"><span class="pre">foo()</span> <span class="pre">||</span> <span class="pre">1</span></tt>” always evaluates to <tt class="docutils literal"><span class="pre">true</span></tt>, but we can’t replace the
+expression with <tt class="docutils literal"><span class="pre">true</span></tt> because it has side effects.</p>
+<div class="section" id="implementation-approach">
+<h4><a class="toc-backref" href="#id40">Implementation Approach</a><a class="headerlink" href="#implementation-approach" title="Permalink to this headline">¶</a></h4>
+<p>After trying several different approaches, we’ve finally converged on a design
+(Note, at the time of this writing, not all of this has been implemented,
+consider this a design goal!).  Our basic approach is to define a single
+recursive method evaluation method (<tt class="docutils literal"><span class="pre">Expr::Evaluate</span></tt>), which is implemented
+in <tt class="docutils literal"><span class="pre">AST/ExprConstant.cpp</span></tt>.  Given an expression with “scalar” type (integer,
+fp, complex, or pointer) this method returns the following information:</p>
+<ul class="simple">
+<li>Whether the expression is an integer constant expression, a general constant
+that was folded but has no side effects, a general constant that was folded
+but that does have side effects, or an uncomputable/unfoldable value.</li>
+<li>If the expression was computable in any way, this method returns the
+<tt class="docutils literal"><span class="pre">APValue</span></tt> for the result of the expression.</li>
+<li>If the expression is not evaluatable at all, this method returns information
+on one of the problems with the expression.  This includes a
+<tt class="docutils literal"><span class="pre">SourceLocation</span></tt> for where the problem is, and a diagnostic ID that explains
+the problem.  The diagnostic should have <tt class="docutils literal"><span class="pre">ERROR</span></tt> type.</li>
+<li>If the expression is not an integer constant expression, this method returns
+information on one of the problems with the expression.  This includes a
+<tt class="docutils literal"><span class="pre">SourceLocation</span></tt> for where the problem is, and a diagnostic ID that
+explains the problem.  The diagnostic should have <tt class="docutils literal"><span class="pre">EXTENSION</span></tt> type.</li>
+</ul>
+<p>This information gives various clients the flexibility that they want, and we
+will eventually have some helper methods for various extensions.  For example,
+<tt class="docutils literal"><span class="pre">Sema</span></tt> should have a <tt class="docutils literal"><span class="pre">Sema::VerifyIntegerConstantExpression</span></tt> method, which
+calls <tt class="docutils literal"><span class="pre">Evaluate</span></tt> on the expression.  If the expression is not foldable, the
+error is emitted, and it would return <tt class="docutils literal"><span class="pre">true</span></tt>.  If the expression is not an
+i-c-e, the <tt class="docutils literal"><span class="pre">EXTENSION</span></tt> diagnostic is emitted.  Finally it would return
+<tt class="docutils literal"><span class="pre">false</span></tt> to indicate that the AST is OK.</p>
+<p>Other clients can use the information in other ways, for example, codegen can
+just use expressions that are foldable in any way.</p>
+</div>
+<div class="section" id="extensions">
+<h4><a class="toc-backref" href="#id41">Extensions</a><a class="headerlink" href="#extensions" title="Permalink to this headline">¶</a></h4>
+<p>This section describes how some of the various extensions Clang supports
+interacts with constant evaluation:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">__extension__</span></tt>: The expression form of this extension causes any
+evaluatable subexpression to be accepted as an integer constant expression.</li>
+<li><tt class="docutils literal"><span class="pre">__builtin_constant_p</span></tt>: This returns true (as an integer constant
+expression) if the operand evaluates to either a numeric value (that is, not
+a pointer cast to integral type) of integral, enumeration, floating or
+complex type, or if it evaluates to the address of the first character of a
+string literal (possibly cast to some other type).  As a special case, if
+<tt class="docutils literal"><span class="pre">__builtin_constant_p</span></tt> is the (potentially parenthesized) condition of a
+conditional operator expression (“<tt class="docutils literal"><span class="pre">?:</span></tt>”), only the true side of the
+conditional operator is considered, and it is evaluated with full constant
+folding.</li>
+<li><tt class="docutils literal"><span class="pre">__builtin_choose_expr</span></tt>: The condition is required to be an integer
+constant expression, but we accept any constant as an “extension of an
+extension”.  This only evaluates one operand depending on which way the
+condition evaluates.</li>
+<li><tt class="docutils literal"><span class="pre">__builtin_classify_type</span></tt>: This always returns an integer constant
+expression.</li>
+<li><tt class="docutils literal"><span class="pre">__builtin_inf,</span> <span class="pre">nan,</span> <span class="pre">...</span></tt>: These are treated just like a floating-point
+literal.</li>
+<li><tt class="docutils literal"><span class="pre">__builtin_abs,</span> <span class="pre">copysign,</span> <span class="pre">...</span></tt>: These are constant folded as general
+constant expressions.</li>
+<li><tt class="docutils literal"><span class="pre">__builtin_strlen</span></tt> and <tt class="docutils literal"><span class="pre">strlen</span></tt>: These are constant folded as integer
+constant expressions if the argument is a string literal.</li>
+</ul>
+</div>
+</div>
+</div>
+<div class="section" id="the-sema-library">
+<span id="sema"></span><h2><a class="toc-backref" href="#id42">The Sema Library</a><a class="headerlink" href="#the-sema-library" title="Permalink to this headline">¶</a></h2>
+<p>This library is called by the <a class="reference internal" href="#parser"><em>Parser library</em></a> during parsing to
+do semantic analysis of the input.  For valid programs, Sema builds an AST for
+parsed constructs.</p>
+</div>
+<div class="section" id="the-codegen-library">
+<span id="codegen"></span><h2><a class="toc-backref" href="#id43">The CodeGen Library</a><a class="headerlink" href="#the-codegen-library" title="Permalink to this headline">¶</a></h2>
+<p>CodeGen takes an <a class="reference internal" href="#ast"><em>AST</em></a> as input and produces <a class="reference external" href="//llvm.org/docs/LangRef.html">LLVM IR code</a> from it.</p>
+</div>
+<div class="section" id="how-to-change-clang">
+<h2><a class="toc-backref" href="#id44">How to change Clang</a><a class="headerlink" href="#how-to-change-clang" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="how-to-add-an-attribute">
+<h3><a class="toc-backref" href="#id45">How to add an attribute</a><a class="headerlink" href="#how-to-add-an-attribute" title="Permalink to this headline">¶</a></h3>
+<div class="section" id="attribute-basics">
+<h4><a class="toc-backref" href="#id46">Attribute Basics</a><a class="headerlink" href="#attribute-basics" title="Permalink to this headline">¶</a></h4>
+<p>Attributes in clang come in two forms: parsed form, and semantic form. Both
+forms are represented via a tablegen definition of the attribute, specified in
+Attr.td.</p>
+</div>
+<div class="section" id="include-clang-basic-attr-td">
+<h4><a class="toc-backref" href="#id47"><tt class="docutils literal"><span class="pre">include/clang/Basic/Attr.td</span></tt></a><a class="headerlink" href="#include-clang-basic-attr-td" title="Permalink to this headline">¶</a></h4>
+<p>First, add your attribute to the <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?view=markup">include/clang/Basic/Attr.td</a>
+file.</p>
+<p>Each attribute gets a <tt class="docutils literal"><span class="pre">def</span></tt> inheriting from <tt class="docutils literal"><span class="pre">Attr</span></tt> or one of its
+subclasses.  <tt class="docutils literal"><span class="pre">InheritableAttr</span></tt> means that the attribute also applies to
+subsequent declarations of the same name.  <tt class="docutils literal"><span class="pre">InheritableParamAttr</span></tt> is similar
+to <tt class="docutils literal"><span class="pre">InheritableAttr</span></tt>, except that the attribute is written on a parameter
+instead of a declaration, type or statement.  Attributes inheriting from
+<tt class="docutils literal"><span class="pre">TypeAttr</span></tt> are pure type attributes which generally are not given a
+representation in the AST.  Attributes inheriting from <tt class="docutils literal"><span class="pre">TargetSpecificAttr</span></tt>
+are attributes specific to one or more target architectures.  An attribute that
+inherits from <tt class="docutils literal"><span class="pre">IgnoredAttr</span></tt> is parsed, but will generate an ignored attribute
+diagnostic when used.  The attribute type may be useful when an attribute is
+supported by another vendor, but not supported by clang.</p>
+<p><tt class="docutils literal"><span class="pre">Spellings</span></tt> lists the strings that can appear in <tt class="docutils literal"><span class="pre">__attribute__((here))</span></tt> or
+<tt class="docutils literal"><span class="pre">[[here]]</span></tt>.  All such strings will be synonymous.  Possible <tt class="docutils literal"><span class="pre">Spellings</span></tt>
+are: <tt class="docutils literal"><span class="pre">GNU</span></tt> (for use with GNU-style __attribute__ spellings), <tt class="docutils literal"><span class="pre">Declspec</span></tt>
+(for use with Microsoft Visual Studio-style __declspec spellings), <tt class="docutils literal"><span class="pre">CXX11`</span>
+<span class="pre">(for</span> <span class="pre">use</span> <span class="pre">with</span> <span class="pre">C++11-style</span> <span class="pre">[[foo]]</span> <span class="pre">and</span> <span class="pre">[[foo::bar]]</span> <span class="pre">spellings),</span> <span class="pre">and</span> <span class="pre">``Keyword</span></tt>
+(for use with attributes that are implemented as keywords, like C++11’s
+<tt class="docutils literal"><span class="pre">override</span></tt> or <tt class="docutils literal"><span class="pre">final</span></tt>). If you want to allow the <tt class="docutils literal"><span class="pre">[[]]</span></tt> C++11 syntax, you
+have to define a list of <tt class="docutils literal"><span class="pre">Namespaces</span></tt>, which will let users write
+<tt class="docutils literal"><span class="pre">[[namespace::spelling]]</span></tt>.  Using the empty string for a namespace will allow
+users to write just the spelling with no “<tt class="docutils literal"><span class="pre">::</span></tt>”.  Attributes which g++-4.8
+or later accepts should also have a <tt class="docutils literal"><span class="pre">CXX11<"gnu",</span> <span class="pre">"spelling"></span></tt> spelling.</p>
+<p><tt class="docutils literal"><span class="pre">Subjects</span></tt> restricts what kinds of AST node to which this attribute can
+appertain (roughly, attach).  The subjects are specified via a <tt class="docutils literal"><span class="pre">SubjectList</span></tt>,
+which specify the list of subjects. Additionally, subject-related diagnostics
+can be specified to be warnings or errors, with the default being a warning.
+The diagnostics displayed to the user are automatically determined based on
+the subjects in the list, but a custom diagnostic parameter can also be
+specified in the <tt class="docutils literal"><span class="pre">SubjectList</span></tt>.  The diagnostics generated for subject list
+violations are either <tt class="docutils literal"><span class="pre">diag::warn_attribute_wrong_decl_type</span></tt> or
+<tt class="docutils literal"><span class="pre">diag::err_attribute_wrong_decl_type</span></tt>, and the parameter enumeration is
+found in <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?view=markup">include/clang/Sema/AttributeList.h</a>
+If you add new Decl nodes to the <tt class="docutils literal"><span class="pre">SubjectList</span></tt>, you may need to update the
+logic used to automatically determine the diagnostic parameter in <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?view=markup">utils/TableGen/ClangAttrEmitter.cpp</a>.</p>
+<p>Diagnostic checking for attribute subject lists is automated except when
+<tt class="docutils literal"><span class="pre">HasCustomParsing</span></tt> is set to <tt class="docutils literal"><span class="pre">1</span></tt>.</p>
+<p>By default, all subjects in the SubjectList must either be a Decl node defined
+in <tt class="docutils literal"><span class="pre">DeclNodes.td</span></tt>, or a statement node defined in <tt class="docutils literal"><span class="pre">StmtNodes.td</span></tt>.  However,
+more complex subjects can be created by creating a <tt class="docutils literal"><span class="pre">SubsetSubject</span></tt> object.
+Each such object has a base subject which it appertains to (which must be a
+Decl or Stmt node, and not a SubsetSubject node), and some custom code which is
+called when determining whether an attribute appertains to the subject.  For
+instance, a <tt class="docutils literal"><span class="pre">NonBitField</span></tt> SubsetSubject appertains to a <tt class="docutils literal"><span class="pre">FieldDecl</span></tt>, and
+tests whether the given FieldDecl is a bit field.  When a SubsetSubject is
+specified in a SubjectList, a custom diagnostic parameter must also be provided.</p>
+<p><tt class="docutils literal"><span class="pre">Args</span></tt> names the arguments the attribute takes, in order.  If <tt class="docutils literal"><span class="pre">Args</span></tt> is
+<tt class="docutils literal"><span class="pre">[StringArgument<"Arg1">,</span> <span class="pre">IntArgument<"Arg2">]</span></tt> then
+<tt class="docutils literal"><span class="pre">__attribute__((myattribute("Hello",</span> <span class="pre">3)))</span></tt> will be a valid use.  Attribute
+arguments specify both the parsed form and the semantic form of the attribute.
+The previous example shows an attribute which requires two attributes while
+parsing, and the Attr subclass’ constructor for the attribute will require a
+string and integer argument.</p>
+<p>Diagnostic checking for argument counts is automated except when
+<tt class="docutils literal"><span class="pre">HasCustomParsing</span></tt> is set to <tt class="docutils literal"><span class="pre">1</span></tt>, or when the attribute uses an optional or
+variadic argument.  Diagnostic checking for argument semantics is not automated.</p>
+<p>If the parsed form of the attribute is more complex, or differs from the
+semantic form, the <tt class="docutils literal"><span class="pre">HasCustomParsing</span></tt> bit can be set to <tt class="docutils literal"><span class="pre">1</span></tt> for the class,
+and the parsing code in <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?view=markup">Parser::ParseGNUAttributeArgs</a>
+can be updated for the special case.  Note that this only applies to arguments
+with a GNU spelling – attributes with a __declspec spelling currently ignore
+this flag and are handled by <tt class="docutils literal"><span class="pre">Parser::ParseMicrosoftDeclSpec</span></tt>.</p>
+<p>Custom accessors can be generated for an attribute based on the spelling list
+for that attribute.  For instance, if an attribute has two different spellings:
+‘Foo’ and ‘Bar’, accessors can be created:
+<tt class="docutils literal"><span class="pre">[Accessor<"isFoo",</span> <span class="pre">[GNU<"Foo">]>,</span> <span class="pre">Accessor<"isBar",</span> <span class="pre">[GNU<"Bar">]>]</span></tt>
+These accessors will be generated on the semantic form of the attribute,
+accepting no arguments and returning a Boolean.</p>
+<p>Attributes which do not require an AST node should set the <tt class="docutils literal"><span class="pre">ASTNode</span></tt> field to
+<tt class="docutils literal"><span class="pre">0</span></tt> to avoid polluting the AST.  Note that anything inheriting from
+<tt class="docutils literal"><span class="pre">TypeAttr</span></tt> or <tt class="docutils literal"><span class="pre">IgnoredAttr</span></tt> automatically do not generate an AST node.  All
+other attributes generate an AST node by default.  The AST node is the semantic
+representation of the attribute.</p>
+<p>Attributes which do not require custom semantic handling should set the
+<tt class="docutils literal"><span class="pre">SemaHandler</span></tt> field to <tt class="docutils literal"><span class="pre">0</span></tt>.  Note that anything inheriting from
+<tt class="docutils literal"><span class="pre">IgnoredAttr</span></tt> automatically do not get a semantic handler.  All other
+attributes are assumed to use a semantic handler by default.  Attributes
+without a semantic handler are not given a parsed attribute Kind enumeration.</p>
+<p>The <tt class="docutils literal"><span class="pre">LangOpts</span></tt> field can be used to specify a list of language options
+required by the attribute.  For instance, all of the CUDA-specific attributes
+specify <tt class="docutils literal"><span class="pre">[CUDA]</span></tt> for the <tt class="docutils literal"><span class="pre">LangOpts</span></tt> field, and when the CUDA language
+option is not enabled, an “attribute ignored” warning diagnostic is emitted.
+Since language options are not table generated nodes, new language options must
+be created manually and should specify the spelling used by <tt class="docutils literal"><span class="pre">LangOptions</span></tt> class.</p>
+<p>Target-specific attribute sometimes share a spelling with other attributes in
+different targets.  For instance, the ARM and MSP430 targets both have an
+attribute spelled <tt class="docutils literal"><span class="pre">GNU<"interrupt"></span></tt>, but with different parsing and semantic
+requirements.  To support this feature, an attribute inheriting from
+<tt class="docutils literal"><span class="pre">TargetSpecificAttribute</span></tt> make specify a <tt class="docutils literal"><span class="pre">ParseKind</span></tt> field.  This field
+should be the same value between all arguments sharing a spelling, and
+corresponds to the parsed attribute’s Kind enumeration.  This allows attributes
+to share a parsed attribute kind, but have distinct semantic attribute classes.
+For instance, <tt class="docutils literal"><span class="pre">AttributeList::AT_Interrupt</span></tt> is the shared parsed attribute
+kind, but ARMInterruptAttr and MSP430InterruptAttr are the semantic attributes
+generated.</p>
+<p>By default, when declarations are merging attributes, an attribute will not be
+duplicated. However, if an attribute can be duplicated during this merging
+stage, set <tt class="docutils literal"><span class="pre">DuplicatesAllowedWhileMerging</span></tt> to <tt class="docutils literal"><span class="pre">1</span></tt>, and the attribute will
+be merged.</p>
+<p>By default, attribute arguments are parsed in an evaluated context. If the
+arguments for an attribute should be parsed in an unevaluated context (akin to
+the way the argument to a <tt class="docutils literal"><span class="pre">sizeof</span></tt> expression is parsed), you can set
+<tt class="docutils literal"><span class="pre">ParseArgumentsAsUnevaluated</span></tt> to <tt class="docutils literal"><span class="pre">1</span></tt>.</p>
+<p>If additional functionality is desired for the semantic form of the attribute,
+the <tt class="docutils literal"><span class="pre">AdditionalMembers</span></tt> field specifies code to be copied verbatim into the
+semantic attribute class object.</p>
+<p>All attributes must have one or more form of documentation, which is provided
+in the <tt class="docutils literal"><span class="pre">Documentation</span></tt> list. Generally, the documentation for an attribute
+is a stand-alone definition in <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttdDocs.td?view=markup">include/clang/Basic/AttrDocs.td</a>
+that is named after the attribute being documented. Each documentation element
+is given a <tt class="docutils literal"><span class="pre">Category</span></tt> (variable, function, or type) and <tt class="docutils literal"><span class="pre">Content</span></tt>. A single
+attribute may contain multiple documentation elements for distinct categories.
+For instance, an attribute which can appertain to both function and types (such
+as a calling convention attribute), should contain two documentation elements.
+The <tt class="docutils literal"><span class="pre">Content</span></tt> for an attribute uses reStructuredText (RST) syntax.</p>
+<p>If an attribute is used internally by the compiler, but is not written by users
+(such as attributes with an empty spelling list), it can use the
+<tt class="docutils literal"><span class="pre">Undocumented</span></tt> documentation element.</p>
+</div>
+<div class="section" id="boilerplate">
+<h4><a class="toc-backref" href="#id48">Boilerplate</a><a class="headerlink" href="#boilerplate" title="Permalink to this headline">¶</a></h4>
+<p>All semantic processing of declaration attributes happens in <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?view=markup">lib/Sema/SemaDeclAttr.cpp</a>,
+and generally starts in the <tt class="docutils literal"><span class="pre">ProcessDeclAttribute</span></tt> function.  If your
+attribute is a “simple” attribute – meaning that it requires no custom
+semantic processing aside from what is automatically  provided for you, you can
+add a call to <tt class="docutils literal"><span class="pre">handleSimpleAttribute<YourAttr>(S,</span> <span class="pre">D,</span> <span class="pre">Attr);</span></tt> to the switch
+statement. Otherwise, write a new <tt class="docutils literal"><span class="pre">handleYourAttr()</span></tt> function, and add that
+to the switch statement.</p>
+<p>If your attribute causes extra warnings to fire, define a <tt class="docutils literal"><span class="pre">DiagGroup</span></tt> in
+<a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?view=markup">include/clang/Basic/DiagnosticGroups.td</a>
+named after the attribute’s <tt class="docutils literal"><span class="pre">Spelling</span></tt> with “_”s replaced by “-“s.  If you’re
+only defining one diagnostic, you can skip <tt class="docutils literal"><span class="pre">DiagnosticGroups.td</span></tt> and use
+<tt class="docutils literal"><span class="pre">InGroup<DiagGroup<"your-attribute">></span></tt> directly in <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?view=markup">DiagnosticSemaKinds.td</a></p>
+<p>All semantic diagnostics generated for your attribute, including automatically-
+generated ones (such as subjects and argument counts), should have a
+corresponding test case.</p>
+</div>
+<div class="section" id="the-meat-of-your-attribute">
+<h4><a class="toc-backref" href="#id49">The meat of your attribute</a><a class="headerlink" href="#the-meat-of-your-attribute" title="Permalink to this headline">¶</a></h4>
+<p>Find an appropriate place in Clang to do whatever your attribute needs to do.
+Check for the attribute’s presence using <tt class="docutils literal"><span class="pre">Decl::getAttr<YourAttr>()</span></tt>.</p>
+<p>Update the <a class="reference internal" href="LanguageExtensions.html"><em>Clang Language Extensions</em></a> document to describe your new attribute.</p>
+</div>
+</div>
+<div class="section" id="how-to-add-an-expression-or-statement">
+<h3><a class="toc-backref" href="#id50">How to add an expression or statement</a><a class="headerlink" href="#how-to-add-an-expression-or-statement" title="Permalink to this headline">¶</a></h3>
+<p>Expressions and statements are one of the most fundamental constructs within a
+compiler, because they interact with many different parts of the AST, semantic
+analysis, and IR generation.  Therefore, adding a new expression or statement
+kind into Clang requires some care.  The following list details the various
+places in Clang where an expression or statement needs to be introduced, along
+with patterns to follow to ensure that the new expression or statement works
+well across all of the C languages.  We focus on expressions, but statements
+are similar.</p>
+<ol class="arabic simple">
+<li>Introduce parsing actions into the parser.  Recursive-descent parsing is
+mostly self-explanatory, but there are a few things that are worth keeping
+in mind:<ul>
+<li>Keep as much source location information as possible! You’ll want it later
+to produce great diagnostics and support Clang’s various features that map
+between source code and the AST.</li>
+<li>Write tests for all of the “bad” parsing cases, to make sure your recovery
+is good.  If you have matched delimiters (e.g., parentheses, square
+brackets, etc.), use <tt class="docutils literal"><span class="pre">Parser::BalancedDelimiterTracker</span></tt> to give nice
+diagnostics when things go wrong.</li>
+</ul>
+</li>
+<li>Introduce semantic analysis actions into <tt class="docutils literal"><span class="pre">Sema</span></tt>.  Semantic analysis should
+always involve two functions: an <tt class="docutils literal"><span class="pre">ActOnXXX</span></tt> function that will be called
+directly from the parser, and a <tt class="docutils literal"><span class="pre">BuildXXX</span></tt> function that performs the
+actual semantic analysis and will (eventually!) build the AST node.  It’s
+fairly common for the <tt class="docutils literal"><span class="pre">ActOnCXX</span></tt> function to do very little (often just
+some minor translation from the parser’s representation to <tt class="docutils literal"><span class="pre">Sema</span></tt>‘s
+representation of the same thing), but the separation is still important:
+C++ template instantiation, for example, should always call the <tt class="docutils literal"><span class="pre">BuildXXX</span></tt>
+variant.  Several notes on semantic analysis before we get into construction
+of the AST:<ul>
+<li>Your expression probably involves some types and some subexpressions.
+Make sure to fully check that those types, and the types of those
+subexpressions, meet your expectations.  Add implicit conversions where
+necessary to make sure that all of the types line up exactly the way you
+want them.  Write extensive tests to check that you’re getting good
+diagnostics for mistakes and that you can use various forms of
+subexpressions with your expression.</li>
+<li>When type-checking a type or subexpression, make sure to first check
+whether the type is “dependent” (<tt class="docutils literal"><span class="pre">Type::isDependentType()</span></tt>) or whether a
+subexpression is type-dependent (<tt class="docutils literal"><span class="pre">Expr::isTypeDependent()</span></tt>).  If any of
+these return <tt class="docutils literal"><span class="pre">true</span></tt>, then you’re inside a template and you can’t do much
+type-checking now.  That’s normal, and your AST node (when you get there)
+will have to deal with this case.  At this point, you can write tests that
+use your expression within templates, but don’t try to instantiate the
+templates.</li>
+<li>For each subexpression, be sure to call <tt class="docutils literal"><span class="pre">Sema::CheckPlaceholderExpr()</span></tt>
+to deal with “weird” expressions that don’t behave well as subexpressions.
+Then, determine whether you need to perform lvalue-to-rvalue conversions
+(<tt class="docutils literal"><span class="pre">Sema::DefaultLvalueConversions</span></tt>) or the usual unary conversions
+(<tt class="docutils literal"><span class="pre">Sema::UsualUnaryConversions</span></tt>), for places where the subexpression is
+producing a value you intend to use.</li>
+<li>Your <tt class="docutils literal"><span class="pre">BuildXXX</span></tt> function will probably just return <tt class="docutils literal"><span class="pre">ExprError()</span></tt> at
+this point, since you don’t have an AST.  That’s perfectly fine, and
+shouldn’t impact your testing.</li>
+</ul>
+</li>
+<li>Introduce an AST node for your new expression.  This starts with declaring
+the node in <tt class="docutils literal"><span class="pre">include/Basic/StmtNodes.td</span></tt> and creating a new class for your
+expression in the appropriate <tt class="docutils literal"><span class="pre">include/AST/Expr*.h</span></tt> header.  It’s best to
+look at the class for a similar expression to get ideas, and there are some
+specific things to watch for:<ul>
+<li>If you need to allocate memory, use the <tt class="docutils literal"><span class="pre">ASTContext</span></tt> allocator to
+allocate memory.  Never use raw <tt class="docutils literal"><span class="pre">malloc</span></tt> or <tt class="docutils literal"><span class="pre">new</span></tt>, and never hold any
+resources in an AST node, because the destructor of an AST node is never
+called.</li>
+<li>Make sure that <tt class="docutils literal"><span class="pre">getSourceRange()</span></tt> covers the exact source range of your
+expression.  This is needed for diagnostics and for IDE support.</li>
+<li>Make sure that <tt class="docutils literal"><span class="pre">children()</span></tt> visits all of the subexpressions.  This is
+important for a number of features (e.g., IDE support, C++ variadic
+templates).  If you have sub-types, you’ll also need to visit those
+sub-types in <tt class="docutils literal"><span class="pre">RecursiveASTVisitor</span></tt> and <tt class="docutils literal"><span class="pre">DataRecursiveASTVisitor</span></tt>.</li>
+<li>Add printing support (<tt class="docutils literal"><span class="pre">StmtPrinter.cpp</span></tt>) for your expression.</li>
+<li>Add profiling support (<tt class="docutils literal"><span class="pre">StmtProfile.cpp</span></tt>) for your AST node, noting the
+distinguishing (non-source location) characteristics of an instance of
+your expression.  Omitting this step will lead to hard-to-diagnose
+failures regarding matching of template declarations.</li>
+<li>Add serialization support (<tt class="docutils literal"><span class="pre">ASTReaderStmt.cpp</span></tt>, <tt class="docutils literal"><span class="pre">ASTWriterStmt.cpp</span></tt>)
+for your AST node.</li>
+</ul>
+</li>
+<li>Teach semantic analysis to build your AST node.  At this point, you can wire
+up your <tt class="docutils literal"><span class="pre">Sema::BuildXXX</span></tt> function to actually create your AST.  A few
+things to check at this point:<ul>
+<li>If your expression can construct a new C++ class or return a new
+Objective-C object, be sure to update and then call
+<tt class="docutils literal"><span class="pre">Sema::MaybeBindToTemporary</span></tt> for your just-created AST node to be sure
+that the object gets properly destructed.  An easy way to test this is to
+return a C++ class with a private destructor: semantic analysis should
+flag an error here with the attempt to call the destructor.</li>
+<li>Inspect the generated AST by printing it using <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span> <span class="pre">-ast-print</span></tt>,
+to make sure you’re capturing all of the important information about how
+the AST was written.</li>
+<li>Inspect the generated AST under <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span> <span class="pre">-ast-dump</span></tt> to verify that
+all of the types in the generated AST line up the way you want them.
+Remember that clients of the AST should never have to “think” to
+understand what’s going on.  For example, all implicit conversions should
+show up explicitly in the AST.</li>
+<li>Write tests that use your expression as a subexpression of other,
+well-known expressions.  Can you call a function using your expression as
+an argument?  Can you use the ternary operator?</li>
+</ul>
+</li>
+<li>Teach code generation to create IR to your AST node.  This step is the first
+(and only) that requires knowledge of LLVM IR.  There are several things to
+keep in mind:<ul>
+<li>Code generation is separated into scalar/aggregate/complex and
+lvalue/rvalue paths, depending on what kind of result your expression
+produces.  On occasion, this requires some careful factoring of code to
+avoid duplication.</li>
+<li><tt class="docutils literal"><span class="pre">CodeGenFunction</span></tt> contains functions <tt class="docutils literal"><span class="pre">ConvertType</span></tt> and
+<tt class="docutils literal"><span class="pre">ConvertTypeForMem</span></tt> that convert Clang’s types (<tt class="docutils literal"><span class="pre">clang::Type*</span></tt> or
+<tt class="docutils literal"><span class="pre">clang::QualType</span></tt>) to LLVM types.  Use the former for values, and the
+later for memory locations: test with the C++ “<tt class="docutils literal"><span class="pre">bool</span></tt>” type to check
+this.  If you find that you are having to use LLVM bitcasts to make the
+subexpressions of your expression have the type that your expression
+expects, STOP!  Go fix semantic analysis and the AST so that you don’t
+need these bitcasts.</li>
+<li>The <tt class="docutils literal"><span class="pre">CodeGenFunction</span></tt> class has a number of helper functions to make
+certain operations easy, such as generating code to produce an lvalue or
+an rvalue, or to initialize a memory location with a given value.  Prefer
+to use these functions rather than directly writing loads and stores,
+because these functions take care of some of the tricky details for you
+(e.g., for exceptions).</li>
+<li>If your expression requires some special behavior in the event of an
+exception, look at the <tt class="docutils literal"><span class="pre">push*Cleanup</span></tt> functions in <tt class="docutils literal"><span class="pre">CodeGenFunction</span></tt>
+to introduce a cleanup.  You shouldn’t have to deal with
+exception-handling directly.</li>
+<li>Testing is extremely important in IR generation.  Use <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span>
+<span class="pre">-emit-llvm</span></tt> and <a class="reference external" href="http://llvm.org/docs/CommandGuide/FileCheck.html">FileCheck</a> to verify that you’re
+generating the right IR.</li>
+</ul>
+</li>
+<li>Teach template instantiation how to cope with your AST node, which requires
+some fairly simple code:<ul>
+<li>Make sure that your expression’s constructor properly computes the flags
+for type dependence (i.e., the type your expression produces can change
+from one instantiation to the next), value dependence (i.e., the constant
+value your expression produces can change from one instantiation to the
+next), instantiation dependence (i.e., a template parameter occurs
+anywhere in your expression), and whether your expression contains a
+parameter pack (for variadic templates).  Often, computing these flags
+just means combining the results from the various types and
+subexpressions.</li>
+<li>Add <tt class="docutils literal"><span class="pre">TransformXXX</span></tt> and <tt class="docutils literal"><span class="pre">RebuildXXX</span></tt> functions to the <tt class="docutils literal"><span class="pre">TreeTransform</span></tt>
+class template in <tt class="docutils literal"><span class="pre">Sema</span></tt>.  <tt class="docutils literal"><span class="pre">TransformXXX</span></tt> should (recursively)
+transform all of the subexpressions and types within your expression,
+using <tt class="docutils literal"><span class="pre">getDerived().TransformYYY</span></tt>.  If all of the subexpressions and
+types transform without error, it will then call the <tt class="docutils literal"><span class="pre">RebuildXXX</span></tt>
+function, which will in turn call <tt class="docutils literal"><span class="pre">getSema().BuildXXX</span></tt> to perform
+semantic analysis and build your expression.</li>
+<li>To test template instantiation, take those tests you wrote to make sure
+that you were type checking with type-dependent expressions and dependent
+types (from step #2) and instantiate those templates with various types,
+some of which type-check and some that don’t, and test the error messages
+in each case.</li>
+</ul>
+</li>
+<li>There are some “extras” that make other features work better.  It’s worth
+handling these extras to give your expression complete integration into
+Clang:<ul>
+<li>Add code completion support for your expression in
+<tt class="docutils literal"><span class="pre">SemaCodeComplete.cpp</span></tt>.</li>
+<li>If your expression has types in it, or has any “interesting” features
+other than subexpressions, extend libclang’s <tt class="docutils literal"><span class="pre">CursorVisitor</span></tt> to provide
+proper visitation for your expression, enabling various IDE features such
+as syntax highlighting, cross-referencing, and so on.  The
+<tt class="docutils literal"><span class="pre">c-index-test</span></tt> helper program can be used to test these features.</li>
+</ul>
+</li>
+</ol>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="ClangFormatStyleOptions.html">Clang-Format Style Options</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="DriverInternals.html">Driver Design & Internals</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/IntroductionToTheClangAST.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/IntroductionToTheClangAST.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/IntroductionToTheClangAST.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/IntroductionToTheClangAST.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,179 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Introduction to the Clang AST — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="LibTooling" href="LibTooling.html" />
+    <link rel="prev" title="External Clang Examples" href="ExternalClangExamples.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Introduction to the Clang AST</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="ExternalClangExamples.html">External Clang Examples</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibTooling.html">LibTooling</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="introduction-to-the-clang-ast">
+<h1>Introduction to the Clang AST<a class="headerlink" href="#introduction-to-the-clang-ast" title="Permalink to this headline">¶</a></h1>
+<p>This document gives a gentle introduction to the mysteries of the Clang
+AST. It is targeted at developers who either want to contribute to
+Clang, or use tools that work based on Clang’s AST, like the AST
+matchers.</p>
+<center><iframe width="560" height="315" src="http://www.youtube.com/embed/VqCkCDFLSsc?vq=hd720" frameborder="0" allowfullscreen></iframe></center><p><a class="reference external" href="http://llvm.org/devmtg/2013-04/klimek-slides.pdf">Slides</a></p>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>Clang’s AST is different from ASTs produced by some other compilers in
+that it closely resembles both the written C++ code and the C++
+standard. For example, parenthesis expressions and compile time
+constants are available in an unreduced form in the AST. This makes
+Clang’s AST a good fit for refactoring tools.</p>
+<p>Documentation for all Clang AST nodes is available via the generated
+<a class="reference external" href="http://clang.llvm.org/doxygen">Doxygen</a>. The doxygen online
+documentation is also indexed by your favorite search engine, which will
+make a search for clang and the AST node’s class name usually turn up
+the doxygen of the class you’re looking for (for example, search for:
+clang ParenExpr).</p>
+</div>
+<div class="section" id="examining-the-ast">
+<h2>Examining the AST<a class="headerlink" href="#examining-the-ast" title="Permalink to this headline">¶</a></h2>
+<p>A good way to familarize yourself with the Clang AST is to actually look
+at it on some simple example code. Clang has a builtin AST-dump mode,
+which can be enabled with the flag <tt class="docutils literal"><span class="pre">-ast-dump</span></tt>.</p>
+<p>Let’s look at a simple example AST:</p>
+<div class="highlight-python"><div class="highlight"><pre>$ cat test.cc
+int f(int x) {
+  int result = (x / 42);
+  return result;
+}
+
+# Clang by default is a frontend for many tools; -Xclang is used to pass
+# options directly to the C++ frontend.
+$ clang -Xclang -ast-dump -fsyntax-only test.cc
+TranslationUnitDecl 0x5aea0d0 <<invalid sloc>>
+... cutting out internal declarations of clang ...
+`-FunctionDecl 0x5aeab50 <test.cc:1:1, line:4:1> f 'int (int)'
+  |-ParmVarDecl 0x5aeaa90 <line:1:7, col:11> x 'int'
+  `-CompoundStmt 0x5aead88 <col:14, line:4:1>
+    |-DeclStmt 0x5aead10 <line:2:3, col:24>
+    | `-VarDecl 0x5aeac10 <col:3, col:23> result 'int'
+    |   `-ParenExpr 0x5aeacf0 <col:16, col:23> 'int'
+    |     `-BinaryOperator 0x5aeacc8 <col:17, col:21> 'int' '/'
+    |       |-ImplicitCastExpr 0x5aeacb0 <col:17> 'int' <LValueToRValue>
+    |       | `-DeclRefExpr 0x5aeac68 <col:17> 'int' lvalue ParmVar 0x5aeaa90 'x' 'int'
+    |       `-IntegerLiteral 0x5aeac90 <col:21> 'int' 42
+    `-ReturnStmt 0x5aead68 <line:3:3, col:10>
+      `-ImplicitCastExpr 0x5aead50 <col:10> 'int' <LValueToRValue>
+        `-DeclRefExpr 0x5aead28 <col:10> 'int' lvalue Var 0x5aeac10 'result' 'int'
+</pre></div>
+</div>
+<p>The toplevel declaration in
+a translation unit is always the <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">translation unit
+declaration</a>.
+In this example, our first user written declaration is the <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">function
+declaration</a>
+of “<tt class="docutils literal"><span class="pre">f</span></tt>”. The body of “<tt class="docutils literal"><span class="pre">f</span></tt>” is a <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">compound
+statement</a>,
+whose child nodes are a <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">declaration
+statement</a>
+that declares our result variable, and the <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">return
+statement</a>.</p>
+</div>
+<div class="section" id="ast-context">
+<h2>AST Context<a class="headerlink" href="#ast-context" title="Permalink to this headline">¶</a></h2>
+<p>All information about the AST for a translation unit is bundled up in
+the class
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html">ASTContext</a>.
+It allows traversal of the whole translation unit starting from
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html#abd909fb01ef10cfd0244832a67b1dd64">getTranslationUnitDecl</a>,
+or to access Clang’s <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1ASTContext.html#a4f95adb9958e22fbe55212ae6482feb4">table of
+identifiers</a>
+for the parsed translation unit.</p>
+</div>
+<div class="section" id="ast-nodes">
+<h2>AST Nodes<a class="headerlink" href="#ast-nodes" title="Permalink to this headline">¶</a></h2>
+<p>Clang’s AST nodes are modeled on a class hierarchy that does not have a
+common ancestor. Instead, there are multiple larger hierarchies for
+basic node types like
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a> and
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>. Many
+important AST nodes derive from
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>,
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>,
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1DeclContext.html">DeclContext</a>
+or <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>, with
+some classes deriving from both Decl and DeclContext.</p>
+<p>There are also a multitude of nodes in the AST that are not part of a
+larger hierarchy, and are only reachable from specific other nodes, like
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>.</p>
+<p>Thus, to traverse the full AST, one starts from the
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>
+and then recursively traverses everything that can be reached from that
+node - this information has to be encoded for each specific node type.
+This algorithm is encoded in the
+<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html">RecursiveASTVisitor</a>.
+See the <a class="reference external" href="http://clang.llvm.org/docs/RAVFrontendAction.html">RecursiveASTVisitor
+tutorial</a>.</p>
+<p>The two most basic nodes in the Clang AST are statements
+(<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>) and
+declarations
+(<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>). Note
+that expressions
+(<a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>) are
+also statements in Clang’s AST.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="ExternalClangExamples.html">External Clang Examples</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibTooling.html">LibTooling</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/JSONCompilationDatabase.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/JSONCompilationDatabase.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/JSONCompilationDatabase.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/JSONCompilationDatabase.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,149 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>JSON Compilation Database Format Specification — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Overview" href="ClangTools.html" />
+    <link rel="prev" title="How To Setup Clang Tooling For LLVM" href="HowToSetupToolingForLLVM.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>JSON Compilation Database Format Specification</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="HowToSetupToolingForLLVM.html">How To Setup Clang Tooling For LLVM</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ClangTools.html">Overview</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="json-compilation-database-format-specification">
+<h1>JSON Compilation Database Format Specification<a class="headerlink" href="#json-compilation-database-format-specification" title="Permalink to this headline">¶</a></h1>
+<p>This document describes a format for specifying how to replay single
+compilations independently of the build system.</p>
+<div class="section" id="background">
+<h2>Background<a class="headerlink" href="#background" title="Permalink to this headline">¶</a></h2>
+<p>Tools based on the C++ Abstract Syntax Tree need full information how to
+parse a translation unit. Usually this information is implicitly
+available in the build system, but running tools as part of the build
+system is not necessarily the best solution:</p>
+<ul class="simple">
+<li>Build systems are inherently change driven, so running multiple tools
+over the same code base without changing the code does not fit into
+the architecture of many build systems.</li>
+<li>Figuring out whether things have changed is often an IO bound
+process; this makes it hard to build low latency end user tools based
+on the build system.</li>
+<li>Build systems are inherently sequential in the build graph, for
+example due to generated source code. While tools that run
+independently of the build still need the generated source code to
+exist, running tools multiple times over unchanging source does not
+require serialization of the runs according to the build dependency
+graph.</li>
+</ul>
+</div>
+<div class="section" id="supported-systems">
+<h2>Supported Systems<a class="headerlink" href="#supported-systems" title="Permalink to this headline">¶</a></h2>
+<p>Currently <a class="reference external" href="http://cmake.org">CMake</a> (since 2.8.5) supports generation
+of compilation databases for Unix Makefile builds (Ninja builds in the
+works) with the option <tt class="docutils literal"><span class="pre">CMAKE_EXPORT_COMPILE_COMMANDS</span></tt>.</p>
+<p>For projects on Linux, there is an alternative to intercept compiler
+calls with a tool called <a class="reference external" href="https://github.com/rizsotto/Bear">Bear</a>.</p>
+<p>Clang’s tooling interface supports reading compilation databases; see
+the <a class="reference internal" href="LibTooling.html"><em>LibTooling documentation</em></a>. libclang and its
+python bindings also support this (since clang 3.2); see
+<a class="reference external" href="/doxygen/group__COMPILATIONDB.html">CXCompilationDatabase.h</a>.</p>
+</div>
+<div class="section" id="format">
+<h2>Format<a class="headerlink" href="#format" title="Permalink to this headline">¶</a></h2>
+<p>A compilation database is a JSON file, which consist of an array of
+“command objects”, where each command object specifies one way a
+translation unit is compiled in the project.</p>
+<p>Each command object contains the translation unit’s main file, the
+working directory of the compile run and the actual compile command.</p>
+<p>Example:</p>
+<div class="highlight-python"><div class="highlight"><pre><span class="p">[</span>
+  <span class="p">{</span> <span class="s">"directory"</span><span class="p">:</span> <span class="s">"/home/user/llvm/build"</span><span class="p">,</span>
+    <span class="s">"command"</span><span class="p">:</span> <span class="s">"/usr/bin/clang++ -Irelative -DSOMEDEF=</span><span class="se">\"</span><span class="s">With spaces, quotes and </span><span class="se">\\</span><span class="s">-es.</span><span class="se">\"</span><span class="s"> -c -o file.o file.cc"</span><span class="p">,</span>
+    <span class="s">"file"</span><span class="p">:</span> <span class="s">"file.cc"</span> <span class="p">},</span>
+  <span class="o">...</span>
+<span class="p">]</span>
+</pre></div>
+</div>
+<p>The contracts for each field in the command object are:</p>
+<ul class="simple">
+<li><strong>directory:</strong> The working directory of the compilation. All paths
+specified in the <strong>command</strong> or <strong>file</strong> fields must be either
+absolute or relative to this directory.</li>
+<li><strong>file:</strong> The main translation unit source processed by this
+compilation step. This is used by tools as the key into the
+compilation database. There can be multiple command objects for the
+same file, for example if the same source file is compiled with
+different configurations.</li>
+<li><strong>command:</strong> The compile command executed. After JSON unescaping,
+this must be a valid command to rerun the exact compilation step for
+the translation unit in the environment the build system uses.
+Parameters use shell quoting and shell escaping of quotes, with ‘<tt class="docutils literal"><span class="pre">"</span></tt>‘
+and ‘<tt class="docutils literal"><span class="pre">\</span></tt>‘ being the only special characters. Shell expansion is not
+supported.</li>
+</ul>
+</div>
+<div class="section" id="build-system-integration">
+<h2>Build System Integration<a class="headerlink" href="#build-system-integration" title="Permalink to this headline">¶</a></h2>
+<p>The convention is to name the file compile_commands.json and put it at
+the top of the build directory. Clang tools are pointed to the top of
+the build directory to detect the file and use the compilation database
+to parse C++ code in the source tree.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="HowToSetupToolingForLLVM.html">How To Setup Clang Tooling For LLVM</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ClangTools.html">Overview</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/LanguageExtensions.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/LanguageExtensions.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/LanguageExtensions.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/LanguageExtensions.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,1860 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Clang Language Extensions — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Objective-C Literals" href="ObjectiveCLiterals.html" />
+    <link rel="prev" title="Clang Compiler User’s Manual" href="UsersManual.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Clang Language Extensions</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="UsersManual.html">Clang Compiler User’s Manual</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ObjectiveCLiterals.html">Objective-C Literals</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="clang-language-extensions">
+<h1>Clang Language Extensions<a class="headerlink" href="#clang-language-extensions" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
+<li><a class="reference internal" href="#feature-checking-macros" id="id2">Feature Checking Macros</a></li>
+<li><a class="reference internal" href="#include-file-checking-macros" id="id3">Include File Checking Macros</a></li>
+<li><a class="reference internal" href="#builtin-macros" id="id4">Builtin Macros</a></li>
+<li><a class="reference internal" href="#vectors-and-extended-vectors" id="id5">Vectors and Extended Vectors</a></li>
+<li><a class="reference internal" href="#messages-on-deprecated-and-unavailable-attributes" id="id6">Messages on <tt class="docutils literal"><span class="pre">deprecated</span></tt> and <tt class="docutils literal"><span class="pre">unavailable</span></tt> Attributes</a></li>
+<li><a class="reference internal" href="#attributes-on-enumerators" id="id7">Attributes on Enumerators</a></li>
+<li><a class="reference internal" href="#user-specified-system-frameworks" id="id8">‘User-Specified’ System Frameworks</a></li>
+<li><a class="reference internal" href="#checks-for-standard-language-features" id="id9">Checks for Standard Language Features</a></li>
+<li><a class="reference internal" href="#checks-for-type-trait-primitives" id="id10">Checks for Type Trait Primitives</a></li>
+<li><a class="reference internal" href="#blocks" id="id11">Blocks</a></li>
+<li><a class="reference internal" href="#objective-c-features" id="id12">Objective-C Features</a></li>
+<li><a class="reference internal" href="#initializer-lists-for-complex-numbers-in-c" id="id13">Initializer lists for complex numbers in C</a></li>
+<li><a class="reference internal" href="#builtin-functions" id="id14">Builtin Functions</a></li>
+<li><a class="reference internal" href="#non-standard-c-11-attributes" id="id15">Non-standard C++11 Attributes</a></li>
+<li><a class="reference internal" href="#target-specific-extensions" id="id16">Target-Specific Extensions</a></li>
+<li><a class="reference internal" href="#extensions-for-static-analysis" id="id17">Extensions for Static Analysis</a></li>
+<li><a class="reference internal" href="#extensions-for-dynamic-analysis" id="id18">Extensions for Dynamic Analysis</a></li>
+<li><a class="reference internal" href="#extensions-for-selectively-disabling-optimization" id="id19">Extensions for selectively disabling optimization</a></li>
+<li><a class="reference internal" href="#extensions-for-loop-hint-optimizations" id="id20">Extensions for loop hint optimizations</a></li>
+</ul>
+</div>
+<div class="toctree-wrapper compound">
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>This document describes the language extensions provided by Clang.  In addition
+to the language extensions listed here, Clang aims to support a broad range of
+GCC extensions.  Please see the <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html">GCC manual</a> for more information on
+these extensions.</p>
+</div>
+<div class="section" id="feature-checking-macros">
+<span id="langext-feature-check"></span><h2><a class="toc-backref" href="#id2">Feature Checking Macros</a><a class="headerlink" href="#feature-checking-macros" title="Permalink to this headline">¶</a></h2>
+<p>Language extensions can be very useful, but only if you know you can depend on
+them.  In order to allow fine-grain features checks, we support three builtin
+function-like macros.  This allows you to directly test for a feature in your
+code without having to resort to something like autoconf or fragile “compiler
+version checks”.</p>
+<div class="section" id="has-builtin">
+<h3><tt class="docutils literal"><span class="pre">__has_builtin</span></tt><a class="headerlink" href="#has-builtin" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single identifier argument that is the name of
+a builtin function.  It evaluates to 1 if the builtin is supported or 0 if not.
+It can be used like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre>#ifndef __has_builtin         // Optional of course.
+  #define __has_builtin(x) 0  // Compatibility with non-clang compilers.
+#endif
+
+...
+#if __has_builtin(__builtin_trap)
+  __builtin_trap();
+#else
+  abort();
+#endif
+...
+</pre></div>
+</div>
+</div>
+<div class="section" id="has-feature-and-has-extension">
+<span id="langext-has-feature-has-extension"></span><h3><tt class="docutils literal"><span class="pre">__has_feature</span></tt> and <tt class="docutils literal"><span class="pre">__has_extension</span></tt><a class="headerlink" href="#has-feature-and-has-extension" title="Permalink to this headline">¶</a></h3>
+<p>These function-like macros take a single identifier argument that is the name
+of a feature.  <tt class="docutils literal"><span class="pre">__has_feature</span></tt> evaluates to 1 if the feature is both
+supported by Clang and standardized in the current language standard or 0 if
+not (but see <a class="reference internal" href="#langext-has-feature-back-compat"><em>below</em></a>), while
+<tt class="docutils literal"><span class="pre">__has_extension</span></tt> evaluates to 1 if the feature is supported by Clang in the
+current language (either as a language extension or a standard language
+feature) or 0 if not.  They can be used like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre>#ifndef __has_feature         // Optional of course.
+  #define __has_feature(x) 0  // Compatibility with non-clang compilers.
+#endif
+#ifndef __has_extension
+  #define __has_extension __has_feature // Compatibility with pre-3.0 compilers.
+#endif
+
+...
+#if __has_feature(cxx_rvalue_references)
+// This code will only be compiled with the -std=c++11 and -std=gnu++11
+// options, because rvalue references are only standardized in C++11.
+#endif
+
+#if __has_extension(cxx_rvalue_references)
+// This code will be compiled with the -std=c++11, -std=gnu++11, -std=c++98
+// and -std=gnu++98 options, because rvalue references are supported as a
+// language extension in C++98.
+#endif
+</pre></div>
+</div>
+<p id="langext-has-feature-back-compat">For backward compatibility, <tt class="docutils literal"><span class="pre">__has_feature</span></tt> can also be used to test
+for support for non-standardized features, i.e. features not prefixed <tt class="docutils literal"><span class="pre">c_</span></tt>,
+<tt class="docutils literal"><span class="pre">cxx_</span></tt> or <tt class="docutils literal"><span class="pre">objc_</span></tt>.</p>
+<p>Another use of <tt class="docutils literal"><span class="pre">__has_feature</span></tt> is to check for compiler features not related
+to the language standard, such as e.g. <a class="reference internal" href="AddressSanitizer.html"><em>AddressSanitizer</em></a>.</p>
+<p>If the <tt class="docutils literal"><span class="pre">-pedantic-errors</span></tt> option is given, <tt class="docutils literal"><span class="pre">__has_extension</span></tt> is equivalent
+to <tt class="docutils literal"><span class="pre">__has_feature</span></tt>.</p>
+<p>The feature tag is described along with the language feature below.</p>
+<p>The feature name or extension name can also be specified with a preceding and
+following <tt class="docutils literal"><span class="pre">__</span></tt> (double underscore) to avoid interference from a macro with
+the same name.  For instance, <tt class="docutils literal"><span class="pre">__cxx_rvalue_references__</span></tt> can be used instead
+of <tt class="docutils literal"><span class="pre">cxx_rvalue_references</span></tt>.</p>
+</div>
+<div class="section" id="has-cpp-attribute">
+<h3><tt class="docutils literal"><span class="pre">__has_cpp_attribute</span></tt><a class="headerlink" href="#has-cpp-attribute" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single argument that is the name of a
+C++11-style attribute. The argument can either be a single identifier, or a
+scoped identifier. If the attribute is supported, a nonzero value is returned.
+If the attribute is a standards-based attribute, this macro returns a nonzero
+value based on the year and month in which the attribute was voted into the
+working draft. If the attribute is not supported by the current compliation
+target, this macro evaluates to 0.  It can be used like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre>#ifndef __has_cpp_attribute         // Optional of course.
+  #define __has_cpp_attribute(x) 0  // Compatibility with non-clang compilers.
+#endif
+
+...
+#if __has_cpp_attribute(clang::fallthrough)
+#define FALLTHROUGH [[clang::fallthrough]]
+#else
+#define FALLTHROUGH
+#endif
+...
+</pre></div>
+</div>
+<p>The attribute identifier (but not scope) can also be specified with a preceding
+and following <tt class="docutils literal"><span class="pre">__</span></tt> (double underscore) to avoid interference from a macro with
+the same name.  For instance, <tt class="docutils literal"><span class="pre">gnu::__const__</span></tt> can be used instead of
+<tt class="docutils literal"><span class="pre">gnu::const</span></tt>.</p>
+</div>
+<div class="section" id="has-attribute">
+<h3><tt class="docutils literal"><span class="pre">__has_attribute</span></tt><a class="headerlink" href="#has-attribute" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single identifier argument that is the name of
+a GNU-style attribute.  It evaluates to 1 if the attribute is supported by the
+current compilation target, or 0 if not.  It can be used like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre>#ifndef __has_attribute         // Optional of course.
+  #define __has_attribute(x) 0  // Compatibility with non-clang compilers.
+#endif
+
+...
+#if __has_attribute(always_inline)
+#define ALWAYS_INLINE __attribute__((always_inline))
+#else
+#define ALWAYS_INLINE
+#endif
+...
+</pre></div>
+</div>
+<p>The attribute name can also be specified with a preceding and following <tt class="docutils literal"><span class="pre">__</span></tt>
+(double underscore) to avoid interference from a macro with the same name.  For
+instance, <tt class="docutils literal"><span class="pre">__always_inline__</span></tt> can be used instead of <tt class="docutils literal"><span class="pre">always_inline</span></tt>.</p>
+</div>
+<div class="section" id="has-declspec-attribute">
+<h3><tt class="docutils literal"><span class="pre">__has_declspec_attribute</span></tt><a class="headerlink" href="#has-declspec-attribute" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single identifier argument that is the name of
+an attribute implemented as a Microsoft-style <tt class="docutils literal"><span class="pre">__declspec</span></tt> attribute.  It
+evaluates to 1 if the attribute is supported by the current compilation target,
+or 0 if not.  It can be used like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre>#ifndef __has_declspec_attribute         // Optional of course.
+  #define __has_declspec_attribute(x) 0  // Compatibility with non-clang compilers.
+#endif
+
+...
+#if __has_declspec_attribute(dllexport)
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+...
+</pre></div>
+</div>
+<p>The attribute name can also be specified with a preceding and following <tt class="docutils literal"><span class="pre">__</span></tt>
+(double underscore) to avoid interference from a macro with the same name.  For
+instance, <tt class="docutils literal"><span class="pre">__dllexport__</span></tt> can be used instead of <tt class="docutils literal"><span class="pre">dllexport</span></tt>.</p>
+</div>
+<div class="section" id="is-identifier">
+<h3><tt class="docutils literal"><span class="pre">__is_identifier</span></tt><a class="headerlink" href="#is-identifier" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single identifier argument that might be either
+a reserved word or a regular identifier. It evaluates to 1 if the argument is just
+a regular identifier and not a reserved word, in the sense that it can then be
+used as the name of a user-defined function or variable. Otherwise it evaluates
+to 0.  It can be used like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre>...
+#ifdef __is_identifier          // Compatibility with non-clang compilers.
+  #if __is_identifier(__wchar_t)
+    typedef wchar_t __wchar_t;
+  #endif
+#endif
+
+__wchar_t WideCharacter;
+...
+</pre></div>
+</div>
+</div>
+</div>
+<div class="section" id="include-file-checking-macros">
+<h2><a class="toc-backref" href="#id3">Include File Checking Macros</a><a class="headerlink" href="#include-file-checking-macros" title="Permalink to this headline">¶</a></h2>
+<p>Not all developments systems have the same include files.  The
+<a class="reference internal" href="#langext-has-include"><em>__has_include</em></a> and <a class="reference internal" href="#langext-has-include-next"><em>__has_include_next</em></a> macros allow
+you to check for the existence of an include file before doing a possibly
+failing <tt class="docutils literal"><span class="pre">#include</span></tt> directive.  Include file checking macros must be used
+as expressions in <tt class="docutils literal"><span class="pre">#if</span></tt> or <tt class="docutils literal"><span class="pre">#elif</span></tt> preprocessing directives.</p>
+<div class="section" id="has-include">
+<span id="langext-has-include"></span><h3><tt class="docutils literal"><span class="pre">__has_include</span></tt><a class="headerlink" href="#has-include" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single file name string argument that is the
+name of an include file.  It evaluates to 1 if the file can be found using the
+include paths, or 0 otherwise:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// Note the two possible file name string formats.</span>
+<span class="cp">#if __has_include("myinclude.h") && __has_include(<stdint.h>)</span>
+<span class="cp"># include "myinclude.h"</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+<p>To test for this feature, use <tt class="docutils literal"><span class="pre">#if</span> <span class="pre">defined(__has_include)</span></tt>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// To avoid problem with non-clang compilers not having this macro.</span>
+<span class="cp">#if defined(__has_include)</span>
+<span class="cp">#if __has_include("myinclude.h")</span>
+<span class="cp"># include "myinclude.h"</span>
+<span class="cp">#endif</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="has-include-next">
+<span id="langext-has-include-next"></span><h3><tt class="docutils literal"><span class="pre">__has_include_next</span></tt><a class="headerlink" href="#has-include-next" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a single file name string argument that is the
+name of an include file.  It is like <tt class="docutils literal"><span class="pre">__has_include</span></tt> except that it looks for
+the second instance of the given file found in the include paths.  It evaluates
+to 1 if the second instance of the file can be found using the include paths,
+or 0 otherwise:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// Note the two possible file name string formats.</span>
+<span class="cp">#if __has_include_next("myinclude.h") && __has_include_next(<stdint.h>)</span>
+<span class="cp"># include_next "myinclude.h"</span>
+<span class="cp">#endif</span>
+
+<span class="c1">// To avoid problem with non-clang compilers not having this macro.</span>
+<span class="cp">#if defined(__has_include_next)</span>
+<span class="cp">#if __has_include_next("myinclude.h")</span>
+<span class="cp"># include_next "myinclude.h"</span>
+<span class="cp">#endif</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+<p>Note that <tt class="docutils literal"><span class="pre">__has_include_next</span></tt>, like the GNU extension <tt class="docutils literal"><span class="pre">#include_next</span></tt>
+directive, is intended for use in headers only, and will issue a warning if
+used in the top-level compilation file.  A warning will also be issued if an
+absolute path is used in the file argument.</p>
+</div>
+<div class="section" id="has-warning">
+<h3><tt class="docutils literal"><span class="pre">__has_warning</span></tt><a class="headerlink" href="#has-warning" title="Permalink to this headline">¶</a></h3>
+<p>This function-like macro takes a string literal that represents a command line
+option for a warning and returns true if that is a valid warning option.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#if __has_warning("-Wformat")</span>
+<span class="p">...</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+</div>
+</div>
+<div class="section" id="builtin-macros">
+<h2><a class="toc-backref" href="#id4">Builtin Macros</a><a class="headerlink" href="#builtin-macros" title="Permalink to this headline">¶</a></h2>
+<dl class="docutils">
+<dt><tt class="docutils literal"><span class="pre">__BASE_FILE__</span></tt></dt>
+<dd>Defined to a string that contains the name of the main input file passed to
+Clang.</dd>
+<dt><tt class="docutils literal"><span class="pre">__COUNTER__</span></tt></dt>
+<dd>Defined to an integer value that starts at zero and is incremented each time
+the <tt class="docutils literal"><span class="pre">__COUNTER__</span></tt> macro is expanded.</dd>
+<dt><tt class="docutils literal"><span class="pre">__INCLUDE_LEVEL__</span></tt></dt>
+<dd>Defined to an integral value that is the include depth of the file currently
+being translated.  For the main file, this value is zero.</dd>
+<dt><tt class="docutils literal"><span class="pre">__TIMESTAMP__</span></tt></dt>
+<dd>Defined to the date and time of the last modification of the current source
+file.</dd>
+<dt><tt class="docutils literal"><span class="pre">__clang__</span></tt></dt>
+<dd>Defined when compiling with Clang</dd>
+<dt><tt class="docutils literal"><span class="pre">__clang_major__</span></tt></dt>
+<dd>Defined to the major marketing version number of Clang (e.g., the 2 in
+2.0.1).  Note that marketing version numbers should not be used to check for
+language features, as different vendors use different numbering schemes.
+Instead, use the <a class="reference internal" href="#langext-feature-check"><em>Feature Checking Macros</em></a>.</dd>
+<dt><tt class="docutils literal"><span class="pre">__clang_minor__</span></tt></dt>
+<dd>Defined to the minor version number of Clang (e.g., the 0 in 2.0.1).  Note
+that marketing version numbers should not be used to check for language
+features, as different vendors use different numbering schemes.  Instead, use
+the <a class="reference internal" href="#langext-feature-check"><em>Feature Checking Macros</em></a>.</dd>
+<dt><tt class="docutils literal"><span class="pre">__clang_patchlevel__</span></tt></dt>
+<dd>Defined to the marketing patch level of Clang (e.g., the 1 in 2.0.1).</dd>
+<dt><tt class="docutils literal"><span class="pre">__clang_version__</span></tt></dt>
+<dd>Defined to a string that captures the Clang marketing version, including the
+Subversion tag or revision number, e.g., “<tt class="docutils literal"><span class="pre">1.5</span> <span class="pre">(trunk</span> <span class="pre">102332)</span></tt>”.</dd>
+</dl>
+</div>
+<div class="section" id="vectors-and-extended-vectors">
+<span id="langext-vectors"></span><h2><a class="toc-backref" href="#id5">Vectors and Extended Vectors</a><a class="headerlink" href="#vectors-and-extended-vectors" title="Permalink to this headline">¶</a></h2>
+<p>Supports the GCC, OpenCL, AltiVec and NEON vector extensions.</p>
+<p>OpenCL vector types are created using <tt class="docutils literal"><span class="pre">ext_vector_type</span></tt> attribute.  It
+support for <tt class="docutils literal"><span class="pre">V.xyzw</span></tt> syntax and other tidbits as seen in OpenCL.  An example
+is:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">typedef</span> <span class="kt">float</span> <span class="n">float4</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">ext_vector_type</span><span class="p">(</span><span class="mi">4</span><span class="p">)));</span>
+<span class="k">typedef</span> <span class="kt">float</span> <span class="n">float2</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">ext_vector_type</span><span class="p">(</span><span class="mi">2</span><span class="p">)));</span>
+
+<span class="n">float4</span> <span class="nf">foo</span><span class="p">(</span><span class="n">float2</span> <span class="n">a</span><span class="p">,</span> <span class="n">float2</span> <span class="n">b</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">float4</span> <span class="n">c</span><span class="p">;</span>
+  <span class="n">c</span><span class="p">.</span><span class="n">xz</span> <span class="o">=</span> <span class="n">a</span><span class="p">;</span>
+  <span class="n">c</span><span class="p">.</span><span class="n">yw</span> <span class="o">=</span> <span class="n">b</span><span class="p">;</span>
+  <span class="k">return</span> <span class="n">c</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_extension(attribute_ext_vector_type)</span></tt>.</p>
+<p>Giving <tt class="docutils literal"><span class="pre">-faltivec</span></tt> option to clang enables support for AltiVec vector syntax
+and functions.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">vector</span> <span class="kt">float</span> <span class="nf">foo</span><span class="p">(</span><span class="n">vector</span> <span class="kt">int</span> <span class="n">a</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">vector</span> <span class="kt">int</span> <span class="n">b</span><span class="p">;</span>
+  <span class="n">b</span> <span class="o">=</span> <span class="n">vec_add</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span> <span class="o">+</span> <span class="n">a</span><span class="p">;</span>
+  <span class="k">return</span> <span class="p">(</span><span class="n">vector</span> <span class="kt">float</span><span class="p">)</span><span class="n">b</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>NEON vector types are created using <tt class="docutils literal"><span class="pre">neon_vector_type</span></tt> and
+<tt class="docutils literal"><span class="pre">neon_polyvector_type</span></tt> attributes.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">typedef</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">neon_vector_type</span><span class="p">(</span><span class="mi">8</span><span class="p">)))</span> <span class="kt">int8_t</span> <span class="kt">int8x8_t</span><span class="p">;</span>
+<span class="k">typedef</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">neon_polyvector_type</span><span class="p">(</span><span class="mi">16</span><span class="p">)))</span> <span class="kt">poly8_t</span> <span class="kt">poly8x16_t</span><span class="p">;</span>
+
+<span class="kt">int8x8_t</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int8x8_t</span> <span class="n">a</span><span class="p">)</span> <span class="p">{</span>
+  <span class="kt">int8x8_t</span> <span class="n">v</span><span class="p">;</span>
+  <span class="n">v</span> <span class="o">=</span> <span class="n">a</span><span class="p">;</span>
+  <span class="k">return</span> <span class="n">v</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<div class="section" id="vector-literals">
+<h3>Vector Literals<a class="headerlink" href="#vector-literals" title="Permalink to this headline">¶</a></h3>
+<p>Vector literals can be used to create vectors from a set of scalars, or
+vectors.  Either parentheses or braces form can be used.  In the parentheses
+form the number of literal values specified must be one, i.e. referring to a
+scalar value, or must match the size of the vector type being created.  If a
+single scalar literal value is specified, the scalar literal value will be
+replicated to all the components of the vector type.  In the brackets form any
+number of literals can be specified.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">typedef</span> <span class="kt">int</span> <span class="n">v4si</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">__vector_size__</span><span class="p">(</span><span class="mi">16</span><span class="p">)));</span>
+<span class="k">typedef</span> <span class="kt">float</span> <span class="n">float4</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">ext_vector_type</span><span class="p">(</span><span class="mi">4</span><span class="p">)));</span>
+<span class="k">typedef</span> <span class="kt">float</span> <span class="n">float2</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">ext_vector_type</span><span class="p">(</span><span class="mi">2</span><span class="p">)));</span>
+
+<span class="n">v4si</span> <span class="n">vsi</span> <span class="o">=</span> <span class="p">(</span><span class="n">v4si</span><span class="p">){</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">};</span>
+<span class="n">float4</span> <span class="n">vf</span> <span class="o">=</span> <span class="p">(</span><span class="n">float4</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">,</span> <span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">);</span>
+<span class="n">vector</span> <span class="kt">int</span> <span class="n">vi1</span> <span class="o">=</span> <span class="p">(</span><span class="n">vector</span> <span class="kt">int</span><span class="p">)(</span><span class="mi">1</span><span class="p">);</span>    <span class="c1">// vi1 will be (1, 1, 1, 1).</span>
+<span class="n">vector</span> <span class="kt">int</span> <span class="n">vi2</span> <span class="o">=</span> <span class="p">(</span><span class="n">vector</span> <span class="kt">int</span><span class="p">){</span><span class="mi">1</span><span class="p">};</span>    <span class="c1">// vi2 will be (1, 0, 0, 0).</span>
+<span class="n">vector</span> <span class="kt">int</span> <span class="n">vi3</span> <span class="o">=</span> <span class="p">(</span><span class="n">vector</span> <span class="kt">int</span><span class="p">)(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span> <span class="c1">// error</span>
+<span class="n">vector</span> <span class="kt">int</span> <span class="n">vi4</span> <span class="o">=</span> <span class="p">(</span><span class="n">vector</span> <span class="kt">int</span><span class="p">){</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">};</span> <span class="c1">// vi4 will be (1, 2, 0, 0).</span>
+<span class="n">vector</span> <span class="kt">int</span> <span class="n">vi5</span> <span class="o">=</span> <span class="p">(</span><span class="n">vector</span> <span class="kt">int</span><span class="p">)(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">);</span>
+<span class="n">float4</span> <span class="n">vf</span> <span class="o">=</span> <span class="p">(</span><span class="n">float4</span><span class="p">)((</span><span class="n">float2</span><span class="p">)(</span><span class="mf">1.0f</span><span class="p">,</span> <span class="mf">2.0f</span><span class="p">),</span> <span class="p">(</span><span class="n">float2</span><span class="p">)(</span><span class="mf">3.0f</span><span class="p">,</span> <span class="mf">4.0f</span><span class="p">));</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="vector-operations">
+<h3>Vector Operations<a class="headerlink" href="#vector-operations" title="Permalink to this headline">¶</a></h3>
+<p>The table below shows the support for each operation by vector extension.  A
+dash indicates that an operation is not accepted according to a corresponding
+specification.</p>
+<table border="1" class="docutils">
+<colgroup>
+<col width="52%" />
+<col width="12%" />
+<col width="12%" />
+<col width="12%" />
+<col width="12%" />
+</colgroup>
+<thead valign="bottom">
+<tr class="row-odd"><th class="head">Opeator</th>
+<th class="head">OpenCL</th>
+<th class="head">AltiVec</th>
+<th class="head">GCC</th>
+<th class="head">NEON</th>
+</tr>
+</thead>
+<tbody valign="top">
+<tr class="row-even"><td>[]</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+</tr>
+<tr class="row-odd"><td>unary operators +, –</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+</tr>
+<tr class="row-even"><td>++, – –</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+</tr>
+<tr class="row-odd"><td>+,–,*,/,%</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+</tr>
+<tr class="row-even"><td>bitwise operators &,|,^,~</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+</tr>
+<tr class="row-odd"><td>>>,<<</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+</tr>
+<tr class="row-even"><td>!, &&, ||</td>
+<td>yes</td>
+<td>–</td>
+<td>–</td>
+<td>–</td>
+</tr>
+<tr class="row-odd"><td>==, !=, >, <, >=, <=</td>
+<td>yes</td>
+<td>yes</td>
+<td>–</td>
+<td>–</td>
+</tr>
+<tr class="row-even"><td>=</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+</tr>
+<tr class="row-odd"><td>:?</td>
+<td>yes</td>
+<td>–</td>
+<td>–</td>
+<td>–</td>
+</tr>
+<tr class="row-even"><td>sizeof</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+</tr>
+<tr class="row-odd"><td>C-style cast</td>
+<td>yes</td>
+<td>yes</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr class="row-even"><td>reinterpret_cast</td>
+<td>yes</td>
+<td>no</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr class="row-odd"><td>static_cast</td>
+<td>yes</td>
+<td>no</td>
+<td>yes</td>
+<td>no</td>
+</tr>
+<tr class="row-even"><td>const_cast</td>
+<td>no</td>
+<td>no</td>
+<td>no</td>
+<td>no</td>
+</tr>
+</tbody>
+</table>
+<p>See also <a class="reference internal" href="#langext-builtin-shufflevector"><em>__builtin_shufflevector</em></a>, <a class="reference internal" href="#langext-builtin-convertvector"><em>__builtin_convertvector</em></a>.</p>
+</div>
+</div>
+<div class="section" id="messages-on-deprecated-and-unavailable-attributes">
+<h2><a class="toc-backref" href="#id6">Messages on <tt class="docutils literal"><span class="pre">deprecated</span></tt> and <tt class="docutils literal"><span class="pre">unavailable</span></tt> Attributes</a><a class="headerlink" href="#messages-on-deprecated-and-unavailable-attributes" title="Permalink to this headline">¶</a></h2>
+<p>An optional string message can be added to the <tt class="docutils literal"><span class="pre">deprecated</span></tt> and
+<tt class="docutils literal"><span class="pre">unavailable</span></tt> attributes.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">explode</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">deprecated</span><span class="p">(</span><span class="s">"extremely unsafe, use 'combust' instead!!!"</span><span class="p">)));</span>
+</pre></div>
+</div>
+<p>If the deprecated or unavailable declaration is used, the message will be
+incorporated into the appropriate diagnostic:</p>
+<div class="highlight-c++"><div class="highlight"><pre>harmless.c:4:3: warning: 'explode' is deprecated: extremely unsafe, use 'combust' instead!!!
+      [-Wdeprecated-declarations]
+  explode();
+  ^
+</pre></div>
+</div>
+<p>Query for this feature with
+<tt class="docutils literal"><span class="pre">__has_extension(attribute_deprecated_with_message)</span></tt> and
+<tt class="docutils literal"><span class="pre">__has_extension(attribute_unavailable_with_message)</span></tt>.</p>
+</div>
+<div class="section" id="attributes-on-enumerators">
+<h2><a class="toc-backref" href="#id7">Attributes on Enumerators</a><a class="headerlink" href="#attributes-on-enumerators" title="Permalink to this headline">¶</a></h2>
+<p>Clang allows attributes to be written on individual enumerators.  This allows
+enumerators to be deprecated, made unavailable, etc.  The attribute must appear
+after the enumerator name and before any initializer, like so:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">enum</span> <span class="n">OperationMode</span> <span class="p">{</span>
+  <span class="n">OM_Invalid</span><span class="p">,</span>
+  <span class="n">OM_Normal</span><span class="p">,</span>
+  <span class="n">OM_Terrified</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">deprecated</span><span class="p">)),</span>
+  <span class="n">OM_AbortOnError</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">deprecated</span><span class="p">))</span> <span class="o">=</span> <span class="mi">4</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>Attributes on the <tt class="docutils literal"><span class="pre">enum</span></tt> declaration do not apply to individual enumerators.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_extension(enumerator_attributes)</span></tt>.</p>
+</div>
+<div class="section" id="user-specified-system-frameworks">
+<h2><a class="toc-backref" href="#id8">‘User-Specified’ System Frameworks</a><a class="headerlink" href="#user-specified-system-frameworks" title="Permalink to this headline">¶</a></h2>
+<p>Clang provides a mechanism by which frameworks can be built in such a way that
+they will always be treated as being “system frameworks”, even if they are not
+present in a system framework directory.  This can be useful to system
+framework developers who want to be able to test building other applications
+with development builds of their framework, including the manner in which the
+compiler changes warning behavior for system headers.</p>
+<p>Framework developers can opt-in to this mechanism by creating a
+“<tt class="docutils literal"><span class="pre">.system_framework</span></tt>” file at the top-level of their framework.  That is, the
+framework should have contents like:</p>
+<div class="highlight-none"><div class="highlight"><pre>.../TestFramework.framework
+.../TestFramework.framework/.system_framework
+.../TestFramework.framework/Headers
+.../TestFramework.framework/Headers/TestFramework.h
+...
+</pre></div>
+</div>
+<p>Clang will treat the presence of this file as an indicator that the framework
+should be treated as a system framework, regardless of how it was found in the
+framework search path.  For consistency, we recommend that such files never be
+included in installed versions of the framework.</p>
+</div>
+<div class="section" id="checks-for-standard-language-features">
+<h2><a class="toc-backref" href="#id9">Checks for Standard Language Features</a><a class="headerlink" href="#checks-for-standard-language-features" title="Permalink to this headline">¶</a></h2>
+<p>The <tt class="docutils literal"><span class="pre">__has_feature</span></tt> macro can be used to query if certain standard language
+features are enabled.  The <tt class="docutils literal"><span class="pre">__has_extension</span></tt> macro can be used to query if
+language features are available as an extension when compiling for a standard
+which does not provide them.  The features which can be tested are listed here.</p>
+<p>Since Clang 3.4, the C++ SD-6 feature test macros are also supported.
+These are macros with names of the form <tt class="docutils literal"><span class="pre">__cpp_<feature_name></span></tt>, and are
+intended to be a portable way to query the supported features of the compiler.
+See <a class="reference external" href="http://clang.llvm.org/cxx_status.html#ts">the C++ status page</a> for
+information on the version of SD-6 supported by each Clang release, and the
+macros provided by that revision of the recommendations.</p>
+<div class="section" id="c-98">
+<h3>C++98<a class="headerlink" href="#c-98" title="Permalink to this headline">¶</a></h3>
+<p>The features listed below are part of the C++98 standard.  These features are
+enabled by default when compiling C++ code.</p>
+<div class="section" id="c-exceptions">
+<h4>C++ exceptions<a class="headerlink" href="#c-exceptions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_exceptions)</span></tt> to determine if C++ exceptions have been
+enabled.  For example, compiling code with <tt class="docutils literal"><span class="pre">-fno-exceptions</span></tt> disables C++
+exceptions.</p>
+</div>
+<div class="section" id="c-rtti">
+<h4>C++ RTTI<a class="headerlink" href="#c-rtti" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_rtti)</span></tt> to determine if C++ RTTI has been enabled.  For
+example, compiling code with <tt class="docutils literal"><span class="pre">-fno-rtti</span></tt> disables the use of RTTI.</p>
+</div>
+</div>
+<div class="section" id="c-11">
+<h3>C++11<a class="headerlink" href="#c-11" title="Permalink to this headline">¶</a></h3>
+<p>The features listed below are part of the C++11 standard.  As a result, all
+these features are enabled with the <tt class="docutils literal"><span class="pre">-std=c++11</span></tt> or <tt class="docutils literal"><span class="pre">-std=gnu++11</span></tt> option
+when compiling C++ code.</p>
+<div class="section" id="c-11-sfinae-includes-access-control">
+<h4>C++11 SFINAE includes access control<a class="headerlink" href="#c-11-sfinae-includes-access-control" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_access_control_sfinae)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_access_control_sfinae)</span></tt> to determine whether
+access-control errors (e.g., calling a private constructor) are considered to
+be template argument deduction errors (aka SFINAE errors), per <a class="reference external" href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1170">C++ DR1170</a>.</p>
+</div>
+<div class="section" id="c-11-alias-templates">
+<h4>C++11 alias templates<a class="headerlink" href="#c-11-alias-templates" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_alias_templates)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_alias_templates)</span></tt> to determine if support for C++11’s
+alias declarations and alias templates is enabled.</p>
+</div>
+<div class="section" id="c-11-alignment-specifiers">
+<h4>C++11 alignment specifiers<a class="headerlink" href="#c-11-alignment-specifiers" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_alignas)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_alignas)</span></tt> to
+determine if support for alignment specifiers using <tt class="docutils literal"><span class="pre">alignas</span></tt> is enabled.</p>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_alignof)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_alignof)</span></tt> to
+determine if support for the <tt class="docutils literal"><span class="pre">alignof</span></tt> keyword is enabled.</p>
+</div>
+<div class="section" id="c-11-attributes">
+<h4>C++11 attributes<a class="headerlink" href="#c-11-attributes" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_attributes)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_attributes)</span></tt> to
+determine if support for attribute parsing with C++11’s square bracket notation
+is enabled.</p>
+</div>
+<div class="section" id="c-11-generalized-constant-expressions">
+<h4>C++11 generalized constant expressions<a class="headerlink" href="#c-11-generalized-constant-expressions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_constexpr)</span></tt> to determine if support for generalized
+constant expressions (e.g., <tt class="docutils literal"><span class="pre">constexpr</span></tt>) is enabled.</p>
+</div>
+<div class="section" id="c-11-decltype">
+<h4>C++11 <tt class="docutils literal"><span class="pre">decltype()</span></tt><a class="headerlink" href="#c-11-decltype" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_decltype)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_decltype)</span></tt> to
+determine if support for the <tt class="docutils literal"><span class="pre">decltype()</span></tt> specifier is enabled.  C++11’s
+<tt class="docutils literal"><span class="pre">decltype</span></tt> does not require type-completeness of a function call expression.
+Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_decltype_incomplete_return_types)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_decltype_incomplete_return_types)</span></tt> to determine if
+support for this feature is enabled.</p>
+</div>
+<div class="section" id="c-11-default-template-arguments-in-function-templates">
+<h4>C++11 default template arguments in function templates<a class="headerlink" href="#c-11-default-template-arguments-in-function-templates" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_default_function_template_args)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_default_function_template_args)</span></tt> to determine if support
+for default template arguments in function templates is enabled.</p>
+</div>
+<div class="section" id="c-11-defaulted-functions">
+<h4>C++11 <tt class="docutils literal"><span class="pre">default</span></tt>ed functions<a class="headerlink" href="#c-11-defaulted-functions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_defaulted_functions)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_defaulted_functions)</span></tt> to determine if support for
+defaulted function definitions (with <tt class="docutils literal"><span class="pre">=</span> <span class="pre">default</span></tt>) is enabled.</p>
+</div>
+<div class="section" id="c-11-delegating-constructors">
+<h4>C++11 delegating constructors<a class="headerlink" href="#c-11-delegating-constructors" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_delegating_constructors)</span></tt> to determine if support for
+delegating constructors is enabled.</p>
+</div>
+<div class="section" id="c-11-deleted-functions">
+<h4>C++11 <tt class="docutils literal"><span class="pre">deleted</span></tt> functions<a class="headerlink" href="#c-11-deleted-functions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_deleted_functions)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_deleted_functions)</span></tt> to determine if support for deleted
+function definitions (with <tt class="docutils literal"><span class="pre">=</span> <span class="pre">delete</span></tt>) is enabled.</p>
+</div>
+<div class="section" id="c-11-explicit-conversion-functions">
+<h4>C++11 explicit conversion functions<a class="headerlink" href="#c-11-explicit-conversion-functions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_explicit_conversions)</span></tt> to determine if support for
+<tt class="docutils literal"><span class="pre">explicit</span></tt> conversion functions is enabled.</p>
+</div>
+<div class="section" id="c-11-generalized-initializers">
+<h4>C++11 generalized initializers<a class="headerlink" href="#c-11-generalized-initializers" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_generalized_initializers)</span></tt> to determine if support for
+generalized initializers (using braced lists and <tt class="docutils literal"><span class="pre">std::initializer_list</span></tt>) is
+enabled.</p>
+</div>
+<div class="section" id="c-11-implicit-move-constructors-assignment-operators">
+<h4>C++11 implicit move constructors/assignment operators<a class="headerlink" href="#c-11-implicit-move-constructors-assignment-operators" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_implicit_moves)</span></tt> to determine if Clang will implicitly
+generate move constructors and move assignment operators where needed.</p>
+</div>
+<div class="section" id="c-11-inheriting-constructors">
+<h4>C++11 inheriting constructors<a class="headerlink" href="#c-11-inheriting-constructors" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_inheriting_constructors)</span></tt> to determine if support for
+inheriting constructors is enabled.</p>
+</div>
+<div class="section" id="c-11-inline-namespaces">
+<h4>C++11 inline namespaces<a class="headerlink" href="#c-11-inline-namespaces" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_inline_namespaces)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_inline_namespaces)</span></tt> to determine if support for inline
+namespaces is enabled.</p>
+</div>
+<div class="section" id="c-11-lambdas">
+<h4>C++11 lambdas<a class="headerlink" href="#c-11-lambdas" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_lambdas)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_lambdas)</span></tt> to
+determine if support for lambdas is enabled.</p>
+</div>
+<div class="section" id="c-11-local-and-unnamed-types-as-template-arguments">
+<h4>C++11 local and unnamed types as template arguments<a class="headerlink" href="#c-11-local-and-unnamed-types-as-template-arguments" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_local_type_template_args)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_local_type_template_args)</span></tt> to determine if support for
+local and unnamed types as template arguments is enabled.</p>
+</div>
+<div class="section" id="c-11-noexcept">
+<h4>C++11 noexcept<a class="headerlink" href="#c-11-noexcept" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_noexcept)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_noexcept)</span></tt> to
+determine if support for noexcept exception specifications is enabled.</p>
+</div>
+<div class="section" id="c-11-in-class-non-static-data-member-initialization">
+<h4>C++11 in-class non-static data member initialization<a class="headerlink" href="#c-11-in-class-non-static-data-member-initialization" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_nonstatic_member_init)</span></tt> to determine whether in-class
+initialization of non-static data members is enabled.</p>
+</div>
+<div class="section" id="c-11-nullptr">
+<h4>C++11 <tt class="docutils literal"><span class="pre">nullptr</span></tt><a class="headerlink" href="#c-11-nullptr" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_nullptr)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_nullptr)</span></tt> to
+determine if support for <tt class="docutils literal"><span class="pre">nullptr</span></tt> is enabled.</p>
+</div>
+<div class="section" id="c-11-override-control">
+<h4>C++11 <tt class="docutils literal"><span class="pre">override</span> <span class="pre">control</span></tt><a class="headerlink" href="#c-11-override-control" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_override_control)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_override_control)</span></tt> to determine if support for the
+override control keywords is enabled.</p>
+</div>
+<div class="section" id="c-11-reference-qualified-functions">
+<h4>C++11 reference-qualified functions<a class="headerlink" href="#c-11-reference-qualified-functions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_reference_qualified_functions)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_reference_qualified_functions)</span></tt> to determine if support
+for reference-qualified functions (e.g., member functions with <tt class="docutils literal"><span class="pre">&</span></tt> or <tt class="docutils literal"><span class="pre">&&</span></tt>
+applied to <tt class="docutils literal"><span class="pre">*this</span></tt>) is enabled.</p>
+</div>
+<div class="section" id="c-11-range-based-for-loop">
+<h4>C++11 range-based <tt class="docutils literal"><span class="pre">for</span></tt> loop<a class="headerlink" href="#c-11-range-based-for-loop" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_range_for)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_range_for)</span></tt> to
+determine if support for the range-based for loop is enabled.</p>
+</div>
+<div class="section" id="c-11-raw-string-literals">
+<h4>C++11 raw string literals<a class="headerlink" href="#c-11-raw-string-literals" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_raw_string_literals)</span></tt> to determine if support for raw
+string literals (e.g., <tt class="docutils literal"><span class="pre">R"x(foo\bar)x"</span></tt>) is enabled.</p>
+</div>
+<div class="section" id="c-11-rvalue-references">
+<h4>C++11 rvalue references<a class="headerlink" href="#c-11-rvalue-references" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_rvalue_references)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_rvalue_references)</span></tt> to determine if support for rvalue
+references is enabled.</p>
+</div>
+<div class="section" id="c-11-static-assert">
+<h4>C++11 <tt class="docutils literal"><span class="pre">static_assert()</span></tt><a class="headerlink" href="#c-11-static-assert" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_static_assert)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_static_assert)</span></tt> to determine if support for compile-time
+assertions using <tt class="docutils literal"><span class="pre">static_assert</span></tt> is enabled.</p>
+</div>
+<div class="section" id="c-11-thread-local">
+<h4>C++11 <tt class="docutils literal"><span class="pre">thread_local</span></tt><a class="headerlink" href="#c-11-thread-local" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_thread_local)</span></tt> to determine if support for
+<tt class="docutils literal"><span class="pre">thread_local</span></tt> variables is enabled.</p>
+</div>
+<div class="section" id="c-11-type-inference">
+<h4>C++11 type inference<a class="headerlink" href="#c-11-type-inference" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_auto_type)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(cxx_auto_type)</span></tt> to
+determine C++11 type inference is supported using the <tt class="docutils literal"><span class="pre">auto</span></tt> specifier.  If
+this is disabled, <tt class="docutils literal"><span class="pre">auto</span></tt> will instead be a storage class specifier, as in C
+or C++98.</p>
+</div>
+<div class="section" id="c-11-strongly-typed-enumerations">
+<h4>C++11 strongly typed enumerations<a class="headerlink" href="#c-11-strongly-typed-enumerations" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_strong_enums)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_strong_enums)</span></tt> to determine if support for strongly
+typed, scoped enumerations is enabled.</p>
+</div>
+<div class="section" id="c-11-trailing-return-type">
+<h4>C++11 trailing return type<a class="headerlink" href="#c-11-trailing-return-type" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_trailing_return)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_trailing_return)</span></tt> to determine if support for the
+alternate function declaration syntax with trailing return type is enabled.</p>
+</div>
+<div class="section" id="c-11-unicode-string-literals">
+<h4>C++11 Unicode string literals<a class="headerlink" href="#c-11-unicode-string-literals" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_unicode_literals)</span></tt> to determine if support for Unicode
+string literals is enabled.</p>
+</div>
+<div class="section" id="c-11-unrestricted-unions">
+<h4>C++11 unrestricted unions<a class="headerlink" href="#c-11-unrestricted-unions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_unrestricted_unions)</span></tt> to determine if support for
+unrestricted unions is enabled.</p>
+</div>
+<div class="section" id="c-11-user-defined-literals">
+<h4>C++11 user-defined literals<a class="headerlink" href="#c-11-user-defined-literals" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_user_literals)</span></tt> to determine if support for
+user-defined literals is enabled.</p>
+</div>
+<div class="section" id="c-11-variadic-templates">
+<h4>C++11 variadic templates<a class="headerlink" href="#c-11-variadic-templates" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_variadic_templates)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_variadic_templates)</span></tt> to determine if support for
+variadic templates is enabled.</p>
+</div>
+</div>
+<div class="section" id="c-1y">
+<h3>C++1y<a class="headerlink" href="#c-1y" title="Permalink to this headline">¶</a></h3>
+<p>The features listed below are part of the committee draft for the C++1y
+standard.  As a result, all these features are enabled with the <tt class="docutils literal"><span class="pre">-std=c++1y</span></tt>
+or <tt class="docutils literal"><span class="pre">-std=gnu++1y</span></tt> option when compiling C++ code.</p>
+<div class="section" id="c-1y-binary-literals">
+<h4>C++1y binary literals<a class="headerlink" href="#c-1y-binary-literals" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_binary_literals)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_binary_literals)</span></tt> to determine whether
+binary literals (for instance, <tt class="docutils literal"><span class="pre">0b10010</span></tt>) are recognized. Clang supports this
+feature as an extension in all language modes.</p>
+</div>
+<div class="section" id="c-1y-contextual-conversions">
+<h4>C++1y contextual conversions<a class="headerlink" href="#c-1y-contextual-conversions" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_contextual_conversions)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_contextual_conversions)</span></tt> to determine if the C++1y rules
+are used when performing an implicit conversion for an array bound in a
+<em>new-expression</em>, the operand of a <em>delete-expression</em>, an integral constant
+expression, or a condition in a <tt class="docutils literal"><span class="pre">switch</span></tt> statement.</p>
+</div>
+<div class="section" id="c-1y-decltype-auto">
+<h4>C++1y decltype(auto)<a class="headerlink" href="#c-1y-decltype-auto" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_decltype_auto)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_decltype_auto)</span></tt> to determine if support
+for the <tt class="docutils literal"><span class="pre">decltype(auto)</span></tt> placeholder type is enabled.</p>
+</div>
+<div class="section" id="c-1y-default-initializers-for-aggregates">
+<h4>C++1y default initializers for aggregates<a class="headerlink" href="#c-1y-default-initializers-for-aggregates" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_aggregate_nsdmi)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_aggregate_nsdmi)</span></tt> to determine if support
+for default initializers in aggregate members is enabled.</p>
+</div>
+<div class="section" id="c-1y-digit-separators">
+<h4>C++1y digit separators<a class="headerlink" href="#c-1y-digit-separators" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__cpp_digit_separators</span></tt> to determine if support for digit separators
+using single quotes (for instance, <tt class="docutils literal"><span class="pre">10'000</span></tt>) is enabled. At this time, there
+is no corresponding <tt class="docutils literal"><span class="pre">__has_feature</span></tt> name</p>
+</div>
+<div class="section" id="c-1y-generalized-lambda-capture">
+<h4>C++1y generalized lambda capture<a class="headerlink" href="#c-1y-generalized-lambda-capture" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_init_captures)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_init_captures)</span></tt> to determine if support for
+lambda captures with explicit initializers is enabled
+(for instance, <tt class="docutils literal"><span class="pre">[n(0)]</span> <span class="pre">{</span> <span class="pre">return</span> <span class="pre">++n;</span> <span class="pre">}</span></tt>).</p>
+</div>
+<div class="section" id="c-1y-generic-lambdas">
+<h4>C++1y generic lambdas<a class="headerlink" href="#c-1y-generic-lambdas" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_generic_lambdas)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_generic_lambdas)</span></tt> to determine if support for generic
+(polymorphic) lambdas is enabled
+(for instance, <tt class="docutils literal"><span class="pre">[]</span> <span class="pre">(auto</span> <span class="pre">x)</span> <span class="pre">{</span> <span class="pre">return</span> <span class="pre">x</span> <span class="pre">+</span> <span class="pre">1;</span> <span class="pre">}</span></tt>).</p>
+</div>
+<div class="section" id="c-1y-relaxed-constexpr">
+<h4>C++1y relaxed constexpr<a class="headerlink" href="#c-1y-relaxed-constexpr" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_relaxed_constexpr)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_relaxed_constexpr)</span></tt> to determine if variable
+declarations, local variable modification, and control flow constructs
+are permitted in <tt class="docutils literal"><span class="pre">constexpr</span></tt> functions.</p>
+</div>
+<div class="section" id="c-1y-return-type-deduction">
+<h4>C++1y return type deduction<a class="headerlink" href="#c-1y-return-type-deduction" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_return_type_deduction)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_return_type_deduction)</span></tt> to determine if support
+for return type deduction for functions (using <tt class="docutils literal"><span class="pre">auto</span></tt> as a return type)
+is enabled.</p>
+</div>
+<div class="section" id="c-1y-runtime-sized-arrays">
+<h4>C++1y runtime-sized arrays<a class="headerlink" href="#c-1y-runtime-sized-arrays" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_runtime_array)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_runtime_array)</span></tt> to determine if support
+for arrays of runtime bound (a restricted form of variable-length arrays)
+is enabled.
+Clang’s implementation of this feature is incomplete.</p>
+</div>
+<div class="section" id="c-1y-variable-templates">
+<h4>C++1y variable templates<a class="headerlink" href="#c-1y-variable-templates" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(cxx_variable_templates)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(cxx_variable_templates)</span></tt> to determine if support for
+templated variable declarations is enabled.</p>
+</div>
+</div>
+<div class="section" id="c11">
+<h3>C11<a class="headerlink" href="#c11" title="Permalink to this headline">¶</a></h3>
+<p>The features listed below are part of the C11 standard.  As a result, all these
+features are enabled with the <tt class="docutils literal"><span class="pre">-std=c11</span></tt> or <tt class="docutils literal"><span class="pre">-std=gnu11</span></tt> option when
+compiling C code.  Additionally, because these features are all
+backward-compatible, they are available as extensions in all language modes.</p>
+<div class="section" id="c11-alignment-specifiers">
+<h4>C11 alignment specifiers<a class="headerlink" href="#c11-alignment-specifiers" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(c_alignas)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(c_alignas)</span></tt> to determine
+if support for alignment specifiers using <tt class="docutils literal"><span class="pre">_Alignas</span></tt> is enabled.</p>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(c_alignof)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(c_alignof)</span></tt> to determine
+if support for the <tt class="docutils literal"><span class="pre">_Alignof</span></tt> keyword is enabled.</p>
+</div>
+<div class="section" id="c11-atomic-operations">
+<h4>C11 atomic operations<a class="headerlink" href="#c11-atomic-operations" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(c_atomic)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(c_atomic)</span></tt> to determine
+if support for atomic types using <tt class="docutils literal"><span class="pre">_Atomic</span></tt> is enabled.  Clang also provides
+<a class="reference internal" href="#langext-c11-atomic"><em>a set of builtins</em></a> which can be used to implement
+the <tt class="docutils literal"><span class="pre"><stdatomic.h></span></tt> operations on <tt class="docutils literal"><span class="pre">_Atomic</span></tt> types. Use
+<tt class="docutils literal"><span class="pre">__has_include(<stdatomic.h>)</span></tt> to determine if C11’s <tt class="docutils literal"><span class="pre"><stdatomic.h></span></tt> header
+is available.</p>
+<p>Clang will use the system’s <tt class="docutils literal"><span class="pre"><stdatomic.h></span></tt> header when one is available, and
+will otherwise use its own. When using its own, implementations of the atomic
+operations are provided as macros. In the cases where C11 also requires a real
+function, this header provides only the declaration of that function (along
+with a shadowing macro implementation), and you must link to a library which
+provides a definition of the function if you use it instead of the macro.</p>
+</div>
+<div class="section" id="c11-generic-selections">
+<h4>C11 generic selections<a class="headerlink" href="#c11-generic-selections" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(c_generic_selections)</span></tt> or
+<tt class="docutils literal"><span class="pre">__has_extension(c_generic_selections)</span></tt> to determine if support for generic
+selections is enabled.</p>
+<p>As an extension, the C11 generic selection expression is available in all
+languages supported by Clang.  The syntax is the same as that given in the C11
+standard.</p>
+<p>In C, type compatibility is decided according to the rules given in the
+appropriate standard, but in C++, which lacks the type compatibility rules used
+in C, types are considered compatible only if they are equivalent.</p>
+</div>
+<div class="section" id="c11-static-assert">
+<h4>C11 <tt class="docutils literal"><span class="pre">_Static_assert()</span></tt><a class="headerlink" href="#c11-static-assert" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(c_static_assert)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(c_static_assert)</span></tt>
+to determine if support for compile-time assertions using <tt class="docutils literal"><span class="pre">_Static_assert</span></tt> is
+enabled.</p>
+</div>
+<div class="section" id="c11-thread-local">
+<h4>C11 <tt class="docutils literal"><span class="pre">_Thread_local</span></tt><a class="headerlink" href="#c11-thread-local" title="Permalink to this headline">¶</a></h4>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(c_thread_local)</span></tt> or <tt class="docutils literal"><span class="pre">__has_extension(c_thread_local)</span></tt>
+to determine if support for <tt class="docutils literal"><span class="pre">_Thread_local</span></tt> variables is enabled.</p>
+</div>
+</div>
+</div>
+<div class="section" id="checks-for-type-trait-primitives">
+<h2><a class="toc-backref" href="#id10">Checks for Type Trait Primitives</a><a class="headerlink" href="#checks-for-type-trait-primitives" title="Permalink to this headline">¶</a></h2>
+<p>Type trait primitives are special builtin constant expressions that can be used
+by the standard C++ library to facilitate or simplify the implementation of
+user-facing type traits in the <type_traits> header.</p>
+<p>They are not intended to be used directly by user code because they are
+implementation-defined and subject to change – as such they’re tied closely to
+the supported set of system headers, currently:</p>
+<ul class="simple">
+<li>LLVM’s own libc++</li>
+<li>GNU libstdc++</li>
+<li>The Microsoft standard C++ library</li>
+</ul>
+<p>Clang supports the <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html">GNU C++ type traits</a> and a subset of the
+<a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms177194(v=VS.100).aspx">Microsoft Visual C++ Type traits</a>.</p>
+<p>Feature detection is supported only for some of the primitives at present. User
+code should not use these checks because they bear no direct relation to the
+actual set of type traits supported by the C++ standard library.</p>
+<p>For type trait <tt class="docutils literal"><span class="pre">__X</span></tt>, <tt class="docutils literal"><span class="pre">__has_extension(X)</span></tt> indicates the presence of the
+type trait primitive in the compiler. A simplistic usage example as might be
+seen in standard C++ headers follows:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#if __has_extension(is_convertible_to)</span>
+<span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">From</span><span class="p">,</span> <span class="k">typename</span> <span class="n">To</span><span class="o">></span>
+<span class="k">struct</span> <span class="n">is_convertible_to</span> <span class="p">{</span>
+  <span class="k">static</span> <span class="k">const</span> <span class="kt">bool</span> <span class="n">value</span> <span class="o">=</span> <span class="n">__is_convertible_to</span><span class="p">(</span><span class="n">From</span><span class="p">,</span> <span class="n">To</span><span class="p">);</span>
+<span class="p">};</span>
+<span class="cp">#else</span>
+<span class="c1">// Emulate type trait for compatibility with other compilers.</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+<p>The following type trait primitives are supported by Clang:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">__has_nothrow_assign</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_nothrow_copy</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_nothrow_constructor</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_trivial_assign</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_trivial_copy</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_trivial_constructor</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_trivial_destructor</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__has_virtual_destructor</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_abstract</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_base_of</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_class</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_convertible_to</span></tt> (Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_empty</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_enum</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_interface_class</span></tt> (Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_pod</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_polymorphic</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_union</span></tt> (GNU, Microsoft)</li>
+<li><tt class="docutils literal"><span class="pre">__is_literal(type)</span></tt>: Determines whether the given type is a literal type</li>
+<li><tt class="docutils literal"><span class="pre">__is_final</span></tt>: Determines whether the given type is declared with a
+<tt class="docutils literal"><span class="pre">final</span></tt> class-virt-specifier.</li>
+<li><tt class="docutils literal"><span class="pre">__underlying_type(type)</span></tt>: Retrieves the underlying type for a given
+<tt class="docutils literal"><span class="pre">enum</span></tt> type.  This trait is required to implement the C++11 standard
+library.</li>
+<li><tt class="docutils literal"><span class="pre">__is_trivially_assignable(totype,</span> <span class="pre">fromtype)</span></tt>: Determines whether a value
+of type <tt class="docutils literal"><span class="pre">totype</span></tt> can be assigned to from a value of type <tt class="docutils literal"><span class="pre">fromtype</span></tt> such
+that no non-trivial functions are called as part of that assignment.  This
+trait is required to implement the C++11 standard library.</li>
+<li><tt class="docutils literal"><span class="pre">__is_trivially_constructible(type,</span> <span class="pre">argtypes...)</span></tt>: Determines whether a
+value of type <tt class="docutils literal"><span class="pre">type</span></tt> can be direct-initialized with arguments of types
+<tt class="docutils literal"><span class="pre">argtypes...</span></tt> such that no non-trivial functions are called as part of
+that initialization.  This trait is required to implement the C++11 standard
+library.</li>
+<li><tt class="docutils literal"><span class="pre">__is_destructible</span></tt> (MSVC 2013): partially implemented</li>
+<li><tt class="docutils literal"><span class="pre">__is_nothrow_destructible</span></tt> (MSVC 2013): partially implemented</li>
+<li><tt class="docutils literal"><span class="pre">__is_nothrow_assignable</span></tt> (MSVC 2013, clang)</li>
+<li><tt class="docutils literal"><span class="pre">__is_constructible</span></tt> (MSVC 2013, clang)</li>
+<li><tt class="docutils literal"><span class="pre">__is_nothrow_constructible</span></tt> (MSVC 2013, clang)</li>
+</ul>
+</div>
+<div class="section" id="blocks">
+<h2><a class="toc-backref" href="#id11">Blocks</a><a class="headerlink" href="#blocks" title="Permalink to this headline">¶</a></h2>
+<p>The syntax and high level language feature description is in
+<a class="reference internal" href="BlockLanguageSpec.html"><em>BlockLanguageSpec</em></a>. Implementation and ABI details for
+the clang implementation are in <a class="reference internal" href="Block-ABI-Apple.html"><em>Block-ABI-Apple</em></a>.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_extension(blocks)</span></tt>.</p>
+</div>
+<div class="section" id="objective-c-features">
+<h2><a class="toc-backref" href="#id12">Objective-C Features</a><a class="headerlink" href="#objective-c-features" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="related-result-types">
+<h3>Related result types<a class="headerlink" href="#related-result-types" title="Permalink to this headline">¶</a></h3>
+<p>According to Cocoa conventions, Objective-C methods with certain names
+(“<tt class="docutils literal"><span class="pre">init</span></tt>”, “<tt class="docutils literal"><span class="pre">alloc</span></tt>”, etc.) always return objects that are an instance of
+the receiving class’s type.  Such methods are said to have a “related result
+type”, meaning that a message send to one of these methods will have the same
+static type as an instance of the receiver class.  For example, given the
+following classes:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="k">@interface</span> <span class="nc">NSObject</span>
+<span class="k">+</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">alloc</span><span class="p">;</span>
+<span class="k">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">init</span><span class="p">;</span>
+<span class="k">@end</span>
+
+<span class="k">@interface</span> <span class="nc">NSArray</span> : <span class="nc">NSObject</span>
+<span class="k">@end</span>
+</pre></div>
+</div>
+<p>and this common initialization pattern</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="n">NSArray</span> <span class="o">*</span><span class="n">array</span> <span class="o">=</span> <span class="p">[[</span><span class="n">NSArray</span> <span class="n">alloc</span><span class="p">]</span> <span class="n">init</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>the type of the expression <tt class="docutils literal"><span class="pre">[NSArray</span> <span class="pre">alloc]</span></tt> is <tt class="docutils literal"><span class="pre">NSArray*</span></tt> because
+<tt class="docutils literal"><span class="pre">alloc</span></tt> implicitly has a related result type.  Similarly, the type of the
+expression <tt class="docutils literal"><span class="pre">[[NSArray</span> <span class="pre">alloc]</span> <span class="pre">init]</span></tt> is <tt class="docutils literal"><span class="pre">NSArray*</span></tt>, since <tt class="docutils literal"><span class="pre">init</span></tt> has a
+related result type and its receiver is known to have the type <tt class="docutils literal"><span class="pre">NSArray</span> <span class="pre">*</span></tt>.
+If neither <tt class="docutils literal"><span class="pre">alloc</span></tt> nor <tt class="docutils literal"><span class="pre">init</span></tt> had a related result type, the expressions
+would have had type <tt class="docutils literal"><span class="pre">id</span></tt>, as declared in the method signature.</p>
+<p>A method with a related result type can be declared by using the type
+<tt class="docutils literal"><span class="pre">instancetype</span></tt> as its result type.  <tt class="docutils literal"><span class="pre">instancetype</span></tt> is a contextual keyword
+that is only permitted in the result type of an Objective-C method, e.g.</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="k">@interface</span> <span class="nc">A</span>
+<span class="k">+</span> <span class="p">(</span><span class="n">instancetype</span><span class="p">)</span><span class="nf">constructAnA</span><span class="p">;</span>
+<span class="k">@end</span>
+</pre></div>
+</div>
+<p>The related result type can also be inferred for some methods.  To determine
+whether a method has an inferred related result type, the first word in the
+camel-case selector (e.g., “<tt class="docutils literal"><span class="pre">init</span></tt>” in “<tt class="docutils literal"><span class="pre">initWithObjects</span></tt>”) is considered,
+and the method will have a related result type if its return type is compatible
+with the type of its class and if:</p>
+<ul class="simple">
+<li>the first word is “<tt class="docutils literal"><span class="pre">alloc</span></tt>” or “<tt class="docutils literal"><span class="pre">new</span></tt>”, and the method is a class method,
+or</li>
+<li>the first word is “<tt class="docutils literal"><span class="pre">autorelease</span></tt>”, “<tt class="docutils literal"><span class="pre">init</span></tt>”, “<tt class="docutils literal"><span class="pre">retain</span></tt>”, or “<tt class="docutils literal"><span class="pre">self</span></tt>”,
+and the method is an instance method.</li>
+</ul>
+<p>If a method with a related result type is overridden by a subclass method, the
+subclass method must also return a type that is compatible with the subclass
+type.  For example:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="k">@interface</span> <span class="nc">NSString</span> : <span class="nc">NSObject</span>
+<span class="k">-</span> <span class="p">(</span><span class="n">NSUnrelated</span> <span class="o">*</span><span class="p">)</span><span class="nf">init</span><span class="p">;</span> <span class="c1">// incorrect usage: NSUnrelated is not NSString or a superclass of NSString</span>
+<span class="k">@end</span>
+</pre></div>
+</div>
+<p>Related result types only affect the type of a message send or property access
+via the given method.  In all other respects, a method with a related result
+type is treated the same way as method that returns <tt class="docutils literal"><span class="pre">id</span></tt>.</p>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(objc_instancetype)</span></tt> to determine whether the
+<tt class="docutils literal"><span class="pre">instancetype</span></tt> contextual keyword is available.</p>
+</div>
+<div class="section" id="automatic-reference-counting">
+<h3>Automatic reference counting<a class="headerlink" href="#automatic-reference-counting" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides support for <a class="reference internal" href="AutomaticReferenceCounting.html"><em>automated reference counting</em></a> in Objective-C, which eliminates the need
+for manual <tt class="docutils literal"><span class="pre">retain</span></tt>/<tt class="docutils literal"><span class="pre">release</span></tt>/<tt class="docutils literal"><span class="pre">autorelease</span></tt> message sends.  There are two
+feature macros associated with automatic reference counting:
+<tt class="docutils literal"><span class="pre">__has_feature(objc_arc)</span></tt> indicates the availability of automated reference
+counting in general, while <tt class="docutils literal"><span class="pre">__has_feature(objc_arc_weak)</span></tt> indicates that
+automated reference counting also includes support for <tt class="docutils literal"><span class="pre">__weak</span></tt> pointers to
+Objective-C objects.</p>
+</div>
+<div class="section" id="enumerations-with-a-fixed-underlying-type">
+<span id="objc-fixed-enum"></span><h3>Enumerations with a fixed underlying type<a class="headerlink" href="#enumerations-with-a-fixed-underlying-type" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides support for C++11 enumerations with a fixed underlying type
+within Objective-C.  For example, one can write an enumeration type as:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">typedef</span> <span class="k">enum</span> <span class="o">:</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="p">{</span> <span class="n">Red</span><span class="p">,</span> <span class="n">Green</span><span class="p">,</span> <span class="n">Blue</span> <span class="p">}</span> <span class="n">Color</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>This specifies that the underlying type, which is used to store the enumeration
+value, is <tt class="docutils literal"><span class="pre">unsigned</span> <span class="pre">char</span></tt>.</p>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(objc_fixed_enum)</span></tt> to determine whether support for fixed
+underlying types is available in Objective-C.</p>
+</div>
+<div class="section" id="interoperability-with-c-11-lambdas">
+<h3>Interoperability with C++11 lambdas<a class="headerlink" href="#interoperability-with-c-11-lambdas" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides interoperability between C++11 lambdas and blocks-based APIs, by
+permitting a lambda to be implicitly converted to a block pointer with the
+corresponding signature.  For example, consider an API such as <tt class="docutils literal"><span class="pre">NSArray</span></tt>‘s
+array-sorting method:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="k">-</span> <span class="p">(</span><span class="n">NSArray</span> <span class="o">*</span><span class="p">)</span><span class="nf">sortedArrayUsingComparator:</span><span class="p">(</span><span class="n">NSComparator</span><span class="p">)</span><span class="nv">cmptr</span><span class="p">;</span>
+</pre></div>
+</div>
+<p><tt class="docutils literal"><span class="pre">NSComparator</span></tt> is simply a typedef for the block pointer <tt class="docutils literal"><span class="pre">NSComparisonResult</span>
+<span class="pre">(^)(id,</span> <span class="pre">id)</span></tt>, and parameters of this type are generally provided with block
+literals as arguments.  However, one can also use a C++11 lambda so long as it
+provides the same signature (in this case, accepting two parameters of type
+<tt class="docutils literal"><span class="pre">id</span></tt> and returning an <tt class="docutils literal"><span class="pre">NSComparisonResult</span></tt>):</p>
+<div class="highlight-objc"><div class="highlight"><pre>NSArray *array = @[@"string 1", @"string 21", @"string 12", @"String 11",
+                   @"String 02"];
+const NSStringCompareOptions comparisonOptions
+  = NSCaseInsensitiveSearch | NSNumericSearch |
+    NSWidthInsensitiveSearch | NSForcedOrderingSearch;
+NSLocale *currentLocale = [NSLocale currentLocale];
+NSArray *sorted
+  = [array sortedArrayUsingComparator:[=](id s1, id s2) -> NSComparisonResult {
+             NSRange string1Range = NSMakeRange(0, [s1 length]);
+             return [s1 compare:s2 options:comparisonOptions
+             range:string1Range locale:currentLocale];
+     }];
+NSLog(@"sorted: %@", sorted);
+</pre></div>
+</div>
+<p>This code relies on an implicit conversion from the type of the lambda
+expression (an unnamed, local class type called the <em>closure type</em>) to the
+corresponding block pointer type.  The conversion itself is expressed by a
+conversion operator in that closure type that produces a block pointer with the
+same signature as the lambda itself, e.g.,</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="n">operator</span> <span class="n">NSComparisonResult</span> <span class="p">(</span><span class="o">^</span><span class="p">)(</span><span class="kt">id</span><span class="p">,</span> <span class="kt">id</span><span class="p">)()</span> <span class="k">const</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>This conversion function returns a new block that simply forwards the two
+parameters to the lambda object (which it captures by copy), then returns the
+result.  The returned block is first copied (with <tt class="docutils literal"><span class="pre">Block_copy</span></tt>) and then
+autoreleased.  As an optimization, if a lambda expression is immediately
+converted to a block pointer (as in the first example, above), then the block
+is not copied and autoreleased: rather, it is given the same lifetime as a
+block literal written at that point in the program, which avoids the overhead
+of copying a block to the heap in the common case.</p>
+<p>The conversion from a lambda to a block pointer is only available in
+Objective-C++, and not in C++ with blocks, due to its use of Objective-C memory
+management (autorelease).</p>
+</div>
+<div class="section" id="object-literals-and-subscripting">
+<h3>Object Literals and Subscripting<a class="headerlink" href="#object-literals-and-subscripting" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides support for <a class="reference internal" href="ObjectiveCLiterals.html"><em>Object Literals and Subscripting</em></a> in Objective-C, which simplifies common Objective-C
+programming patterns, makes programs more concise, and improves the safety of
+container creation.  There are several feature macros associated with object
+literals and subscripting: <tt class="docutils literal"><span class="pre">__has_feature(objc_array_literals)</span></tt> tests the
+availability of array literals; <tt class="docutils literal"><span class="pre">__has_feature(objc_dictionary_literals)</span></tt>
+tests the availability of dictionary literals;
+<tt class="docutils literal"><span class="pre">__has_feature(objc_subscripting)</span></tt> tests the availability of object
+subscripting.</p>
+</div>
+<div class="section" id="objective-c-autosynthesis-of-properties">
+<h3>Objective-C Autosynthesis of Properties<a class="headerlink" href="#objective-c-autosynthesis-of-properties" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides support for autosynthesis of declared properties.  Using this
+feature, clang provides default synthesis of those properties not declared
+@dynamic and not having user provided backing getter and setter methods.
+<tt class="docutils literal"><span class="pre">__has_feature(objc_default_synthesize_properties)</span></tt> checks for availability
+of this feature in version of clang being used.</p>
+</div>
+<div class="section" id="objective-c-retaining-behavior-attributes">
+<span id="langext-objc-retain-release"></span><h3>Objective-C retaining behavior attributes<a class="headerlink" href="#objective-c-retaining-behavior-attributes" title="Permalink to this headline">¶</a></h3>
+<p>In Objective-C, functions and methods are generally assumed to follow the
+<a class="reference external" href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html">Cocoa Memory Management</a>
+conventions for ownership of object arguments and
+return values. However, there are exceptions, and so Clang provides attributes
+to allow these exceptions to be documented. This are used by ARC and the
+<a class="reference external" href="http://clang-analyzer.llvm.org">static analyzer</a> Some exceptions may be
+better described using the <tt class="docutils literal"><span class="pre">objc_method_family</span></tt> attribute instead.</p>
+<p><strong>Usage</strong>: The <tt class="docutils literal"><span class="pre">ns_returns_retained</span></tt>, <tt class="docutils literal"><span class="pre">ns_returns_not_retained</span></tt>,
+<tt class="docutils literal"><span class="pre">ns_returns_autoreleased</span></tt>, <tt class="docutils literal"><span class="pre">cf_returns_retained</span></tt>, and
+<tt class="docutils literal"><span class="pre">cf_returns_not_retained</span></tt> attributes can be placed on methods and functions
+that return Objective-C or CoreFoundation objects. They are commonly placed at
+the end of a function prototype or method declaration:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="kt">id</span> <span class="nf">foo</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">ns_returns_retained</span><span class="p">));</span>
+
+<span class="k">-</span> <span class="p">(</span><span class="n">NSString</span> <span class="o">*</span><span class="p">)</span><span class="nf">bar:</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="nv">x</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">ns_returns_retained</span><span class="p">));</span>
+</pre></div>
+</div>
+<p>The <tt class="docutils literal"><span class="pre">*_returns_retained</span></tt> attributes specify that the returned object has a +1
+retain count.  The <tt class="docutils literal"><span class="pre">*_returns_not_retained</span></tt> attributes specify that the return
+object has a +0 retain count, even if the normal convention for its selector
+would be +1.  <tt class="docutils literal"><span class="pre">ns_returns_autoreleased</span></tt> specifies that the returned object is
++0, but is guaranteed to live at least as long as the next flush of an
+autorelease pool.</p>
+<p><strong>Usage</strong>: The <tt class="docutils literal"><span class="pre">ns_consumed</span></tt> and <tt class="docutils literal"><span class="pre">cf_consumed</span></tt> attributes can be placed on
+an parameter declaration; they specify that the argument is expected to have a
++1 retain count, which will be balanced in some way by the function or method.
+The <tt class="docutils literal"><span class="pre">ns_consumes_self</span></tt> attribute can only be placed on an Objective-C
+method; it specifies that the method expects its <tt class="docutils literal"><span class="pre">self</span></tt> parameter to have a
++1 retain count, which it will balance in some way.</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="n">__attribute__</span><span class="p">((</span><span class="n">ns_consumed</span><span class="p">))</span> <span class="n">NSString</span> <span class="o">*</span><span class="n">string</span><span class="p">);</span>
+
+<span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="nf">bar</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">ns_consumes_self</span><span class="p">));</span>
+<span class="k">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="nf">baz:</span><span class="p">(</span><span class="kt">id</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">ns_consumed</span><span class="p">))</span> <span class="n">x</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>Further examples of these attributes are available in the static analyzer’s <a class="reference external" href="http://clang-analyzer.llvm.org/annotations.html#cocoa_mem">list of annotations for analysis</a>.</p>
+<p>Query for these features with <tt class="docutils literal"><span class="pre">__has_attribute(ns_consumed)</span></tt>,
+<tt class="docutils literal"><span class="pre">__has_attribute(ns_returns_retained)</span></tt>, etc.</p>
+</div>
+<div class="section" id="objective-c-abi-protocol-qualifier-mangling-of-parameters">
+<h3>Objective-C++ ABI: protocol-qualifier mangling of parameters<a class="headerlink" href="#objective-c-abi-protocol-qualifier-mangling-of-parameters" title="Permalink to this headline">¶</a></h3>
+<p>Starting with LLVM 3.4, Clang produces a new mangling for parameters whose
+type is a qualified-<tt class="docutils literal"><span class="pre">id</span></tt> (e.g., <tt class="docutils literal"><span class="pre">id<Foo></span></tt>).  This mangling allows such
+parameters to be differentiated from those with the regular unqualified <tt class="docutils literal"><span class="pre">id</span></tt>
+type.</p>
+<p>This was a non-backward compatible mangling change to the ABI.  This change
+allows proper overloading, and also prevents mangling conflicts with template
+parameters of protocol-qualified type.</p>
+<p>Query the presence of this new mangling with
+<tt class="docutils literal"><span class="pre">__has_feature(objc_protocol_qualifier_mangling)</span></tt>.</p>
+</div>
+</div>
+<div class="section" id="initializer-lists-for-complex-numbers-in-c">
+<span id="langext-overloading"></span><h2><a class="toc-backref" href="#id13">Initializer lists for complex numbers in C</a><a class="headerlink" href="#initializer-lists-for-complex-numbers-in-c" title="Permalink to this headline">¶</a></h2>
+<p>clang supports an extension which allows the following in C:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include <math.h></span>
+<span class="cp">#include <complex.h></span>
+<span class="n">complex</span> <span class="kt">float</span> <span class="n">x</span> <span class="o">=</span> <span class="p">{</span> <span class="mf">1.0f</span><span class="p">,</span> <span class="n">INFINITY</span> <span class="p">};</span> <span class="c1">// Init to (1, Inf)</span>
+</pre></div>
+</div>
+<p>This construct is useful because there is no way to separately initialize the
+real and imaginary parts of a complex variable in standard C, given that clang
+does not support <tt class="docutils literal"><span class="pre">_Imaginary</span></tt>.  (Clang also supports the <tt class="docutils literal"><span class="pre">__real__</span></tt> and
+<tt class="docutils literal"><span class="pre">__imag__</span></tt> extensions from gcc, which help in some cases, but are not usable
+in static initializers.)</p>
+<p>Note that this extension does not allow eliding the braces; the meaning of the
+following two lines is different:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">complex</span> <span class="kt">float</span> <span class="n">x</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="p">{</span> <span class="mf">1.0f</span><span class="p">,</span> <span class="mf">1.0f</span> <span class="p">}</span> <span class="p">};</span> <span class="c1">// [0] = (1, 1)</span>
+<span class="n">complex</span> <span class="kt">float</span> <span class="n">x</span><span class="p">[]</span> <span class="o">=</span> <span class="p">{</span> <span class="mf">1.0f</span><span class="p">,</span> <span class="mf">1.0f</span> <span class="p">};</span> <span class="c1">// [0] = (1, 0), [1] = (1, 0)</span>
+</pre></div>
+</div>
+<p>This extension also works in C++ mode, as far as that goes, but does not apply
+to the C++ <tt class="docutils literal"><span class="pre">std::complex</span></tt>.  (In C++11, list initialization allows the same
+syntax to be used with <tt class="docutils literal"><span class="pre">std::complex</span></tt> with the same meaning.)</p>
+</div>
+<div class="section" id="builtin-functions">
+<h2><a class="toc-backref" href="#id14">Builtin Functions</a><a class="headerlink" href="#builtin-functions" title="Permalink to this headline">¶</a></h2>
+<p>Clang supports a number of builtin library functions with the same syntax as
+GCC, including things like <tt class="docutils literal"><span class="pre">__builtin_nan</span></tt>, <tt class="docutils literal"><span class="pre">__builtin_constant_p</span></tt>,
+<tt class="docutils literal"><span class="pre">__builtin_choose_expr</span></tt>, <tt class="docutils literal"><span class="pre">__builtin_types_compatible_p</span></tt>,
+<tt class="docutils literal"><span class="pre">__builtin_assume_aligned</span></tt>, <tt class="docutils literal"><span class="pre">__sync_fetch_and_add</span></tt>, etc.  In addition to
+the GCC builtins, Clang supports a number of builtins that GCC does not, which
+are listed here.</p>
+<p>Please note that Clang does not and will not support all of the GCC builtins
+for vector operations.  Instead of using builtins, you should use the functions
+defined in target-specific header files like <tt class="docutils literal"><span class="pre"><xmmintrin.h></span></tt>, which define
+portable wrappers for these.  Many of the Clang versions of these functions are
+implemented directly in terms of <a class="reference internal" href="#langext-vectors"><em>extended vector support</em></a> instead of builtins, in order to reduce the number of
+builtins that we need to implement.</p>
+<div class="section" id="builtin-assume">
+<h3><tt class="docutils literal"><span class="pre">__builtin_assume</span></tt><a class="headerlink" href="#builtin-assume" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_assume</span></tt> is used to provide the optimizer with a boolean
+invariant that is defined to be true.</p>
+<p><strong>Syntax</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">__builtin_assume</span><span class="p">(</span><span class="kt">bool</span><span class="p">)</span>
+</pre></div>
+</div>
+<p><strong>Example of Use</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">__builtin_assume</span><span class="p">(</span><span class="n">x</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">);</span>
+
+  <span class="c1">// The optimizer may short-circuit this check using the invariant.</span>
+  <span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span>
+    <span class="k">return</span> <span class="n">do_something</span><span class="p">();</span>
+
+  <span class="k">return</span> <span class="n">do_something_else</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p><strong>Description</strong>:</p>
+<p>The boolean argument to this function is defined to be true. The optimizer may
+analyze the form of the expression provided as the argument and deduce from
+that information used to optimize the program. If the condition is violated
+during execution, the behavior is undefined. The argument itself is never
+evaluated, so any side effects of the expression will be discarded.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_builtin(__builtin_assume)</span></tt>.</p>
+</div>
+<div class="section" id="builtin-readcyclecounter">
+<h3><tt class="docutils literal"><span class="pre">__builtin_readcyclecounter</span></tt><a class="headerlink" href="#builtin-readcyclecounter" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_readcyclecounter</span></tt> is used to access the cycle counter register (or
+a similar low-latency, high-accuracy clock) on those targets that support it.</p>
+<p><strong>Syntax</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">__builtin_readcyclecounter</span><span class="p">()</span>
+</pre></div>
+</div>
+<p><strong>Example of Use</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">t0</span> <span class="o">=</span> <span class="n">__builtin_readcyclecounter</span><span class="p">();</span>
+<span class="n">do_something</span><span class="p">();</span>
+<span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">t1</span> <span class="o">=</span> <span class="n">__builtin_readcyclecounter</span><span class="p">();</span>
+<span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">cycles_to_do_something</span> <span class="o">=</span> <span class="n">t1</span> <span class="o">-</span> <span class="n">t0</span><span class="p">;</span> <span class="c1">// assuming no overflow</span>
+</pre></div>
+</div>
+<p><strong>Description</strong>:</p>
+<p>The <tt class="docutils literal"><span class="pre">__builtin_readcyclecounter()</span></tt> builtin returns the cycle counter value,
+which may be either global or process/thread-specific depending on the target.
+As the backing counters often overflow quickly (on the order of seconds) this
+should only be used for timing small intervals.  When not supported by the
+target, the return value is always zero.  This builtin takes no arguments and
+produces an unsigned long long result.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_builtin(__builtin_readcyclecounter)</span></tt>. Note
+that even if present, its use may depend on run-time privilege or other OS
+controlled state.</p>
+</div>
+<div class="section" id="builtin-shufflevector">
+<span id="langext-builtin-shufflevector"></span><h3><tt class="docutils literal"><span class="pre">__builtin_shufflevector</span></tt><a class="headerlink" href="#builtin-shufflevector" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_shufflevector</span></tt> is used to express generic vector
+permutation/shuffle/swizzle operations.  This builtin is also very important
+for the implementation of various target-specific header files like
+<tt class="docutils literal"><span class="pre"><xmmintrin.h></span></tt>.</p>
+<p><strong>Syntax</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">vec1</span><span class="p">,</span> <span class="n">vec2</span><span class="p">,</span> <span class="n">index1</span><span class="p">,</span> <span class="n">index2</span><span class="p">,</span> <span class="p">...)</span>
+</pre></div>
+</div>
+<p><strong>Examples</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// identity operation - return 4-element vector v1.</span>
+<span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="n">v1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
+
+<span class="c1">// "Splat" element 0 of V1 into a 4-element result.</span>
+<span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">V1</span><span class="p">,</span> <span class="n">V1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
+
+<span class="c1">// Reverse 4-element vector V1.</span>
+<span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">V1</span><span class="p">,</span> <span class="n">V1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
+
+<span class="c1">// Concatenate every other element of 4-element vectors V1 and V2.</span>
+<span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">V1</span><span class="p">,</span> <span class="n">V2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span>
+
+<span class="c1">// Concatenate every other element of 8-element vectors V1 and V2.</span>
+<span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">V1</span><span class="p">,</span> <span class="n">V2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">14</span><span class="p">)</span>
+
+<span class="c1">// Shuffle v1 with some elements being undefined</span>
+<span class="n">__builtin_shufflevector</span><span class="p">(</span><span class="n">v1</span><span class="p">,</span> <span class="n">v1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
+</pre></div>
+</div>
+<p><strong>Description</strong>:</p>
+<p>The first two arguments to <tt class="docutils literal"><span class="pre">__builtin_shufflevector</span></tt> are vectors that have
+the same element type.  The remaining arguments are a list of integers that
+specify the elements indices of the first two vectors that should be extracted
+and returned in a new vector.  These element indices are numbered sequentially
+starting with the first vector, continuing into the second vector.  Thus, if
+<tt class="docutils literal"><span class="pre">vec1</span></tt> is a 4-element vector, index 5 would refer to the second element of
+<tt class="docutils literal"><span class="pre">vec2</span></tt>. An index of -1 can be used to indicate that the corresponding element
+in the returned vector is a don’t care and can be optimized by the backend.</p>
+<p>The result of <tt class="docutils literal"><span class="pre">__builtin_shufflevector</span></tt> is a vector with the same element
+type as <tt class="docutils literal"><span class="pre">vec1</span></tt>/<tt class="docutils literal"><span class="pre">vec2</span></tt> but that has an element count equal to the number of
+indices specified.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_builtin(__builtin_shufflevector)</span></tt>.</p>
+</div>
+<div class="section" id="builtin-convertvector">
+<span id="langext-builtin-convertvector"></span><h3><tt class="docutils literal"><span class="pre">__builtin_convertvector</span></tt><a class="headerlink" href="#builtin-convertvector" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_convertvector</span></tt> is used to express generic vector
+type-conversion operations. The input vector and the output vector
+type must have the same number of elements.</p>
+<p><strong>Syntax</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">__builtin_convertvector</span><span class="p">(</span><span class="n">src_vec</span><span class="p">,</span> <span class="n">dst_vec_type</span><span class="p">)</span>
+</pre></div>
+</div>
+<p><strong>Examples</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">typedef</span> <span class="kt">double</span> <span class="n">vector4double</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">__vector_size__</span><span class="p">(</span><span class="mi">32</span><span class="p">)));</span>
+<span class="k">typedef</span> <span class="kt">float</span>  <span class="n">vector4float</span>  <span class="nf">__attribute__</span><span class="p">((</span><span class="n">__vector_size__</span><span class="p">(</span><span class="mi">16</span><span class="p">)));</span>
+<span class="k">typedef</span> <span class="kt">short</span>  <span class="n">vector4short</span>  <span class="nf">__attribute__</span><span class="p">((</span><span class="n">__vector_size__</span><span class="p">(</span><span class="mi">8</span><span class="p">)));</span>
+<span class="n">vector4float</span> <span class="n">vf</span><span class="p">;</span> <span class="n">vector4short</span> <span class="n">vs</span><span class="p">;</span>
+
+<span class="c1">// convert from a vector of 4 floats to a vector of 4 doubles.</span>
+<span class="n">__builtin_convertvector</span><span class="p">(</span><span class="n">vf</span><span class="p">,</span> <span class="n">vector4double</span><span class="p">)</span>
+<span class="c1">// equivalent to:</span>
+<span class="p">(</span><span class="n">vector4double</span><span class="p">)</span> <span class="p">{</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span> <span class="n">vf</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span> <span class="n">vf</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span> <span class="n">vf</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="kt">double</span><span class="p">)</span> <span class="n">vf</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="p">}</span>
+
+<span class="c1">// convert from a vector of 4 shorts to a vector of 4 floats.</span>
+<span class="n">__builtin_convertvector</span><span class="p">(</span><span class="n">vs</span><span class="p">,</span> <span class="n">vector4float</span><span class="p">)</span>
+<span class="c1">// equivalent to:</span>
+<span class="p">(</span><span class="n">vector4float</span><span class="p">)</span> <span class="p">{</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span> <span class="n">vs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span> <span class="n">vs</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span> <span class="n">vs</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span> <span class="n">vs</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="p">}</span>
+</pre></div>
+</div>
+<p><strong>Description</strong>:</p>
+<p>The first argument to <tt class="docutils literal"><span class="pre">__builtin_convertvector</span></tt> is a vector, and the second
+argument is a vector type with the same number of elements as the first
+argument.</p>
+<p>The result of <tt class="docutils literal"><span class="pre">__builtin_convertvector</span></tt> is a vector with the same element
+type as the second argument, with a value defined in terms of the action of a
+C-style cast applied to each element of the first argument.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_builtin(__builtin_convertvector)</span></tt>.</p>
+</div>
+<div class="section" id="builtin-unreachable">
+<h3><tt class="docutils literal"><span class="pre">__builtin_unreachable</span></tt><a class="headerlink" href="#builtin-unreachable" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_unreachable</span></tt> is used to indicate that a specific point in the
+program cannot be reached, even if the compiler might otherwise think it can.
+This is useful to improve optimization and eliminates certain warnings.  For
+example, without the <tt class="docutils literal"><span class="pre">__builtin_unreachable</span></tt> in the example below, the
+compiler assumes that the inline asm can fall through and prints a “function
+declared ‘<tt class="docutils literal"><span class="pre">noreturn</span></tt>‘ should not return” warning.</p>
+<p><strong>Syntax</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">__builtin_unreachable</span><span class="p">()</span>
+</pre></div>
+</div>
+<p><strong>Example of use</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">myabort</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">noreturn</span><span class="p">));</span>
+<span class="kt">void</span> <span class="nf">myabort</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">asm</span><span class="p">(</span><span class="s">"int3"</span><span class="p">);</span>
+  <span class="n">__builtin_unreachable</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p><strong>Description</strong>:</p>
+<p>The <tt class="docutils literal"><span class="pre">__builtin_unreachable()</span></tt> builtin has completely undefined behavior.
+Since it has undefined behavior, it is a statement that it is never reached and
+the optimizer can take advantage of this to produce better code.  This builtin
+takes no arguments and produces a void result.</p>
+<p>Query for this feature with <tt class="docutils literal"><span class="pre">__has_builtin(__builtin_unreachable)</span></tt>.</p>
+</div>
+<div class="section" id="sync-swap">
+<h3><tt class="docutils literal"><span class="pre">__sync_swap</span></tt><a class="headerlink" href="#sync-swap" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__sync_swap</span></tt> is used to atomically swap integers or pointers in memory.</p>
+<p><strong>Syntax</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">type</span> <span class="n">__sync_swap</span><span class="p">(</span><span class="n">type</span> <span class="o">*</span><span class="n">ptr</span><span class="p">,</span> <span class="n">type</span> <span class="n">value</span><span class="p">,</span> <span class="p">...)</span>
+</pre></div>
+</div>
+<p><strong>Example of Use</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="n">old_value</span> <span class="o">=</span> <span class="n">__sync_swap</span><span class="p">(</span><span class="o">&</span><span class="n">value</span><span class="p">,</span> <span class="n">new_value</span><span class="p">);</span>
+</pre></div>
+</div>
+<p><strong>Description</strong>:</p>
+<p>The <tt class="docutils literal"><span class="pre">__sync_swap()</span></tt> builtin extends the existing <tt class="docutils literal"><span class="pre">__sync_*()</span></tt> family of
+atomic intrinsics to allow code to atomically swap the current value with the
+new value.  More importantly, it helps developers write more efficient and
+correct code by avoiding expensive loops around
+<tt class="docutils literal"><span class="pre">__sync_bool_compare_and_swap()</span></tt> or relying on the platform specific
+implementation details of <tt class="docutils literal"><span class="pre">__sync_lock_test_and_set()</span></tt>.  The
+<tt class="docutils literal"><span class="pre">__sync_swap()</span></tt> builtin is a full barrier.</p>
+</div>
+<div class="section" id="builtin-addressof">
+<h3><tt class="docutils literal"><span class="pre">__builtin_addressof</span></tt><a class="headerlink" href="#builtin-addressof" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_addressof</span></tt> performs the functionality of the built-in <tt class="docutils literal"><span class="pre">&</span></tt>
+operator, ignoring any <tt class="docutils literal"><span class="pre">operator&</span></tt> overload.  This is useful in constant
+expressions in C++11, where there is no other way to take the address of an
+object that overloads <tt class="docutils literal"><span class="pre">operator&</span></tt>.</p>
+<p><strong>Example of use</strong>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="n">constexpr</span> <span class="n">T</span> <span class="o">*</span><span class="n">addressof</span><span class="p">(</span><span class="n">T</span> <span class="o">&</span><span class="n">value</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">return</span> <span class="n">__builtin_addressof</span><span class="p">(</span><span class="n">value</span><span class="p">);</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="builtin-operator-new-and-builtin-operator-delete">
+<h3><tt class="docutils literal"><span class="pre">__builtin_operator_new</span></tt> and <tt class="docutils literal"><span class="pre">__builtin_operator_delete</span></tt><a class="headerlink" href="#builtin-operator-new-and-builtin-operator-delete" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__builtin_operator_new</span></tt> allocates memory just like a non-placement non-class
+<em>new-expression</em>. This is exactly like directly calling the normal
+non-placement <tt class="docutils literal"><span class="pre">::operator</span> <span class="pre">new</span></tt>, except that it allows certain optimizations
+that the C++ standard does not permit for a direct function call to
+<tt class="docutils literal"><span class="pre">::operator</span> <span class="pre">new</span></tt> (in particular, removing <tt class="docutils literal"><span class="pre">new</span></tt> / <tt class="docutils literal"><span class="pre">delete</span></tt> pairs and
+merging allocations).</p>
+<p>Likewise, <tt class="docutils literal"><span class="pre">__builtin_operator_delete</span></tt> deallocates memory just like a
+non-class <em>delete-expression</em>, and is exactly like directly calling the normal
+<tt class="docutils literal"><span class="pre">::operator</span> <span class="pre">delete</span></tt>, except that it permits optimizations. Only the unsized
+form of <tt class="docutils literal"><span class="pre">__builtin_operator_delete</span></tt> is currently available.</p>
+<p>These builtins are intended for use in the implementation of <tt class="docutils literal"><span class="pre">std::allocator</span></tt>
+and other similar allocation libraries, and are only available in C++.</p>
+</div>
+<div class="section" id="multiprecision-arithmetic-builtins">
+<h3>Multiprecision Arithmetic Builtins<a class="headerlink" href="#multiprecision-arithmetic-builtins" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides a set of builtins which expose multiprecision arithmetic in a
+manner amenable to C. They all have the following form:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="kt">unsigned</span> <span class="n">x</span> <span class="o">=</span> <span class="p">...,</span> <span class="n">y</span> <span class="o">=</span> <span class="p">...,</span> <span class="n">carryin</span> <span class="o">=</span> <span class="p">...,</span> <span class="n">carryout</span><span class="p">;</span>
+<span class="kt">unsigned</span> <span class="n">sum</span> <span class="o">=</span> <span class="n">__builtin_addc</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">carryin</span><span class="p">,</span> <span class="o">&</span><span class="n">carryout</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>Thus one can form a multiprecision addition chain in the following manner:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="kt">unsigned</span> <span class="o">*</span><span class="n">x</span><span class="p">,</span> <span class="o">*</span><span class="n">y</span><span class="p">,</span> <span class="o">*</span><span class="n">z</span><span class="p">,</span> <span class="n">carryin</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">carryout</span><span class="p">;</span>
+<span class="n">z</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">__builtin_addc</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">carryin</span><span class="p">,</span> <span class="o">&</span><span class="n">carryout</span><span class="p">);</span>
+<span class="n">carryin</span> <span class="o">=</span> <span class="n">carryout</span><span class="p">;</span>
+<span class="n">z</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="n">__builtin_addc</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">carryin</span><span class="p">,</span> <span class="o">&</span><span class="n">carryout</span><span class="p">);</span>
+<span class="n">carryin</span> <span class="o">=</span> <span class="n">carryout</span><span class="p">;</span>
+<span class="n">z</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="n">__builtin_addc</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">carryin</span><span class="p">,</span> <span class="o">&</span><span class="n">carryout</span><span class="p">);</span>
+<span class="n">carryin</span> <span class="o">=</span> <span class="n">carryout</span><span class="p">;</span>
+<span class="n">z</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">__builtin_addc</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">y</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span> <span class="n">carryin</span><span class="p">,</span> <span class="o">&</span><span class="n">carryout</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>The complete list of builtins are:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="kt">unsigned</span> <span class="kt">char</span>      <span class="nf">__builtin_addcb</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">short</span>     <span class="nf">__builtin_addcs</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">short</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">short</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">short</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">short</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span>           <span class="nf">__builtin_addc</span>  <span class="p">(</span><span class="kt">unsigned</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">long</span>      <span class="nf">__builtin_addcl</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="nf">__builtin_addcll</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">char</span>      <span class="nf">__builtin_subcb</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">short</span>     <span class="nf">__builtin_subcs</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">short</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">short</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">short</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">short</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span>           <span class="nf">__builtin_subc</span>  <span class="p">(</span><span class="kt">unsigned</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">long</span>      <span class="nf">__builtin_subcl</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+<span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="nf">__builtin_subcll</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">carryin</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">carryout</span><span class="p">);</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="checked-arithmetic-builtins">
+<h3>Checked Arithmetic Builtins<a class="headerlink" href="#checked-arithmetic-builtins" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides a set of builtins that implement checked arithmetic for security
+critical applications in a manner that is fast and easily expressable in C. As
+an example of their usage:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="kt">errorcode_t</span> <span class="nf">security_critical_application</span><span class="p">(...)</span> <span class="p">{</span>
+  <span class="kt">unsigned</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">result</span><span class="p">;</span>
+  <span class="p">...</span>
+  <span class="k">if</span> <span class="p">(</span><span class="n">__builtin_umul_overflow</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="o">&</span><span class="n">result</span><span class="p">))</span>
+    <span class="k">return</span> <span class="n">kErrorCodeHackers</span><span class="p">;</span>
+  <span class="p">...</span>
+  <span class="n">use_multiply</span><span class="p">(</span><span class="n">result</span><span class="p">);</span>
+  <span class="p">...</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>A complete enumeration of the builtins are:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="kt">bool</span> <span class="nf">__builtin_uadd_overflow</span>  <span class="p">(</span><span class="kt">unsigned</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="o">*</span><span class="n">sum</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_uaddl_overflow</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="o">*</span><span class="n">sum</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_uaddll_overflow</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">sum</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_usub_overflow</span>  <span class="p">(</span><span class="kt">unsigned</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="o">*</span><span class="n">diff</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_usubl_overflow</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="o">*</span><span class="n">diff</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_usubll_overflow</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">diff</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_umul_overflow</span>  <span class="p">(</span><span class="kt">unsigned</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="o">*</span><span class="n">prod</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_umull_overflow</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="o">*</span><span class="n">prod</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_umulll_overflow</span><span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">prod</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_sadd_overflow</span>  <span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">sum</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_saddl_overflow</span> <span class="p">(</span><span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">long</span> <span class="o">*</span><span class="n">sum</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_saddll_overflow</span><span class="p">(</span><span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">sum</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_ssub_overflow</span>  <span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">diff</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_ssubl_overflow</span> <span class="p">(</span><span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">long</span> <span class="o">*</span><span class="n">diff</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_ssubll_overflow</span><span class="p">(</span><span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">diff</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_smul_overflow</span>  <span class="p">(</span><span class="kt">int</span> <span class="n">x</span><span class="p">,</span> <span class="kt">int</span> <span class="n">y</span><span class="p">,</span> <span class="kt">int</span> <span class="o">*</span><span class="n">prod</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_smull_overflow</span> <span class="p">(</span><span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">long</span> <span class="o">*</span><span class="n">prod</span><span class="p">);</span>
+<span class="kt">bool</span> <span class="nf">__builtin_smulll_overflow</span><span class="p">(</span><span class="kt">long</span> <span class="kt">long</span> <span class="n">x</span><span class="p">,</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">y</span><span class="p">,</span> <span class="kt">long</span> <span class="kt">long</span> <span class="o">*</span><span class="n">prod</span><span class="p">);</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="c11-atomic-builtins">
+<span id="langext-c11-atomic"></span><h3>__c11_atomic builtins<a class="headerlink" href="#c11-atomic-builtins" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides a set of builtins which are intended to be used to implement
+C11’s <tt class="docutils literal"><span class="pre"><stdatomic.h></span></tt> header.  These builtins provide the semantics of the
+<tt class="docutils literal"><span class="pre">_explicit</span></tt> form of the corresponding C11 operation, and are named with a
+<tt class="docutils literal"><span class="pre">__c11_</span></tt> prefix.  The supported operations, and the differences from
+the corresponding C11 operations, are:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_init</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_thread_fence</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_signal_fence</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_is_lock_free</span></tt> (The argument is the size of the
+<tt class="docutils literal"><span class="pre">_Atomic(...)</span></tt> object, instead of its address)</li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_store</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_load</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_exchange</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_compare_exchange_strong</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_compare_exchange_weak</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_fetch_add</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_fetch_sub</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_fetch_and</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_fetch_or</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">__c11_atomic_fetch_xor</span></tt></li>
+</ul>
+<p>The macros <tt class="docutils literal"><span class="pre">__ATOMIC_RELAXED</span></tt>, <tt class="docutils literal"><span class="pre">__ATOMIC_CONSUME</span></tt>, <tt class="docutils literal"><span class="pre">__ATOMIC_ACQUIRE</span></tt>,
+<tt class="docutils literal"><span class="pre">__ATOMIC_RELEASE</span></tt>, <tt class="docutils literal"><span class="pre">__ATOMIC_ACQ_REL</span></tt>, and <tt class="docutils literal"><span class="pre">__ATOMIC_SEQ_CST</span></tt> are
+provided, with values corresponding to the enumerators of C11’s
+<tt class="docutils literal"><span class="pre">memory_order</span></tt> enumeration.</p>
+</div>
+<div class="section" id="low-level-arm-exclusive-memory-builtins">
+<h3>Low-level ARM exclusive memory builtins<a class="headerlink" href="#low-level-arm-exclusive-memory-builtins" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides overloaded builtins giving direct access to the three key ARM
+instructions for implementing atomic operations.</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="n">T</span> <span class="nf">__builtin_arm_ldrex</span><span class="p">(</span><span class="k">const</span> <span class="k">volatile</span> <span class="n">T</span> <span class="o">*</span><span class="n">addr</span><span class="p">);</span>
+<span class="n">T</span> <span class="nf">__builtin_arm_ldaex</span><span class="p">(</span><span class="k">const</span> <span class="k">volatile</span> <span class="n">T</span> <span class="o">*</span><span class="n">addr</span><span class="p">);</span>
+<span class="kt">int</span> <span class="nf">__builtin_arm_strex</span><span class="p">(</span><span class="n">T</span> <span class="n">val</span><span class="p">,</span> <span class="k">volatile</span> <span class="n">T</span> <span class="o">*</span><span class="n">addr</span><span class="p">);</span>
+<span class="kt">int</span> <span class="nf">__builtin_arm_stlex</span><span class="p">(</span><span class="n">T</span> <span class="n">val</span><span class="p">,</span> <span class="k">volatile</span> <span class="n">T</span> <span class="o">*</span><span class="n">addr</span><span class="p">);</span>
+<span class="kt">void</span> <span class="nf">__builtin_arm_clrex</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>The types <tt class="docutils literal"><span class="pre">T</span></tt> currently supported are:
+* Integer types with width at most 64 bits (or 128 bits on AArch64).
+* Floating-point types
+* Pointer types.</p>
+<p>Note that the compiler does not guarantee it will not insert stores which clear
+the exclusive monitor in between an <tt class="docutils literal"><span class="pre">ldrex</span></tt> type operation and its paired
+<tt class="docutils literal"><span class="pre">strex</span></tt>. In practice this is only usually a risk when the extra store is on
+the same cache line as the variable being modified and Clang will only insert
+stack stores on its own, so it is best not to use these operations on variables
+with automatic storage duration.</p>
+<p>Also, loads and stores may be implicit in code written between the <tt class="docutils literal"><span class="pre">ldrex</span></tt> and
+<tt class="docutils literal"><span class="pre">strex</span></tt>. Clang will not necessarily mitigate the effects of these either, so
+care should be exercised.</p>
+<p>For these reasons the higher level atomic primitives should be preferred where
+possible.</p>
+</div>
+</div>
+<div class="section" id="non-standard-c-11-attributes">
+<h2><a class="toc-backref" href="#id15">Non-standard C++11 Attributes</a><a class="headerlink" href="#non-standard-c-11-attributes" title="Permalink to this headline">¶</a></h2>
+<p>Clang’s non-standard C++11 attributes live in the <tt class="docutils literal"><span class="pre">clang</span></tt> attribute
+namespace.</p>
+<p>Clang supports GCC’s <tt class="docutils literal"><span class="pre">gnu</span></tt> attribute namespace. All GCC attributes which
+are accepted with the <tt class="docutils literal"><span class="pre">__attribute__((foo))</span></tt> syntax are also accepted as
+<tt class="docutils literal"><span class="pre">[[gnu::foo]]</span></tt>. This only extends to attributes which are specified by GCC
+(see the list of <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html">GCC function attributes</a>, <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html">GCC variable
+attributes</a>, and
+<a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html">GCC type attributes</a>). As with the GCC
+implementation, these attributes must appertain to the <em>declarator-id</em> in a
+declaration, which means they must go either at the start of the declaration or
+immediately after the name being declared.</p>
+<p>For example, this applies the GNU <tt class="docutils literal"><span class="pre">unused</span></tt> attribute to <tt class="docutils literal"><span class="pre">a</span></tt> and <tt class="docutils literal"><span class="pre">f</span></tt>, and
+also applies the GNU <tt class="docutils literal"><span class="pre">noreturn</span></tt> attribute to <tt class="docutils literal"><span class="pre">f</span></tt>.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="p">[[</span><span class="n">gnu</span><span class="o">::</span><span class="n">unused</span><span class="p">]]</span> <span class="kt">int</span> <span class="n">a</span><span class="p">,</span> <span class="n">f</span> <span class="p">[[</span><span class="n">gnu</span><span class="o">::</span><span class="n">noreturn</span><span class="p">]]</span> <span class="p">();</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="target-specific-extensions">
+<h2><a class="toc-backref" href="#id16">Target-Specific Extensions</a><a class="headerlink" href="#target-specific-extensions" title="Permalink to this headline">¶</a></h2>
+<p>Clang supports some language features conditionally on some targets.</p>
+<div class="section" id="arm-aarch64-language-extensions">
+<h3>ARM/AArch64 Language Extensions<a class="headerlink" href="#arm-aarch64-language-extensions" title="Permalink to this headline">¶</a></h3>
+<div class="section" id="memory-barrier-intrinsics">
+<h4>Memory Barrier Intrinsics<a class="headerlink" href="#memory-barrier-intrinsics" title="Permalink to this headline">¶</a></h4>
+<p>Clang implements the <tt class="docutils literal"><span class="pre">__dmb</span></tt>, <tt class="docutils literal"><span class="pre">__dsb</span></tt> and <tt class="docutils literal"><span class="pre">__isb</span></tt> intrinsics as defined
+in the <a class="reference external" href="http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf">ARM C Language Extensions Release 2.0</a>.
+Note that these intrinsics are implemented as motion barriers that block
+reordering of memory accesses and side effect instructions. Other instructions
+like simple arithmatic may be reordered around the intrinsic. If you expect to
+have no reordering at all, use inline assembly instead.</p>
+</div>
+</div>
+<div class="section" id="x86-x86-64-language-extensions">
+<h3>X86/X86-64 Language Extensions<a class="headerlink" href="#x86-x86-64-language-extensions" title="Permalink to this headline">¶</a></h3>
+<p>The X86 backend has these language extensions:</p>
+<div class="section" id="memory-references-off-the-gs-segment">
+<h4>Memory references off the GS segment<a class="headerlink" href="#memory-references-off-the-gs-segment" title="Permalink to this headline">¶</a></h4>
+<p>Annotating a pointer with address space #256 causes it to be code generated
+relative to the X86 GS segment register, and address space #257 causes it to be
+relative to the X86 FS segment.  Note that this is a very very low-level
+feature that should only be used if you know what you’re doing (for example in
+an OS kernel).</p>
+<p>Here is an example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#define GS_RELATIVE __attribute__((address_space(256)))</span>
+<span class="kt">int</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">GS_RELATIVE</span> <span class="o">*</span><span class="n">P</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">return</span> <span class="o">*</span><span class="n">P</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Which compiles to (on X86-32):</p>
+<div class="highlight-gas"><div class="highlight"><pre><span class="nl">_foo:</span>
+        <span class="nf">movl</span>    <span class="mi">4</span><span class="p">(</span><span class="nv">%esp</span><span class="p">),</span> <span class="nv">%eax</span>
+        <span class="nf">movl</span>    <span class="nv">%gs</span><span class="p">:(</span><span class="nv">%eax</span><span class="p">),</span> <span class="nv">%eax</span>
+        <span class="nf">ret</span>
+</pre></div>
+</div>
+</div>
+</div>
+</div>
+<div class="section" id="extensions-for-static-analysis">
+<h2><a class="toc-backref" href="#id17">Extensions for Static Analysis</a><a class="headerlink" href="#extensions-for-static-analysis" title="Permalink to this headline">¶</a></h2>
+<p>Clang supports additional attributes that are useful for documenting program
+invariants and rules for static analysis tools, such as the <a class="reference external" href="http://clang-analyzer.llvm.org/">Clang Static
+Analyzer</a>. These attributes are documented
+in the analyzer’s <a class="reference external" href="http://clang-analyzer.llvm.org/annotations.html">list of source-level annotations</a>.</p>
+</div>
+<div class="section" id="extensions-for-dynamic-analysis">
+<h2><a class="toc-backref" href="#id18">Extensions for Dynamic Analysis</a><a class="headerlink" href="#extensions-for-dynamic-analysis" title="Permalink to this headline">¶</a></h2>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(address_sanitizer)</span></tt> to check if the code is being built
+with <a class="reference internal" href="AddressSanitizer.html"><em>AddressSanitizer</em></a>.</p>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(thread_sanitizer)</span></tt> to check if the code is being built
+with <a class="reference internal" href="ThreadSanitizer.html"><em>ThreadSanitizer</em></a>.</p>
+<p>Use <tt class="docutils literal"><span class="pre">__has_feature(memory_sanitizer)</span></tt> to check if the code is being built
+with <a class="reference internal" href="MemorySanitizer.html"><em>MemorySanitizer</em></a>.</p>
+</div>
+<div class="section" id="extensions-for-selectively-disabling-optimization">
+<h2><a class="toc-backref" href="#id19">Extensions for selectively disabling optimization</a><a class="headerlink" href="#extensions-for-selectively-disabling-optimization" title="Permalink to this headline">¶</a></h2>
+<p>Clang provides a mechanism for selectively disabling optimizations in functions
+and methods.</p>
+<p>To disable optimizations in a single function definition, the GNU-style or C++11
+non-standard attribute <tt class="docutils literal"><span class="pre">optnone</span></tt> can be used.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// The following functions will not be optimized.</span>
+<span class="c1">// GNU-style attribute</span>
+<span class="n">__attribute__</span><span class="p">((</span><span class="n">optnone</span><span class="p">))</span> <span class="kt">int</span> <span class="n">foo</span><span class="p">()</span> <span class="p">{</span>
+  <span class="c1">// ... code</span>
+<span class="p">}</span>
+<span class="c1">// C++11 attribute</span>
+<span class="p">[[</span><span class="n">clang</span><span class="o">::</span><span class="n">optnone</span><span class="p">]]</span> <span class="kt">int</span> <span class="n">bar</span><span class="p">()</span> <span class="p">{</span>
+  <span class="c1">// ... code</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>To facilitate disabling optimization for a range of function definitions, a
+range-based pragma is provided. Its syntax is <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">optimize</span></tt>
+followed by <tt class="docutils literal"><span class="pre">off</span></tt> or <tt class="docutils literal"><span class="pre">on</span></tt>.</p>
+<p>All function definitions in the region between an <tt class="docutils literal"><span class="pre">off</span></tt> and the following
+<tt class="docutils literal"><span class="pre">on</span></tt> will be decorated with the <tt class="docutils literal"><span class="pre">optnone</span></tt> attribute unless doing so would
+conflict with explicit attributes already present on the function (e.g. the
+ones that control inlining).</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma clang optimize off</span>
+<span class="c1">// This function will be decorated with optnone.</span>
+<span class="kt">int</span> <span class="nf">foo</span><span class="p">()</span> <span class="p">{</span>
+  <span class="c1">// ... code</span>
+<span class="p">}</span>
+
+<span class="c1">// optnone conflicts with always_inline, so bar() will not be decorated.</span>
+<span class="n">__attribute__</span><span class="p">((</span><span class="n">always_inline</span><span class="p">))</span> <span class="kt">int</span> <span class="n">bar</span><span class="p">()</span> <span class="p">{</span>
+  <span class="c1">// ... code</span>
+<span class="p">}</span>
+<span class="cp">#pragma clang optimize on</span>
+</pre></div>
+</div>
+<p>If no <tt class="docutils literal"><span class="pre">on</span></tt> is found to close an <tt class="docutils literal"><span class="pre">off</span></tt> region, the end of the region is the
+end of the compilation unit.</p>
+<p>Note that a stray <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">optimize</span> <span class="pre">on</span></tt> does not selectively enable
+additional optimizations when compiling at low optimization levels. This feature
+can only be used to selectively disable optimizations.</p>
+<p>The pragma has an effect on functions only at the point of their definition; for
+function templates, this means that the state of the pragma at the point of an
+instantiation is not necessarily relevant. Consider the following example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="n">T</span> <span class="n">twice</span><span class="p">(</span><span class="n">T</span> <span class="n">t</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">return</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">t</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="cp">#pragma clang optimize off</span>
+<span class="k">template</span><span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span> <span class="n">T</span> <span class="n">thrice</span><span class="p">(</span><span class="n">T</span> <span class="n">t</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">return</span> <span class="mi">3</span> <span class="o">*</span> <span class="n">t</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="kt">int</span> <span class="n">container</span><span class="p">(</span><span class="kt">int</span> <span class="n">a</span><span class="p">,</span> <span class="kt">int</span> <span class="n">b</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">return</span> <span class="n">twice</span><span class="p">(</span><span class="n">a</span><span class="p">)</span> <span class="o">+</span> <span class="n">thrice</span><span class="p">(</span><span class="n">b</span><span class="p">);</span>
+<span class="p">}</span>
+<span class="cp">#pragma clang optimize on</span>
+</pre></div>
+</div>
+<p>In this example, the definition of the template function <tt class="docutils literal"><span class="pre">twice</span></tt> is outside
+the pragma region, whereas the definition of <tt class="docutils literal"><span class="pre">thrice</span></tt> is inside the region.
+The <tt class="docutils literal"><span class="pre">container</span></tt> function is also in the region and will not be optimized, but
+it causes the instantiation of <tt class="docutils literal"><span class="pre">twice</span></tt> and <tt class="docutils literal"><span class="pre">thrice</span></tt> with an <tt class="docutils literal"><span class="pre">int</span></tt> type; of
+these two instantiations, <tt class="docutils literal"><span class="pre">twice</span></tt> will be optimized (because its definition
+was outside the region) and <tt class="docutils literal"><span class="pre">thrice</span></tt> will not be optimized.</p>
+</div>
+<div class="section" id="extensions-for-loop-hint-optimizations">
+<h2><a class="toc-backref" href="#id20">Extensions for loop hint optimizations</a><a class="headerlink" href="#extensions-for-loop-hint-optimizations" title="Permalink to this headline">¶</a></h2>
+<p>The <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">loop</span></tt> directive is used to specify hints for optimizing the
+subsequent for, while, do-while, or c++11 range-based for loop. The directive
+provides options for vectorization, interleaving, and unrolling. Loop hints can
+be specified before any loop and will be ignored if the optimization is not safe
+to apply.</p>
+<div class="section" id="vectorization-and-interleaving">
+<h3>Vectorization and Interleaving<a class="headerlink" href="#vectorization-and-interleaving" title="Permalink to this headline">¶</a></h3>
+<p>A vectorized loop performs multiple iterations of the original loop
+in parallel using vector instructions. The instruction set of the target
+processor determines which vector instructions are available and their vector
+widths. This restricts the types of loops that can be vectorized. The vectorizer
+automatically determines if the loop is safe and profitable to vectorize. A
+vector instruction cost model is used to select the vector width.</p>
+<p>Interleaving multiple loop iterations allows modern processors to further
+improve instruction-level parallelism (ILP) using advanced hardware features,
+such as multiple execution units and out-of-order execution. The vectorizer uses
+a cost model that depends on the register pressure and generated code size to
+select the interleaving count.</p>
+<p>Vectorization is enabled by <tt class="docutils literal"><span class="pre">vectorize(enable)</span></tt> and interleaving is enabled
+by <tt class="docutils literal"><span class="pre">interleave(enable)</span></tt>. This is useful when compiling with <tt class="docutils literal"><span class="pre">-Os</span></tt> to
+manually enable vectorization or interleaving.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma clang loop vectorize(enable)</span>
+<span class="cp">#pragma clang loop interleave(enable)</span>
+<span class="k">for</span><span class="p">(...)</span> <span class="p">{</span>
+  <span class="p">...</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>The vector width is specified by <tt class="docutils literal"><span class="pre">vectorize_width(_value_)</span></tt> and the interleave
+count is specified by <tt class="docutils literal"><span class="pre">interleave_count(_value_)</span></tt>, where
+_value_ is a positive integer. This is useful for specifying the optimal
+width/count of the set of target architectures supported by your application.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma clang loop vectorize_width(2)</span>
+<span class="cp">#pragma clang loop interleave_count(2)</span>
+<span class="k">for</span><span class="p">(...)</span> <span class="p">{</span>
+  <span class="p">...</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Specifying a width/count of 1 disables the optimization, and is equivalent to
+<tt class="docutils literal"><span class="pre">vectorize(disable)</span></tt> or <tt class="docutils literal"><span class="pre">interleave(disable)</span></tt>.</p>
+</div>
+<div class="section" id="loop-unrolling">
+<h3>Loop Unrolling<a class="headerlink" href="#loop-unrolling" title="Permalink to this headline">¶</a></h3>
+<p>Unrolling a loop reduces the loop control overhead and exposes more
+opportunities for ILP. Loops can be fully or partially unrolled. Full unrolling
+eliminates the loop and replaces it with an enumerated sequence of loop
+iterations. Full unrolling is only possible if the loop trip count is known at
+compile time. Partial unrolling replicates the loop body within the loop and
+reduces the trip count.</p>
+<p>If <tt class="docutils literal"><span class="pre">unroll(full)</span></tt> is specified the unroller will attempt to fully unroll the
+loop if the trip count is known at compile time. If the loop count is not known
+or the fully unrolled code size is greater than the limit specified by the
+<cite>-pragma-unroll-threshold</cite> command line option the loop will be partially
+unrolled subject to the same limit.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma clang loop unroll(full)</span>
+<span class="k">for</span><span class="p">(...)</span> <span class="p">{</span>
+  <span class="p">...</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>The unroll count can be specified explicitly with <tt class="docutils literal"><span class="pre">unroll_count(_value_)</span></tt> where
+_value_ is a positive integer. If this value is greater than the trip count the
+loop will be fully unrolled. Otherwise the loop is partially unrolled subject
+to the <cite>-pragma-unroll-threshold</cite> limit.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma clang loop unroll_count(8)</span>
+<span class="k">for</span><span class="p">(...)</span> <span class="p">{</span>
+  <span class="p">...</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Unrolling of a loop can be prevented by specifying <tt class="docutils literal"><span class="pre">unroll(disable)</span></tt>.</p>
+</div>
+<div class="section" id="additional-information">
+<h3>Additional Information<a class="headerlink" href="#additional-information" title="Permalink to this headline">¶</a></h3>
+<p>For convenience multiple loop hints can be specified on a single line.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma clang loop vectorize_width(4) interleave_count(8)</span>
+<span class="k">for</span><span class="p">(...)</span> <span class="p">{</span>
+  <span class="p">...</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>If an optimization cannot be applied any hints that apply to it will be ignored.
+For example, the hint <tt class="docutils literal"><span class="pre">vectorize_width(4)</span></tt> is ignored if the loop is not
+proven safe to vectorize. To identify and diagnose optimization issues use
+<cite>-Rpass</cite>, <cite>-Rpass-missed</cite>, and <cite>-Rpass-analysis</cite> command line options. See the
+user guide for details.</p>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="UsersManual.html">Clang Compiler User’s Manual</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ObjectiveCLiterals.html">Objective-C Literals</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/LeakSanitizer.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/LeakSanitizer.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/LeakSanitizer.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/LeakSanitizer.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,99 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>LeakSanitizer — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Sanitizer special case list" href="SanitizerSpecialCaseList.html" />
+    <link rel="prev" title="DataFlowSanitizer Design Document" href="DataFlowSanitizerDesign.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>LeakSanitizer</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="DataFlowSanitizerDesign.html">DataFlowSanitizer Design Document</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="SanitizerSpecialCaseList.html">Sanitizer special case list</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="leaksanitizer">
+<h1>LeakSanitizer<a class="headerlink" href="#leaksanitizer" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
+<li><a class="reference internal" href="#current-status" id="id2">Current status</a></li>
+<li><a class="reference internal" href="#more-information" id="id3">More Information</a></li>
+</ul>
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>LeakSanitizer is a run-time memory leak detector. It can be combined with
+<a class="reference internal" href="AddressSanitizer.html"><em>AddressSanitizer</em></a> to get both memory error and leak detection.
+LeakSanitizer does not introduce any additional slowdown when used in this mode.
+The LeakSanitizer runtime can also be linked in separately to get leak detection
+only, at a minimal performance cost.</p>
+</div>
+<div class="section" id="current-status">
+<h2><a class="toc-backref" href="#id2">Current status</a><a class="headerlink" href="#current-status" title="Permalink to this headline">¶</a></h2>
+<p>LeakSanitizer is experimental and supported only on x86_64 Linux.</p>
+<p>The combined mode has been tested on fairly large software projects. The
+stand-alone mode has received much less testing.</p>
+<p>There are plans to support LeakSanitizer in <a class="reference internal" href="MemorySanitizer.html"><em>MemorySanitizer</em></a> builds.</p>
+</div>
+<div class="section" id="more-information">
+<h2><a class="toc-backref" href="#id3">More Information</a><a class="headerlink" href="#more-information" title="Permalink to this headline">¶</a></h2>
+<p><a class="reference external" href="https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer">https://code.google.com/p/address-sanitizer/wiki/LeakSanitizer</a></p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="DataFlowSanitizerDesign.html">DataFlowSanitizer Design Document</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="SanitizerSpecialCaseList.html">Sanitizer special case list</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchers.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchers.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchers.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchers.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,167 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Matching the Clang AST — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="How To Setup Clang Tooling For LLVM" href="HowToSetupToolingForLLVM.html" />
+    <link rel="prev" title="Tutorial for building tools using LibTooling and LibASTMatchers" href="LibASTMatchersTutorial.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Matching the Clang AST</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="LibASTMatchersTutorial.html">Tutorial for building tools using LibTooling and LibASTMatchers</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="HowToSetupToolingForLLVM.html">How To Setup Clang Tooling For LLVM</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="matching-the-clang-ast">
+<h1>Matching the Clang AST<a class="headerlink" href="#matching-the-clang-ast" title="Permalink to this headline">¶</a></h1>
+<p>This document explains how to use Clang’s LibASTMatchers to match interesting
+nodes of the AST and execute code that uses the matched nodes.  Combined with
+<a class="reference internal" href="LibTooling.html"><em>LibTooling</em></a>, LibASTMatchers helps to write code-to-code transformation
+tools or query tools.</p>
+<p>We assume basic knowledge about the Clang AST.  See the <a class="reference internal" href="IntroductionToTheClangAST.html"><em>Introduction
+to the Clang AST</em></a> if you want to learn more
+about how the AST is structured.</p>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>LibASTMatchers provides a domain specific language to create predicates on
+Clang’s AST.  This DSL is written in and can be used from C++, allowing users
+to write a single program to both match AST nodes and access the node’s C++
+interface to extract attributes, source locations, or any other information
+provided on the AST level.</p>
+<p>AST matchers are predicates on nodes in the AST.  Matchers are created by
+calling creator functions that allow building up a tree of matchers, where
+inner matchers are used to make the match more specific.</p>
+<p>For example, to create a matcher that matches all class or union declarations
+in the AST of a translation unit, you can call <a class="reference external" href="LibASTMatchersReference.html#recordDecl0Anchor">recordDecl()</a>.  To narrow the match down,
+for example to find all class or union declarations with the name “<tt class="docutils literal"><span class="pre">Foo</span></tt>”,
+insert a <a class="reference external" href="LibASTMatchersReference.html#hasName0Anchor">hasName</a> matcher: the
+call <tt class="docutils literal"><span class="pre">recordDecl(hasName("Foo"))</span></tt> returns a matcher that matches classes or
+unions that are named “<tt class="docutils literal"><span class="pre">Foo</span></tt>”, in any namespace.  By default, matchers that
+accept multiple inner matchers use an implicit <a class="reference external" href="LibASTMatchersReference.html#allOf0Anchor">allOf()</a>.  This allows further narrowing
+down the match, for example to match all classes that are derived from
+“<tt class="docutils literal"><span class="pre">Bar</span></tt>”: <tt class="docutils literal"><span class="pre">recordDecl(hasName("Foo"),</span> <span class="pre">isDerivedFrom("Bar"))</span></tt>.</p>
+</div>
+<div class="section" id="how-to-create-a-matcher">
+<h2>How to create a matcher<a class="headerlink" href="#how-to-create-a-matcher" title="Permalink to this headline">¶</a></h2>
+<p>With more than a thousand classes in the Clang AST, one can quickly get lost
+when trying to figure out how to create a matcher for a specific pattern.  This
+section will teach you how to use a rigorous step-by-step pattern to build the
+matcher you are interested in.  Note that there will always be matchers missing
+for some part of the AST.  See the section about <a class="reference internal" href="#astmatchers-writing"><em>how to write your own
+AST matchers</em></a> later in this document.</p>
+<p>The precondition to using the matchers is to understand how the AST for what you
+want to match looks like.  The
+<a class="reference internal" href="IntroductionToTheClangAST.html"><em>Introduction to the Clang AST</em></a> teaches you
+how to dump a translation unit’s AST into a human readable format.</p>
+<p>In general, the strategy to create the right matchers is:</p>
+<ol class="arabic simple">
+<li>Find the outermost class in Clang’s AST you want to match.</li>
+<li>Look at the <a class="reference external" href="LibASTMatchersReference.html">AST Matcher Reference</a> for
+matchers that either match the node you’re interested in or narrow down
+attributes on the node.</li>
+<li>Create your outer match expression.  Verify that it works as expected.</li>
+<li>Examine the matchers for what the next inner node you want to match is.</li>
+<li>Repeat until the matcher is finished.</li>
+</ol>
+</div>
+<div class="section" id="binding-nodes-in-match-expressions">
+<span id="astmatchers-bind"></span><h2>Binding nodes in match expressions<a class="headerlink" href="#binding-nodes-in-match-expressions" title="Permalink to this headline">¶</a></h2>
+<p>Matcher expressions allow you to specify which parts of the AST are interesting
+for a certain task.  Often you will want to then do something with the nodes
+that were matched, like building source code transformations.</p>
+<p>To that end, matchers that match specific AST nodes (so called node matchers)
+are bindable; for example, <tt class="docutils literal"><span class="pre">recordDecl(hasName("MyClass")).bind("id")</span></tt> will
+bind the matched <tt class="docutils literal"><span class="pre">recordDecl</span></tt> node to the string “<tt class="docutils literal"><span class="pre">id</span></tt>”, to be later
+retrieved in the <a class="reference external" href="http://clang.llvm.org/doxygen/classclang_1_1ast__matchers_1_1MatchFinder_1_1MatchCallback.html">match callback</a>.</p>
+</div>
+<div class="section" id="writing-your-own-matchers">
+<h2>Writing your own matchers<a class="headerlink" href="#writing-your-own-matchers" title="Permalink to this headline">¶</a></h2>
+<p>There are multiple different ways to define a matcher, depending on its type
+and flexibility.</p>
+<div class="section" id="variadicdyncastallofmatcher-base-derived">
+<h3><tt class="docutils literal"><span class="pre">VariadicDynCastAllOfMatcher<Base,</span> <span class="pre">Derived></span></tt><a class="headerlink" href="#variadicdyncastallofmatcher-base-derived" title="Permalink to this headline">¶</a></h3>
+<p>Those match all nodes of type <em>Base</em> if they can be dynamically casted to
+<em>Derived</em>.  The names of those matchers are nouns, which closely resemble
+<em>Derived</em>.  <tt class="docutils literal"><span class="pre">VariadicDynCastAllOfMatchers</span></tt> are the backbone of the matcher
+hierarchy.  Most often, your match expression will start with one of them, and
+you can <a class="reference internal" href="#astmatchers-bind"><em>bind</em></a> the node they represent to ids for later
+processing.</p>
+<p><tt class="docutils literal"><span class="pre">VariadicDynCastAllOfMatchers</span></tt> are callable classes that model variadic
+template functions in C++03.  They take an aribtrary number of
+<tt class="docutils literal"><span class="pre">Matcher<Derived></span></tt> and return a <tt class="docutils literal"><span class="pre">Matcher<Base></span></tt>.</p>
+</div>
+<div class="section" id="ast-matcher-p-type-name-paramtype-param">
+<h3><tt class="docutils literal"><span class="pre">AST_MATCHER_P(Type,</span> <span class="pre">Name,</span> <span class="pre">ParamType,</span> <span class="pre">Param)</span></tt><a class="headerlink" href="#ast-matcher-p-type-name-paramtype-param" title="Permalink to this headline">¶</a></h3>
+<p>Most matcher definitions use the matcher creation macros.  Those define both
+the matcher of type <tt class="docutils literal"><span class="pre">Matcher<Type></span></tt> itself, and a matcher-creation function
+named <em>Name</em> that takes a parameter of type <em>ParamType</em> and returns the
+corresponding matcher.</p>
+<p>There are multiple matcher definition macros that deal with polymorphic return
+values and different parameter counts.  See <a class="reference external" href="http://clang.llvm.org/doxygen/ASTMatchersMacros_8h.html">ASTMatchersMacros.h</a>.</p>
+</div>
+<div class="section" id="matcher-creation-functions">
+<span id="astmatchers-writing"></span><h3>Matcher creation functions<a class="headerlink" href="#matcher-creation-functions" title="Permalink to this headline">¶</a></h3>
+<p>Matchers are generated by nesting calls to matcher creation functions.  Most of
+the time those functions are either created by using
+<tt class="docutils literal"><span class="pre">VariadicDynCastAllOfMatcher</span></tt> or the matcher creation macros (see below).
+The free-standing functions are an indication that this matcher is just a
+combination of other matchers, as is for example the case with <a class="reference external" href="LibASTMatchersReference.html#callee1Anchor">callee</a>.</p>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="LibASTMatchersTutorial.html">Tutorial for building tools using LibTooling and LibASTMatchers</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="HowToSetupToolingForLLVM.html">How To Setup Clang Tooling For LLVM</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchersTutorial.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchersTutorial.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchersTutorial.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/LibASTMatchersTutorial.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,543 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Tutorial for building tools using LibTooling and LibASTMatchers — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Matching the Clang AST" href="LibASTMatchers.html" />
+    <link rel="prev" title="How to write RecursiveASTVisitor based ASTFrontendActions." href="RAVFrontendAction.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Tutorial for building tools using LibTooling and LibASTMatchers</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="RAVFrontendAction.html">How to write RecursiveASTVisitor based ASTFrontendActions.</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibASTMatchers.html">Matching the Clang AST</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="tutorial-for-building-tools-using-libtooling-and-libastmatchers">
+<h1>Tutorial for building tools using LibTooling and LibASTMatchers<a class="headerlink" href="#tutorial-for-building-tools-using-libtooling-and-libastmatchers" title="Permalink to this headline">¶</a></h1>
+<p>This document is intended to show how to build a useful source-to-source
+translation tool based on Clang’s <a class="reference external" href="LibTooling.html">LibTooling</a>. It is
+explicitly aimed at people who are new to Clang, so all you should need
+is a working knowledge of C++ and the command line.</p>
+<p>In order to work on the compiler, you need some basic knowledge of the
+abstract syntax tree (AST). To this end, the reader is incouraged to
+skim the <a class="reference internal" href="IntroductionToTheClangAST.html"><em>Introduction to the Clang
+AST</em></a></p>
+<div class="section" id="step-0-obtaining-clang">
+<h2>Step 0: Obtaining Clang<a class="headerlink" href="#step-0-obtaining-clang" title="Permalink to this headline">¶</a></h2>
+<p>As Clang is part of the LLVM project, you’ll need to download LLVM’s
+source code first. Both Clang and LLVM are maintained as Subversion
+repositories, but we’ll be accessing them through the git mirror. For
+further information, see the <a class="reference external" href="http://llvm.org/docs/GettingStarted.html">getting started
+guide</a>.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">mkdir ~/clang-llvm && cd ~/clang-llvm</span>
+<span class="go">git clone http://llvm.org/git/llvm.git</span>
+<span class="go">cd llvm/tools</span>
+<span class="go">git clone http://llvm.org/git/clang.git</span>
+<span class="go">cd clang/tools</span>
+<span class="go">git clone http://llvm.org/git/clang-tools-extra.git extra</span>
+</pre></div>
+</div>
+<p>Next you need to obtain the CMake build system and Ninja build tool. You
+may already have CMake installed, but current binary versions of CMake
+aren’t built with Ninja support.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cd ~/clang-llvm</span>
+<span class="go">git clone https://github.com/martine/ninja.git</span>
+<span class="go">cd ninja</span>
+<span class="go">git checkout release</span>
+<span class="go">./bootstrap.py</span>
+<span class="go">sudo cp ninja /usr/bin/</span>
+
+<span class="go">cd ~/clang-llvm</span>
+<span class="go">git clone git://cmake.org/stage/cmake.git</span>
+<span class="go">cd cmake</span>
+<span class="go">git checkout next</span>
+<span class="go">./bootstrap</span>
+<span class="go">make</span>
+<span class="go">sudo make install</span>
+</pre></div>
+</div>
+<p>Okay. Now we’ll build Clang!</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cd ~/clang-llvm</span>
+<span class="go">mkdir build && cd build</span>
+<span class="go">cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON  # Enable tests; default is off.</span>
+<span class="go">ninja</span>
+<span class="go">ninja check       # Test LLVM only.</span>
+<span class="go">ninja clang-test  # Test Clang only.</span>
+<span class="go">ninja install</span>
+</pre></div>
+</div>
+<p>And we’re live.</p>
+<p>All of the tests should pass, though there is a (very) small chance that
+you can catch LLVM and Clang out of sync. Running <tt class="docutils literal"><span class="pre">'git</span> <span class="pre">svn</span> <span class="pre">rebase'</span></tt>
+in both the llvm and clang directories should fix any problems.</p>
+<p>Finally, we want to set Clang as its own compiler.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cd ~/clang-llvm/build</span>
+<span class="go">ccmake ../llvm</span>
+</pre></div>
+</div>
+<p>The second command will bring up a GUI for configuring Clang. You need
+to set the entry for <tt class="docutils literal"><span class="pre">CMAKE_CXX_COMPILER</span></tt>. Press <tt class="docutils literal"><span class="pre">'t'</span></tt> to turn on
+advanced mode. Scroll down to <tt class="docutils literal"><span class="pre">CMAKE_CXX_COMPILER</span></tt>, and set it to
+<tt class="docutils literal"><span class="pre">/usr/bin/clang++</span></tt>, or wherever you installed it. Press <tt class="docutils literal"><span class="pre">'c'</span></tt> to
+configure, then <tt class="docutils literal"><span class="pre">'g'</span></tt> to generate CMake’s files.</p>
+<p>Finally, run ninja one last time, and you’re done.</p>
+</div>
+<div class="section" id="step-1-create-a-clangtool">
+<h2>Step 1: Create a ClangTool<a class="headerlink" href="#step-1-create-a-clangtool" title="Permalink to this headline">¶</a></h2>
+<p>Now that we have enough background knowledge, it’s time to create the
+simplest productive ClangTool in existence: a syntax checker. While this
+already exists as <tt class="docutils literal"><span class="pre">clang-check</span></tt>, it’s important to understand what’s
+going on.</p>
+<p>First, we’ll need to create a new directory for our tool and tell CMake
+that it exists. As this is not going to be a core clang tool, it will
+live in the <tt class="docutils literal"><span class="pre">tools/extra</span></tt> repository.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cd ~/clang-llvm/llvm/tools/clang</span>
+<span class="go">mkdir tools/extra/loop-convert</span>
+<span class="go">echo 'add_subdirectory(loop-convert)' >> tools/extra/CMakeLists.txt</span>
+<span class="go">vim tools/extra/loop-convert/CMakeLists.txt</span>
+</pre></div>
+</div>
+<p>CMakeLists.txt should have the following contents:</p>
+<div class="highlight-python"><div class="highlight"><pre>set(LLVM_LINK_COMPONENTS support)
+set(LLVM_USED_LIBS clangTooling clangBasic clangAST)
+
+add_clang_executable(loop-convert
+  LoopConvert.cpp
+  )
+target_link_libraries(loop-convert
+  clangTooling
+  clangBasic
+  clangASTMatchers
+  )
+</pre></div>
+</div>
+<p>With that done, Ninja will be able to compile our tool. Let’s give it
+something to compile! Put the following into
+<tt class="docutils literal"><span class="pre">tools/extra/loop-convert/LoopConvert.cpp</span></tt>. A detailed explanation of
+why the different parts are needed can be found in the <a class="reference external" href="LibTooling.html">LibTooling
+documentation</a>.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// Declares clang::SyntaxOnlyAction.</span>
+<span class="cp">#include "clang/Frontend/FrontendActions.h"</span>
+<span class="cp">#include "clang/Tooling/CommonOptionsParser.h"</span>
+<span class="cp">#include "clang/Tooling/Tooling.h"</span>
+<span class="c1">// Declares llvm::cl::extrahelp.</span>
+<span class="cp">#include "llvm/Support/CommandLine.h"</span>
+
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">clang</span><span class="o">::</span><span class="n">tooling</span><span class="p">;</span>
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">llvm</span><span class="p">;</span>
+
+<span class="c1">// Apply a custom category to all command-line options so that they are the</span>
+<span class="c1">// only ones displayed.</span>
+<span class="k">static</span> <span class="n">llvm</span><span class="o">::</span><span class="n">cl</span><span class="o">::</span><span class="n">OptionCategory</span> <span class="n">MyToolCategory</span><span class="p">(</span><span class="s">"my-tool options"</span><span class="p">);</span>
+
+<span class="c1">// CommonOptionsParser declares HelpMessage with a description of the common</span>
+<span class="c1">// command-line options related to the compilation database and input files.</span>
+<span class="c1">// It's nice to have this help message in all tools.</span>
+<span class="k">static</span> <span class="n">cl</span><span class="o">::</span><span class="n">extrahelp</span> <span class="n">CommonHelp</span><span class="p">(</span><span class="n">CommonOptionsParser</span><span class="o">::</span><span class="n">HelpMessage</span><span class="p">);</span>
+
+<span class="c1">// A help message for this specific tool can be added afterwards.</span>
+<span class="k">static</span> <span class="n">cl</span><span class="o">::</span><span class="n">extrahelp</span> <span class="n">MoreHelp</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">More help text..."</span><span class="p">);</span>
+
+<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">CommonOptionsParser</span> <span class="n">OptionsParser</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">MyToolCategory</span><span class="p">);</span>
+  <span class="n">ClangTool</span> <span class="n">Tool</span><span class="p">(</span><span class="n">OptionsParser</span><span class="p">.</span><span class="n">getCompilations</span><span class="p">(),</span>
+                 <span class="n">OptionsParser</span><span class="p">.</span><span class="n">getSourcePathList</span><span class="p">());</span>
+  <span class="k">return</span> <span class="n">Tool</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">newFrontendActionFactory</span><span class="o"><</span><span class="n">clang</span><span class="o">::</span><span class="n">SyntaxOnlyAction</span><span class="o">></span><span class="p">().</span><span class="n">get</span><span class="p">());</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>And that’s it! You can compile our new tool by running ninja from the
+<tt class="docutils literal"><span class="pre">build</span></tt> directory.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cd ~/clang-llvm/build</span>
+<span class="go">ninja</span>
+</pre></div>
+</div>
+<p>You should now be able to run the syntax checker, which is located in
+<tt class="docutils literal"><span class="pre">~/clang-llvm/build/bin</span></tt>, on any source file. Try it!</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cat "int main() { return 0; }" > test.cpp</span>
+<span class="go">bin/loop-convert test.cpp --</span>
+</pre></div>
+</div>
+<p>Note the two dashes after we specify the source file. The additional
+options for the compiler are passed after the dashes rather than loading
+them from a compilation database - there just aren’t any options needed
+right now.</p>
+</div>
+<div class="section" id="intermezzo-learn-ast-matcher-basics">
+<h2>Intermezzo: Learn AST matcher basics<a class="headerlink" href="#intermezzo-learn-ast-matcher-basics" title="Permalink to this headline">¶</a></h2>
+<p>Clang recently introduced the <a class="reference internal" href="LibASTMatchers.html"><em>ASTMatcher
+library</em></a> to provide a simple, powerful, and
+concise way to describe specific patterns in the AST. Implemented as a
+DSL powered by macros and templates (see
+<a class="reference external" href="../doxygen/ASTMatchers_8h_source.html">ASTMatchers.h</a> if you’re
+curious), matchers offer the feel of algebraic data types common to
+functional programming languages.</p>
+<p>For example, suppose you wanted to examine only binary operators. There
+is a matcher to do exactly that, conveniently named <tt class="docutils literal"><span class="pre">binaryOperator</span></tt>.
+I’ll give you one guess what this matcher does:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">binaryOperator</span><span class="p">(</span><span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"+"</span><span class="p">),</span> <span class="n">hasLHS</span><span class="p">(</span><span class="n">integerLiteral</span><span class="p">(</span><span class="n">equals</span><span class="p">(</span><span class="mi">0</span><span class="p">))))</span>
+</pre></div>
+</div>
+<p>Shockingly, it will match against addition expressions whose left hand
+side is exactly the literal 0. It will not match against other forms of
+0, such as <tt class="docutils literal"><span class="pre">'\0'</span></tt> or <tt class="docutils literal"><span class="pre">NULL</span></tt>, but it will match against macros that
+expand to 0. The matcher will also not match against calls to the
+overloaded operator <tt class="docutils literal"><span class="pre">'+'</span></tt>, as there is a separate <tt class="docutils literal"><span class="pre">operatorCallExpr</span></tt>
+matcher to handle overloaded operators.</p>
+<p>There are AST matchers to match all the different nodes of the AST,
+narrowing matchers to only match AST nodes fulfilling specific criteria,
+and traversal matchers to get from one kind of AST node to another. For
+a complete list of AST matchers, take a look at the <a class="reference external" href="LibASTMatchersReference.html">AST Matcher
+References</a></p>
+<p>All matcher that are nouns describe entities in the AST and can be
+bound, so that they can be referred to whenever a match is found. To do
+so, simply call the method <tt class="docutils literal"><span class="pre">bind</span></tt> on these matchers, e.g.:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">variable</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())).</span><span class="n">bind</span><span class="p">(</span><span class="s">"intvar"</span><span class="p">)</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="step-2-using-ast-matchers">
+<h2>Step 2: Using AST matchers<a class="headerlink" href="#step-2-using-ast-matchers" title="Permalink to this headline">¶</a></h2>
+<p>Okay, on to using matchers for real. Let’s start by defining a matcher
+which will capture all <tt class="docutils literal"><span class="pre">for</span></tt> statements that define a new variable
+initialized to zero. Let’s start with matching all <tt class="docutils literal"><span class="pre">for</span></tt> loops:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">forStmt</span><span class="p">()</span>
+</pre></div>
+</div>
+<p>Next, we want to specify that a single variable is declared in the first
+portion of the loop, so we can extend the matcher to</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">forStmt</span><span class="p">(</span><span class="n">hasLoopInit</span><span class="p">(</span><span class="n">declStmt</span><span class="p">(</span><span class="n">hasSingleDecl</span><span class="p">(</span><span class="n">varDecl</span><span class="p">()))))</span>
+</pre></div>
+</div>
+<p>Finally, we can add the condition that the variable is initialized to
+zero.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">forStmt</span><span class="p">(</span><span class="n">hasLoopInit</span><span class="p">(</span><span class="n">declStmt</span><span class="p">(</span><span class="n">hasSingleDecl</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span>
+  <span class="n">hasInitializer</span><span class="p">(</span><span class="n">integerLiteral</span><span class="p">(</span><span class="n">equals</span><span class="p">(</span><span class="mi">0</span><span class="p">))))))))</span>
+</pre></div>
+</div>
+<p>It is fairly easy to read and understand the matcher definition (“match
+loops whose init portion declares a single variable which is initialized
+to the integer literal 0”), but deciding that every piece is necessary
+is more difficult. Note that this matcher will not match loops whose
+variables are initialized to <tt class="docutils literal"><span class="pre">'\0'</span></tt>, <tt class="docutils literal"><span class="pre">0.0</span></tt>, <tt class="docutils literal"><span class="pre">NULL</span></tt>, or any form of
+zero besides the integer 0.</p>
+<p>The last step is giving the matcher a name and binding the <tt class="docutils literal"><span class="pre">ForStmt</span></tt>
+as we will want to do something with it:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">StatementMatcher</span> <span class="n">LoopMatcher</span> <span class="o">=</span>
+  <span class="n">forStmt</span><span class="p">(</span><span class="n">hasLoopInit</span><span class="p">(</span><span class="n">declStmt</span><span class="p">(</span><span class="n">hasSingleDecl</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span>
+    <span class="n">hasInitializer</span><span class="p">(</span><span class="n">integerLiteral</span><span class="p">(</span><span class="n">equals</span><span class="p">(</span><span class="mi">0</span><span class="p">)))))))).</span><span class="n">bind</span><span class="p">(</span><span class="s">"forLoop"</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>Once you have defined your matchers, you will need to add a little more
+scaffolding in order to run them. Matchers are paired with a
+<tt class="docutils literal"><span class="pre">MatchCallback</span></tt> and registered with a <tt class="docutils literal"><span class="pre">MatchFinder</span></tt> object, then run
+from a <tt class="docutils literal"><span class="pre">ClangTool</span></tt>. More code!</p>
+<p>Add the following to <tt class="docutils literal"><span class="pre">LoopConvert.cpp</span></tt>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include "clang/ASTMatchers/ASTMatchers.h"</span>
+<span class="cp">#include "clang/ASTMatchers/ASTMatchFinder.h"</span>
+
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">clang</span><span class="p">;</span>
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">clang</span><span class="o">::</span><span class="n">ast_matchers</span><span class="p">;</span>
+
+<span class="n">StatementMatcher</span> <span class="n">LoopMatcher</span> <span class="o">=</span>
+  <span class="n">forStmt</span><span class="p">(</span><span class="n">hasLoopInit</span><span class="p">(</span><span class="n">declStmt</span><span class="p">(</span><span class="n">hasSingleDecl</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span>
+    <span class="n">hasInitializer</span><span class="p">(</span><span class="n">integerLiteral</span><span class="p">(</span><span class="n">equals</span><span class="p">(</span><span class="mi">0</span><span class="p">)))))))).</span><span class="n">bind</span><span class="p">(</span><span class="s">"forLoop"</span><span class="p">);</span>
+
+<span class="k">class</span> <span class="nc">LoopPrinter</span> <span class="o">:</span> <span class="k">public</span> <span class="n">MatchFinder</span><span class="o">::</span><span class="n">MatchCallback</span> <span class="p">{</span>
+<span class="k">public</span> <span class="o">:</span>
+  <span class="k">virtual</span> <span class="kt">void</span> <span class="n">run</span><span class="p">(</span><span class="k">const</span> <span class="n">MatchFinder</span><span class="o">::</span><span class="n">MatchResult</span> <span class="o">&</span><span class="n">Result</span><span class="p">)</span> <span class="p">{</span>
+    <span class="k">if</span> <span class="p">(</span><span class="k">const</span> <span class="n">ForStmt</span> <span class="o">*</span><span class="n">FS</span> <span class="o">=</span> <span class="n">Result</span><span class="p">.</span><span class="n">Nodes</span><span class="p">.</span><span class="n">getNodeAs</span><span class="o"><</span><span class="n">clang</span><span class="o">::</span><span class="n">ForStmt</span><span class="o">></span><span class="p">(</span><span class="s">"forLoop"</span><span class="p">))</span>
+      <span class="n">FS</span><span class="o">-></span><span class="n">dump</span><span class="p">();</span>
+  <span class="p">}</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>And change <tt class="docutils literal"><span class="pre">main()</span></tt> to:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">CommonOptionsParser</span> <span class="n">OptionsParser</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">MyToolCategory</span><span class="p">);</span>
+  <span class="n">ClangTool</span> <span class="n">Tool</span><span class="p">(</span><span class="n">OptionsParser</span><span class="p">.</span><span class="n">getCompilations</span><span class="p">(),</span>
+                 <span class="n">OptionsParser</span><span class="p">.</span><span class="n">getSourcePathList</span><span class="p">());</span>
+
+  <span class="n">LoopPrinter</span> <span class="n">Printer</span><span class="p">;</span>
+  <span class="n">MatchFinder</span> <span class="n">Finder</span><span class="p">;</span>
+  <span class="n">Finder</span><span class="p">.</span><span class="n">addMatcher</span><span class="p">(</span><span class="n">LoopMatcher</span><span class="p">,</span> <span class="o">&</span><span class="n">Printer</span><span class="p">);</span>
+
+  <span class="k">return</span> <span class="n">Tool</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">newFrontendActionFactory</span><span class="p">(</span><span class="o">&</span><span class="n">Finder</span><span class="p">).</span><span class="n">get</span><span class="p">());</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Now, you should be able to recompile and run the code to discover for
+loops. Create a new file with a few examples, and test out our new
+handiwork:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">cd ~/clang-llvm/llvm/llvm_build/</span>
+<span class="go">ninja loop-convert</span>
+<span class="go">vim ~/test-files/simple-loops.cc</span>
+<span class="go">bin/loop-convert ~/test-files/simple-loops.cc</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="step-3-5-more-complicated-matchers">
+<h2>Step 3.5: More Complicated Matchers<a class="headerlink" href="#step-3-5-more-complicated-matchers" title="Permalink to this headline">¶</a></h2>
+<p>Our simple matcher is capable of discovering for loops, but we would
+still need to filter out many more ourselves. We can do a good portion
+of the remaining work with some cleverly chosen matchers, but first we
+need to decide exactly which properties we want to allow.</p>
+<p>How can we characterize for loops over arrays which would be eligible
+for translation to range-based syntax? Range based loops over arrays of
+size <tt class="docutils literal"><span class="pre">N</span></tt> that:</p>
+<ul class="simple">
+<li>start at index <tt class="docutils literal"><span class="pre">0</span></tt></li>
+<li>iterate consecutively</li>
+<li>end at index <tt class="docutils literal"><span class="pre">N-1</span></tt></li>
+</ul>
+<p>We already check for (1), so all we need to add is a check to the loop’s
+condition to ensure that the loop’s index variable is compared against
+<tt class="docutils literal"><span class="pre">N</span></tt> and another check to ensure that the increment step just
+increments this same variable. The matcher for (2) is straightforward:
+require a pre- or post-increment of the same variable declared in the
+init portion.</p>
+<p>Unfortunately, such a matcher is impossible to write. Matchers contain
+no logic for comparing two arbitrary AST nodes and determining whether
+or not they are equal, so the best we can do is matching more than we
+would like to allow, and punting extra comparisons to the callback.</p>
+<p>In any case, we can start building this sub-matcher. We can require that
+the increment step be a unary increment like this:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasIncrement</span><span class="p">(</span><span class="n">unaryOperator</span><span class="p">(</span><span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"++"</span><span class="p">)))</span>
+</pre></div>
+</div>
+<p>Specifying what is incremented introduces another quirk of Clang’s AST:
+Usages of variables are represented as <tt class="docutils literal"><span class="pre">DeclRefExpr</span></tt>‘s (“declaration
+reference expressions”) because they are expressions which refer to
+variable declarations. To find a <tt class="docutils literal"><span class="pre">unaryOperator</span></tt> that refers to a
+specific declaration, we can simply add a second condition to it:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasIncrement</span><span class="p">(</span><span class="n">unaryOperator</span><span class="p">(</span>
+  <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"++"</span><span class="p">),</span>
+  <span class="n">hasUnaryOperand</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">())))</span>
+</pre></div>
+</div>
+<p>Furthermore, we can restrict our matcher to only match if the
+incremented variable is an integer:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasIncrement</span><span class="p">(</span><span class="n">unaryOperator</span><span class="p">(</span>
+  <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"++"</span><span class="p">),</span>
+  <span class="n">hasUnaryOperand</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">(</span><span class="n">to</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())))))))</span>
+</pre></div>
+</div>
+<p>And the last step will be to attach an identifier to this variable, so
+that we can retrieve it in the callback:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasIncrement</span><span class="p">(</span><span class="n">unaryOperator</span><span class="p">(</span>
+  <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"++"</span><span class="p">),</span>
+  <span class="n">hasUnaryOperand</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">(</span><span class="n">to</span><span class="p">(</span>
+    <span class="n">varDecl</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())).</span><span class="n">bind</span><span class="p">(</span><span class="s">"incrementVariable"</span><span class="p">))))))</span>
+</pre></div>
+</div>
+<p>We can add this code to the definition of <tt class="docutils literal"><span class="pre">LoopMatcher</span></tt> and make sure
+that our program, outfitted with the new matcher, only prints out loops
+that declare a single variable initialized to zero and have an increment
+step consisting of a unary increment of some variable.</p>
+<p>Now, we just need to add a matcher to check if the condition part of the
+<tt class="docutils literal"><span class="pre">for</span></tt> loop compares a variable against the size of the array. There is
+only one problem - we don’t know which array we’re iterating over
+without looking at the body of the loop! We are again restricted to
+approximating the result we want with matchers, filling in the details
+in the callback. So we start with:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasCondition</span><span class="p">(</span><span class="n">binaryOperator</span><span class="p">(</span><span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"<"</span><span class="p">))</span>
+</pre></div>
+</div>
+<p>It makes sense to ensure that the left-hand side is a reference to a
+variable, and that the right-hand side has integer type.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasCondition</span><span class="p">(</span><span class="n">binaryOperator</span><span class="p">(</span>
+  <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"<"</span><span class="p">),</span>
+  <span class="n">hasLHS</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">(</span><span class="n">to</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">()))))),</span>
+  <span class="n">hasRHS</span><span class="p">(</span><span class="n">expr</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())))))</span>
+</pre></div>
+</div>
+<p>Why? Because it doesn’t work. Of the three loops provided in
+<tt class="docutils literal"><span class="pre">test-files/simple.cpp</span></tt>, zero of them have a matching condition. A
+quick look at the AST dump of the first for loop, produced by the
+previous iteration of loop-convert, shows us the answer:</p>
+<div class="highlight-python"><div class="highlight"><pre>(ForStmt 0x173b240
+  (DeclStmt 0x173afc8
+    0x173af50 "int i =
+      (IntegerLiteral 0x173afa8 'int' 0)")
+  <<>>
+  (BinaryOperator 0x173b060 '_Bool' '<'
+    (ImplicitCastExpr 0x173b030 'int'
+      (DeclRefExpr 0x173afe0 'int' lvalue Var 0x173af50 'i' 'int'))
+    (ImplicitCastExpr 0x173b048 'int'
+      (DeclRefExpr 0x173b008 'const int' lvalue Var 0x170fa80 'N' 'const int')))
+  (UnaryOperator 0x173b0b0 'int' lvalue prefix '++'
+    (DeclRefExpr 0x173b088 'int' lvalue Var 0x173af50 'i' 'int'))
+  (CompoundStatement ...
+</pre></div>
+</div>
+<p>We already know that the declaration and increments both match, or this
+loop wouldn’t have been dumped. The culprit lies in the implicit cast
+applied to the first operand (i.e. the LHS) of the less-than operator,
+an L-value to R-value conversion applied to the expression referencing
+<tt class="docutils literal"><span class="pre">i</span></tt>. Thankfully, the matcher library offers a solution to this problem
+in the form of <tt class="docutils literal"><span class="pre">ignoringParenImpCasts</span></tt>, which instructs the matcher to
+ignore implicit casts and parentheses before continuing to match.
+Adjusting the condition operator will restore the desired match.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">hasCondition</span><span class="p">(</span><span class="n">binaryOperator</span><span class="p">(</span>
+  <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"<"</span><span class="p">),</span>
+  <span class="n">hasLHS</span><span class="p">(</span><span class="n">ignoringParenImpCasts</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">(</span>
+    <span class="n">to</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())))))),</span>
+  <span class="n">hasRHS</span><span class="p">(</span><span class="n">expr</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())))))</span>
+</pre></div>
+</div>
+<p>After adding binds to the expressions we wished to capture and
+extracting the identifier strings into variables, we have array-step-2
+completed.</p>
+</div>
+<div class="section" id="step-4-retrieving-matched-nodes">
+<h2>Step 4: Retrieving Matched Nodes<a class="headerlink" href="#step-4-retrieving-matched-nodes" title="Permalink to this headline">¶</a></h2>
+<p>So far, the matcher callback isn’t very interesting: it just dumps the
+loop’s AST. At some point, we will need to make changes to the input
+source code. Next, we’ll work on using the nodes we bound in the
+previous step.</p>
+<p>The <tt class="docutils literal"><span class="pre">MatchFinder::run()</span></tt> callback takes a
+<tt class="docutils literal"><span class="pre">MatchFinder::MatchResult&</span></tt> as its parameter. We’re most interested in
+its <tt class="docutils literal"><span class="pre">Context</span></tt> and <tt class="docutils literal"><span class="pre">Nodes</span></tt> members. Clang uses the <tt class="docutils literal"><span class="pre">ASTContext</span></tt>
+class to represent contextual information about the AST, as the name
+implies, though the most functionally important detail is that several
+operations require an <tt class="docutils literal"><span class="pre">ASTContext*</span></tt> parameter. More immediately useful
+is the set of matched nodes, and how we retrieve them.</p>
+<p>Since we bind three variables (identified by ConditionVarName,
+InitVarName, and IncrementVarName), we can obtain the matched nodes by
+using the <tt class="docutils literal"><span class="pre">getNodeAs()</span></tt> member function.</p>
+<p>In <tt class="docutils literal"><span class="pre">LoopConvert.cpp</span></tt> add</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include "clang/AST/ASTContext.h"</span>
+</pre></div>
+</div>
+<p>Change <tt class="docutils literal"><span class="pre">LoopMatcher</span></tt> to</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">StatementMatcher</span> <span class="n">LoopMatcher</span> <span class="o">=</span>
+    <span class="n">forStmt</span><span class="p">(</span><span class="n">hasLoopInit</span><span class="p">(</span><span class="n">declStmt</span><span class="p">(</span>
+                <span class="n">hasSingleDecl</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span><span class="n">hasInitializer</span><span class="p">(</span><span class="n">integerLiteral</span><span class="p">(</span><span class="n">equals</span><span class="p">(</span><span class="mi">0</span><span class="p">))))</span>
+                                  <span class="p">.</span><span class="n">bind</span><span class="p">(</span><span class="s">"initVarName"</span><span class="p">)))),</span>
+            <span class="n">hasIncrement</span><span class="p">(</span><span class="n">unaryOperator</span><span class="p">(</span>
+                <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"++"</span><span class="p">),</span>
+                <span class="n">hasUnaryOperand</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">(</span>
+                    <span class="n">to</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())).</span><span class="n">bind</span><span class="p">(</span><span class="s">"incVarName"</span><span class="p">)))))),</span>
+            <span class="n">hasCondition</span><span class="p">(</span><span class="n">binaryOperator</span><span class="p">(</span>
+                <span class="n">hasOperatorName</span><span class="p">(</span><span class="s">"<"</span><span class="p">),</span>
+                <span class="n">hasLHS</span><span class="p">(</span><span class="n">ignoringParenImpCasts</span><span class="p">(</span><span class="n">declRefExpr</span><span class="p">(</span>
+                    <span class="n">to</span><span class="p">(</span><span class="n">varDecl</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())).</span><span class="n">bind</span><span class="p">(</span><span class="s">"condVarName"</span><span class="p">))))),</span>
+                <span class="n">hasRHS</span><span class="p">(</span><span class="n">expr</span><span class="p">(</span><span class="n">hasType</span><span class="p">(</span><span class="n">isInteger</span><span class="p">())))))).</span><span class="n">bind</span><span class="p">(</span><span class="s">"forLoop"</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>And change <tt class="docutils literal"><span class="pre">LoopPrinter::run</span></tt> to</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="n">LoopPrinter</span><span class="o">::</span><span class="n">run</span><span class="p">(</span><span class="k">const</span> <span class="n">MatchFinder</span><span class="o">::</span><span class="n">MatchResult</span> <span class="o">&</span><span class="n">Result</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">ASTContext</span> <span class="o">*</span><span class="n">Context</span> <span class="o">=</span> <span class="n">Result</span><span class="p">.</span><span class="n">Context</span><span class="p">;</span>
+  <span class="k">const</span> <span class="n">ForStmt</span> <span class="o">*</span><span class="n">FS</span> <span class="o">=</span> <span class="n">Result</span><span class="p">.</span><span class="n">Nodes</span><span class="p">.</span><span class="n">getStmtAs</span><span class="o"><</span><span class="n">ForStmt</span><span class="o">></span><span class="p">(</span><span class="s">"forLoop"</span><span class="p">);</span>
+  <span class="c1">// We do not want to convert header files!</span>
+  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">FS</span> <span class="o">||</span> <span class="o">!</span><span class="n">Context</span><span class="o">-></span><span class="n">getSourceManager</span><span class="p">().</span><span class="n">isFromMainFile</span><span class="p">(</span><span class="n">FS</span><span class="o">-></span><span class="n">getForLoc</span><span class="p">()))</span>
+    <span class="k">return</span><span class="p">;</span>
+  <span class="k">const</span> <span class="n">VarDecl</span> <span class="o">*</span><span class="n">IncVar</span> <span class="o">=</span> <span class="n">Result</span><span class="p">.</span><span class="n">Nodes</span><span class="p">.</span><span class="n">getNodeAs</span><span class="o"><</span><span class="n">VarDecl</span><span class="o">></span><span class="p">(</span><span class="s">"incVarName"</span><span class="p">);</span>
+  <span class="k">const</span> <span class="n">VarDecl</span> <span class="o">*</span><span class="n">CondVar</span> <span class="o">=</span> <span class="n">Result</span><span class="p">.</span><span class="n">Nodes</span><span class="p">.</span><span class="n">getNodeAs</span><span class="o"><</span><span class="n">VarDecl</span><span class="o">></span><span class="p">(</span><span class="s">"condVarName"</span><span class="p">);</span>
+  <span class="k">const</span> <span class="n">VarDecl</span> <span class="o">*</span><span class="n">InitVar</span> <span class="o">=</span> <span class="n">Result</span><span class="p">.</span><span class="n">Nodes</span><span class="p">.</span><span class="n">getNodeAs</span><span class="o"><</span><span class="n">VarDecl</span><span class="o">></span><span class="p">(</span><span class="s">"initVarName"</span><span class="p">);</span>
+
+  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">areSameVariable</span><span class="p">(</span><span class="n">IncVar</span><span class="p">,</span> <span class="n">CondVar</span><span class="p">)</span> <span class="o">||</span> <span class="o">!</span><span class="n">areSameVariable</span><span class="p">(</span><span class="n">IncVar</span><span class="p">,</span> <span class="n">InitVar</span><span class="p">))</span>
+    <span class="k">return</span><span class="p">;</span>
+  <span class="n">llvm</span><span class="o">::</span><span class="n">outs</span><span class="p">()</span> <span class="o"><<</span> <span class="s">"Potential array-based loop discovered.</span><span class="se">\n</span><span class="s">"</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Clang associates a <tt class="docutils literal"><span class="pre">VarDecl</span></tt> with each variable to represent the variable’s
+declaration. Since the “canonical” form of each declaration is unique by
+address, all we need to do is make sure neither <tt class="docutils literal"><span class="pre">ValueDecl</span></tt> (base class of
+<tt class="docutils literal"><span class="pre">VarDecl</span></tt>) is <tt class="docutils literal"><span class="pre">NULL</span></tt> and compare the canonical Decls.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">static</span> <span class="kt">bool</span> <span class="nf">areSameVariable</span><span class="p">(</span><span class="k">const</span> <span class="n">ValueDecl</span> <span class="o">*</span><span class="n">First</span><span class="p">,</span> <span class="k">const</span> <span class="n">ValueDecl</span> <span class="o">*</span><span class="n">Second</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">return</span> <span class="n">First</span> <span class="o">&&</span> <span class="n">Second</span> <span class="o">&&</span>
+         <span class="n">First</span><span class="o">-></span><span class="n">getCanonicalDecl</span><span class="p">()</span> <span class="o">==</span> <span class="n">Second</span><span class="o">-></span><span class="n">getCanonicalDecl</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>If execution reaches the end of <tt class="docutils literal"><span class="pre">LoopPrinter::run()</span></tt>, we know that the
+loop shell that looks like</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o"><</span> <span class="n">expr</span><span class="p">();</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
+</pre></div>
+</div>
+<p>For now, we will just print a message explaining that we found a loop.
+The next section will deal with recursively traversing the AST to
+discover all changes needed.</p>
+<p>As a side note, it’s not as trivial to test if two expressions are the same,
+though Clang has already done the hard work for us by providing a way to
+canonicalize expressions:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">static</span> <span class="kt">bool</span> <span class="nf">areSameExpr</span><span class="p">(</span><span class="n">ASTContext</span> <span class="o">*</span><span class="n">Context</span><span class="p">,</span> <span class="k">const</span> <span class="n">Expr</span> <span class="o">*</span><span class="n">First</span><span class="p">,</span>
+                        <span class="k">const</span> <span class="n">Expr</span> <span class="o">*</span><span class="n">Second</span><span class="p">)</span> <span class="p">{</span>
+  <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">First</span> <span class="o">||</span> <span class="o">!</span><span class="n">Second</span><span class="p">)</span>
+    <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
+  <span class="n">llvm</span><span class="o">::</span><span class="n">FoldingSetNodeID</span> <span class="n">FirstID</span><span class="p">,</span> <span class="n">SecondID</span><span class="p">;</span>
+  <span class="n">First</span><span class="o">-></span><span class="n">Profile</span><span class="p">(</span><span class="n">FirstID</span><span class="p">,</span> <span class="o">*</span><span class="n">Context</span><span class="p">,</span> <span class="nb">true</span><span class="p">);</span>
+  <span class="n">Second</span><span class="o">-></span><span class="n">Profile</span><span class="p">(</span><span class="n">SecondID</span><span class="p">,</span> <span class="o">*</span><span class="n">Context</span><span class="p">,</span> <span class="nb">true</span><span class="p">);</span>
+  <span class="k">return</span> <span class="n">FirstID</span> <span class="o">==</span> <span class="n">SecondID</span><span class="p">;</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>This code relies on the comparison between two
+<tt class="docutils literal"><span class="pre">llvm::FoldingSetNodeIDs</span></tt>. As the documentation for
+<tt class="docutils literal"><span class="pre">Stmt::Profile()</span></tt> indicates, the <tt class="docutils literal"><span class="pre">Profile()</span></tt> member function builds
+a description of a node in the AST, based on its properties, along with
+those of its children. <tt class="docutils literal"><span class="pre">FoldingSetNodeID</span></tt> then serves as a hash we can
+use to compare expressions. We will need <tt class="docutils literal"><span class="pre">areSameExpr</span></tt> later. Before
+you run the new code on the additional loops added to
+test-files/simple.cpp, try to figure out which ones will be considered
+potentially convertible.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="RAVFrontendAction.html">How to write RecursiveASTVisitor based ASTFrontendActions.</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibASTMatchers.html">Matching the Clang AST</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/LibFormat.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/LibFormat.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/LibFormat.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/LibFormat.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,112 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>LibFormat — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Clang Plugins" href="ClangPlugins.html" />
+    <link rel="prev" title="LibTooling" href="LibTooling.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>LibFormat</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="LibTooling.html">LibTooling</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ClangPlugins.html">Clang Plugins</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="libformat">
+<h1>LibFormat<a class="headerlink" href="#libformat" title="Permalink to this headline">¶</a></h1>
+<p>LibFormat is a library that implements automatic source code formatting based
+on Clang. This documents describes the LibFormat interface and design as well
+as some basic style discussions.</p>
+<p>If you just want to use <cite>clang-format</cite> as a tool or integrated into an editor,
+checkout <a class="reference internal" href="ClangFormat.html"><em>ClangFormat</em></a>.</p>
+<div class="section" id="design">
+<h2>Design<a class="headerlink" href="#design" title="Permalink to this headline">¶</a></h2>
+<p>FIXME: Write up design.</p>
+</div>
+<div class="section" id="interface">
+<h2>Interface<a class="headerlink" href="#interface" title="Permalink to this headline">¶</a></h2>
+<p>The core routine of LibFormat is <tt class="docutils literal"><span class="pre">reformat()</span></tt>:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">tooling</span><span class="o">::</span><span class="n">Replacements</span> <span class="n">reformat</span><span class="p">(</span><span class="k">const</span> <span class="n">FormatStyle</span> <span class="o">&</span><span class="n">Style</span><span class="p">,</span> <span class="n">Lexer</span> <span class="o">&</span><span class="n">Lex</span><span class="p">,</span>
+                               <span class="n">SourceManager</span> <span class="o">&</span><span class="n">SourceMgr</span><span class="p">,</span>
+                               <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o"><</span><span class="n">CharSourceRange</span><span class="o">></span> <span class="n">Ranges</span><span class="p">);</span>
+</pre></div>
+</div>
+<p>This reads a token stream out of the lexer <tt class="docutils literal"><span class="pre">Lex</span></tt> and reformats all the code
+ranges in <tt class="docutils literal"><span class="pre">Ranges</span></tt>. The <tt class="docutils literal"><span class="pre">FormatStyle</span></tt> controls basic decisions made during
+formatting. A list of options can be found under <a class="reference internal" href="#style-options"><em>Style Options</em></a>.</p>
+</div>
+<div class="section" id="style-options">
+<span id="id1"></span><h2>Style Options<a class="headerlink" href="#style-options" title="Permalink to this headline">¶</a></h2>
+<p>The style options describe specific formatting options that can be used in
+order to make <cite>ClangFormat</cite> comply with different style guides. Currently,
+two style guides are hard-coded:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">/// \brief Returns a format style complying with the LLVM coding standards:</span>
+<span class="c1">/// http://llvm.org/docs/CodingStandards.html.</span>
+<span class="n">FormatStyle</span> <span class="nf">getLLVMStyle</span><span class="p">();</span>
+
+<span class="c1">/// \brief Returns a format style complying with Google's C++ style guide:</span>
+<span class="c1">/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.</span>
+<span class="n">FormatStyle</span> <span class="nf">getGoogleStyle</span><span class="p">();</span>
+</pre></div>
+</div>
+<p>These options are also exposed in the <a class="reference internal" href="ClangFormat.html"><em>standalone tools</em></a>
+through the <cite>-style</cite> option.</p>
+<p>In the future, we plan on making this configurable.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="LibTooling.html">LibTooling</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ClangPlugins.html">Clang Plugins</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/LibTooling.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/LibTooling.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/LibTooling.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/LibTooling.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,242 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>LibTooling — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="LibFormat" href="LibFormat.html" />
+    <link rel="prev" title="Introduction to the Clang AST" href="IntroductionToTheClangAST.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>LibTooling</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="IntroductionToTheClangAST.html">Introduction to the Clang AST</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibFormat.html">LibFormat</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="libtooling">
+<h1>LibTooling<a class="headerlink" href="#libtooling" title="Permalink to this headline">¶</a></h1>
+<p>LibTooling is a library to support writing standalone tools based on Clang.
+This document will provide a basic walkthrough of how to write a tool using
+LibTooling.</p>
+<p>For the information on how to setup Clang Tooling for LLVM see
+<a class="reference internal" href="HowToSetupToolingForLLVM.html"><em>How To Setup Clang Tooling For LLVM</em></a></p>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>Tools built with LibTooling, like Clang Plugins, run <tt class="docutils literal"><span class="pre">FrontendActions</span></tt> over
+code.</p>
+<p>In this tutorial, we’ll demonstrate the different ways of running Clang’s
+<tt class="docutils literal"><span class="pre">SyntaxOnlyAction</span></tt>, which runs a quick syntax check, over a bunch of code.</p>
+</div>
+<div class="section" id="parsing-a-code-snippet-in-memory">
+<h2>Parsing a code snippet in memory<a class="headerlink" href="#parsing-a-code-snippet-in-memory" title="Permalink to this headline">¶</a></h2>
+<p>If you ever wanted to run a <tt class="docutils literal"><span class="pre">FrontendAction</span></tt> over some sample code, for
+example to unit test parts of the Clang AST, <tt class="docutils literal"><span class="pre">runToolOnCode</span></tt> is what you
+looked for.  Let me give you an example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include "clang/Tooling/Tooling.h"</span>
+
+<span class="n">TEST</span><span class="p">(</span><span class="n">runToolOnCode</span><span class="p">,</span> <span class="n">CanSyntaxCheckCode</span><span class="p">)</span> <span class="p">{</span>
+  <span class="c1">// runToolOnCode returns whether the action was correctly run over the</span>
+  <span class="c1">// given code.</span>
+  <span class="n">EXPECT_TRUE</span><span class="p">(</span><span class="n">runToolOnCode</span><span class="p">(</span><span class="k">new</span> <span class="n">clang</span><span class="o">::</span><span class="n">SyntaxOnlyAction</span><span class="p">,</span> <span class="s">"class X {};"</span><span class="p">));</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="writing-a-standalone-tool">
+<h2>Writing a standalone tool<a class="headerlink" href="#writing-a-standalone-tool" title="Permalink to this headline">¶</a></h2>
+<p>Once you unit tested your <tt class="docutils literal"><span class="pre">FrontendAction</span></tt> to the point where it cannot
+possibly break, it’s time to create a standalone tool.  For a standalone tool
+to run clang, it first needs to figure out what command line arguments to use
+for a specified file.  To that end we create a <tt class="docutils literal"><span class="pre">CompilationDatabase</span></tt>.  There
+are different ways to create a compilation database, and we need to support all
+of them depending on command-line options.  There’s the <tt class="docutils literal"><span class="pre">CommonOptionsParser</span></tt>
+class that takes the responsibility to parse command-line parameters related to
+compilation databases and inputs, so that all tools share the implementation.</p>
+<div class="section" id="parsing-common-tools-options">
+<h3>Parsing common tools options<a class="headerlink" href="#parsing-common-tools-options" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">CompilationDatabase</span></tt> can be read from a build directory or the command line.
+Using <tt class="docutils literal"><span class="pre">CommonOptionsParser</span></tt> allows for explicit specification of a compile
+command line, specification of build path using the <tt class="docutils literal"><span class="pre">-p</span></tt> command-line option,
+and automatic location of the compilation database using source files paths.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include "clang/Tooling/CommonOptionsParser.h"</span>
+<span class="cp">#include "llvm/Support/CommandLine.h"</span>
+
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">clang</span><span class="o">::</span><span class="n">tooling</span><span class="p">;</span>
+
+<span class="c1">// Apply a custom category to all command-line options so that they are the</span>
+<span class="c1">// only ones displayed.</span>
+<span class="k">static</span> <span class="n">llvm</span><span class="o">::</span><span class="n">cl</span><span class="o">::</span><span class="n">OptionCategory</span> <span class="n">MyToolCategory</span><span class="p">(</span><span class="s">"my-tool options"</span><span class="p">);</span>
+
+<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span> <span class="p">{</span>
+  <span class="c1">// CommonOptionsParser constructor will parse arguments and create a</span>
+  <span class="c1">// CompilationDatabase.  In case of error it will terminate the program.</span>
+  <span class="n">CommonOptionsParser</span> <span class="n">OptionsParser</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">MyToolCategory</span><span class="p">);</span>
+
+  <span class="c1">// Use OptionsParser.getCompilations() and OptionsParser.getSourcePathList()</span>
+  <span class="c1">// to retrieve CompilationDatabase and the list of input file paths.</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="creating-and-running-a-clangtool">
+<h3>Creating and running a ClangTool<a class="headerlink" href="#creating-and-running-a-clangtool" title="Permalink to this headline">¶</a></h3>
+<p>Once we have a <tt class="docutils literal"><span class="pre">CompilationDatabase</span></tt>, we can create a <tt class="docutils literal"><span class="pre">ClangTool</span></tt> and run
+our <tt class="docutils literal"><span class="pre">FrontendAction</span></tt> over some code.  For example, to run the
+<tt class="docutils literal"><span class="pre">SyntaxOnlyAction</span></tt> over the files “a.cc” and “b.cc” one would write:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// A clang tool can run over a number of sources in the same process...</span>
+<span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o"><</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">></span> <span class="n">Sources</span><span class="p">;</span>
+<span class="n">Sources</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="s">"a.cc"</span><span class="p">);</span>
+<span class="n">Sources</span><span class="p">.</span><span class="n">push_back</span><span class="p">(</span><span class="s">"b.cc"</span><span class="p">);</span>
+
+<span class="c1">// We hand the CompilationDatabase we created and the sources to run over into</span>
+<span class="c1">// the tool constructor.</span>
+<span class="n">ClangTool</span> <span class="nf">Tool</span><span class="p">(</span><span class="n">OptionsParser</span><span class="p">.</span><span class="n">getCompilations</span><span class="p">(),</span> <span class="n">Sources</span><span class="p">);</span>
+
+<span class="c1">// The ClangTool needs a new FrontendAction for each translation unit we run</span>
+<span class="c1">// on.  Thus, it takes a FrontendActionFactory as parameter.  To create a</span>
+<span class="c1">// FrontendActionFactory from a given FrontendAction type, we call</span>
+<span class="c1">// newFrontendActionFactory<clang::SyntaxOnlyAction>().</span>
+<span class="kt">int</span> <span class="n">result</span> <span class="o">=</span> <span class="n">Tool</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">newFrontendActionFactory</span><span class="o"><</span><span class="n">clang</span><span class="o">::</span><span class="n">SyntaxOnlyAction</span><span class="o">></span><span class="p">().</span><span class="n">get</span><span class="p">());</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="putting-it-together-the-first-tool">
+<h3>Putting it together — the first tool<a class="headerlink" href="#putting-it-together-the-first-tool" title="Permalink to this headline">¶</a></h3>
+<p>Now we combine the two previous steps into our first real tool.  A more advanced
+version of this example tool is also checked into the clang tree at
+<tt class="docutils literal"><span class="pre">tools/clang-check/ClangCheck.cpp</span></tt>.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// Declares clang::SyntaxOnlyAction.</span>
+<span class="cp">#include "clang/Frontend/FrontendActions.h"</span>
+<span class="cp">#include "clang/Tooling/CommonOptionsParser.h"</span>
+<span class="cp">#include "clang/Tooling/Tooling.h"</span>
+<span class="c1">// Declares llvm::cl::extrahelp.</span>
+<span class="cp">#include "llvm/Support/CommandLine.h"</span>
+
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">clang</span><span class="o">::</span><span class="n">tooling</span><span class="p">;</span>
+<span class="k">using</span> <span class="k">namespace</span> <span class="n">llvm</span><span class="p">;</span>
+
+<span class="c1">// Apply a custom category to all command-line options so that they are the</span>
+<span class="c1">// only ones displayed.</span>
+<span class="k">static</span> <span class="n">cl</span><span class="o">::</span><span class="n">OptionCategory</span> <span class="n">MyToolCategory</span><span class="p">(</span><span class="s">"my-tool options"</span><span class="p">);</span>
+
+<span class="c1">// CommonOptionsParser declares HelpMessage with a description of the common</span>
+<span class="c1">// command-line options related to the compilation database and input files.</span>
+<span class="c1">// It's nice to have this help message in all tools.</span>
+<span class="k">static</span> <span class="n">cl</span><span class="o">::</span><span class="n">extrahelp</span> <span class="n">CommonHelp</span><span class="p">(</span><span class="n">CommonOptionsParser</span><span class="o">::</span><span class="n">HelpMessage</span><span class="p">);</span>
+
+<span class="c1">// A help message for this specific tool can be added afterwards.</span>
+<span class="k">static</span> <span class="n">cl</span><span class="o">::</span><span class="n">extrahelp</span> <span class="n">MoreHelp</span><span class="p">(</span><span class="s">"</span><span class="se">\n</span><span class="s">More help text..."</span><span class="p">);</span>
+
+<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">CommonOptionsParser</span> <span class="n">OptionsParser</span><span class="p">(</span><span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">,</span> <span class="n">MyToolCategory</span><span class="p">);</span>
+  <span class="n">ClangTool</span> <span class="n">Tool</span><span class="p">(</span><span class="n">OptionsParser</span><span class="p">.</span><span class="n">getCompilations</span><span class="p">(),</span>
+                 <span class="n">OptionsParser</span><span class="p">.</span><span class="n">getSourcePathList</span><span class="p">());</span>
+  <span class="k">return</span> <span class="n">Tool</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="n">newFrontendActionFactory</span><span class="o"><</span><span class="n">clang</span><span class="o">::</span><span class="n">SyntaxOnlyAction</span><span class="o">></span><span class="p">().</span><span class="n">get</span><span class="p">());</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="running-the-tool-on-some-code">
+<h3>Running the tool on some code<a class="headerlink" href="#running-the-tool-on-some-code" title="Permalink to this headline">¶</a></h3>
+<p>When you check out and build clang, clang-check is already built and available
+to you in bin/clang-check inside your build directory.</p>
+<p>You can run clang-check on a file in the llvm repository by specifying all the
+needed parameters after a “<tt class="docutils literal"><span class="pre">--</span></tt>” separator:</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span><span class="nb">cd</span> /path/to/source/llvm
+<span class="nv">$ </span><span class="nb">export </span><span class="nv">BD</span><span class="o">=</span>/path/to/build/llvm
+<span class="nv">$ $BD</span>/bin/clang-check tools/clang/tools/clang-check/ClangCheck.cpp -- <span class="se">\</span>
+      clang++ -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS <span class="se">\</span>
+      -Itools/clang/include -I<span class="nv">$BD</span>/include -Iinclude <span class="se">\</span>
+      -Itools/clang/lib/Headers -c
+</pre></div>
+</div>
+<p>As an alternative, you can also configure cmake to output a compile command
+database into its build directory:</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="c"># Alternatively to calling cmake, use ccmake, toggle to advanced mode and</span>
+<span class="c"># set the parameter CMAKE_EXPORT_COMPILE_COMMANDS from the UI.</span>
+<span class="nv">$ </span>cmake -DCMAKE_EXPORT_COMPILE_COMMANDS<span class="o">=</span>ON .
+</pre></div>
+</div>
+<p>This creates a file called <tt class="docutils literal"><span class="pre">compile_commands.json</span></tt> in the build directory.
+Now you can run <strong class="program">clang-check</strong> over files in the project by specifying
+the build path as first argument and some source files as further positional
+arguments:</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span><span class="nb">cd</span> /path/to/source/llvm
+<span class="nv">$ </span><span class="nb">export </span><span class="nv">BD</span><span class="o">=</span>/path/to/build/llvm
+<span class="nv">$ $BD</span>/bin/clang-check -p <span class="nv">$BD</span> tools/clang/tools/clang-check/ClangCheck.cpp
+</pre></div>
+</div>
+</div>
+<div class="section" id="builtin-includes">
+<span id="libtooling-builtin-includes"></span><h3>Builtin includes<a class="headerlink" href="#builtin-includes" title="Permalink to this headline">¶</a></h3>
+<p>Clang tools need their builtin headers and search for them the same way Clang
+does.  Thus, the default location to look for builtin headers is in a path
+<tt class="docutils literal"><span class="pre">$(dirname</span> <span class="pre">/path/to/tool)/../lib/clang/3.3/include</span></tt> relative to the tool
+binary.  This works out-of-the-box for tools running from llvm’s toplevel
+binary directory after building clang-headers, or if the tool is running from
+the binary directory of a clang install next to the clang binary.</p>
+<p>Tips: if your tool fails to find <tt class="docutils literal"><span class="pre">stddef.h</span></tt> or similar headers, call the tool
+with <tt class="docutils literal"><span class="pre">-v</span></tt> and look at the search paths it looks through.</p>
+</div>
+<div class="section" id="linking">
+<h3>Linking<a class="headerlink" href="#linking" title="Permalink to this headline">¶</a></h3>
+<p>For a list of libraries to link, look at one of the tools’ Makefiles (for
+example <a class="reference external" href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-check/Makefile?view=markup">clang-check/Makefile</a>).</p>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="IntroductionToTheClangAST.html">Introduction to the Clang AST</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibFormat.html">LibFormat</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/MSVCCompatibility.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/MSVCCompatibility.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/MSVCCompatibility.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/MSVCCompatibility.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,182 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>MSVC compatibility — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Frequently Asked Questions (FAQ)" href="FAQ.html" />
+    <link rel="prev" title="Modules" href="Modules.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>MSVC compatibility</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="Modules.html">Modules</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="FAQ.html">Frequently Asked Questions (FAQ)</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <style type="text/css">
+  .none { background-color: #FFCCCC }
+  .partial { background-color: #FFFF99 }
+  .good { background-color: #CCFF99 }
+</style><div class="section" id="msvc-compatibility">
+<h1>MSVC compatibility<a class="headerlink" href="#msvc-compatibility" title="Permalink to this headline">¶</a></h1>
+<p>When Clang compiles C++ code for Windows, it attempts to be compatible with
+MSVC.  There are multiple dimensions to compatibility.</p>
+<p>First, Clang attempts to be ABI-compatible, meaning that Clang-compiled code
+should be able to link against MSVC-compiled code successfully.  However, C++
+ABIs are particularly large and complicated, and Clang’s support for MSVC’s C++
+ABI is a work in progress.  If you don’t require MSVC ABI compatibility or don’t
+want to use Microsoft’s C and C++ runtimes, the mingw32 toolchain might be a
+better fit for your project.</p>
+<p>Second, Clang implements many MSVC language extensions, such as
+<tt class="docutils literal"><span class="pre">__declspec(dllexport)</span></tt> and a handful of pragmas.  These are typically
+controlled by <tt class="docutils literal"><span class="pre">-fms-extensions</span></tt>.</p>
+<p>Third, MSVC accepts some C++ code that Clang will typically diagnose as
+invalid.  When these constructs are present in widely included system headers,
+Clang attempts to recover and continue compiling the user’s program.  Most
+parsing and semantic compatibility tweaks are controlled by
+<tt class="docutils literal"><span class="pre">-fms-compatibility</span></tt> and <tt class="docutils literal"><span class="pre">-fdelayed-template-parsing</span></tt>, and they are a work
+in progress.</p>
+<p>Finally, there is <a class="reference internal" href="UsersManual.html#clang-cl"><em>clang-cl</em></a>, a driver program for clang that attempts to
+be compatible with MSVC’s cl.exe.</p>
+<div class="section" id="abi-features">
+<h2>ABI features<a class="headerlink" href="#abi-features" title="Permalink to this headline">¶</a></h2>
+<p>The status of major ABI-impacting C++ features:</p>
+<ul class="simple">
+<li>Record layout: <span class="good">Complete</span>.  We’ve tested this with a fuzzer and have
+fixed all known bugs.</li>
+<li>Class inheritance: <span class="good">Mostly complete</span>.  This covers all of the standard
+OO features you would expect: virtual method inheritance, multiple
+inheritance, and virtual inheritance.  Every so often we uncover a bug where
+our tables are incompatible, but this is pretty well in hand.  This feature
+has also been fuzz tested.</li>
+<li>Name mangling: <span class="good">Ongoing</span>.  Every new C++ feature generally needs its own
+mangling.  For example, member pointer template arguments have an interesting
+and distinct mangling.  Fortunately, incorrect manglings usually do not result
+in runtime errors.  Non-inline functions with incorrect manglings usually
+result in link errors, which are relatively easy to diagnose.  Incorrect
+manglings for inline functions and templates result in multiple copies in the
+final image.  The C++ standard requires that those addresses be equal, but few
+programs rely on this.</li>
+<li>Member pointers: <span class="good">Mostly complete</span>.  Standard C++ member pointers are
+fully implemented and should be ABI compatible.  Both <a class="reference external" href="http://msdn.microsoft.com/en-us/library/83cch5a6.aspx">#pragma
+pointers_to_members</a> and the <a class="reference external" href="http://msdn.microsoft.com/en-us/library/yad46a6z.aspx">/vm</a> flags are supported. However, MSVC
+supports an extension to allow creating a <a class="reference external" href="http://llvm.org/PR15713">pointer to a member of a virtual
+base class</a>.  Clang does not yet support this.</li>
+</ul>
+<ul class="simple">
+<li>Debug info: <span class="partial">Minimal</span>.  Clang emits both CodeView line tables
+(similar to what MSVC emits when given the <tt class="docutils literal"><span class="pre">/Z7</span></tt> flag) and DWARF debug
+information into the object file.
+Microsoft’s link.exe will transform the CodeView line tables into a PDB,
+enabling stack traces in all modern Windows debuggers.  Clang does not emit
+any CodeView-compatible type info or description of variable layout.
+Binaries linked with either binutils’ ld or LLVM’s lld should be usable with
+GDB however sophisticated C++ expressions are likely to fail.</li>
+<li>RTTI: <span class="good">Complete</span>.  Generation of RTTI data structures has been
+finished, along with support for the <tt class="docutils literal"><span class="pre">/GR</span></tt> flag.</li>
+<li>Exceptions and SEH: <span class="partial">Minimal</span>.  Clang can parse both constructs, but
+does not know how to emit compatible handlers.  Clang cannot throw exceptions
+but it can rethrow them.</li>
+<li>Thread-safe initialization of local statics: <span class="none">Unstarted</span>.  We are ABI
+compatible with MSVC 2013, which does not support thread-safe local statics.
+MSVC “14” changed the ABI to make initialization of local statics thread safe,
+and we have not yet implemented this.</li>
+<li>Lambdas: <span class="good">Mostly complete</span>.  Clang is compatible with Microsoft’s
+implementation of lambdas except for providing overloads for conversion to
+function pointer for different calling conventions.  However, Microsoft’s
+extension is non-conforming.</li>
+</ul>
+</div>
+<div class="section" id="template-instantiation-and-name-lookup">
+<h2>Template instantiation and name lookup<a class="headerlink" href="#template-instantiation-and-name-lookup" title="Permalink to this headline">¶</a></h2>
+<p>MSVC allows many invalid constructs in class templates that Clang has
+historically rejected.  In order to parse widely distributed headers for
+libraries such as the Active Template Library (ATL) and Windows Runtime Library
+(WRL), some template rules have been relaxed or extended in Clang on Windows.</p>
+<p>The first major semantic difference is that MSVC appears to defer all parsing
+an analysis of inline method bodies in class templates until instantiation
+time.  By default on Windows, Clang attempts to follow suit.  This behavior is
+controlled by the <tt class="docutils literal"><span class="pre">-fdelayed-template-parsing</span></tt> flag.  While Clang delays
+parsing of method bodies, it still parses the bodies <em>before</em> template argument
+substitution, which is not what MSVC does.  The following compatibility tweaks
+are necessary to parse the the template in those cases.</p>
+<p>MSVC allows some name lookup into dependent base classes.  Even on other
+platforms, this has been a <a class="reference external" href="http://clang.llvm.org/compatibility.html#dep_lookup">frequently asked question</a> for Clang users.  A
+dependent base class is a base class that depends on the value of a template
+parameter.  Clang cannot see any of the names inside dependent bases while it
+is parsing your template, so the user is sometimes required to use the
+<tt class="docutils literal"><span class="pre">typename</span></tt> keyword to assist the parser.  On Windows, Clang attempts to
+follow the normal lookup rules, but if lookup fails, it will assume that the
+user intended to find the name in a dependent base.  While parsing the
+following program, Clang will recover as if the user had written the
+commented-out code:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">typename</span> <span class="n">T</span><span class="o">></span>
+<span class="k">struct</span> <span class="n">Foo</span> <span class="o">:</span> <span class="n">T</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">f</span><span class="p">()</span> <span class="p">{</span>
+    <span class="cm">/*typename*/</span> <span class="n">T</span><span class="o">::</span><span class="n">UnknownType</span> <span class="n">x</span> <span class="o">=</span>  <span class="cm">/*this->*/</span><span class="n">unknownMember</span><span class="p">;</span>
+  <span class="p">}</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>After recovery, Clang warns the user that this code is non-standard and issues
+a hint suggesting how to fix the problem.</p>
+<p>As of this writing, Clang is able to compile a simple ATL hello world
+application.  There are still issues parsing WRL headers for modern Windows 8
+apps, but they should be addressed soon.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="Modules.html">Modules</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="FAQ.html">Frequently Asked Questions (FAQ)</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/MemorySanitizer.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/MemorySanitizer.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/MemorySanitizer.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/MemorySanitizer.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,285 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>MemorySanitizer — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="DataFlowSanitizer" href="DataFlowSanitizer.html" />
+    <link rel="prev" title="ThreadSanitizer" href="ThreadSanitizer.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>MemorySanitizer</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="ThreadSanitizer.html">ThreadSanitizer</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="DataFlowSanitizer.html">DataFlowSanitizer</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="memorysanitizer">
+<h1>MemorySanitizer<a class="headerlink" href="#memorysanitizer" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
+<li><a class="reference internal" href="#how-to-build" id="id2">How to build</a></li>
+<li><a class="reference internal" href="#usage" id="id3">Usage</a><ul>
+<li><a class="reference internal" href="#has-feature-memory-sanitizer" id="id4"><tt class="docutils literal"><span class="pre">__has_feature(memory_sanitizer)</span></tt></a></li>
+<li><a class="reference internal" href="#attribute-no-sanitize-memory" id="id5"><tt class="docutils literal"><span class="pre">__attribute__((no_sanitize_memory))</span></tt></a></li>
+<li><a class="reference internal" href="#blacklist" id="id6">Blacklist</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#report-symbolization" id="id7">Report symbolization</a></li>
+<li><a class="reference internal" href="#origin-tracking" id="id8">Origin Tracking</a></li>
+<li><a class="reference internal" href="#handling-external-code" id="id9">Handling external code</a></li>
+<li><a class="reference internal" href="#supported-platforms" id="id10">Supported Platforms</a></li>
+<li><a class="reference internal" href="#limitations" id="id11">Limitations</a></li>
+<li><a class="reference internal" href="#current-status" id="id12">Current Status</a></li>
+<li><a class="reference internal" href="#more-information" id="id13">More Information</a></li>
+</ul>
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>MemorySanitizer is a detector of uninitialized reads. It consists of a
+compiler instrumentation module and a run-time library.</p>
+<p>Typical slowdown introduced by MemorySanitizer is <strong>3x</strong>.</p>
+</div>
+<div class="section" id="how-to-build">
+<h2><a class="toc-backref" href="#id2">How to build</a><a class="headerlink" href="#how-to-build" title="Permalink to this headline">¶</a></h2>
+<p>Follow the <a class="reference external" href="../get_started.html">clang build instructions</a>. CMake
+build is supported.</p>
+</div>
+<div class="section" id="usage">
+<h2><a class="toc-backref" href="#id3">Usage</a><a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
+<p>Simply compile and link your program with <tt class="docutils literal"><span class="pre">-fsanitize=memory</span></tt> flag.
+The MemorySanitizer run-time library should be linked to the final
+executable, so make sure to use <tt class="docutils literal"><span class="pre">clang</span></tt> (not <tt class="docutils literal"><span class="pre">ld</span></tt>) for the final
+link step. When linking shared libraries, the MemorySanitizer run-time
+is not linked, so <tt class="docutils literal"><span class="pre">-Wl,-z,defs</span></tt> may cause link errors (don’t use it
+with MemorySanitizer). To get a reasonable performance add <tt class="docutils literal"><span class="pre">-O1</span></tt> or
+higher. To get meaninful stack traces in error messages add
+<tt class="docutils literal"><span class="pre">-fno-omit-frame-pointer</span></tt>. To get perfect stack traces you may need
+to disable inlining (just use <tt class="docutils literal"><span class="pre">-O1</span></tt>) and tail call elimination
+(<tt class="docutils literal"><span class="pre">-fno-optimize-sibling-calls</span></tt>).</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">%</span> cat umr.cc
+<span class="gp">#</span>include <stdio.h>
+
+<span class="go">int main(int argc, char** argv) {</span>
+<span class="go">  int* a = new int[10];</span>
+<span class="go">  a[5] = 0;</span>
+<span class="go">  if (a[argc])</span>
+<span class="go">    printf("xx\n");</span>
+<span class="go">  return 0;</span>
+<span class="go">}</span>
+
+<span class="gp">%</span> clang -fsanitize<span class="o">=</span>memory -fno-omit-frame-pointer -g -O2 umr.cc
+</pre></div>
+</div>
+<p>If a bug is detected, the program will print an error message to
+stderr and exit with a non-zero exit code. Currently, MemorySanitizer
+does not symbolize its output by default, so you may need to use a
+separate script to symbolize the result offline (this will be fixed in
+future).</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">%</span> ./a.out
+<span class="go">WARNING: MemorySanitizer: use-of-uninitialized-value</span>
+<span class="go">    #0 0x7f45944b418a in main umr.cc:6</span>
+<span class="go">    #1 0x7f45938b676c in __libc_start_main libc-start.c:226</span>
+</pre></div>
+</div>
+<p>By default, MemorySanitizer exits on the first detected error.</p>
+<div class="section" id="has-feature-memory-sanitizer">
+<h3><a class="toc-backref" href="#id4"><tt class="docutils literal"><span class="pre">__has_feature(memory_sanitizer)</span></tt></a><a class="headerlink" href="#has-feature-memory-sanitizer" title="Permalink to this headline">¶</a></h3>
+<p>In some cases one may need to execute different code depending on
+whether MemorySanitizer is enabled. <a class="reference internal" href="LanguageExtensions.html#langext-has-feature-has-extension"><em>__has_feature</em></a> can be used for this purpose.</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cp">#if defined(__has_feature)</span>
+<span class="cp">#  if __has_feature(memory_sanitizer)</span>
+<span class="c1">// code that builds only under MemorySanitizer</span>
+<span class="cp">#  endif</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="attribute-no-sanitize-memory">
+<h3><a class="toc-backref" href="#id5"><tt class="docutils literal"><span class="pre">__attribute__((no_sanitize_memory))</span></tt></a><a class="headerlink" href="#attribute-no-sanitize-memory" title="Permalink to this headline">¶</a></h3>
+<p>Some code should not be checked by MemorySanitizer.
+One may use the function attribute
+<a class="reference internal" href="AttributeReference.html#langext-memory-sanitizer"><em>no_sanitize_memory</em></a>
+to disable uninitialized checks in a particular function.
+MemorySanitizer may still instrument such functions to avoid false positives.
+This attribute may not be
+supported by other compilers, so we suggest to use it together with
+<tt class="docutils literal"><span class="pre">__has_feature(memory_sanitizer)</span></tt>.</p>
+</div>
+<div class="section" id="blacklist">
+<h3><a class="toc-backref" href="#id6">Blacklist</a><a class="headerlink" href="#blacklist" title="Permalink to this headline">¶</a></h3>
+<p>MemorySanitizer supports <tt class="docutils literal"><span class="pre">src</span></tt> and <tt class="docutils literal"><span class="pre">fun</span></tt> entity types in
+<a class="reference internal" href="SanitizerSpecialCaseList.html"><em>Sanitizer special case list</em></a>, that can be used to relax MemorySanitizer
+checks for certain source files and functions. All “Use of uninitialized value”
+warnings will be suppressed and all values loaded from memory will be
+considered fully initialized.</p>
+</div>
+</div>
+<div class="section" id="report-symbolization">
+<h2><a class="toc-backref" href="#id7">Report symbolization</a><a class="headerlink" href="#report-symbolization" title="Permalink to this headline">¶</a></h2>
+<p>MemorySanitizer uses an external symbolizer to print files and line numbers in
+reports. Make sure that <tt class="docutils literal"><span class="pre">llvm-symbolizer</span></tt> binary is in <tt class="docutils literal"><span class="pre">PATH</span></tt>,
+or set environment variable <tt class="docutils literal"><span class="pre">MSAN_SYMBOLIZER_PATH</span></tt> to point to it.</p>
+</div>
+<div class="section" id="origin-tracking">
+<h2><a class="toc-backref" href="#id8">Origin Tracking</a><a class="headerlink" href="#origin-tracking" title="Permalink to this headline">¶</a></h2>
+<p>MemorySanitizer can track origins of unitialized values, similar to
+Valgrind’s –track-origins option. This feature is enabled by
+<tt class="docutils literal"><span class="pre">-fsanitize-memory-track-origins</span></tt> Clang option. With the code from
+the example above,</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">%</span> clang -fsanitize<span class="o">=</span>memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O2 umr.cc
+<span class="gp">%</span> ./a.out
+<span class="go">WARNING: MemorySanitizer: use-of-uninitialized-value</span>
+<span class="go">    #0 0x7f7893912f0b in main umr2.cc:6</span>
+<span class="go">    #1 0x7f789249b76c in __libc_start_main libc-start.c:226</span>
+
+<span class="go">  Uninitialized value was created by a heap allocation</span>
+<span class="go">    #0 0x7f7893901cbd in operator new[](unsigned long) msan_new_delete.cc:44</span>
+<span class="go">    #1 0x7f7893912e06 in main umr2.cc:4</span>
+</pre></div>
+</div>
+<p>Origin tracking has proved to be very useful for debugging MemorySanitizer
+reports. It slows down program execution by a factor of 1.5x-2x on top
+of the usual MemorySanitizer slowdown.</p>
+<p>MemorySanitizer can provide even more information with
+<tt class="docutils literal"><span class="pre">-fsanitize-memory-track-origins=2</span></tt> flag. In this mode reports
+include information about intermediate stores the uninitialized value went
+through.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">%</span> cat umr2.cc
+<span class="gp">#</span>include <stdio.h>
+
+<span class="go">int main(int argc, char** argv) {</span>
+<span class="go">  int* a = new int[10];</span>
+<span class="go">  a[5] = 0;</span>
+<span class="go">  volatile int b = a[argc];</span>
+<span class="go">  if (b)</span>
+<span class="go">    printf("xx\n");</span>
+<span class="go">  return 0;</span>
+<span class="go">}</span>
+
+<span class="gp">%</span> clang -fsanitize<span class="o">=</span>memory -fsanitize-memory-track-origins<span class="o">=</span>2 -fno-omit-frame-pointer -g -O2 umr2.cc
+<span class="gp">%</span> ./a.out
+<span class="go">WARNING: MemorySanitizer: use-of-uninitialized-value</span>
+<span class="go">    #0 0x7f7893912f0b in main umr2.cc:7</span>
+<span class="go">    #1 0x7f789249b76c in __libc_start_main libc-start.c:226</span>
+
+<span class="go">  Uninitialized value was stored to memory at</span>
+<span class="go">    #0 0x7f78938b5c25 in __msan_chain_origin msan.cc:484</span>
+<span class="go">    #1 0x7f7893912ecd in main umr2.cc:6</span>
+
+<span class="go">  Uninitialized value was created by a heap allocation</span>
+<span class="go">    #0 0x7f7893901cbd in operator new[](unsigned long) msan_new_delete.cc:44</span>
+<span class="go">    #1 0x7f7893912e06 in main umr2.cc:4</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="handling-external-code">
+<h2><a class="toc-backref" href="#id9">Handling external code</a><a class="headerlink" href="#handling-external-code" title="Permalink to this headline">¶</a></h2>
+<p>MemorySanitizer requires that all program code is instrumented. This
+also includes any libraries that the program depends on, even libc.
+Failing to achieve this may result in false reports.</p>
+<p>Full MemorySanitizer instrumentation is very difficult to achieve. To
+make it easier, MemorySanitizer runtime library includes 70+
+interceptors for the most common libc functions. They make it possible
+to run MemorySanitizer-instrumented programs linked with
+uninstrumented libc. For example, the authors were able to bootstrap
+MemorySanitizer-instrumented Clang compiler by linking it with
+self-built instrumented libcxx (as a replacement for libstdc++).</p>
+<p>In the case when rebuilding all program dependencies with
+MemorySanitizer is problematic, an experimental MSanDR tool can be
+used. It is a DynamoRio-based tool that uses dynamic instrumentation
+to avoid false positives due to uninstrumented code. The tool simply
+marks memory from instrumented libraries as fully initialized. See
+<cite>http://code.google.com/p/memory-sanitizer/wiki/Running#Running_with_the_dynamic_tool</cite>
+for more information.</p>
+</div>
+<div class="section" id="supported-platforms">
+<h2><a class="toc-backref" href="#id10">Supported Platforms</a><a class="headerlink" href="#supported-platforms" title="Permalink to this headline">¶</a></h2>
+<p>MemorySanitizer is supported on</p>
+<ul class="simple">
+<li>Linux x86_64 (tested on Ubuntu 12.04);</li>
+</ul>
+</div>
+<div class="section" id="limitations">
+<h2><a class="toc-backref" href="#id11">Limitations</a><a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h2>
+<ul class="simple">
+<li>MemorySanitizer uses 2x more real memory than a native run, 3x with
+origin tracking.</li>
+<li>MemorySanitizer maps (but not reserves) 64 Terabytes of virtual
+address space. This means that tools like <tt class="docutils literal"><span class="pre">ulimit</span></tt> may not work as
+usually expected.</li>
+<li>Static linking is not supported.</li>
+<li>Non-position-independent executables are not supported.  Therefore, the
+<tt class="docutils literal"><span class="pre">fsanitize=memory</span></tt> flag will cause Clang to act as though the <tt class="docutils literal"><span class="pre">-fPIE</span></tt>
+flag had been supplied if compiling without <tt class="docutils literal"><span class="pre">-fPIC</span></tt>, and as though the
+<tt class="docutils literal"><span class="pre">-pie</span></tt> flag had been supplied if linking an executable.</li>
+<li>Depending on the version of Linux kernel, running without ASLR may
+be not supported. Note that GDB disables ASLR by default. To debug
+instrumented programs, use “set disable-randomization off”.</li>
+</ul>
+</div>
+<div class="section" id="current-status">
+<h2><a class="toc-backref" href="#id12">Current Status</a><a class="headerlink" href="#current-status" title="Permalink to this headline">¶</a></h2>
+<p>MemorySanitizer is an experimental tool. It is known to work on large
+real-world programs, like Clang/LLVM itself.</p>
+</div>
+<div class="section" id="more-information">
+<h2><a class="toc-backref" href="#id13">More Information</a><a class="headerlink" href="#more-information" title="Permalink to this headline">¶</a></h2>
+<p><a class="reference external" href="http://code.google.com/p/memory-sanitizer/">http://code.google.com/p/memory-sanitizer</a></p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="ThreadSanitizer.html">ThreadSanitizer</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="DataFlowSanitizer.html">DataFlowSanitizer</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/Modules.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/Modules.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/Modules.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/Modules.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,880 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Modules — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="MSVC compatibility" href="MSVCCompatibility.html" />
+    <link rel="prev" title="Sanitizer special case list" href="SanitizerSpecialCaseList.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Modules</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="SanitizerSpecialCaseList.html">Sanitizer special case list</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="MSVCCompatibility.html">MSVC compatibility</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="modules">
+<h1>Modules<a class="headerlink" href="#modules" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id9">Introduction</a><ul>
+<li><a class="reference internal" href="#problems-with-the-current-model" id="id10">Problems with the current model</a></li>
+<li><a class="reference internal" href="#semantic-import" id="id11">Semantic import</a></li>
+<li><a class="reference internal" href="#problems-modules-do-not-solve" id="id12">Problems modules do not solve</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#using-modules" id="id13">Using Modules</a><ul>
+<li><a class="reference internal" href="#objective-c-import-declaration" id="id14">Objective-C Import declaration</a></li>
+<li><a class="reference internal" href="#includes-as-imports" id="id15">Includes as imports</a></li>
+<li><a class="reference internal" href="#module-maps" id="id16">Module maps</a></li>
+<li><a class="reference internal" href="#compilation-model" id="id17">Compilation model</a></li>
+<li><a class="reference internal" href="#command-line-parameters" id="id18">Command-line parameters</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#module-semantics" id="id19">Module Semantics</a><ul>
+<li><a class="reference internal" href="#macros" id="id20">Macros</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#module-map-language" id="id21">Module Map Language</a><ul>
+<li><a class="reference internal" href="#lexical-structure" id="id22">Lexical structure</a></li>
+<li><a class="reference internal" href="#module-map-file" id="id23">Module map file</a></li>
+<li><a class="reference internal" href="#module-declaration" id="id24">Module declaration</a><ul>
+<li><a class="reference internal" href="#requires-declaration" id="id25">Requires declaration</a></li>
+<li><a class="reference internal" href="#header-declaration" id="id26">Header declaration</a></li>
+<li><a class="reference internal" href="#umbrella-directory-declaration" id="id27">Umbrella directory declaration</a></li>
+<li><a class="reference internal" href="#submodule-declaration" id="id28">Submodule declaration</a></li>
+<li><a class="reference internal" href="#export-declaration" id="id29">Export declaration</a></li>
+<li><a class="reference internal" href="#use-declaration" id="id30">Use declaration</a></li>
+<li><a class="reference internal" href="#link-declaration" id="id31">Link declaration</a></li>
+<li><a class="reference internal" href="#configuration-macros-declaration" id="id32">Configuration macros declaration</a></li>
+<li><a class="reference internal" href="#conflict-declarations" id="id33">Conflict declarations</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#attributes" id="id34">Attributes</a></li>
+<li><a class="reference internal" href="#private-module-map-files" id="id35">Private Module Map Files</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#modularizing-a-platform" id="id36">Modularizing a Platform</a></li>
+<li><a class="reference internal" href="#future-directions" id="id37">Future Directions</a></li>
+<li><a class="reference internal" href="#where-to-learn-more-about-modules" id="id38">Where To Learn More About Modules</a></li>
+</ul>
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id9">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>Most software is built using a number of software libraries, including libraries supplied by the platform, internal libraries built as part of the software itself to provide structure, and third-party libraries. For each library, one needs to access both its interface (API) and its implementation. In the C family of languages, the interface to a library is accessed by including the appropriate header files(s):</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include <SomeLib.h></span>
+</pre></div>
+</div>
+<p>The implementation is handled separately by linking against the appropriate library. For example, by passing <tt class="docutils literal"><span class="pre">-lSomeLib</span></tt> to the linker.</p>
+<p>Modules provide an alternative, simpler way to use software libraries that provides better compile-time scalability and eliminates many of the problems inherent to using the C preprocessor to access the API of a library.</p>
+<div class="section" id="problems-with-the-current-model">
+<h3><a class="toc-backref" href="#id10">Problems with the current model</a><a class="headerlink" href="#problems-with-the-current-model" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">#include</span></tt> mechanism provided by the C preprocessor is a very poor way to access the API of a library, for a number of reasons:</p>
+<ul class="simple">
+<li><strong>Compile-time scalability</strong>: Each time a header is included, the
+compiler must preprocess and parse the text in that header and every
+header it includes, transitively. This process must be repeated for
+every translation unit in the application, which involves a huge
+amount of redundant work. In a project with <em>N</em> translation units
+and <em>M</em> headers included in each translation unit, the compiler is
+performing <em>M x N</em> work even though most of the <em>M</em> headers are
+shared among multiple translation units. C++ is particularly bad,
+because the compilation model for templates forces a huge amount of
+code into headers.</li>
+<li><strong>Fragility</strong>: <tt class="docutils literal"><span class="pre">#include</span></tt> directives are treated as textual
+inclusion by the preprocessor, and are therefore subject to any
+active macro definitions at the time of inclusion. If any of the
+active macro definitions happens to collide with a name in the
+library, it can break the library API or cause compilation failures
+in the library header itself. For an extreme example,
+<tt class="docutils literal"><span class="pre">#define</span> <span class="pre">std</span> <span class="pre">"The</span> <span class="pre">C++</span> <span class="pre">Standard"</span></tt> and then include a standard
+library header: the result is a horrific cascade of failures in the
+C++ Standard Library’s implementation. More subtle real-world
+problems occur when the headers for two different libraries interact
+due to macro collisions, and users are forced to reorder
+<tt class="docutils literal"><span class="pre">#include</span></tt> directives or introduce <tt class="docutils literal"><span class="pre">#undef</span></tt> directives to break
+the (unintended) dependency.</li>
+<li><strong>Conventional workarounds</strong>: C programmers have
+adopted a number of conventions to work around the fragility of the
+C preprocessor model. Include guards, for example, are required for
+the vast majority of headers to ensure that multiple inclusion
+doesn’t break the compile. Macro names are written with
+<tt class="docutils literal"><span class="pre">LONG_PREFIXED_UPPERCASE_IDENTIFIERS</span></tt> to avoid collisions, and some
+library/framework developers even use <tt class="docutils literal"><span class="pre">__underscored</span></tt> names
+in headers to avoid collisions with “normal” names that (by
+convention) shouldn’t even be macros. These conventions are a
+barrier to entry for developers coming from non-C languages, are
+boilerplate for more experienced developers, and make our headers
+far uglier than they should be.</li>
+<li><strong>Tool confusion</strong>: In a C-based language, it is hard to build tools
+that work well with software libraries, because the boundaries of
+the libraries are not clear. Which headers belong to a particular
+library, and in what order should those headers be included to
+guarantee that they compile correctly? Are the headers C, C++,
+Objective-C++, or one of the variants of these languages? What
+declarations in those headers are actually meant to be part of the
+API, and what declarations are present only because they had to be
+written as part of the header file?</li>
+</ul>
+</div>
+<div class="section" id="semantic-import">
+<h3><a class="toc-backref" href="#id11">Semantic import</a><a class="headerlink" href="#semantic-import" title="Permalink to this headline">¶</a></h3>
+<p>Modules improve access to the API of software libraries by replacing the textual preprocessor inclusion model with a more robust, more efficient semantic model. From the user’s perspective, the code looks only slightly different, because one uses an <tt class="docutils literal"><span class="pre">import</span></tt> declaration rather than a <tt class="docutils literal"><span class="pre">#include</span></tt> preprocessor directive:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="n">import</span> <span class="n">std</span><span class="p">.</span><span class="n">io</span><span class="p">;</span> <span class="c1">// pseudo-code; see below for syntax discussion</span>
+</pre></div>
+</div>
+<p>However, this module import behaves quite differently from the corresponding <tt class="docutils literal"><span class="pre">#include</span> <span class="pre"><stdio.h></span></tt>: when the compiler sees the module import above, it loads a binary representation of the <tt class="docutils literal"><span class="pre">std.io</span></tt> module and makes its API available to the application directly. Preprocessor definitions that precede the import declaration have no impact on the API provided by <tt class="docutils literal"><span class="pre">std.io</span></tt>, because the module itself was compiled as a separate, standalone module. Additionally, any linker flags required to use the <tt class="docutils literal"><span class="pre">std.io</span></tt> module will automatically be provided when the module is imported <a class="footnote-reference" href="#id5" id="id1">[1]</a>
+This semantic import model addresses many of the problems of the preprocessor inclusion model:</p>
+<ul class="simple">
+<li><strong>Compile-time scalability</strong>: The <tt class="docutils literal"><span class="pre">std.io</span></tt> module is only compiled once, and importing the module into a translation unit is a constant-time operation (independent of module system). Thus, the API of each software library is only parsed once, reducing the <em>M x N</em> compilation problem to an <em>M + N</em> problem.</li>
+<li><strong>Fragility</strong>: Each module is parsed as a standalone entity, so it has a consistent preprocessor environment. This completely eliminates the need for <tt class="docutils literal"><span class="pre">__underscored</span></tt> names and similarly defensive tricks. Moreover, the current preprocessor definitions when an import declaration is encountered are ignored, so one software library can not affect how another software library is compiled, eliminating include-order dependencies.</li>
+<li><strong>Tool confusion</strong>: Modules describe the API of software libraries, and tools can reason about and present a module as a representation of that API. Because modules can only be built standalone, tools can rely on the module definition to ensure that they get the complete API for the library. Moreover, modules can specify which languages they work with, so, e.g., one can not accidentally attempt to load a C++ module into a C program.</li>
+</ul>
+</div>
+<div class="section" id="problems-modules-do-not-solve">
+<h3><a class="toc-backref" href="#id12">Problems modules do not solve</a><a class="headerlink" href="#problems-modules-do-not-solve" title="Permalink to this headline">¶</a></h3>
+<p>Many programming languages have a module or package system, and because of the variety of features provided by these languages it is important to define what modules do <em>not</em> do. In particular, all of the following are considered out-of-scope for modules:</p>
+<ul class="simple">
+<li><strong>Rewrite the world’s code</strong>: It is not realistic to require applications or software libraries to make drastic or non-backward-compatible changes, nor is it feasible to completely eliminate headers. Modules must interoperate with existing software libraries and allow a gradual transition.</li>
+<li><strong>Versioning</strong>: Modules have no notion of version information. Programmers must still rely on the existing versioning mechanisms of the underlying language (if any exist) to version software libraries.</li>
+<li><strong>Namespaces</strong>: Unlike in some languages, modules do not imply any notion of namespaces. Thus, a struct declared in one module will still conflict with a struct of the same name declared in a different module, just as they would if declared in two different headers. This aspect is important for backward compatibility, because (for example) the mangled names of entities in software libraries must not change when introducing modules.</li>
+<li><strong>Binary distribution of modules</strong>: Headers (particularly C++ headers) expose the full complexity of the language. Maintaining a stable binary module format across architectures, compiler versions, and compiler vendors is technically infeasible.</li>
+</ul>
+</div>
+</div>
+<div class="section" id="using-modules">
+<h2><a class="toc-backref" href="#id13">Using Modules</a><a class="headerlink" href="#using-modules" title="Permalink to this headline">¶</a></h2>
+<p>To enable modules, pass the command-line flag <tt class="docutils literal"><span class="pre">-fmodules</span></tt>. This will make any modules-enabled software libraries available as modules as well as introducing any modules-specific syntax. Additional <a class="reference internal" href="#command-line-parameters">command-line parameters</a> are described in a separate section later.</p>
+<div class="section" id="objective-c-import-declaration">
+<h3><a class="toc-backref" href="#id14">Objective-C Import declaration</a><a class="headerlink" href="#objective-c-import-declaration" title="Permalink to this headline">¶</a></h3>
+<p>Objective-C provides syntax for importing a module via an <em>@import declaration</em>, which imports the named module:</p>
+<div class="highlight-python"><div class="highlight"><pre>@import std;
+</pre></div>
+</div>
+<p>The <tt class="docutils literal"><span class="pre">@import</span></tt> declaration above imports the entire contents of the <tt class="docutils literal"><span class="pre">std</span></tt> module (which would contain, e.g., the entire C or C++ standard library) and make its API available within the current translation unit. To import only part of a module, one may use dot syntax to specific a particular submodule, e.g.,</p>
+<div class="highlight-python"><div class="highlight"><pre>@import std.io;
+</pre></div>
+</div>
+<p>Redundant import declarations are ignored, and one is free to import modules at any point within the translation unit, so long as the import declaration is at global scope.</p>
+<p>At present, there is no C or C++ syntax for import declarations. Clang
+will track the modules proposal in the C++ committee. See the section
+<a class="reference internal" href="#includes-as-imports">Includes as imports</a> to see how modules get imported today.</p>
+</div>
+<div class="section" id="includes-as-imports">
+<h3><a class="toc-backref" href="#id15">Includes as imports</a><a class="headerlink" href="#includes-as-imports" title="Permalink to this headline">¶</a></h3>
+<p>The primary user-level feature of modules is the import operation, which provides access to the API of software libraries. However, today’s programs make extensive use of <tt class="docutils literal"><span class="pre">#include</span></tt>, and it is unrealistic to assume that all of this code will change overnight. Instead, modules automatically translate <tt class="docutils literal"><span class="pre">#include</span></tt> directives into the corresponding module import. For example, the include directive</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include <stdio.h></span>
+</pre></div>
+</div>
+<p>will be automatically mapped to an import of the module <tt class="docutils literal"><span class="pre">std.io</span></tt>. Even with specific <tt class="docutils literal"><span class="pre">import</span></tt> syntax in the language, this particular feature is important for both adoption and backward compatibility: automatic translation of <tt class="docutils literal"><span class="pre">#include</span></tt> to <tt class="docutils literal"><span class="pre">import</span></tt> allows an application to get the benefits of modules (for all modules-enabled libraries) without any changes to the application itself. Thus, users can easily use modules with one compiler while falling back to the preprocessor-inclusion mechanism with other compilers.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">The automatic mapping of <tt class="docutils literal"><span class="pre">#include</span></tt> to <tt class="docutils literal"><span class="pre">import</span></tt> also solves an implementation problem: importing a module with a definition of some entity (say, a <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">Point</span></tt>) and then parsing a header containing another definition of <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">Point</span></tt> would cause a redefinition error, even if it is the same <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">Point</span></tt>. By mapping <tt class="docutils literal"><span class="pre">#include</span></tt> to <tt class="docutils literal"><span class="pre">import</span></tt>, the compiler can guarantee that it always sees just the already-parsed definition from the module.</p>
+</div>
+<p>While building a module, <tt class="docutils literal"><span class="pre">#include_next</span></tt> is also supported, with one caveat.
+The usual behavior of <tt class="docutils literal"><span class="pre">#include_next</span></tt> is to search for the specified filename
+in the list of include paths, starting from the path <em>after</em> the one
+in which the current file was found.
+Because files listed in module maps are not found through include paths, a
+different strategy is used for <tt class="docutils literal"><span class="pre">#include_next</span></tt> directives in such files: the
+list of include paths is searched for the specified header name, to find the
+first include path that would refer to the current file. <tt class="docutils literal"><span class="pre">#include_next</span></tt> is
+interpreted as if the current file had been found in that path.
+If this search finds a file named by a module map, the <tt class="docutils literal"><span class="pre">#include_next</span></tt>
+directive is translated into an import, just like for a <tt class="docutils literal"><span class="pre">#include</span></tt>
+directive.``</p>
+</div>
+<div class="section" id="module-maps">
+<h3><a class="toc-backref" href="#id16">Module maps</a><a class="headerlink" href="#module-maps" title="Permalink to this headline">¶</a></h3>
+<p>The crucial link between modules and headers is described by a <em>module map</em>, which describes how a collection of existing headers maps on to the (logical) structure of a module. For example, one could imagine a module <tt class="docutils literal"><span class="pre">std</span></tt> covering the C standard library. Each of the C standard library headers (<tt class="docutils literal"><span class="pre"><stdio.h></span></tt>, <tt class="docutils literal"><span class="pre"><stdlib.h></span></tt>, <tt class="docutils literal"><span class="pre"><math.h></span></tt>, etc.) would contribute to the <tt class="docutils literal"><span class="pre">std</span></tt> module, by placing their respective APIs into the corresponding submodule (<tt class="docutils literal"><span class="pre">std.io</span></tt>, <tt class="docutils literal"><span class="pre">std.lib</span></tt>, <tt class="docutils literal"><span class="pre">std.math</span></tt>, etc.). Having a list of the heade
 rs that are part of the <tt class="docutils literal"><span class="pre">std</span></tt> module allows the compiler to build the <tt class="docutils literal"><span class="pre">std</span></tt> module as a standalone entity, and having the mapping from header names to (sub)modules allows the automatic translation of <tt class="docutils literal"><span class="pre">#include</span></tt> directives to module imports.</p>
+<p>Module maps are specified as separate files (each named <tt class="docutils literal"><span class="pre">module.modulemap</span></tt>) alongside the headers they describe, which allows them to be added to existing software libraries without having to change the library headers themselves (in most cases <a class="footnote-reference" href="#id6" id="id2">[2]</a>). The actual <a class="reference internal" href="#module-map-language">Module map language</a> is described in a later section.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">To actually see any benefits from modules, one first has to introduce module maps for the underlying C standard library and the libraries and headers on which it depends. The section <a class="reference internal" href="#modularizing-a-platform">Modularizing a Platform</a> describes the steps one must take to write these module maps.</p>
+</div>
+<p>One can use module maps without modules to check the integrity of the use of header files. To do this, use the <tt class="docutils literal"><span class="pre">-fmodule-maps</span></tt> option instead of the <tt class="docutils literal"><span class="pre">-fmodules</span></tt> option.</p>
+</div>
+<div class="section" id="compilation-model">
+<h3><a class="toc-backref" href="#id17">Compilation model</a><a class="headerlink" href="#compilation-model" title="Permalink to this headline">¶</a></h3>
+<p>The binary representation of modules is automatically generated by the compiler on an as-needed basis. When a module is imported (e.g., by an <tt class="docutils literal"><span class="pre">#include</span></tt> of one of the module’s headers), the compiler will spawn a second instance of itself <a class="footnote-reference" href="#id7" id="id3">[3]</a>, with a fresh preprocessing context <a class="footnote-reference" href="#id8" id="id4">[4]</a>, to parse just the headers in that module. The resulting Abstract Syntax Tree (AST) is then persisted into the binary representation of the module that is then loaded into translation unit where the module import was encountered.</p>
+<p>The binary representation of modules is persisted in the <em>module cache</em>. Imports of a module will first query the module cache and, if a binary representation of the required module is already available, will load that representation directly. Thus, a module’s headers will only be parsed once per language configuration, rather than once per translation unit that uses the module.</p>
+<p>Modules maintain references to each of the headers that were part of the module build. If any of those headers changes, or if any of the modules on which a module depends change, then the module will be (automatically) recompiled. The process should never require any user intervention.</p>
+</div>
+<div class="section" id="command-line-parameters">
+<h3><a class="toc-backref" href="#id18">Command-line parameters</a><a class="headerlink" href="#command-line-parameters" title="Permalink to this headline">¶</a></h3>
+<dl class="docutils">
+<dt><tt class="docutils literal"><span class="pre">-fmodules</span></tt></dt>
+<dd>Enable the modules feature.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodule-maps</span></tt></dt>
+<dd>Enable interpretation of module maps. This option is implied by <tt class="docutils literal"><span class="pre">-fmodules</span></tt>.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodules-cache-path=<directory></span></tt></dt>
+<dd>Specify the path to the modules cache. If not provided, Clang will select a system-appropriate default.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fno-autolink</span></tt></dt>
+<dd>Disable automatic linking against the libraries associated with imported modules.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodules-ignore-macro=macroname</span></tt></dt>
+<dd>Instruct modules to ignore the named macro when selecting an appropriate module variant. Use this for macros defined on the command line that don’t affect how modules are built, to improve sharing of compiled module files.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodules-prune-interval=seconds</span></tt></dt>
+<dd>Specify the minimum delay (in seconds) between attempts to prune the module cache. Module cache pruning attempts to clear out old, unused module files so that the module cache itself does not grow without bound. The default delay is large (604,800 seconds, or 7 days) because this is an expensive operation. Set this value to 0 to turn off pruning.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodules-prune-after=seconds</span></tt></dt>
+<dd>Specify the minimum time (in seconds) for which a file in the module cache must be unused (according to access time) before module pruning will remove it. The default delay is large (2,678,400 seconds, or 31 days) to avoid excessive module rebuilding.</dd>
+<dt><tt class="docutils literal"><span class="pre">-module-file-info</span> <span class="pre"><module</span> <span class="pre">file</span> <span class="pre">name></span></tt></dt>
+<dd>Debugging aid that prints information about a given module file (with a <tt class="docutils literal"><span class="pre">.pcm</span></tt> extension), including the language and preprocessor options that particular module variant was built with.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodules-decluse</span></tt></dt>
+<dd>Enable checking of module <tt class="docutils literal"><span class="pre">use</span></tt> declarations.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodule-name=module-id</span></tt></dt>
+<dd>Consider a source file as a part of the given module.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodule-map-file=<file></span></tt></dt>
+<dd>Load the given module map file if a header from its directory or one of its subdirectories is loaded.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fmodules-search-all</span></tt></dt>
+<dd>If a symbol is not found, search modules referenced in the current module maps but not imported for symbols, so the error message can reference the module by name.  Note that if the global module index has not been built before, this might take some time as it needs to build all the modules.  Note that this option doesn’t apply in module builds, to avoid the recursion.</dd>
+<dt><tt class="docutils literal"><span class="pre">-fno-modules-implicit-maps</span></tt></dt>
+<dd>Suppresses the implicit search for files called <tt class="docutils literal"><span class="pre">module.modulemap</span></tt> and similar. Instead, module files need to be explicitly specified via <tt class="docutils literal"><span class="pre">-fmodule-map-file</span></tt> or transitively used.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="module-semantics">
+<h2><a class="toc-backref" href="#id19">Module Semantics</a><a class="headerlink" href="#module-semantics" title="Permalink to this headline">¶</a></h2>
+<p>Modules are modeled as if each submodule were a separate translation unit, and a module import makes names from the other translation unit visible. Each submodule starts with a new preprocessor state and an empty translation unit.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">This behavior is currently only approximated when building a module with submodules. Entities within a submodule that has already been built are visible when building later submodules in that module. This can lead to fragile modules that depend on the build order used for the submodules of the module, and should not be relied upon. This behavior is subject to change.</p>
+</div>
+<p>As an example, in C, this implies that if two structs are defined in different submodules with the same name, those two types are distinct types (but may be <em>compatible</em> types if their definitions match. In C++, two structs defined with the same name in different submodules are the <em>same</em> type, and must be equivalent under C++’s One Definition Rule.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">Clang currently only performs minimal checking for violations of the One Definition Rule.</p>
+</div>
+<p>If any submodule of a module is imported into any part of a program, the entire top-level module is considered to be part of the program. As a consequence of this, Clang may diagnose conflicts between an entity declared in an unimported submodule and an entity declared in the current translation unit, and Clang may inline or devirtualize based on knowledge from unimported submodules.</p>
+<div class="section" id="macros">
+<h3><a class="toc-backref" href="#id20">Macros</a><a class="headerlink" href="#macros" title="Permalink to this headline">¶</a></h3>
+<p>The C and C++ preprocessor assumes that the input text is a single linear buffer, but with modules this is not the case. It is possible to import two modules that have conflicting definitions for a macro (or where one <tt class="docutils literal"><span class="pre">#define</span></tt>s a macro and the other <tt class="docutils literal"><span class="pre">#undef</span></tt>ines it). The rules for handling macro definitions in the presence of modules are as follows:</p>
+<ul class="simple">
+<li>Each definition and undefinition of a macro is considered to be a distinct entity.</li>
+<li>Such entities are <em>visible</em> if they are from the current submodule or translation unit, or if they were exported from a submodule that has been imported.</li>
+<li>A <tt class="docutils literal"><span class="pre">#define</span> <span class="pre">X</span></tt> or <tt class="docutils literal"><span class="pre">#undef</span> <span class="pre">X</span></tt> directive <em>overrides</em> all definitions of <tt class="docutils literal"><span class="pre">X</span></tt> that are visible at the point of the directive.</li>
+<li>A <tt class="docutils literal"><span class="pre">#define</span></tt> or <tt class="docutils literal"><span class="pre">#undef</span></tt> directive is <em>active</em> if it is visible and no visible directive overrides it.</li>
+<li>A set of macro directives is <em>consistent</em> if it consists of only <tt class="docutils literal"><span class="pre">#undef</span></tt> directives, or if all <tt class="docutils literal"><span class="pre">#define</span></tt> directives in the set define the macro name to the same sequence of tokens (following the usual rules for macro redefinitions).</li>
+<li>If a macro name is used and the set of active directives is not consistent, the program is ill-formed. Otherwise, the (unique) meaning of the macro name is used.</li>
+</ul>
+<p>For example, suppose:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre"><stdio.h></span></tt> defines a macro <tt class="docutils literal"><span class="pre">getc</span></tt> (and exports its <tt class="docutils literal"><span class="pre">#define</span></tt>)</li>
+<li><tt class="docutils literal"><span class="pre"><cstdio></span></tt> imports the <tt class="docutils literal"><span class="pre"><stdio.h></span></tt> module and undefines the macro (and exports its <tt class="docutils literal"><span class="pre">#undef</span></tt>)</li>
+</ul>
+<p>The <tt class="docutils literal"><span class="pre">#undef</span></tt> overrides the <tt class="docutils literal"><span class="pre">#define</span></tt>, and a source file that imports both modules <em>in any order</em> will not see <tt class="docutils literal"><span class="pre">getc</span></tt> defined as a macro.</p>
+</div>
+</div>
+<div class="section" id="module-map-language">
+<h2><a class="toc-backref" href="#id21">Module Map Language</a><a class="headerlink" href="#module-map-language" title="Permalink to this headline">¶</a></h2>
+<div class="admonition warning">
+<p class="first admonition-title">Warning</p>
+<p class="last">The module map language is not currently guaranteed to be stable between major revisions of Clang.</p>
+</div>
+<p>The module map language describes the mapping from header files to the
+logical structure of modules. To enable support for using a library as
+a module, one must write a <tt class="docutils literal"><span class="pre">module.modulemap</span></tt> file for that library. The
+<tt class="docutils literal"><span class="pre">module.modulemap</span></tt> file is placed alongside the header files themselves,
+and is written in the module map language described below.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">For compatibility with previous releases, if a module map file named
+<tt class="docutils literal"><span class="pre">module.modulemap</span></tt> is not found, Clang will also search for a file named
+<tt class="docutils literal"><span class="pre">module.map</span></tt>. This behavior is deprecated and we plan to eventually
+remove it.</p>
+</div>
+<p>As an example, the module map file for the C standard library might look a bit like this:</p>
+<div class="highlight-python"><div class="highlight"><pre>module std [system] [extern_c] {
+  module assert {
+    textual header "assert.h"
+    header "bits/assert-decls.h"
+    export *
+  }
+
+  module complex {
+    header "complex.h"
+    export *
+  }
+
+  module ctype {
+    header "ctype.h"
+    export *
+  }
+
+  module errno {
+    header "errno.h"
+    header "sys/errno.h"
+    export *
+  }
+
+  module fenv {
+    header "fenv.h"
+    export *
+  }
+
+  // ...more headers follow...
+}
+</pre></div>
+</div>
+<p>Here, the top-level module <tt class="docutils literal"><span class="pre">std</span></tt> encompasses the whole C standard library. It has a number of submodules containing different parts of the standard library: <tt class="docutils literal"><span class="pre">complex</span></tt> for complex numbers, <tt class="docutils literal"><span class="pre">ctype</span></tt> for character types, etc. Each submodule lists one of more headers that provide the contents for that submodule. Finally, the <tt class="docutils literal"><span class="pre">export</span> <span class="pre">*</span></tt> command specifies that anything included by that submodule will be automatically re-exported.</p>
+<div class="section" id="lexical-structure">
+<h3><a class="toc-backref" href="#id22">Lexical structure</a><a class="headerlink" href="#lexical-structure" title="Permalink to this headline">¶</a></h3>
+<p>Module map files use a simplified form of the C99 lexer, with the same rules for identifiers, tokens, string literals, <tt class="docutils literal"><span class="pre">/*</span> <span class="pre">*/</span></tt> and <tt class="docutils literal"><span class="pre">//</span></tt> comments. The module map language has the following reserved words; all other C identifiers are valid identifiers.</p>
+<pre class="literal-block">
+<tt class="docutils literal"><span class="pre">config_macros</span></tt> <tt class="docutils literal"><span class="pre">export</span></tt>     <tt class="docutils literal"><span class="pre">private</span></tt>
+<tt class="docutils literal"><span class="pre">conflict</span></tt>      <tt class="docutils literal"><span class="pre">framework</span></tt>  <tt class="docutils literal"><span class="pre">requires</span></tt>
+<tt class="docutils literal"><span class="pre">exclude</span></tt>       <tt class="docutils literal"><span class="pre">header</span></tt>     <tt class="docutils literal"><span class="pre">textual</span></tt>
+<tt class="docutils literal"><span class="pre">explicit</span></tt>      <tt class="docutils literal"><span class="pre">link</span></tt>       <tt class="docutils literal"><span class="pre">umbrella</span></tt>
+<tt class="docutils literal"><span class="pre">extern</span></tt>        <tt class="docutils literal"><span class="pre">module</span></tt>     <tt class="docutils literal"><span class="pre">use</span></tt>
+</pre>
+</div>
+<div class="section" id="module-map-file">
+<h3><a class="toc-backref" href="#id23">Module map file</a><a class="headerlink" href="#module-map-file" title="Permalink to this headline">¶</a></h3>
+<p>A module map file consists of a series of module declarations:</p>
+<pre class="literal-block">
+<em>module-map-file</em>:
+  <em>module-declaration*</em>
+</pre>
+<p>Within a module map file, modules are referred to by a <em>module-id</em>, which uses periods to separate each part of a module’s name:</p>
+<pre class="literal-block">
+<em>module-id</em>:
+  <em>identifier</em> ('.' <em>identifier</em>)*
+</pre>
+</div>
+<div class="section" id="module-declaration">
+<h3><a class="toc-backref" href="#id24">Module declaration</a><a class="headerlink" href="#module-declaration" title="Permalink to this headline">¶</a></h3>
+<p>A module declaration describes a module, including the headers that contribute to that module, its submodules, and other aspects of the module.</p>
+<pre class="literal-block">
+<em>module-declaration</em>:
+  <tt class="docutils literal"><span class="pre">explicit</span></tt><sub>opt</sub> <tt class="docutils literal"><span class="pre">framework</span></tt><sub>opt</sub> <tt class="docutils literal"><span class="pre">module</span></tt> <em>module-id</em> <em>attributes</em><sub>opt</sub> '{' <em>module-member*</em> '}'
+  <tt class="docutils literal"><span class="pre">extern</span></tt> <tt class="docutils literal"><span class="pre">module</span></tt> <em>module-id</em> <em>string-literal</em>
+</pre>
+<p>The <em>module-id</em> should consist of only a single <em>identifier</em>, which provides the name of the module being defined. Each module shall have a single definition.</p>
+<p>The <tt class="docutils literal"><span class="pre">explicit</span></tt> qualifier can only be applied to a submodule, i.e., a module that is nested within another module. The contents of explicit submodules are only made available when the submodule itself was explicitly named in an import declaration or was re-exported from an imported module.</p>
+<p>The <tt class="docutils literal"><span class="pre">framework</span></tt> qualifier specifies that this module corresponds to a Darwin-style framework. A Darwin-style framework (used primarily on Mac OS X and iOS) is contained entirely in directory <tt class="docutils literal"><span class="pre">Name.framework</span></tt>, where <tt class="docutils literal"><span class="pre">Name</span></tt> is the name of the framework (and, therefore, the name of the module). That directory has the following layout:</p>
+<div class="highlight-python"><div class="highlight"><pre>Name.framework/
+  Modules/module.modulemap  Module map for the framework
+  Headers/                  Subdirectory containing framework headers
+  Frameworks/               Subdirectory containing embedded frameworks
+  Resources/                Subdirectory containing additional resources
+  Name                      Symbolic link to the shared library for the framework
+</pre></div>
+</div>
+<p>The <tt class="docutils literal"><span class="pre">system</span></tt> attribute specifies that the module is a system module. When a system module is rebuilt, all of the module’s headers will be considered system headers, which suppresses warnings. This is equivalent to placing <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">GCC</span> <span class="pre">system_header</span></tt> in each of the module’s headers. The form of attributes is described in the section <a class="reference internal" href="#attributes">Attributes</a>, below.</p>
+<p>The <tt class="docutils literal"><span class="pre">extern_c</span></tt> attribute specifies that the module contains C code that can be used from within C++. When such a module is built for use in C++ code, all of the module’s headers will be treated as if they were contained within an implicit <tt class="docutils literal"><span class="pre">extern</span> <span class="pre">"C"</span></tt> block. An import for a module with this attribute can appear within an <tt class="docutils literal"><span class="pre">extern</span> <span class="pre">"C"</span></tt> block. No other restrictions are lifted, however: the module currently cannot be imported within an <tt class="docutils literal"><span class="pre">extern</span> <span class="pre">"C"</span></tt> block in a namespace.</p>
+<p>Modules can have a number of different kinds of members, each of which is described below:</p>
+<pre class="literal-block">
+<em>module-member</em>:
+  <em>requires-declaration</em>
+  <em>header-declaration</em>
+  <em>umbrella-dir-declaration</em>
+  <em>submodule-declaration</em>
+  <em>export-declaration</em>
+  <em>use-declaration</em>
+  <em>link-declaration</em>
+  <em>config-macros-declaration</em>
+  <em>conflict-declaration</em>
+</pre>
+<p>An extern module references a module defined by the <em>module-id</em> in a file given by the <em>string-literal</em>. The file can be referenced either by an absolute path or by a path relative to the current map file.</p>
+<div class="section" id="requires-declaration">
+<h4><a class="toc-backref" href="#id25">Requires declaration</a><a class="headerlink" href="#requires-declaration" title="Permalink to this headline">¶</a></h4>
+<p>A <em>requires-declaration</em> specifies the requirements that an importing translation unit must satisfy to use the module.</p>
+<pre class="literal-block">
+<em>requires-declaration</em>:
+  <tt class="docutils literal"><span class="pre">requires</span></tt> <em>feature-list</em>
+
+<em>feature-list</em>:
+  <em>feature</em> (',' <em>feature</em>)*
+
+<em>feature</em>:
+  <tt class="docutils literal"><span class="pre">!</span></tt><sub>opt</sub> <em>identifier</em>
+</pre>
+<p>The requirements clause allows specific modules or submodules to specify that they are only accessible with certain language dialects or on certain platforms. The feature list is a set of identifiers, defined below. If any of the features is not available in a given translation unit, that translation unit shall not import the module. The optional <tt class="docutils literal"><span class="pre">!</span></tt> indicates that a feature is incompatible with the module.</p>
+<p>The following features are defined:</p>
+<dl class="docutils">
+<dt>altivec</dt>
+<dd>The target supports AltiVec.</dd>
+<dt>blocks</dt>
+<dd>The “blocks” language feature is available.</dd>
+<dt>cplusplus</dt>
+<dd>C++ support is available.</dd>
+<dt>cplusplus11</dt>
+<dd>C++11 support is available.</dd>
+<dt>objc</dt>
+<dd>Objective-C support is available.</dd>
+<dt>objc_arc</dt>
+<dd>Objective-C Automatic Reference Counting (ARC) is available</dd>
+<dt>opencl</dt>
+<dd>OpenCL is available</dd>
+<dt>tls</dt>
+<dd>Thread local storage is available.</dd>
+<dt><em>target feature</em></dt>
+<dd>A specific target feature (e.g., <tt class="docutils literal"><span class="pre">sse4</span></tt>, <tt class="docutils literal"><span class="pre">avx</span></tt>, <tt class="docutils literal"><span class="pre">neon</span></tt>) is available.</dd>
+</dl>
+<p><strong>Example</strong>: The <tt class="docutils literal"><span class="pre">std</span></tt> module can be extended to also include C++ and C++11 headers using a <em>requires-declaration</em>:</p>
+<div class="highlight-python"><div class="highlight"><pre>module std {
+   // C standard library...
+
+   module vector {
+     requires cplusplus
+     header "vector"
+   }
+
+   module type_traits {
+     requires cplusplus11
+     header "type_traits"
+   }
+ }
+</pre></div>
+</div>
+</div>
+<div class="section" id="header-declaration">
+<h4><a class="toc-backref" href="#id26">Header declaration</a><a class="headerlink" href="#header-declaration" title="Permalink to this headline">¶</a></h4>
+<p>A header declaration specifies that a particular header is associated with the enclosing module.</p>
+<pre class="literal-block">
+<em>header-declaration</em>:
+  <tt class="docutils literal"><span class="pre">private</span></tt><sub>opt</sub> <tt class="docutils literal"><span class="pre">textual</span></tt><sub>opt</sub> <tt class="docutils literal"><span class="pre">header</span></tt> <em>string-literal</em>
+  <tt class="docutils literal"><span class="pre">umbrella</span></tt> <tt class="docutils literal"><span class="pre">header</span></tt> <em>string-literal</em>
+  <tt class="docutils literal"><span class="pre">exclude</span></tt> <tt class="docutils literal"><span class="pre">header</span></tt> <em>string-literal</em>
+</pre>
+<p>A header declaration that does not contain <tt class="docutils literal"><span class="pre">exclude</span></tt> nor <tt class="docutils literal"><span class="pre">textual</span></tt> specifies a header that contributes to the enclosing module. Specifically, when the module is built, the named header will be parsed and its declarations will be (logically) placed into the enclosing submodule.</p>
+<p>A header with the <tt class="docutils literal"><span class="pre">umbrella</span></tt> specifier is called an umbrella header. An umbrella header includes all of the headers within its directory (and any subdirectories), and is typically used (in the <tt class="docutils literal"><span class="pre">#include</span></tt> world) to easily access the full API provided by a particular library. With modules, an umbrella header is a convenient shortcut that eliminates the need to write out <tt class="docutils literal"><span class="pre">header</span></tt> declarations for every library header. A given directory can only contain a single umbrella header.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">Any headers not included by the umbrella header should have
+explicit <tt class="docutils literal"><span class="pre">header</span></tt> declarations. Use the
+<tt class="docutils literal"><span class="pre">-Wincomplete-umbrella</span></tt> warning option to ask Clang to complain
+about headers not covered by the umbrella header or the module map.</p>
+</div>
+<p>A header with the <tt class="docutils literal"><span class="pre">private</span></tt> specifier may not be included from outside the module itself.</p>
+<p>A header with the <tt class="docutils literal"><span class="pre">textual</span></tt> specifier will not be included when the module is built, and will be textually included if it is named by a <tt class="docutils literal"><span class="pre">#include</span></tt> directive. However, it is considered to be part of the module for the purpose of checking <em>use-declaration</em>s.</p>
+<p>A header with the <tt class="docutils literal"><span class="pre">exclude</span></tt> specifier is excluded from the module. It will not be included when the module is built, nor will it be considered to be part of the module, even if an <tt class="docutils literal"><span class="pre">umbrella</span></tt> header or directory would otherwise make it part of the module.</p>
+<p><strong>Example</strong>: The C header <tt class="docutils literal"><span class="pre">assert.h</span></tt> is an excellent candidate for a textual header, because it is meant to be included multiple times (possibly with different <tt class="docutils literal"><span class="pre">NDEBUG</span></tt> settings). However, declarations within it should typically be split into a separate modular header.</p>
+<div class="highlight-python"><div class="highlight"><pre>module std [system] {
+  textual header "assert.h"
+}
+</pre></div>
+</div>
+<p>A given header shall not be referenced by more than one <em>header-declaration</em>.</p>
+</div>
+<div class="section" id="umbrella-directory-declaration">
+<h4><a class="toc-backref" href="#id27">Umbrella directory declaration</a><a class="headerlink" href="#umbrella-directory-declaration" title="Permalink to this headline">¶</a></h4>
+<p>An umbrella directory declaration specifies that all of the headers in the specified directory should be included within the module.</p>
+<pre class="literal-block">
+<em>umbrella-dir-declaration</em>:
+  <tt class="docutils literal"><span class="pre">umbrella</span></tt> <em>string-literal</em>
+</pre>
+<p>The <em>string-literal</em> refers to a directory. When the module is built, all of the header files in that directory (and its subdirectories) are included in the module.</p>
+<p>An <em>umbrella-dir-declaration</em> shall not refer to the same directory as the location of an umbrella <em>header-declaration</em>. In other words, only a single kind of umbrella can be specified for a given directory.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">Umbrella directories are useful for libraries that have a large number of headers but do not have an umbrella header.</p>
+</div>
+</div>
+<div class="section" id="submodule-declaration">
+<h4><a class="toc-backref" href="#id28">Submodule declaration</a><a class="headerlink" href="#submodule-declaration" title="Permalink to this headline">¶</a></h4>
+<p>Submodule declarations describe modules that are nested within their enclosing module.</p>
+<pre class="literal-block">
+<em>submodule-declaration</em>:
+  <em>module-declaration</em>
+  <em>inferred-submodule-declaration</em>
+</pre>
+<p>A <em>submodule-declaration</em> that is a <em>module-declaration</em> is a nested module. If the <em>module-declaration</em> has a <tt class="docutils literal"><span class="pre">framework</span></tt> specifier, the enclosing module shall have a <tt class="docutils literal"><span class="pre">framework</span></tt> specifier; the submodule’s contents shall be contained within the subdirectory <tt class="docutils literal"><span class="pre">Frameworks/SubName.framework</span></tt>, where <tt class="docutils literal"><span class="pre">SubName</span></tt> is the name of the submodule.</p>
+<p>A <em>submodule-declaration</em> that is an <em>inferred-submodule-declaration</em> describes a set of submodules that correspond to any headers that are part of the module but are not explicitly described by a <em>header-declaration</em>.</p>
+<pre class="literal-block">
+<em>inferred-submodule-declaration</em>:
+  <tt class="docutils literal"><span class="pre">explicit</span></tt><sub>opt</sub> <tt class="docutils literal"><span class="pre">framework</span></tt><sub>opt</sub> <tt class="docutils literal"><span class="pre">module</span></tt> '*' <em>attributes</em><sub>opt</sub> '{' <em>inferred-submodule-member*</em> '}'
+
+<em>inferred-submodule-member</em>:
+  <tt class="docutils literal"><span class="pre">export</span></tt> '*'
+</pre>
+<p>A module containing an <em>inferred-submodule-declaration</em> shall have either an umbrella header or an umbrella directory. The headers to which the <em>inferred-submodule-declaration</em> applies are exactly those headers included by the umbrella header (transitively) or included in the module because they reside within the umbrella directory (or its subdirectories).</p>
+<p>For each header included by the umbrella header or in the umbrella directory that is not named by a <em>header-declaration</em>, a module declaration is implicitly generated from the <em>inferred-submodule-declaration</em>. The module will:</p>
+<ul class="simple">
+<li>Have the same name as the header (without the file extension)</li>
+<li>Have the <tt class="docutils literal"><span class="pre">explicit</span></tt> specifier, if the <em>inferred-submodule-declaration</em> has the <tt class="docutils literal"><span class="pre">explicit</span></tt> specifier</li>
+<li>Have the <tt class="docutils literal"><span class="pre">framework</span></tt> specifier, if the
+<em>inferred-submodule-declaration</em> has the <tt class="docutils literal"><span class="pre">framework</span></tt> specifier</li>
+<li>Have the attributes specified by the <em>inferred-submodule-declaration</em></li>
+<li>Contain a single <em>header-declaration</em> naming that header</li>
+<li>Contain a single <em>export-declaration</em> <tt class="docutils literal"><span class="pre">export</span> <span class="pre">*</span></tt>, if the <em>inferred-submodule-declaration</em> contains the <em>inferred-submodule-member</em> <tt class="docutils literal"><span class="pre">export</span> <span class="pre">*</span></tt></li>
+</ul>
+<p><strong>Example</strong>: If the subdirectory “MyLib” contains the headers <tt class="docutils literal"><span class="pre">A.h</span></tt> and <tt class="docutils literal"><span class="pre">B.h</span></tt>, then the following module map:</p>
+<div class="highlight-python"><div class="highlight"><pre>module MyLib {
+  umbrella "MyLib"
+  explicit module * {
+    export *
+  }
+}
+</pre></div>
+</div>
+<p>is equivalent to the (more verbose) module map:</p>
+<div class="highlight-python"><div class="highlight"><pre>module MyLib {
+  explicit module A {
+    header "A.h"
+    export *
+  }
+
+  explicit module B {
+    header "B.h"
+    export *
+  }
+}
+</pre></div>
+</div>
+</div>
+<div class="section" id="export-declaration">
+<h4><a class="toc-backref" href="#id29">Export declaration</a><a class="headerlink" href="#export-declaration" title="Permalink to this headline">¶</a></h4>
+<p>An <em>export-declaration</em> specifies which imported modules will automatically be re-exported as part of a given module’s API.</p>
+<pre class="literal-block">
+<em>export-declaration</em>:
+  <tt class="docutils literal"><span class="pre">export</span></tt> <em>wildcard-module-id</em>
+
+<em>wildcard-module-id</em>:
+  <em>identifier</em>
+  '*'
+  <em>identifier</em> '.' <em>wildcard-module-id</em>
+</pre>
+<p>The <em>export-declaration</em> names a module or a set of modules that will be re-exported to any translation unit that imports the enclosing module. Each imported module that matches the <em>wildcard-module-id</em> up to, but not including, the first <tt class="docutils literal"><span class="pre">*</span></tt> will be re-exported.</p>
+<p><strong>Example</strong>:: In the following example, importing <tt class="docutils literal"><span class="pre">MyLib.Derived</span></tt> also provides the API for <tt class="docutils literal"><span class="pre">MyLib.Base</span></tt>:</p>
+<div class="highlight-python"><div class="highlight"><pre>module MyLib {
+  module Base {
+    header "Base.h"
+  }
+
+  module Derived {
+    header "Derived.h"
+    export Base
+  }
+}
+</pre></div>
+</div>
+<p>Note that, if <tt class="docutils literal"><span class="pre">Derived.h</span></tt> includes <tt class="docutils literal"><span class="pre">Base.h</span></tt>, one can simply use a wildcard export to re-export everything <tt class="docutils literal"><span class="pre">Derived.h</span></tt> includes:</p>
+<div class="highlight-python"><div class="highlight"><pre>module MyLib {
+  module Base {
+    header "Base.h"
+  }
+
+  module Derived {
+    header "Derived.h"
+    export *
+  }
+}
+</pre></div>
+</div>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">The wildcard export syntax <tt class="docutils literal"><span class="pre">export</span> <span class="pre">*</span></tt> re-exports all of the
+modules that were imported in the actual header file. Because
+<tt class="docutils literal"><span class="pre">#include</span></tt> directives are automatically mapped to module imports,
+<tt class="docutils literal"><span class="pre">export</span> <span class="pre">*</span></tt> provides the same transitive-inclusion behavior
+provided by the C preprocessor, e.g., importing a given module
+implicitly imports all of the modules on which it depends.
+Therefore, liberal use of <tt class="docutils literal"><span class="pre">export</span> <span class="pre">*</span></tt> provides excellent backward
+compatibility for programs that rely on transitive inclusion (i.e.,
+all of them).</p>
+</div>
+</div>
+<div class="section" id="use-declaration">
+<h4><a class="toc-backref" href="#id30">Use declaration</a><a class="headerlink" href="#use-declaration" title="Permalink to this headline">¶</a></h4>
+<p>A <em>use-declaration</em> specifies one of the other modules that the module is allowed to use. An import or include not matching one of these is rejected when the option <em>-fmodules-decluse</em>.</p>
+<pre class="literal-block">
+<em>use-declaration</em>:
+  <tt class="docutils literal"><span class="pre">use</span></tt> <em>module-id</em>
+</pre>
+<p><strong>Example</strong>:: In the following example, use of A from C is not declared, so will trigger a warning.</p>
+<div class="highlight-python"><div class="highlight"><pre>module A {
+  header "a.h"
+}
+
+module B {
+  header "b.h"
+}
+
+module C {
+  header "c.h"
+  use B
+}
+</pre></div>
+</div>
+<p>When compiling a source file that implements a module, use the option <tt class="docutils literal"><span class="pre">-fmodule-name=module-id</span></tt> to indicate that the source file is logically part of that module.</p>
+<p>The compiler at present only applies restrictions to the module directly being built.</p>
+</div>
+<div class="section" id="link-declaration">
+<h4><a class="toc-backref" href="#id31">Link declaration</a><a class="headerlink" href="#link-declaration" title="Permalink to this headline">¶</a></h4>
+<p>A <em>link-declaration</em> specifies a library or framework against which a program should be linked if the enclosing module is imported in any translation unit in that program.</p>
+<pre class="literal-block">
+<em>link-declaration</em>:
+  <tt class="docutils literal"><span class="pre">link</span></tt> <tt class="docutils literal"><span class="pre">framework</span></tt><sub>opt</sub> <em>string-literal</em>
+</pre>
+<p>The <em>string-literal</em> specifies the name of the library or framework against which the program should be linked. For example, specifying “clangBasic” would instruct the linker to link with <tt class="docutils literal"><span class="pre">-lclangBasic</span></tt> for a Unix-style linker.</p>
+<p>A <em>link-declaration</em> with the <tt class="docutils literal"><span class="pre">framework</span></tt> specifies that the linker should link against the named framework, e.g., with <tt class="docutils literal"><span class="pre">-framework</span> <span class="pre">MyFramework</span></tt>.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">Automatic linking with the <tt class="docutils literal"><span class="pre">link</span></tt> directive is not yet widely
+implemented, because it requires support from both the object file
+format and the linker. The notion is similar to Microsoft Visual
+Studio’s <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">comment(lib...)</span></tt>.</p>
+</div>
+</div>
+<div class="section" id="configuration-macros-declaration">
+<h4><a class="toc-backref" href="#id32">Configuration macros declaration</a><a class="headerlink" href="#configuration-macros-declaration" title="Permalink to this headline">¶</a></h4>
+<p>The <em>config-macros-declaration</em> specifies the set of configuration macros that have an effect on the the API of the enclosing module.</p>
+<pre class="literal-block">
+<em>config-macros-declaration</em>:
+  <tt class="docutils literal"><span class="pre">config_macros</span></tt> <em>attributes</em><sub>opt</sub> <em>config-macro-list</em><sub>opt</sub>
+
+<em>config-macro-list</em>:
+  <em>identifier</em> (',' <em>identifier</em>)*
+</pre>
+<p>Each <em>identifier</em> in the <em>config-macro-list</em> specifies the name of a macro. The compiler is required to maintain different variants of the given module for differing definitions of any of the named macros.</p>
+<p>A <em>config-macros-declaration</em> shall only be present on a top-level module, i.e., a module that is not nested within an enclosing module.</p>
+<p>The <tt class="docutils literal"><span class="pre">exhaustive</span></tt> attribute specifies that the list of macros in the <em>config-macros-declaration</em> is exhaustive, meaning that no other macro definition is intended to have an effect on the API of that module.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">The <tt class="docutils literal"><span class="pre">exhaustive</span></tt> attribute implies that any macro definitions
+for macros not listed as configuration macros should be ignored
+completely when building the module. As an optimization, the
+compiler could reduce the number of unique module variants by not
+considering these non-configuration macros. This optimization is not
+yet implemented in Clang.</p>
+</div>
+<p>A translation unit shall not import the same module under different definitions of the configuration macros.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">Clang implements a weak form of this requirement: the definitions
+used for configuration macros are fixed based on the definitions
+provided by the command line. If an import occurs and the definition
+of any configuration macro has changed, the compiler will produce a
+warning (under the control of <tt class="docutils literal"><span class="pre">-Wconfig-macros</span></tt>).</p>
+</div>
+<p><strong>Example:</strong> A logging library might provide different API (e.g., in the form of different definitions for a logging macro) based on the <tt class="docutils literal"><span class="pre">NDEBUG</span></tt> macro setting:</p>
+<div class="highlight-python"><div class="highlight"><pre>module MyLogger {
+  umbrella header "MyLogger.h"
+  config_macros [exhaustive] NDEBUG
+}
+</pre></div>
+</div>
+</div>
+<div class="section" id="conflict-declarations">
+<h4><a class="toc-backref" href="#id33">Conflict declarations</a><a class="headerlink" href="#conflict-declarations" title="Permalink to this headline">¶</a></h4>
+<p>A <em>conflict-declaration</em> describes a case where the presence of two different modules in the same translation unit is likely to cause a problem. For example, two modules may provide similar-but-incompatible functionality.</p>
+<pre class="literal-block">
+<em>conflict-declaration</em>:
+  <tt class="docutils literal"><span class="pre">conflict</span></tt> <em>module-id</em> ',' <em>string-literal</em>
+</pre>
+<p>The <em>module-id</em> of the <em>conflict-declaration</em> specifies the module with which the enclosing module conflicts. The specified module shall not have been imported in the translation unit when the enclosing module is imported.</p>
+<p>The <em>string-literal</em> provides a message to be provided as part of the compiler diagnostic when two modules conflict.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p class="last">Clang emits a warning (under the control of <tt class="docutils literal"><span class="pre">-Wmodule-conflict</span></tt>)
+when a module conflict is discovered.</p>
+</div>
+<p><strong>Example:</strong></p>
+<div class="highlight-python"><div class="highlight"><pre>module Conflicts {
+  explicit module A {
+    header "conflict_a.h"
+    conflict B, "we just don't like B"
+  }
+
+  module B {
+    header "conflict_b.h"
+  }
+}
+</pre></div>
+</div>
+</div>
+</div>
+<div class="section" id="attributes">
+<h3><a class="toc-backref" href="#id34">Attributes</a><a class="headerlink" href="#attributes" title="Permalink to this headline">¶</a></h3>
+<p>Attributes are used in a number of places in the grammar to describe specific behavior of other declarations. The format of attributes is fairly simple.</p>
+<pre class="literal-block">
+<em>attributes</em>:
+  <em>attribute</em> <em>attributes</em><sub>opt</sub>
+
+<em>attribute</em>:
+  '[' <em>identifier</em> ']'
+</pre>
+<p>Any <em>identifier</em> can be used as an attribute, and each declaration specifies what attributes can be applied to it.</p>
+</div>
+<div class="section" id="private-module-map-files">
+<h3><a class="toc-backref" href="#id35">Private Module Map Files</a><a class="headerlink" href="#private-module-map-files" title="Permalink to this headline">¶</a></h3>
+<p>Module map files are typically named <tt class="docutils literal"><span class="pre">module.modulemap</span></tt> and live
+either alongside the headers they describe or in a parent directory of
+the headers they describe. These module maps typically describe all of
+the API for the library.</p>
+<p>However, in some cases, the presence or absence of particular headers
+is used to distinguish between the “public” and “private” APIs of a
+particular library. For example, a library may contain the headers
+<tt class="docutils literal"><span class="pre">Foo.h</span></tt> and <tt class="docutils literal"><span class="pre">Foo_Private.h</span></tt>, providing public and private APIs,
+respectively. Additionally, <tt class="docutils literal"><span class="pre">Foo_Private.h</span></tt> may only be available on
+some versions of library, and absent in others. One cannot easily
+express this with a single module map file in the library:</p>
+<div class="highlight-python"><div class="highlight"><pre>module Foo {
+  header "Foo.h"
+
+  explicit module Private {
+    header "Foo_Private.h"
+  }
+}
+</pre></div>
+</div>
+<p>because the header <tt class="docutils literal"><span class="pre">Foo_Private.h</span></tt> won’t always be available. The
+module map file could be customized based on whether
+<tt class="docutils literal"><span class="pre">Foo_Private.h</span></tt> is available or not, but doing so requires custom
+build machinery.</p>
+<p>Private module map files, which are named <tt class="docutils literal"><span class="pre">module.private.modulemap</span></tt>
+(or, for backward compatibility, <tt class="docutils literal"><span class="pre">module_private.map</span></tt>), allow one to
+augment the primary module map file with an additional submodule. For
+example, we would split the module map file above into two module map
+files:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cm">/* module.modulemap */</span>
+<span class="n">module</span> <span class="n">Foo</span> <span class="p">{</span>
+  <span class="n">header</span> <span class="s">"Foo.h"</span>
+<span class="p">}</span>
+
+<span class="cm">/* module.private.modulemap */</span>
+<span class="n">explicit</span> <span class="n">module</span> <span class="n">Foo</span><span class="p">.</span><span class="n">Private</span> <span class="p">{</span>
+  <span class="n">header</span> <span class="s">"Foo_Private.h"</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>When a <tt class="docutils literal"><span class="pre">module.private.modulemap</span></tt> file is found alongside a
+<tt class="docutils literal"><span class="pre">module.modulemap</span></tt> file, it is loaded after the <tt class="docutils literal"><span class="pre">module.modulemap</span></tt>
+file. In our example library, the <tt class="docutils literal"><span class="pre">module.private.modulemap</span></tt> file
+would be available when <tt class="docutils literal"><span class="pre">Foo_Private.h</span></tt> is available, making it
+easier to split a library’s public and private APIs along header
+boundaries.</p>
+</div>
+</div>
+<div class="section" id="modularizing-a-platform">
+<h2><a class="toc-backref" href="#id36">Modularizing a Platform</a><a class="headerlink" href="#modularizing-a-platform" title="Permalink to this headline">¶</a></h2>
+<p>To get any benefit out of modules, one needs to introduce module maps for software libraries starting at the bottom of the stack. This typically means introducing a module map covering the operating system’s headers and the C standard library headers (in <tt class="docutils literal"><span class="pre">/usr/include</span></tt>, for a Unix system).</p>
+<p>The module maps will be written using the <a class="reference internal" href="#module-map-language">module map language</a>, which provides the tools necessary to describe the mapping between headers and modules. Because the set of headers differs from one system to the next, the module map will likely have to be somewhat customized for, e.g., a particular distribution and version of the operating system. Moreover, the system headers themselves may require some modification, if they exhibit any anti-patterns that break modules. Such common patterns are described below.</p>
+<dl class="docutils">
+<dt><strong>Macro-guarded copy-and-pasted definitions</strong></dt>
+<dd><p class="first">System headers vend core types such as <tt class="docutils literal"><span class="pre">size_t</span></tt> for users. These types are often needed in a number of system headers, and are almost trivial to write. Hence, it is fairly common to see a definition such as the following copy-and-pasted throughout the headers:</p>
+<div class="highlight-python"><div class="highlight"><pre>#ifndef _SIZE_T
+#define _SIZE_T
+typedef __SIZE_TYPE__ size_t;
+#endif
+</pre></div>
+</div>
+<p class="last">Unfortunately, when modules compiles all of the C library headers together into a single module, only the first actual type definition of <tt class="docutils literal"><span class="pre">size_t</span></tt> will be visible, and then only in the submodule corresponding to the lucky first header. Any other headers that have copy-and-pasted versions of this pattern will <em>not</em> have a definition of <tt class="docutils literal"><span class="pre">size_t</span></tt>. Importing the submodule corresponding to one of those headers will therefore not yield <tt class="docutils literal"><span class="pre">size_t</span></tt> as part of the API, because it wasn’t there when the header was parsed. The fix for this problem is either to pull the copied declarations into a common header that gets included everywhere <tt class="docutils literal"><span class="pre">size_t</span></tt> is part of the API, or to eliminate the <tt class="docutils literal"><span class="pre">#ifndef</sp
 an></tt> and redefine the <tt class="docutils literal"><span class="pre">size_t</span></tt> type. The latter works for C++ headers and C11, but will cause an error for non-modules C90/C99, where redefinition of <tt class="docutils literal"><span class="pre">typedefs</span></tt> is not permitted.</p>
+</dd>
+<dt><strong>Conflicting definitions</strong></dt>
+<dd>Different system headers may provide conflicting definitions for various macros, functions, or types. These conflicting definitions don’t tend to cause problems in a pre-modules world unless someone happens to include both headers in one translation unit. Since the fix is often simply “don’t do that”, such problems persist. Modules requires that the conflicting definitions be eliminated or that they be placed in separate modules (the former is generally the better answer).</dd>
+<dt><strong>Missing includes</strong></dt>
+<dd>Headers are often missing <tt class="docutils literal"><span class="pre">#include</span></tt> directives for headers that they actually depend on. As with the problem of conflicting definitions, this only affects unlucky users who don’t happen to include headers in the right order. With modules, the headers of a particular module will be parsed in isolation, so the module may fail to build if there are missing includes.</dd>
+<dt><strong>Headers that vend multiple APIs at different times</strong></dt>
+<dd>Some systems have headers that contain a number of different kinds of API definitions, only some of which are made available with a given include. For example, the header may vend <tt class="docutils literal"><span class="pre">size_t</span></tt> only when the macro <tt class="docutils literal"><span class="pre">__need_size_t</span></tt> is defined before that header is included, and also vend <tt class="docutils literal"><span class="pre">wchar_t</span></tt> only when the macro <tt class="docutils literal"><span class="pre">__need_wchar_t</span></tt> is defined. Such headers are often included many times in a single translation unit, and will have no include guards. There is no sane way to map this header to a submodule. One can either eliminate the header (e.g., by splitting it into separate headers, one per actual API) or simply <tt class="docutils literal"><span class="pre">exclude</span></tt> it in the module map.</dd>
+</dl>
+<p>To detect and help address some of these problems, the <tt class="docutils literal"><span class="pre">clang-tools-extra</span></tt> repository contains a <tt class="docutils literal"><span class="pre">modularize</span></tt> tool that parses a set of given headers and attempts to detect these problems and produce a report. See the tool’s in-source documentation for information on how to check your system or library headers.</p>
+</div>
+<div class="section" id="future-directions">
+<h2><a class="toc-backref" href="#id37">Future Directions</a><a class="headerlink" href="#future-directions" title="Permalink to this headline">¶</a></h2>
+<p>Modules support is under active development, and there are many opportunities remaining to improve it. Here are a few ideas:</p>
+<dl class="docutils">
+<dt><strong>Detect unused module imports</strong></dt>
+<dd>Unlike with <tt class="docutils literal"><span class="pre">#include</span></tt> directives, it should be fairly simple to track whether a directly-imported module has ever been used. By doing so, Clang can emit <tt class="docutils literal"><span class="pre">unused</span> <span class="pre">import</span></tt> or <tt class="docutils literal"><span class="pre">unused</span> <span class="pre">#include</span></tt> diagnostics, including Fix-Its to remove the useless imports/includes.</dd>
+<dt><strong>Fix-Its for missing imports</strong></dt>
+<dd>It’s fairly common for one to make use of some API while writing code, only to get a compiler error about “unknown type” or “no function named” because the corresponding header has not been included. Clang can detect such cases and auto-import the required module, but should provide a Fix-It to add the import.</dd>
+<dt><strong>Improve modularize</strong></dt>
+<dd>The modularize tool is both extremely important (for deployment) and extremely crude. It needs better UI, better detection of problems (especially for C++), and perhaps an assistant mode to help write module maps for you.</dd>
+</dl>
+</div>
+<div class="section" id="where-to-learn-more-about-modules">
+<h2><a class="toc-backref" href="#id38">Where To Learn More About Modules</a><a class="headerlink" href="#where-to-learn-more-about-modules" title="Permalink to this headline">¶</a></h2>
+<p>The Clang source code provides additional information about modules:</p>
+<dl class="docutils">
+<dt><tt class="docutils literal"><span class="pre">clang/lib/Headers/module.modulemap</span></tt></dt>
+<dd>Module map for Clang’s compiler-specific header files.</dd>
+<dt><tt class="docutils literal"><span class="pre">clang/test/Modules/</span></tt></dt>
+<dd>Tests specifically related to modules functionality.</dd>
+<dt><tt class="docutils literal"><span class="pre">clang/include/clang/Basic/Module.h</span></tt></dt>
+<dd>The <tt class="docutils literal"><span class="pre">Module</span></tt> class in this header describes a module, and is used throughout the compiler to implement modules.</dd>
+<dt><tt class="docutils literal"><span class="pre">clang/include/clang/Lex/ModuleMap.h</span></tt></dt>
+<dd>The <tt class="docutils literal"><span class="pre">ModuleMap</span></tt> class in this header describes the full module map, consisting of all of the module map files that have been parsed, and providing facilities for looking up module maps and mapping between modules and headers (in both directions).</dd>
+<dt><a class="reference external" href="PCHInternals.html">PCHInternals</a></dt>
+<dd>Information about the serialized AST format used for precompiled headers and modules. The actual implementation is in the <tt class="docutils literal"><span class="pre">clangSerialization</span></tt> library.</dd>
+</dl>
+<table class="docutils footnote" frame="void" id="id5" rules="none">
+<colgroup><col class="label" /><col /></colgroup>
+<tbody valign="top">
+<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>Automatic linking against the libraries of modules requires specific linker support, which is not widely available.</td></tr>
+</tbody>
+</table>
+<table class="docutils footnote" frame="void" id="id6" rules="none">
+<colgroup><col class="label" /><col /></colgroup>
+<tbody valign="top">
+<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>There are certain anti-patterns that occur in headers, particularly system headers, that cause problems for modules. The section <a class="reference internal" href="#modularizing-a-platform">Modularizing a Platform</a> describes some of them.</td></tr>
+</tbody>
+</table>
+<table class="docutils footnote" frame="void" id="id7" rules="none">
+<colgroup><col class="label" /><col /></colgroup>
+<tbody valign="top">
+<tr><td class="label"><a class="fn-backref" href="#id3">[3]</a></td><td>The second instance is actually a new thread within the current process, not a separate process. However, the original compiler instance is blocked on the execution of this thread.</td></tr>
+</tbody>
+</table>
+<table class="docutils footnote" frame="void" id="id8" rules="none">
+<colgroup><col class="label" /><col /></colgroup>
+<tbody valign="top">
+<tr><td class="label"><a class="fn-backref" href="#id4">[4]</a></td><td>The preprocessing context in which the modules are parsed is actually dependent on the command-line options provided to the compiler, including the language dialect and any <tt class="docutils literal"><span class="pre">-D</span></tt> options. However, the compiled modules for different command-line options are kept distinct, and any preprocessor directives that occur within the translation unit are ignored. See the section on the <a class="reference internal" href="#configuration-macros-declaration">Configuration macros declaration</a> for more information.</td></tr>
+</tbody>
+</table>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="SanitizerSpecialCaseList.html">Sanitizer special case list</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="MSVCCompatibility.html">MSVC compatibility</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/ObjectiveCLiterals.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/ObjectiveCLiterals.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/ObjectiveCLiterals.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/ObjectiveCLiterals.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,543 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Objective-C Literals — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="up" title="Clang Language Extensions" href="LanguageExtensions.html" />
+    <link rel="next" title="Language Specification for Blocks" href="BlockLanguageSpec.html" />
+    <link rel="prev" title="Clang Language Extensions" href="LanguageExtensions.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Objective-C Literals</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="LanguageExtensions.html">Clang Language Extensions</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="BlockLanguageSpec.html">Language Specification for Blocks</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="objective-c-literals">
+<h1>Objective-C Literals<a class="headerlink" href="#objective-c-literals" title="Permalink to this headline">¶</a></h1>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>Three new features were introduced into clang at the same time:
+<em>NSNumber Literals</em> provide a syntax for creating <tt class="docutils literal"><span class="pre">NSNumber</span></tt> from
+scalar literal expressions; <em>Collection Literals</em> provide a short-hand
+for creating arrays and dictionaries; <em>Object Subscripting</em> provides a
+way to use subscripting with Objective-C objects. Users of Apple
+compiler releases can use these features starting with the Apple LLVM
+Compiler 4.0. Users of open-source LLVM.org compiler releases can use
+these features starting with clang v3.1.</p>
+<p>These language additions simplify common Objective-C programming
+patterns, make programs more concise, and improve the safety of
+container creation.</p>
+<p>This document describes how the features are implemented in clang, and
+how to use them in your own programs.</p>
+</div>
+<div class="section" id="nsnumber-literals">
+<h2>NSNumber Literals<a class="headerlink" href="#nsnumber-literals" title="Permalink to this headline">¶</a></h2>
+<p>The framework class <tt class="docutils literal"><span class="pre">NSNumber</span></tt> is used to wrap scalar values inside
+objects: signed and unsigned integers (<tt class="docutils literal"><span class="pre">char</span></tt>, <tt class="docutils literal"><span class="pre">short</span></tt>, <tt class="docutils literal"><span class="pre">int</span></tt>,
+<tt class="docutils literal"><span class="pre">long</span></tt>, <tt class="docutils literal"><span class="pre">long</span> <span class="pre">long</span></tt>), floating point numbers (<tt class="docutils literal"><span class="pre">float</span></tt>,
+<tt class="docutils literal"><span class="pre">double</span></tt>), and boolean values (<tt class="docutils literal"><span class="pre">BOOL</span></tt>, C++ <tt class="docutils literal"><span class="pre">bool</span></tt>). Scalar values
+wrapped in objects are also known as <em>boxed</em> values.</p>
+<p>In Objective-C, any character, numeric or boolean literal prefixed with
+the <tt class="docutils literal"><span class="pre">'@'</span></tt> character will evaluate to a pointer to an <tt class="docutils literal"><span class="pre">NSNumber</span></tt>
+object initialized with that value. C’s type suffixes may be used to
+control the size of numeric literals.</p>
+<div class="section" id="examples">
+<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
+<p>The following program illustrates the rules for <tt class="docutils literal"><span class="pre">NSNumber</span></tt> literals:</p>
+<div class="highlight-objc"><div class="highlight"><pre>void main(int argc, const char *argv[]) {
+  // character literals.
+  NSNumber *theLetterZ = @'Z';          // equivalent to [NSNumber numberWithChar:'Z']
+
+  // integral literals.
+  NSNumber *fortyTwo = @42;             // equivalent to [NSNumber numberWithInt:42]
+  NSNumber *fortyTwoUnsigned = @42U;    // equivalent to [NSNumber numberWithUnsignedInt:42U]
+  NSNumber *fortyTwoLong = @42L;        // equivalent to [NSNumber numberWithLong:42L]
+  NSNumber *fortyTwoLongLong = @42LL;   // equivalent to [NSNumber numberWithLongLong:42LL]
+
+  // floating point literals.
+  NSNumber *piFloat = @3.141592654F;    // equivalent to [NSNumber numberWithFloat:3.141592654F]
+  NSNumber *piDouble = @3.1415926535;   // equivalent to [NSNumber numberWithDouble:3.1415926535]
+
+  // BOOL literals.
+  NSNumber *yesNumber = @YES;           // equivalent to [NSNumber numberWithBool:YES]
+  NSNumber *noNumber = @NO;             // equivalent to [NSNumber numberWithBool:NO]
+
+#ifdef __cplusplus
+  NSNumber *trueNumber = @true;         // equivalent to [NSNumber numberWithBool:(BOOL)true]
+  NSNumber *falseNumber = @false;       // equivalent to [NSNumber numberWithBool:(BOOL)false]
+#endif
+}
+</pre></div>
+</div>
+</div>
+<div class="section" id="discussion">
+<h3>Discussion<a class="headerlink" href="#discussion" title="Permalink to this headline">¶</a></h3>
+<p>NSNumber literals only support literal scalar values after the <tt class="docutils literal"><span class="pre">'@'</span></tt>.
+Consequently, <tt class="docutils literal"><span class="pre">@INT_MAX</span></tt> works, but <tt class="docutils literal"><span class="pre">@INT_MIN</span></tt> does not, because
+they are defined like this:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="cp">#define INT_MAX   2147483647  </span><span class="cm">/* max value for an int */</span><span class="cp"></span>
+<span class="cp">#define INT_MIN   (-2147483647-1) </span><span class="cm">/* min value for an int */</span><span class="cp"></span>
+</pre></div>
+</div>
+<p>The definition of <tt class="docutils literal"><span class="pre">INT_MIN</span></tt> is not a simple literal, but a
+parenthesized expression. Parenthesized expressions are supported using
+the <a class="reference external" href="#objc_boxed_expressions">boxed expression</a> syntax, which is
+described in the next section.</p>
+<p>Because <tt class="docutils literal"><span class="pre">NSNumber</span></tt> does not currently support wrapping <tt class="docutils literal"><span class="pre">long</span> <span class="pre">double</span></tt>
+values, the use of a <tt class="docutils literal"><span class="pre">long</span> <span class="pre">double</span> <span class="pre">NSNumber</span></tt> literal (e.g.
+<tt class="docutils literal"><span class="pre">@123.23L</span></tt>) will be rejected by the compiler.</p>
+<p>Previously, the <tt class="docutils literal"><span class="pre">BOOL</span></tt> type was simply a typedef for <tt class="docutils literal"><span class="pre">signed</span> <span class="pre">char</span></tt>,
+and <tt class="docutils literal"><span class="pre">YES</span></tt> and <tt class="docutils literal"><span class="pre">NO</span></tt> were macros that expand to <tt class="docutils literal"><span class="pre">(BOOL)1</span></tt> and
+<tt class="docutils literal"><span class="pre">(BOOL)0</span></tt> respectively. To support <tt class="docutils literal"><span class="pre">@YES</span></tt> and <tt class="docutils literal"><span class="pre">@NO</span></tt> expressions,
+these macros are now defined using new language keywords in
+<tt class="docutils literal"><span class="pre"><objc/objc.h></span></tt>:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="cp">#if __has_feature(objc_bool)</span>
+<span class="cp">#define YES             __objc_yes</span>
+<span class="cp">#define NO              __objc_no</span>
+<span class="cp">#else</span>
+<span class="cp">#define YES             ((BOOL)1)</span>
+<span class="cp">#define NO              ((BOOL)0)</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+<p>The compiler implicitly converts <tt class="docutils literal"><span class="pre">__objc_yes</span></tt> and <tt class="docutils literal"><span class="pre">__objc_no</span></tt> to
+<tt class="docutils literal"><span class="pre">(BOOL)1</span></tt> and <tt class="docutils literal"><span class="pre">(BOOL)0</span></tt>. The keywords are used to disambiguate
+<tt class="docutils literal"><span class="pre">BOOL</span></tt> and integer literals.</p>
+<p>Objective-C++ also supports <tt class="docutils literal"><span class="pre">@true</span></tt> and <tt class="docutils literal"><span class="pre">@false</span></tt> expressions, which
+are equivalent to <tt class="docutils literal"><span class="pre">@YES</span></tt> and <tt class="docutils literal"><span class="pre">@NO</span></tt>.</p>
+</div>
+</div>
+<div class="section" id="boxed-expressions">
+<h2>Boxed Expressions<a class="headerlink" href="#boxed-expressions" title="Permalink to this headline">¶</a></h2>
+<p>Objective-C provides a new syntax for boxing C expressions:</p>
+<div class="highlight-objc"><div class="highlight"><pre>@( <expression> )
+</pre></div>
+</div>
+<p>Expressions of scalar (numeric, enumerated, BOOL) and C string pointer
+types are supported:</p>
+<div class="highlight-objc"><div class="highlight"><pre>// numbers.
+NSNumber *smallestInt = @(-INT_MAX - 1);  // [NSNumber numberWithInt:(-INT_MAX - 1)]
+NSNumber *piOverTwo = @(M_PI / 2);        // [NSNumber numberWithDouble:(M_PI / 2)]
+
+// enumerated types.
+typedef enum { Red, Green, Blue } Color;
+NSNumber *favoriteColor = @(Green);       // [NSNumber numberWithInt:((int)Green)]
+
+// strings.
+NSString *path = @(getenv("PATH"));       // [NSString stringWithUTF8String:(getenv("PATH"))]
+NSArray *pathComponents = [path componentsSeparatedByString:@":"];
+</pre></div>
+</div>
+<div class="section" id="boxed-enums">
+<h3>Boxed Enums<a class="headerlink" href="#boxed-enums" title="Permalink to this headline">¶</a></h3>
+<p>Cocoa frameworks frequently define constant values using <em>enums.</em>
+Although enum values are integral, they may not be used directly as
+boxed literals (this avoids conflicts with future <tt class="docutils literal"><span class="pre">'@'</span></tt>-prefixed
+Objective-C keywords). Instead, an enum value must be placed inside a
+boxed expression. The following example demonstrates configuring an
+<tt class="docutils literal"><span class="pre">AVAudioRecorder</span></tt> using a dictionary that contains a boxed enumeration
+value:</p>
+<div class="highlight-objc"><div class="highlight"><pre>enum {
+  AVAudioQualityMin = 0,
+  AVAudioQualityLow = 0x20,
+  AVAudioQualityMedium = 0x40,
+  AVAudioQualityHigh = 0x60,
+  AVAudioQualityMax = 0x7F
+};
+
+- (AVAudioRecorder *)recordToFile:(NSURL *)fileURL {
+  NSDictionary *settings = @{ AVEncoderAudioQualityKey : @(AVAudioQualityMax) };
+  return [[AVAudioRecorder alloc] initWithURL:fileURL settings:settings error:NULL];
+}
+</pre></div>
+</div>
+<p>The expression <tt class="docutils literal"><span class="pre">@(AVAudioQualityMax)</span></tt> converts <tt class="docutils literal"><span class="pre">AVAudioQualityMax</span></tt>
+to an integer type, and boxes the value accordingly. If the enum has a
+<a class="reference internal" href="LanguageExtensions.html#objc-fixed-enum"><em>fixed underlying type</em></a> as in:</p>
+<div class="highlight-objc"><div class="highlight"><pre>typedef enum : unsigned char { Red, Green, Blue } Color;
+NSNumber *red = @(Red), *green = @(Green), *blue = @(Blue); // => [NSNumber numberWithUnsignedChar:]
+</pre></div>
+</div>
+<p>then the fixed underlying type will be used to select the correct
+<tt class="docutils literal"><span class="pre">NSNumber</span></tt> creation method.</p>
+<p>Boxing a value of enum type will result in a <tt class="docutils literal"><span class="pre">NSNumber</span></tt> pointer with a
+creation method according to the underlying type of the enum, which can
+be a <a class="reference internal" href="LanguageExtensions.html#objc-fixed-enum"><em>fixed underlying type</em></a>
+or a compiler-defined integer type capable of representing the values of
+all the members of the enumeration:</p>
+<div class="highlight-objc"><div class="highlight"><pre>typedef enum : unsigned char { Red, Green, Blue } Color;
+Color col = Red;
+NSNumber *nsCol = @(col); // => [NSNumber numberWithUnsignedChar:]
+</pre></div>
+</div>
+</div>
+<div class="section" id="boxed-c-strings">
+<h3>Boxed C Strings<a class="headerlink" href="#boxed-c-strings" title="Permalink to this headline">¶</a></h3>
+<p>A C string literal prefixed by the <tt class="docutils literal"><span class="pre">'@'</span></tt> token denotes an <tt class="docutils literal"><span class="pre">NSString</span></tt>
+literal in the same way a numeric literal prefixed by the <tt class="docutils literal"><span class="pre">'@'</span></tt> token
+denotes an <tt class="docutils literal"><span class="pre">NSNumber</span></tt> literal. When the type of the parenthesized
+expression is <tt class="docutils literal"><span class="pre">(char</span> <span class="pre">*)</span></tt> or <tt class="docutils literal"><span class="pre">(const</span> <span class="pre">char</span> <span class="pre">*)</span></tt>, the result of the
+boxed expression is a pointer to an <tt class="docutils literal"><span class="pre">NSString</span></tt> object containing
+equivalent character data, which is assumed to be ‘\0’-terminated and
+UTF-8 encoded. The following example converts C-style command line
+arguments into <tt class="docutils literal"><span class="pre">NSString</span></tt> objects.</p>
+<div class="highlight-objc"><div class="highlight"><pre>// Partition command line arguments into positional and option arguments.
+NSMutableArray *args = [NSMutableArray new];
+NSMutableDictionary *options = [NSMutableDictionary new];
+while (--argc) {
+    const char *arg = *++argv;
+    if (strncmp(arg, "--", 2) == 0) {
+        options[@(arg + 2)] = @(*++argv);   // --key value
+    } else {
+        [args addObject:@(arg)];            // positional argument
+    }
+}
+</pre></div>
+</div>
+<p>As with all C pointers, character pointer expressions can involve
+arbitrary pointer arithmetic, therefore programmers must ensure that the
+character data is valid. Passing <tt class="docutils literal"><span class="pre">NULL</span></tt> as the character pointer will
+raise an exception at runtime. When possible, the compiler will reject
+<tt class="docutils literal"><span class="pre">NULL</span></tt> character pointers used in boxed expressions.</p>
+</div>
+</div>
+<div class="section" id="container-literals">
+<h2>Container Literals<a class="headerlink" href="#container-literals" title="Permalink to this headline">¶</a></h2>
+<p>Objective-C now supports a new expression syntax for creating immutable
+array and dictionary container objects.</p>
+<div class="section" id="id1">
+<h3>Examples<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
+<p>Immutable array expression:</p>
+<div class="highlight-objc"><div class="highlight"><pre>NSArray *array = @[ @"Hello", NSApp, [NSNumber numberWithInt:42] ];
+</pre></div>
+</div>
+<p>This creates an <tt class="docutils literal"><span class="pre">NSArray</span></tt> with 3 elements. The comma-separated
+sub-expressions of an array literal can be any Objective-C object
+pointer typed expression.</p>
+<p>Immutable dictionary expression:</p>
+<div class="highlight-objc"><div class="highlight"><pre>NSDictionary *dictionary = @{
+    @"name" : NSUserName(),
+    @"date" : [NSDate date],
+    @"processInfo" : [NSProcessInfo processInfo]
+};
+</pre></div>
+</div>
+<p>This creates an <tt class="docutils literal"><span class="pre">NSDictionary</span></tt> with 3 key/value pairs. Value
+sub-expressions of a dictionary literal must be Objective-C object
+pointer typed, as in array literals. Key sub-expressions must be of an
+Objective-C object pointer type that implements the
+<tt class="docutils literal"><span class="pre"><NSCopying></span></tt> protocol.</p>
+</div>
+<div class="section" id="id2">
+<h3>Discussion<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
+<p>Neither keys nor values can have the value <tt class="docutils literal"><span class="pre">nil</span></tt> in containers. If the
+compiler can prove that a key or value is <tt class="docutils literal"><span class="pre">nil</span></tt> at compile time, then
+a warning will be emitted. Otherwise, a runtime error will occur.</p>
+<p>Using array and dictionary literals is safer than the variadic creation
+forms commonly in use today. Array literal expressions expand to calls
+to <tt class="docutils literal"><span class="pre">+[NSArray</span> <span class="pre">arrayWithObjects:count:]</span></tt>, which validates that all
+objects are non-<tt class="docutils literal"><span class="pre">nil</span></tt>. The variadic form,
+<tt class="docutils literal"><span class="pre">+[NSArray</span> <span class="pre">arrayWithObjects:]</span></tt> uses <tt class="docutils literal"><span class="pre">nil</span></tt> as an argument list
+terminator, which can lead to malformed array objects. Dictionary
+literals are similarly created with
+<tt class="docutils literal"><span class="pre">+[NSDictionary</span> <span class="pre">dictionaryWithObjects:forKeys:count:]</span></tt> which validates
+all objects and keys, unlike
+<tt class="docutils literal"><span class="pre">+[NSDictionary</span> <span class="pre">dictionaryWithObjectsAndKeys:]</span></tt> which also uses a
+<tt class="docutils literal"><span class="pre">nil</span></tt> parameter as an argument list terminator.</p>
+</div>
+</div>
+<div class="section" id="object-subscripting">
+<h2>Object Subscripting<a class="headerlink" href="#object-subscripting" title="Permalink to this headline">¶</a></h2>
+<p>Objective-C object pointer values can now be used with C’s subscripting
+operator.</p>
+<div class="section" id="id3">
+<h3>Examples<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
+<p>The following code demonstrates the use of object subscripting syntax
+with <tt class="docutils literal"><span class="pre">NSMutableArray</span></tt> and <tt class="docutils literal"><span class="pre">NSMutableDictionary</span></tt> objects:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="n">NSMutableArray</span> <span class="o">*</span><span class="n">array</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="n">NSUInteger</span> <span class="n">idx</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="kt">id</span> <span class="n">newObject</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="kt">id</span> <span class="n">oldObject</span> <span class="o">=</span> <span class="n">array</span><span class="p">[</span><span class="n">idx</span><span class="p">];</span>
+<span class="n">array</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">newObject</span><span class="p">;</span>         <span class="c1">// replace oldObject with newObject</span>
+
+<span class="n">NSMutableDictionary</span> <span class="o">*</span><span class="n">dictionary</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="n">NSString</span> <span class="o">*</span><span class="n">key</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="n">oldObject</span> <span class="o">=</span> <span class="n">dictionary</span><span class="p">[</span><span class="n">key</span><span class="p">];</span>
+<span class="n">dictionary</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">newObject</span><span class="p">;</span>    <span class="c1">// replace oldObject with newObject</span>
+</pre></div>
+</div>
+<p>The next section explains how subscripting expressions map to accessor
+methods.</p>
+</div>
+<div class="section" id="subscripting-methods">
+<h3>Subscripting Methods<a class="headerlink" href="#subscripting-methods" title="Permalink to this headline">¶</a></h3>
+<p>Objective-C supports two kinds of subscript expressions: <em>array-style</em>
+subscript expressions use integer typed subscripts; <em>dictionary-style</em>
+subscript expressions use Objective-C object pointer typed subscripts.
+Each type of subscript expression is mapped to a message send using a
+predefined selector. The advantage of this design is flexibility: class
+designers are free to introduce subscripting by declaring methods or by
+adopting protocols. Moreover, because the method names are selected by
+the type of the subscript, an object can be subscripted using both array
+and dictionary styles.</p>
+<div class="section" id="array-style-subscripting">
+<h4>Array-Style Subscripting<a class="headerlink" href="#array-style-subscripting" title="Permalink to this headline">¶</a></h4>
+<p>When the subscript operand has an integral type, the expression is
+rewritten to use one of two different selectors, depending on whether
+the element is being read or written. When an expression reads an
+element using an integral index, as in the following example:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="n">NSUInteger</span> <span class="n">idx</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="kt">id</span> <span class="n">value</span> <span class="o">=</span> <span class="n">object</span><span class="p">[</span><span class="n">idx</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>it is translated into a call to <tt class="docutils literal"><span class="pre">objectAtIndexedSubscript:</span></tt></p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="kt">id</span> <span class="n">value</span> <span class="o">=</span> <span class="p">[</span><span class="n">object</span> <span class="n">objectAtIndexedSubscript</span><span class="o">:</span><span class="n">idx</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>When an expression writes an element using an integral index:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="n">object</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>it is translated to a call to <tt class="docutils literal"><span class="pre">setObject:atIndexedSubscript:</span></tt></p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="p">[</span><span class="n">object</span> <span class="n">setObject</span><span class="o">:</span><span class="n">newValue</span> <span class="n">atIndexedSubscript</span><span class="o">:</span><span class="n">idx</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>These message sends are then type-checked and performed just like
+explicit message sends. The method used for objectAtIndexedSubscript:
+must be declared with an argument of integral type and a return value of
+some Objective-C object pointer type. The method used for
+setObject:atIndexedSubscript: must be declared with its first argument
+having some Objective-C pointer type and its second argument having
+integral type.</p>
+<p>The meaning of indexes is left up to the declaring class. The compiler
+will coerce the index to the appropriate argument type of the method it
+uses for type-checking. For an instance of <tt class="docutils literal"><span class="pre">NSArray</span></tt>, reading an
+element using an index outside the range <tt class="docutils literal"><span class="pre">[0,</span> <span class="pre">array.count)</span></tt> will raise
+an exception. For an instance of <tt class="docutils literal"><span class="pre">NSMutableArray</span></tt>, assigning to an
+element using an index within this range will replace that element, but
+assigning to an element using an index outside this range will raise an
+exception; no syntax is provided for inserting, appending, or removing
+elements for mutable arrays.</p>
+<p>A class need not declare both methods in order to take advantage of this
+language feature. For example, the class <tt class="docutils literal"><span class="pre">NSArray</span></tt> declares only
+<tt class="docutils literal"><span class="pre">objectAtIndexedSubscript:</span></tt>, so that assignments to elements will fail
+to type-check; moreover, its subclass <tt class="docutils literal"><span class="pre">NSMutableArray</span></tt> declares
+<tt class="docutils literal"><span class="pre">setObject:atIndexedSubscript:</span></tt>.</p>
+</div>
+<div class="section" id="dictionary-style-subscripting">
+<h4>Dictionary-Style Subscripting<a class="headerlink" href="#dictionary-style-subscripting" title="Permalink to this headline">¶</a></h4>
+<p>When the subscript operand has an Objective-C object pointer type, the
+expression is rewritten to use one of two different selectors, depending
+on whether the element is being read from or written to. When an
+expression reads an element using an Objective-C object pointer
+subscript operand, as in the following example:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="kt">id</span> <span class="n">key</span> <span class="o">=</span> <span class="p">...;</span>
+<span class="kt">id</span> <span class="n">value</span> <span class="o">=</span> <span class="n">object</span><span class="p">[</span><span class="n">key</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>it is translated into a call to the <tt class="docutils literal"><span class="pre">objectForKeyedSubscript:</span></tt> method:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="kt">id</span> <span class="n">value</span> <span class="o">=</span> <span class="p">[</span><span class="n">object</span> <span class="n">objectForKeyedSubscript</span><span class="o">:</span><span class="n">key</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>When an expression writes an element using an Objective-C object pointer
+subscript:</p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="n">object</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">newValue</span><span class="p">;</span>
+</pre></div>
+</div>
+<p>it is translated to a call to <tt class="docutils literal"><span class="pre">setObject:forKeyedSubscript:</span></tt></p>
+<div class="highlight-objc"><div class="highlight"><pre><span class="p">[</span><span class="n">object</span> <span class="n">setObject</span><span class="o">:</span><span class="n">newValue</span> <span class="n">forKeyedSubscript</span><span class="o">:</span><span class="n">key</span><span class="p">];</span>
+</pre></div>
+</div>
+<p>The behavior of <tt class="docutils literal"><span class="pre">setObject:forKeyedSubscript:</span></tt> is class-specific; but
+in general it should replace an existing value if one is already
+associated with a key, otherwise it should add a new value for the key.
+No syntax is provided for removing elements from mutable dictionaries.</p>
+</div>
+</div>
+<div class="section" id="id4">
+<h3>Discussion<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
+<p>An Objective-C subscript expression occurs when the base operand of the
+C subscript operator has an Objective-C object pointer type. Since this
+potentially collides with pointer arithmetic on the value, these
+expressions are only supported under the modern Objective-C runtime,
+which categorically forbids such arithmetic.</p>
+<p>Currently, only subscripts of integral or Objective-C object pointer
+type are supported. In C++, a class type can be used if it has a single
+conversion function to an integral or Objective-C pointer type, in which
+case that conversion is applied and analysis continues as appropriate.
+Otherwise, the expression is ill-formed.</p>
+<p>An Objective-C object subscript expression is always an l-value. If the
+expression appears on the left-hand side of a simple assignment operator
+(=), the element is written as described below. If the expression
+appears on the left-hand side of a compound assignment operator (e.g.
++=), the program is ill-formed, because the result of reading an element
+is always an Objective-C object pointer and no binary operators are
+legal on such pointers. If the expression appears in any other position,
+the element is read as described below. It is an error to take the
+address of a subscript expression, or (in C++) to bind a reference to
+it.</p>
+<p>Programs can use object subscripting with Objective-C object pointers of
+type <tt class="docutils literal"><span class="pre">id</span></tt>. Normal dynamic message send rules apply; the compiler must
+see <em>some</em> declaration of the subscripting methods, and will pick the
+declaration seen first.</p>
+</div>
+</div>
+<div class="section" id="caveats">
+<h2>Caveats<a class="headerlink" href="#caveats" title="Permalink to this headline">¶</a></h2>
+<p>Objects created using the literal or boxed expression syntax are not
+guaranteed to be uniqued by the runtime, but nor are they guaranteed to
+be newly-allocated. As such, the result of performing direct comparisons
+against the location of an object literal (using <tt class="docutils literal"><span class="pre">==</span></tt>, <tt class="docutils literal"><span class="pre">!=</span></tt>, <tt class="docutils literal"><span class="pre"><</span></tt>,
+<tt class="docutils literal"><span class="pre"><=</span></tt>, <tt class="docutils literal"><span class="pre">></span></tt>, or <tt class="docutils literal"><span class="pre">>=</span></tt>) is not well-defined. This is usually a simple
+mistake in code that intended to call the <tt class="docutils literal"><span class="pre">isEqual:</span></tt> method (or the
+<tt class="docutils literal"><span class="pre">compare:</span></tt> method).</p>
+<p>This caveat applies to compile-time string literals as well.
+Historically, string literals (using the <tt class="docutils literal"><span class="pre">@"..."</span></tt> syntax) have been
+uniqued across translation units during linking. This is an
+implementation detail of the compiler and should not be relied upon. If
+you are using such code, please use global string constants instead
+(<tt class="docutils literal"><span class="pre">NSString</span> <span class="pre">*</span> <span class="pre">const</span> <span class="pre">MyConst</span> <span class="pre">=</span> <span class="pre">@"..."</span></tt>) or use <tt class="docutils literal"><span class="pre">isEqual:</span></tt>.</p>
+</div>
+<div class="section" id="grammar-additions">
+<h2>Grammar Additions<a class="headerlink" href="#grammar-additions" title="Permalink to this headline">¶</a></h2>
+<p>To support the new syntax described above, the Objective-C
+<tt class="docutils literal"><span class="pre">@</span></tt>-expression grammar has the following new productions:</p>
+<div class="highlight-python"><div class="highlight"><pre>objc-at-expression : '@' (string-literal | encode-literal | selector-literal | protocol-literal | object-literal)
+                   ;
+
+object-literal : ('+' | '-')? numeric-constant
+               | character-constant
+               | boolean-constant
+               | array-literal
+               | dictionary-literal
+               ;
+
+boolean-constant : '__objc_yes' | '__objc_no' | 'true' | 'false'  /* boolean keywords. */
+                 ;
+
+array-literal : '[' assignment-expression-list ']'
+              ;
+
+assignment-expression-list : assignment-expression (',' assignment-expression-list)?
+                           | /* empty */
+                           ;
+
+dictionary-literal : '{' key-value-list '}'
+                   ;
+
+key-value-list : key-value-pair (',' key-value-list)?
+               | /* empty */
+               ;
+
+key-value-pair : assignment-expression ':' assignment-expression
+               ;
+</pre></div>
+</div>
+<p>Note: <tt class="docutils literal"><span class="pre">@true</span></tt> and <tt class="docutils literal"><span class="pre">@false</span></tt> are only supported in Objective-C++.</p>
+</div>
+<div class="section" id="availability-checks">
+<h2>Availability Checks<a class="headerlink" href="#availability-checks" title="Permalink to this headline">¶</a></h2>
+<p>Programs test for the new features by using clang’s __has_feature
+checks. Here are examples of their use:</p>
+<div class="highlight-objc"><div class="highlight"><pre>#if __has_feature(objc_array_literals)
+    // new way.
+    NSArray *elements = @[ @"H", @"He", @"O", @"C" ];
+#else
+    // old way (equivalent).
+    id objects[] = { @"H", @"He", @"O", @"C" };
+    NSArray *elements = [NSArray arrayWithObjects:objects count:4];
+#endif
+
+#if __has_feature(objc_dictionary_literals)
+    // new way.
+    NSDictionary *masses = @{ @"H" : @1.0078,  @"He" : @4.0026, @"O" : @15.9990, @"C" : @12.0096 };
+#else
+    // old way (equivalent).
+    id keys[] = { @"H", @"He", @"O", @"C" };
+    id values[] = { [NSNumber numberWithDouble:1.0078], [NSNumber numberWithDouble:4.0026],
+                    [NSNumber numberWithDouble:15.9990], [NSNumber numberWithDouble:12.0096] };
+    NSDictionary *masses = [NSDictionary dictionaryWithObjects:objects forKeys:keys count:4];
+#endif
+
+#if __has_feature(objc_subscripting)
+    NSUInteger i, count = elements.count;
+    for (i = 0; i < count; ++i) {
+        NSString *element = elements[i];
+        NSNumber *mass = masses[element];
+        NSLog(@"the mass of %@ is %@", element, mass);
+    }
+#else
+    NSUInteger i, count = [elements count];
+    for (i = 0; i < count; ++i) {
+        NSString *element = [elements objectAtIndex:i];
+        NSNumber *mass = [masses objectForKey:element];
+        NSLog(@"the mass of %@ is %@", element, mass);
+    }
+#endif
+</pre></div>
+</div>
+<p>Code can use also <tt class="docutils literal"><span class="pre">__has_feature(objc_bool)</span></tt> to check for the
+availability of numeric literals support. This checks for the new
+<tt class="docutils literal"><span class="pre">__objc_yes</span> <span class="pre">/</span> <span class="pre">__objc_no</span></tt> keywords, which enable the use of
+<tt class="docutils literal"><span class="pre">@YES</span> <span class="pre">/</span> <span class="pre">@NO</span></tt> literals.</p>
+<p>To check whether boxed expressions are supported, use
+<tt class="docutils literal"><span class="pre">__has_feature(objc_boxed_expressions)</span></tt> feature macro.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="LanguageExtensions.html">Clang Language Extensions</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="BlockLanguageSpec.html">Language Specification for Blocks</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/PCHInternals.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/PCHInternals.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/PCHInternals.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/PCHInternals.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,577 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Precompiled Header and Modules Internals — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="prev" title="Pretokenized Headers (PTH)" href="PTHInternals.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Precompiled Header and Modules Internals</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="PTHInternals.html">Pretokenized Headers (PTH)</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="precompiled-header-and-modules-internals">
+<h1>Precompiled Header and Modules Internals<a class="headerlink" href="#precompiled-header-and-modules-internals" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#using-precompiled-headers-with-clang" id="id1">Using Precompiled Headers with <tt class="docutils literal"><span class="pre">clang</span></tt></a></li>
+<li><a class="reference internal" href="#design-philosophy" id="id2">Design Philosophy</a></li>
+<li><a class="reference internal" href="#ast-file-contents" id="id3">AST File Contents</a><ul>
+<li><a class="reference internal" href="#metadata-block" id="id4">Metadata Block</a></li>
+<li><a class="reference internal" href="#source-manager-block" id="id5">Source Manager Block</a></li>
+<li><a class="reference internal" href="#preprocessor-block" id="id6">Preprocessor Block</a></li>
+<li><a class="reference internal" href="#types-block" id="id7">Types Block</a></li>
+<li><a class="reference internal" href="#declarations-block" id="id8">Declarations Block</a></li>
+<li><a class="reference internal" href="#statements-and-expressions" id="id9">Statements and Expressions</a></li>
+<li><a class="reference internal" href="#pchinternals-ident-table" id="id10">Identifier Table Block</a></li>
+<li><a class="reference internal" href="#method-pool-block" id="id11">Method Pool Block</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#ast-reader-integration-points" id="id12">AST Reader Integration Points</a></li>
+<li><a class="reference internal" href="#chained-precompiled-headers" id="id13">Chained precompiled headers</a></li>
+<li><a class="reference internal" href="#modules" id="id14">Modules</a></li>
+</ul>
+</div>
+<p>This document describes the design and implementation of Clang’s precompiled
+headers (PCH) and modules.  If you are interested in the end-user view, please
+see the <a class="reference internal" href="UsersManual.html#usersmanual-precompiled-headers"><em>User’s Manual</em></a>.</p>
+<div class="section" id="using-precompiled-headers-with-clang">
+<h2><a class="toc-backref" href="#id1">Using Precompiled Headers with <tt class="docutils literal"><span class="pre">clang</span></tt></a><a class="headerlink" href="#using-precompiled-headers-with-clang" title="Permalink to this headline">¶</a></h2>
+<p>The Clang compiler frontend, <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt>, supports two command line options
+for generating and using PCH files.</p>
+<p>To generate PCH files using <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt>, use the option <em class="xref std std-option">-emit-pch</em>:</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>clang -cc1 test.h -emit-pch -o test.h.pch
+</pre></div>
+</div>
+<p>This option is transparently used by <tt class="docutils literal"><span class="pre">clang</span></tt> when generating PCH files.  The
+resulting PCH file contains the serialized form of the compiler’s internal
+representation after it has completed parsing and semantic analysis.  The PCH
+file can then be used as a prefix header with the <em class="xref std std-option">-include-pch</em>
+option:</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>clang -cc1 -include-pch test.h.pch test.c -o test.s
+</pre></div>
+</div>
+</div>
+<div class="section" id="design-philosophy">
+<h2><a class="toc-backref" href="#id2">Design Philosophy</a><a class="headerlink" href="#design-philosophy" title="Permalink to this headline">¶</a></h2>
+<p>Precompiled headers are meant to improve overall compile times for projects, so
+the design of precompiled headers is entirely driven by performance concerns.
+The use case for precompiled headers is relatively simple: when there is a
+common set of headers that is included in nearly every source file in the
+project, we <em>precompile</em> that bundle of headers into a single precompiled
+header (PCH file).  Then, when compiling the source files in the project, we
+load the PCH file first (as a prefix header), which acts as a stand-in for that
+bundle of headers.</p>
+<p>A precompiled header implementation improves performance when:</p>
+<ul class="simple">
+<li>Loading the PCH file is significantly faster than re-parsing the bundle of
+headers stored within the PCH file.  Thus, a precompiled header design
+attempts to minimize the cost of reading the PCH file.  Ideally, this cost
+should not vary with the size of the precompiled header file.</li>
+<li>The cost of generating the PCH file initially is not so large that it
+counters the per-source-file performance improvement due to eliminating the
+need to parse the bundled headers in the first place.  This is particularly
+important on multi-core systems, because PCH file generation serializes the
+build when all compilations require the PCH file to be up-to-date.</li>
+</ul>
+<p>Modules, as implemented in Clang, use the same mechanisms as precompiled
+headers to save a serialized AST file (one per module) and use those AST
+modules.  From an implementation standpoint, modules are a generalization of
+precompiled headers, lifting a number of restrictions placed on precompiled
+headers.  In particular, there can only be one precompiled header and it must
+be included at the beginning of the translation unit.  The extensions to the
+AST file format required for modules are discussed in the section on
+<a class="reference internal" href="#pchinternals-modules"><em>modules</em></a>.</p>
+<p>Clang’s AST files are designed with a compact on-disk representation, which
+minimizes both creation time and the time required to initially load the AST
+file.  The AST file itself contains a serialized representation of Clang’s
+abstract syntax trees and supporting data structures, stored using the same
+compressed bitstream as <a class="reference external" href="http://llvm.org/docs/BitCodeFormat.html">LLVM’s bitcode file format</a>.</p>
+<p>Clang’s AST files are loaded “lazily” from disk.  When an AST file is initially
+loaded, Clang reads only a small amount of data from the AST file to establish
+where certain important data structures are stored.  The amount of data read in
+this initial load is independent of the size of the AST file, such that a
+larger AST file does not lead to longer AST load times.  The actual header data
+in the AST file — macros, functions, variables, types, etc. — is loaded
+only when it is referenced from the user’s code, at which point only that
+entity (and those entities it depends on) are deserialized from the AST file.
+With this approach, the cost of using an AST file for a translation unit is
+proportional to the amount of code actually used from the AST file, rather than
+being proportional to the size of the AST file itself.</p>
+<p>When given the <em class="xref std std-option">-print-stats</em> option, Clang produces statistics
+describing how much of the AST file was actually loaded from disk.  For a
+simple “Hello, World!” program that includes the Apple <tt class="docutils literal"><span class="pre">Cocoa.h</span></tt> header
+(which is built as a precompiled header), this option illustrates how little of
+the actual precompiled header is required:</p>
+<div class="highlight-none"><div class="highlight"><pre>*** AST File Statistics:
+  895/39981 source location entries read (2.238563%)
+  19/15315 types read (0.124061%)
+  20/82685 declarations read (0.024188%)
+  154/58070 identifiers read (0.265197%)
+  0/7260 selectors read (0.000000%)
+  0/30842 statements read (0.000000%)
+  4/8400 macros read (0.047619%)
+  1/4995 lexical declcontexts read (0.020020%)
+  0/4413 visible declcontexts read (0.000000%)
+  0/7230 method pool entries read (0.000000%)
+  0 method pool misses
+</pre></div>
+</div>
+<p>For this small program, only a tiny fraction of the source locations, types,
+declarations, identifiers, and macros were actually deserialized from the
+precompiled header.  These statistics can be useful to determine whether the
+AST file implementation can be improved by making more of the implementation
+lazy.</p>
+<p>Precompiled headers can be chained.  When you create a PCH while including an
+existing PCH, Clang can create the new PCH by referencing the original file and
+only writing the new data to the new file.  For example, you could create a PCH
+out of all the headers that are very commonly used throughout your project, and
+then create a PCH for every single source file in the project that includes the
+code that is specific to that file, so that recompiling the file itself is very
+fast, without duplicating the data from the common headers for every file.  The
+mechanisms behind chained precompiled headers are discussed in a <a class="reference internal" href="#pchinternals-chained"><em>later
+section</em></a>.</p>
+</div>
+<div class="section" id="ast-file-contents">
+<h2><a class="toc-backref" href="#id3">AST File Contents</a><a class="headerlink" href="#ast-file-contents" title="Permalink to this headline">¶</a></h2>
+<p>Clang’s AST files are organized into several different blocks, each of which
+contains the serialized representation of a part of Clang’s internal
+representation.  Each of the blocks corresponds to either a block or a record
+within <a class="reference external" href="http://llvm.org/docs/BitCodeFormat.html">LLVM’s bitstream format</a>.
+The contents of each of these logical blocks are described below.</p>
+<img alt="_images/PCHLayout.png" src="_images/PCHLayout.png" />
+<p>For a given AST file, the <a class="reference external" href="http://llvm.org/docs/CommandGuide/llvm-bcanalyzer.html">llvm-bcanalyzer</a> utility can be used
+to examine the actual structure of the bitstream for the AST file.  This
+information can be used both to help understand the structure of the AST file
+and to isolate areas where AST files can still be optimized, e.g., through the
+introduction of abbreviations.</p>
+<div class="section" id="metadata-block">
+<h3><a class="toc-backref" href="#id4">Metadata Block</a><a class="headerlink" href="#metadata-block" title="Permalink to this headline">¶</a></h3>
+<p>The metadata block contains several records that provide information about how
+the AST file was built.  This metadata is primarily used to validate the use of
+an AST file.  For example, a precompiled header built for a 32-bit x86 target
+cannot be used when compiling for a 64-bit x86 target.  The metadata block
+contains information about:</p>
+<dl class="docutils">
+<dt>Language options</dt>
+<dd>Describes the particular language dialect used to compile the AST file,
+including major options (e.g., Objective-C support) and more minor options
+(e.g., support for “<tt class="docutils literal"><span class="pre">//</span></tt>” comments).  The contents of this record correspond to
+the <tt class="docutils literal"><span class="pre">LangOptions</span></tt> class.</dd>
+<dt>Target architecture</dt>
+<dd>The target triple that describes the architecture, platform, and ABI for
+which the AST file was generated, e.g., <tt class="docutils literal"><span class="pre">i386-apple-darwin9</span></tt>.</dd>
+<dt>AST version</dt>
+<dd>The major and minor version numbers of the AST file format.  Changes in the
+minor version number should not affect backward compatibility, while changes
+in the major version number imply that a newer compiler cannot read an older
+precompiled header (and vice-versa).</dd>
+<dt>Original file name</dt>
+<dd>The full path of the header that was used to generate the AST file.</dd>
+<dt>Predefines buffer</dt>
+<dd>Although not explicitly stored as part of the metadata, the predefines buffer
+is used in the validation of the AST file.  The predefines buffer itself
+contains code generated by the compiler to initialize the preprocessor state
+according to the current target, platform, and command-line options.  For
+example, the predefines buffer will contain “<tt class="docutils literal"><span class="pre">#define</span> <span class="pre">__STDC__</span> <span class="pre">1</span></tt>” when we
+are compiling C without Microsoft extensions.  The predefines buffer itself
+is stored within the <a class="reference internal" href="#pchinternals-sourcemgr"><em>Source Manager Block</em></a>, but its contents are
+verified along with the rest of the metadata.</dd>
+</dl>
+<p>A chained PCH file (that is, one that references another PCH) and a module
+(which may import other modules) have additional metadata containing the list
+of all AST files that this AST file depends on.  Each of those files will be
+loaded along with this AST file.</p>
+<p>For chained precompiled headers, the language options, target architecture and
+predefines buffer data is taken from the end of the chain, since they have to
+match anyway.</p>
+</div>
+<div class="section" id="source-manager-block">
+<span id="pchinternals-sourcemgr"></span><h3><a class="toc-backref" href="#id5">Source Manager Block</a><a class="headerlink" href="#source-manager-block" title="Permalink to this headline">¶</a></h3>
+<p>The source manager block contains the serialized representation of Clang’s
+<a class="reference internal" href="InternalsManual.html#sourcemanager"><em>SourceManager</em></a> class, which handles the mapping from
+source locations (as represented in Clang’s abstract syntax tree) into actual
+column/line positions within a source file or macro instantiation.  The AST
+file’s representation of the source manager also includes information about all
+of the headers that were (transitively) included when building the AST file.</p>
+<p>The bulk of the source manager block is dedicated to information about the
+various files, buffers, and macro instantiations into which a source location
+can refer.  Each of these is referenced by a numeric “file ID”, which is a
+unique number (allocated starting at 1) stored in the source location.  Clang
+serializes the information for each kind of file ID, along with an index that
+maps file IDs to the position within the AST file where the information about
+that file ID is stored.  The data associated with a file ID is loaded only when
+required by the front end, e.g., to emit a diagnostic that includes a macro
+instantiation history inside the header itself.</p>
+<p>The source manager block also contains information about all of the headers
+that were included when building the AST file.  This includes information about
+the controlling macro for the header (e.g., when the preprocessor identified
+that the contents of the header dependent on a macro like
+<tt class="docutils literal"><span class="pre">LLVM_CLANG_SOURCEMANAGER_H</span></tt>).</p>
+</div>
+<div class="section" id="preprocessor-block">
+<span id="pchinternals-preprocessor"></span><h3><a class="toc-backref" href="#id6">Preprocessor Block</a><a class="headerlink" href="#preprocessor-block" title="Permalink to this headline">¶</a></h3>
+<p>The preprocessor block contains the serialized representation of the
+preprocessor.  Specifically, it contains all of the macros that have been
+defined by the end of the header used to build the AST file, along with the
+token sequences that comprise each macro.  The macro definitions are only read
+from the AST file when the name of the macro first occurs in the program.  This
+lazy loading of macro definitions is triggered by lookups into the
+<a class="reference internal" href="#pchinternals-ident-table"><em>identifier table</em></a>.</p>
+</div>
+<div class="section" id="types-block">
+<span id="pchinternals-types"></span><h3><a class="toc-backref" href="#id7">Types Block</a><a class="headerlink" href="#types-block" title="Permalink to this headline">¶</a></h3>
+<p>The types block contains the serialized representation of all of the types
+referenced in the translation unit.  Each Clang type node (<tt class="docutils literal"><span class="pre">PointerType</span></tt>,
+<tt class="docutils literal"><span class="pre">FunctionProtoType</span></tt>, etc.) has a corresponding record type in the AST file.
+When types are deserialized from the AST file, the data within the record is
+used to reconstruct the appropriate type node using the AST context.</p>
+<p>Each type has a unique type ID, which is an integer that uniquely identifies
+that type.  Type ID 0 represents the NULL type, type IDs less than
+<tt class="docutils literal"><span class="pre">NUM_PREDEF_TYPE_IDS</span></tt> represent predefined types (<tt class="docutils literal"><span class="pre">void</span></tt>, <tt class="docutils literal"><span class="pre">float</span></tt>, etc.),
+while other “user-defined” type IDs are assigned consecutively from
+<tt class="docutils literal"><span class="pre">NUM_PREDEF_TYPE_IDS</span></tt> upward as the types are encountered.  The AST file has
+an associated mapping from the user-defined types block to the location within
+the types block where the serialized representation of that type resides,
+enabling lazy deserialization of types.  When a type is referenced from within
+the AST file, that reference is encoded using the type ID shifted left by 3
+bits.  The lower three bits are used to represent the <tt class="docutils literal"><span class="pre">const</span></tt>, <tt class="docutils literal"><span class="pre">volatile</span></tt>,
+and <tt class="docutils literal"><span class="pre">restrict</span></tt> qualifiers, as in Clang’s <a class="reference internal" href="InternalsManual.html#qualtype"><em>QualType</em></a> class.</p>
+</div>
+<div class="section" id="declarations-block">
+<span id="pchinternals-decls"></span><h3><a class="toc-backref" href="#id8">Declarations Block</a><a class="headerlink" href="#declarations-block" title="Permalink to this headline">¶</a></h3>
+<p>The declarations block contains the serialized representation of all of the
+declarations referenced in the translation unit.  Each Clang declaration node
+(<tt class="docutils literal"><span class="pre">VarDecl</span></tt>, <tt class="docutils literal"><span class="pre">FunctionDecl</span></tt>, etc.) has a corresponding record type in the
+AST file.  When declarations are deserialized from the AST file, the data
+within the record is used to build and populate a new instance of the
+corresponding <tt class="docutils literal"><span class="pre">Decl</span></tt> node.  As with types, each declaration node has a
+numeric ID that is used to refer to that declaration within the AST file.  In
+addition, a lookup table provides a mapping from that numeric ID to the offset
+within the precompiled header where that declaration is described.</p>
+<p>Declarations in Clang’s abstract syntax trees are stored hierarchically.  At
+the top of the hierarchy is the translation unit (<tt class="docutils literal"><span class="pre">TranslationUnitDecl</span></tt>),
+which contains all of the declarations in the translation unit but is not
+actually written as a specific declaration node.  Its child declarations (such
+as functions or struct types) may also contain other declarations inside them,
+and so on.  Within Clang, each declaration is stored within a <a class="reference internal" href="InternalsManual.html#declcontext"><em>declaration
+context</em></a>, as represented by the <tt class="docutils literal"><span class="pre">DeclContext</span></tt> class.
+Declaration contexts provide the mechanism to perform name lookup within a
+given declaration (e.g., find the member named <tt class="docutils literal"><span class="pre">x</span></tt> in a structure) and
+iterate over the declarations stored within a context (e.g., iterate over all
+of the fields of a structure for structure layout).</p>
+<p>In Clang’s AST file format, deserializing a declaration that is a
+<tt class="docutils literal"><span class="pre">DeclContext</span></tt> is a separate operation from deserializing all of the
+declarations stored within that declaration context.  Therefore, Clang will
+deserialize the translation unit declaration without deserializing the
+declarations within that translation unit.  When required, the declarations
+stored within a declaration context will be deserialized.  There are two
+representations of the declarations within a declaration context, which
+correspond to the name-lookup and iteration behavior described above:</p>
+<ul class="simple">
+<li>When the front end performs name lookup to find a name <tt class="docutils literal"><span class="pre">x</span></tt> within a given
+declaration context (for example, during semantic analysis of the expression
+<tt class="docutils literal"><span class="pre">p->x</span></tt>, where <tt class="docutils literal"><span class="pre">p</span></tt>‘s type is defined in the precompiled header), Clang
+refers to an on-disk hash table that maps from the names within that
+declaration context to the declaration IDs that represent each visible
+declaration with that name.  The actual declarations will then be
+deserialized to provide the results of name lookup.</li>
+<li>When the front end performs iteration over all of the declarations within a
+declaration context, all of those declarations are immediately
+de-serialized.  For large declaration contexts (e.g., the translation unit),
+this operation is expensive; however, large declaration contexts are not
+traversed in normal compilation, since such a traversal is unnecessary.
+However, it is common for the code generator and semantic analysis to
+traverse declaration contexts for structs, classes, unions, and
+enumerations, although those contexts contain relatively few declarations in
+the common case.</li>
+</ul>
+</div>
+<div class="section" id="statements-and-expressions">
+<h3><a class="toc-backref" href="#id9">Statements and Expressions</a><a class="headerlink" href="#statements-and-expressions" title="Permalink to this headline">¶</a></h3>
+<p>Statements and expressions are stored in the AST file in both the <a class="reference internal" href="#pchinternals-types"><em>types</em></a> and the <a class="reference internal" href="#pchinternals-decls"><em>declarations</em></a> blocks,
+because every statement or expression will be associated with either a type or
+declaration.  The actual statement and expression records are stored
+immediately following the declaration or type that owns the statement or
+expression.  For example, the statement representing the body of a function
+will be stored directly following the declaration of the function.</p>
+<p>As with types and declarations, each statement and expression kind in Clang’s
+abstract syntax tree (<tt class="docutils literal"><span class="pre">ForStmt</span></tt>, <tt class="docutils literal"><span class="pre">CallExpr</span></tt>, etc.) has a corresponding
+record type in the AST file, which contains the serialized representation of
+that statement or expression.  Each substatement or subexpression within an
+expression is stored as a separate record (which keeps most records to a fixed
+size).  Within the AST file, the subexpressions of an expression are stored, in
+reverse order, prior to the expression that owns those expression, using a form
+of <a class="reference external" href="http://en.wikipedia.org/wiki/Reverse_Polish_notation">Reverse Polish Notation</a>.  For example, an
+expression <tt class="docutils literal"><span class="pre">3</span> <span class="pre">-</span> <span class="pre">4</span> <span class="pre">+</span> <span class="pre">5</span></tt> would be represented as follows:</p>
+<table border="1" class="docutils">
+<colgroup>
+<col width="100%" />
+</colgroup>
+<tbody valign="top">
+<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">IntegerLiteral(5)</span></tt></td>
+</tr>
+<tr class="row-even"><td><tt class="docutils literal"><span class="pre">IntegerLiteral(4)</span></tt></td>
+</tr>
+<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">IntegerLiteral(3)</span></tt></td>
+</tr>
+<tr class="row-even"><td><tt class="docutils literal"><span class="pre">IntegerLiteral(-)</span></tt></td>
+</tr>
+<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">IntegerLiteral(+)</span></tt></td>
+</tr>
+<tr class="row-even"><td><tt class="docutils literal"><span class="pre">STOP</span></tt></td>
+</tr>
+</tbody>
+</table>
+<p>When reading this representation, Clang evaluates each expression record it
+encounters, builds the appropriate abstract syntax tree node, and then pushes
+that expression on to a stack.  When a record contains <em>N</em> subexpressions —
+<tt class="docutils literal"><span class="pre">BinaryOperator</span></tt> has two of them — those expressions are popped from the
+top of the stack.  The special STOP code indicates that we have reached the end
+of a serialized expression or statement; other expression or statement records
+may follow, but they are part of a different expression.</p>
+</div>
+<div class="section" id="pchinternals-ident-table">
+<span id="identifier-table-block"></span><h3><a class="toc-backref" href="#id10">Identifier Table Block</a><a class="headerlink" href="#pchinternals-ident-table" title="Permalink to this headline">¶</a></h3>
+<p>The identifier table block contains an on-disk hash table that maps each
+identifier mentioned within the AST file to the serialized representation of
+the identifier’s information (e.g, the <tt class="docutils literal"><span class="pre">IdentifierInfo</span></tt> structure).  The
+serialized representation contains:</p>
+<ul class="simple">
+<li>The actual identifier string.</li>
+<li>Flags that describe whether this identifier is the name of a built-in, a
+poisoned identifier, an extension token, or a macro.</li>
+<li>If the identifier names a macro, the offset of the macro definition within
+the <a class="reference internal" href="#pchinternals-preprocessor"><em>Preprocessor Block</em></a>.</li>
+<li>If the identifier names one or more declarations visible from translation
+unit scope, the <a class="reference internal" href="#pchinternals-decls"><em>declaration IDs</em></a> of these
+declarations.</li>
+</ul>
+<p>When an AST file is loaded, the AST file reader mechanism introduces itself
+into the identifier table as an external lookup source.  Thus, when the user
+program refers to an identifier that has not yet been seen, Clang will perform
+a lookup into the identifier table.  If an identifier is found, its contents
+(macro definitions, flags, top-level declarations, etc.) will be deserialized,
+at which point the corresponding <tt class="docutils literal"><span class="pre">IdentifierInfo</span></tt> structure will have the
+same contents it would have after parsing the headers in the AST file.</p>
+<p>Within the AST file, the identifiers used to name declarations are represented
+with an integral value.  A separate table provides a mapping from this integral
+value (the identifier ID) to the location within the on-disk hash table where
+that identifier is stored.  This mapping is used when deserializing the name of
+a declaration, the identifier of a token, or any other construct in the AST
+file that refers to a name.</p>
+</div>
+<div class="section" id="method-pool-block">
+<span id="pchinternals-method-pool"></span><h3><a class="toc-backref" href="#id11">Method Pool Block</a><a class="headerlink" href="#method-pool-block" title="Permalink to this headline">¶</a></h3>
+<p>The method pool block is represented as an on-disk hash table that serves two
+purposes: it provides a mapping from the names of Objective-C selectors to the
+set of Objective-C instance and class methods that have that particular
+selector (which is required for semantic analysis in Objective-C) and also
+stores all of the selectors used by entities within the AST file.  The design
+of the method pool is similar to that of the <a class="reference internal" href="#pchinternals-ident-table"><em>identifier table</em></a>: the first time a particular selector is formed
+during the compilation of the program, Clang will search in the on-disk hash
+table of selectors; if found, Clang will read the Objective-C methods
+associated with that selector into the appropriate front-end data structure
+(<tt class="docutils literal"><span class="pre">Sema::InstanceMethodPool</span></tt> and <tt class="docutils literal"><span class="pre">Sema::FactoryMethodPool</span></tt> for instance and
+class methods, respectively).</p>
+<p>As with identifiers, selectors are represented by numeric values within the AST
+file.  A separate index maps these numeric selector values to the offset of the
+selector within the on-disk hash table, and will be used when de-serializing an
+Objective-C method declaration (or other Objective-C construct) that refers to
+the selector.</p>
+</div>
+</div>
+<div class="section" id="ast-reader-integration-points">
+<h2><a class="toc-backref" href="#id12">AST Reader Integration Points</a><a class="headerlink" href="#ast-reader-integration-points" title="Permalink to this headline">¶</a></h2>
+<p>The “lazy” deserialization behavior of AST files requires their integration
+into several completely different submodules of Clang.  For example, lazily
+deserializing the declarations during name lookup requires that the name-lookup
+routines be able to query the AST file to find entities stored there.</p>
+<p>For each Clang data structure that requires direct interaction with the AST
+reader logic, there is an abstract class that provides the interface between
+the two modules.  The <tt class="docutils literal"><span class="pre">ASTReader</span></tt> class, which handles the loading of an AST
+file, inherits from all of these abstract classes to provide lazy
+deserialization of Clang’s data structures.  <tt class="docutils literal"><span class="pre">ASTReader</span></tt> implements the
+following abstract classes:</p>
+<dl class="docutils">
+<dt><tt class="docutils literal"><span class="pre">ExternalSLocEntrySource</span></tt></dt>
+<dd>This abstract interface is associated with the <tt class="docutils literal"><span class="pre">SourceManager</span></tt> class, and
+is used whenever the <a class="reference internal" href="#pchinternals-sourcemgr"><em>source manager</em></a> needs to
+load the details of a file, buffer, or macro instantiation.</dd>
+<dt><tt class="docutils literal"><span class="pre">IdentifierInfoLookup</span></tt></dt>
+<dd>This abstract interface is associated with the <tt class="docutils literal"><span class="pre">IdentifierTable</span></tt> class, and
+is used whenever the program source refers to an identifier that has not yet
+been seen.  In this case, the AST reader searches for this identifier within
+its <a class="reference internal" href="#pchinternals-ident-table"><em>identifier table</em></a> to load any top-level
+declarations or macros associated with that identifier.</dd>
+<dt><tt class="docutils literal"><span class="pre">ExternalASTSource</span></tt></dt>
+<dd>This abstract interface is associated with the <tt class="docutils literal"><span class="pre">ASTContext</span></tt> class, and is
+used whenever the abstract syntax tree nodes need to loaded from the AST
+file.  It provides the ability to de-serialize declarations and types
+identified by their numeric values, read the bodies of functions when
+required, and read the declarations stored within a declaration context
+(either for iteration or for name lookup).</dd>
+<dt><tt class="docutils literal"><span class="pre">ExternalSemaSource</span></tt></dt>
+<dd>This abstract interface is associated with the <tt class="docutils literal"><span class="pre">Sema</span></tt> class, and is used
+whenever semantic analysis needs to read information from the <a class="reference internal" href="#pchinternals-method-pool"><em>global
+method pool</em></a>.</dd>
+</dl>
+</div>
+<div class="section" id="chained-precompiled-headers">
+<span id="pchinternals-chained"></span><h2><a class="toc-backref" href="#id13">Chained precompiled headers</a><a class="headerlink" href="#chained-precompiled-headers" title="Permalink to this headline">¶</a></h2>
+<p>Chained precompiled headers were initially intended to improve the performance
+of IDE-centric operations such as syntax highlighting and code completion while
+a particular source file is being edited by the user.  To minimize the amount
+of reparsing required after a change to the file, a form of precompiled header
+— called a precompiled <em>preamble</em> — is automatically generated by parsing
+all of the headers in the source file, up to and including the last
+<tt class="docutils literal"><span class="pre">#include</span></tt>.  When only the source file changes (and none of the headers it
+depends on), reparsing of that source file can use the precompiled preamble and
+start parsing after the <tt class="docutils literal"><span class="pre">#include</span></tt>s, so parsing time is proportional to the
+size of the source file (rather than all of its includes).  However, the
+compilation of that translation unit may already use a precompiled header: in
+this case, Clang will create the precompiled preamble as a chained precompiled
+header that refers to the original precompiled header.  This drastically
+reduces the time needed to serialize the precompiled preamble for use in
+reparsing.</p>
+<p>Chained precompiled headers get their name because each precompiled header can
+depend on one other precompiled header, forming a chain of dependencies.  A
+translation unit will then include the precompiled header that starts the chain
+(i.e., nothing depends on it).  This linearity of dependencies is important for
+the semantic model of chained precompiled headers, because the most-recent
+precompiled header can provide information that overrides the information
+provided by the precompiled headers it depends on, just like a header file
+<tt class="docutils literal"><span class="pre">B.h</span></tt> that includes another header <tt class="docutils literal"><span class="pre">A.h</span></tt> can modify the state produced by
+parsing <tt class="docutils literal"><span class="pre">A.h</span></tt>, e.g., by <tt class="docutils literal"><span class="pre">#undef</span></tt>‘ing a macro defined in <tt class="docutils literal"><span class="pre">A.h</span></tt>.</p>
+<p>There are several ways in which chained precompiled headers generalize the AST
+file model:</p>
+<dl class="docutils">
+<dt>Numbering of IDs</dt>
+<dd>Many different kinds of entities — identifiers, declarations, types, etc.
+— have ID numbers that start at 1 or some other predefined constant and
+grow upward.  Each precompiled header records the maximum ID number it has
+assigned in each category.  Then, when a new precompiled header is generated
+that depends on (chains to) another precompiled header, it will start
+counting at the next available ID number.  This way, one can determine, given
+an ID number, which AST file actually contains the entity.</dd>
+<dt>Name lookup</dt>
+<dd>When writing a chained precompiled header, Clang attempts to write only
+information that has changed from the precompiled header on which it is
+based.  This changes the lookup algorithm for the various tables, such as the
+<a class="reference internal" href="#pchinternals-ident-table"><em>identifier table</em></a>: the search starts at the
+most-recent precompiled header.  If no entry is found, lookup then proceeds
+to the identifier table in the precompiled header it depends on, and so one.
+Once a lookup succeeds, that result is considered definitive, overriding any
+results from earlier precompiled headers.</dd>
+<dt>Update records</dt>
+<dd>There are various ways in which a later precompiled header can modify the
+entities described in an earlier precompiled header.  For example, later
+precompiled headers can add entries into the various name-lookup tables for
+the translation unit or namespaces, or add new categories to an Objective-C
+class.  Each of these updates is captured in an “update record” that is
+stored in the chained precompiled header file and will be loaded along with
+the original entity.</dd>
+</dl>
+</div>
+<div class="section" id="modules">
+<span id="pchinternals-modules"></span><h2><a class="toc-backref" href="#id14">Modules</a><a class="headerlink" href="#modules" title="Permalink to this headline">¶</a></h2>
+<p>Modules generalize the chained precompiled header model yet further, from a
+linear chain of precompiled headers to an arbitrary directed acyclic graph
+(DAG) of AST files.  All of the same techniques used to make chained
+precompiled headers work — ID number, name lookup, update records — are
+shared with modules.  However, the DAG nature of modules introduce a number of
+additional complications to the model:</p>
+<dl class="docutils">
+<dt>Numbering of IDs</dt>
+<dd>The simple, linear numbering scheme used in chained precompiled headers falls
+apart with the module DAG, because different modules may end up with
+different numbering schemes for entities they imported from common shared
+modules.  To account for this, each module file provides information about
+which modules it depends on and which ID numbers it assigned to the entities
+in those modules, as well as which ID numbers it took for its own new
+entities.  The AST reader then maps these “local” ID numbers into a “global”
+ID number space for the current translation unit, providing a 1-1 mapping
+between entities (in whatever AST file they inhabit) and global ID numbers.
+If that translation unit is then serialized into an AST file, this mapping
+will be stored for use when the AST file is imported.</dd>
+<dt>Declaration merging</dt>
+<dd>It is possible for a given entity (from the language’s perspective) to be
+declared multiple times in different places.  For example, two different
+headers can have the declaration of <tt class="docutils literal"><span class="pre">printf</span></tt> or could forward-declare
+<tt class="docutils literal"><span class="pre">struct</span> <span class="pre">stat</span></tt>.  If each of those headers is included in a module, and some
+third party imports both of those modules, there is a potentially serious
+problem: name lookup for <tt class="docutils literal"><span class="pre">printf</span></tt> or <tt class="docutils literal"><span class="pre">struct</span> <span class="pre">stat</span></tt> will find both
+declarations, but the AST nodes are unrelated.  This would result in a
+compilation error, due to an ambiguity in name lookup.  Therefore, the AST
+reader performs declaration merging according to the appropriate language
+semantics, ensuring that the two disjoint declarations are merged into a
+single redeclaration chain (with a common canonical declaration), so that it
+is as if one of the headers had been included before the other.</dd>
+<dt>Name Visibility</dt>
+<dd>Modules allow certain names that occur during module creation to be “hidden”,
+so that they are not part of the public interface of the module and are not
+visible to its clients.  The AST reader maintains a “visible” bit on various
+AST nodes (declarations, macros, etc.) to indicate whether that particular
+AST node is currently visible; the various name lookup mechanisms in Clang
+inspect the visible bit to determine whether that entity, which is still in
+the AST (because other, visible AST nodes may depend on it), can actually be
+found by name lookup.  When a new (sub)module is imported, it may make
+existing, non-visible, already-deserialized AST nodes visible; it is the
+responsibility of the AST reader to find and update these AST nodes when it
+is notified of the import.</dd>
+</dl>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="PTHInternals.html">Pretokenized Headers (PTH)</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/PTHInternals.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/PTHInternals.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/PTHInternals.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/PTHInternals.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,214 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Pretokenized Headers (PTH) — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Precompiled Header and Modules Internals" href="PCHInternals.html" />
+    <link rel="prev" title="Driver Design & Internals" href="DriverInternals.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Pretokenized Headers (PTH)</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="DriverInternals.html">Driver Design & Internals</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="PCHInternals.html">Precompiled Header and Modules Internals</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="pretokenized-headers-pth">
+<h1>Pretokenized Headers (PTH)<a class="headerlink" href="#pretokenized-headers-pth" title="Permalink to this headline">¶</a></h1>
+<p>This document first describes the low-level interface for using PTH and
+then briefly elaborates on its design and implementation. If you are
+interested in the end-user view, please see the <a class="reference internal" href="UsersManual.html#usersmanual-precompiled-headers"><em>User’s Manual</em></a>.</p>
+<div class="section" id="using-pretokenized-headers-with-clang-low-level-interface">
+<h2>Using Pretokenized Headers with <tt class="docutils literal"><span class="pre">clang</span></tt> (Low-level Interface)<a class="headerlink" href="#using-pretokenized-headers-with-clang-low-level-interface" title="Permalink to this headline">¶</a></h2>
+<p>The Clang compiler frontend, <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt>, supports three command line
+options for generating and using PTH files.</p>
+<p>To generate PTH files using <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt>, use the option <tt class="docutils literal"><span class="pre">-emit-pth</span></tt>:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang -cc1 test.h -emit-pth -o test.h.pth
+</pre></div>
+</div>
+<p>This option is transparently used by <tt class="docutils literal"><span class="pre">clang</span></tt> when generating PTH
+files. Similarly, PTH files can be used as prefix headers using the
+<tt class="docutils literal"><span class="pre">-include-pth</span></tt> option:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang -cc1 -include-pth test.h.pth test.c -o test.s
+</pre></div>
+</div>
+<p>Alternatively, Clang’s PTH files can be used as a raw “token-cache” (or
+“content” cache) of the source included by the original header file.
+This means that the contents of the PTH file are searched as substitutes
+for <em>any</em> source files that are used by <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt> to process a
+source file. This is done by specifying the <tt class="docutils literal"><span class="pre">-token-cache</span></tt> option:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> cat test.h
+<span class="gp">#</span>include <stdio.h>
+<span class="gp">$</span> clang -cc1 -emit-pth test.h -o test.h.pth
+<span class="gp">$</span> cat test.c
+<span class="gp">#</span>include <span class="s2">"test.h"</span>
+<span class="gp">$</span> clang -cc1 test.c -o <span class="nb">test</span> -token-cache test.h.pth
+</pre></div>
+</div>
+<p>In this example the contents of <tt class="docutils literal"><span class="pre">stdio.h</span></tt> (and the files it includes)
+will be retrieved from <tt class="docutils literal"><span class="pre">test.h.pth</span></tt>, as the PTH file is being used in
+this case as a raw cache of the contents of <tt class="docutils literal"><span class="pre">test.h</span></tt>. This is a
+low-level interface used to both implement the high-level PTH interface
+as well as to provide alternative means to use PTH-style caching.</p>
+</div>
+<div class="section" id="pth-design-and-implementation">
+<h2>PTH Design and Implementation<a class="headerlink" href="#pth-design-and-implementation" title="Permalink to this headline">¶</a></h2>
+<p>Unlike GCC’s precompiled headers, which cache the full ASTs and
+preprocessor state of a header file, Clang’s pretokenized header files
+mainly cache the raw lexer <em>tokens</em> that are needed to segment the
+stream of characters in a source file into keywords, identifiers, and
+operators. Consequently, PTH serves to mainly directly speed up the
+lexing and preprocessing of a source file, while parsing and
+type-checking must be completely redone every time a PTH file is used.</p>
+<div class="section" id="basic-design-tradeoffs">
+<h3>Basic Design Tradeoffs<a class="headerlink" href="#basic-design-tradeoffs" title="Permalink to this headline">¶</a></h3>
+<p>In the long term there are plans to provide an alternate PCH
+implementation for Clang that also caches the work for parsing and type
+checking the contents of header files. The current implementation of PCH
+in Clang as pretokenized header files was motivated by the following
+factors:</p>
+<dl class="docutils">
+<dt><strong>Language independence</strong></dt>
+<dd>PTH files work with any language that
+Clang’s lexer can handle, including C, Objective-C, and (in the early
+stages) C++. This means development on language features at the
+parsing level or above (which is basically almost all interesting
+pieces) does not require PTH to be modified.</dd>
+<dt><strong>Simple design</strong></dt>
+<dd>Relatively speaking, PTH has a simple design and
+implementation, making it easy to test. Further, because the
+machinery for PTH resides at the lower-levels of the Clang library
+stack it is fairly straightforward to profile and optimize.</dd>
+</dl>
+<p>Further, compared to GCC’s PCH implementation (which is the dominate
+precompiled header file implementation that Clang can be directly
+compared against) the PTH design in Clang yields several attractive
+features:</p>
+<dl class="docutils">
+<dt><strong>Architecture independence</strong></dt>
+<dd><p class="first">In contrast to GCC’s PCH files (and
+those of several other compilers), Clang’s PTH files are architecture
+independent, requiring only a single PTH file when building a
+program for multiple architectures.</p>
+<p class="last">For example, on Mac OS X one may wish to compile a “universal binary”
+that runs on PowerPC, 32-bit Intel (i386), and 64-bit Intel
+architectures. In contrast, GCC requires a PCH file for each
+architecture, as the definitions of types in the AST are
+architecture-specific. Since a Clang PTH file essentially represents
+a lexical cache of header files, a single PTH file can be safely used
+when compiling for multiple architectures. This can also reduce
+compile times because only a single PTH file needs to be generated
+during a build instead of several.</p>
+</dd>
+<dt><strong>Reduced memory pressure</strong></dt>
+<dd>Similar to GCC, Clang reads PTH files
+via the use of memory mapping (i.e., <tt class="docutils literal"><span class="pre">mmap</span></tt>). Clang, however,
+memory maps PTH files as read-only, meaning that multiple invocations
+of <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt> can share the same pages in memory from a
+memory-mapped PTH file. In comparison, GCC also memory maps its PCH
+files but also modifies those pages in memory, incurring the
+copy-on-write costs. The read-only nature of PTH can greatly reduce
+memory pressure for builds involving multiple cores, thus improving
+overall scalability.</dd>
+<dt><strong>Fast generation</strong></dt>
+<dd>PTH files can be generated in a small fraction
+of the time needed to generate GCC’s PCH files. Since PTH/PCH
+generation is a serial operation that typically blocks progress
+during a build, faster generation time leads to improved processor
+utilization with parallel builds on multicore machines.</dd>
+</dl>
+<p>Despite these strengths, PTH’s simple design suffers some algorithmic
+handicaps compared to other PCH strategies such as those used by GCC.
+While PTH can greatly speed up the processing time of a header file, the
+amount of work required to process a header file is still roughly linear
+in the size of the header file. In contrast, the amount of work done by
+GCC to process a precompiled header is (theoretically) constant (the
+ASTs for the header are literally memory mapped into the compiler). This
+means that only the pieces of the header file that are referenced by the
+source file including the header are the only ones the compiler needs to
+process during actual compilation. While GCC’s particular implementation
+of PCH mitigates some of these algorithmic strengths via the use of
+copy-on-write pages, the approach itself can fundamentally dominate at
+an algorithmic level, especially when one considers header files of
+arbitrary size.</p>
+<p>There is also a PCH implementation for Clang based on the lazy
+deserialization of ASTs. This approach theoretically has the same
+constant-time algorithmic advantages just mentioned but also retains some
+of the strengths of PTH such as reduced memory pressure (ideal for
+multi-core builds).</p>
+</div>
+<div class="section" id="internal-pth-optimizations">
+<h3>Internal PTH Optimizations<a class="headerlink" href="#internal-pth-optimizations" title="Permalink to this headline">¶</a></h3>
+<p>While the main optimization employed by PTH is to reduce lexing time of
+header files by caching pre-lexed tokens, PTH also employs several other
+optimizations to speed up the processing of header files:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">stat</span></tt> caching: PTH files cache information obtained via calls to
+<tt class="docutils literal"><span class="pre">stat</span></tt> that <tt class="docutils literal"><span class="pre">clang</span> <span class="pre">-cc1</span></tt> uses to resolve which files are included
+by <tt class="docutils literal"><span class="pre">#include</span></tt> directives. This greatly reduces the overhead
+involved in context-switching to the kernel to resolve included
+files.</li>
+<li>Fast skipping of <tt class="docutils literal"><span class="pre">#ifdef</span></tt> ... <tt class="docutils literal"><span class="pre">#endif</span></tt> chains: PTH files
+record the basic structure of nested preprocessor blocks. When the
+condition of the preprocessor block is false, all of its tokens are
+immediately skipped instead of requiring them to be handled by
+Clang’s preprocessor.</li>
+</ul>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="DriverInternals.html">Driver Design & Internals</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="PCHInternals.html">Precompiled Header and Modules Internals</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/RAVFrontendAction.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/RAVFrontendAction.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/RAVFrontendAction.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/RAVFrontendAction.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,266 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>How to write RecursiveASTVisitor based ASTFrontendActions. — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Tutorial for building tools using LibTooling and LibASTMatchers" href="LibASTMatchersTutorial.html" />
+    <link rel="prev" title="Clang Plugins" href="ClangPlugins.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>How to write RecursiveASTVisitor based ASTFrontendActions.</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="ClangPlugins.html">Clang Plugins</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibASTMatchersTutorial.html">Tutorial for building tools using LibTooling and LibASTMatchers</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="how-to-write-recursiveastvisitor-based-astfrontendactions">
+<h1>How to write RecursiveASTVisitor based ASTFrontendActions.<a class="headerlink" href="#how-to-write-recursiveastvisitor-based-astfrontendactions" title="Permalink to this headline">¶</a></h1>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>In this tutorial you will learn how to create a FrontendAction that uses
+a RecursiveASTVisitor to find CXXRecordDecl AST nodes with a specified
+name.</p>
+</div>
+<div class="section" id="creating-a-frontendaction">
+<h2>Creating a FrontendAction<a class="headerlink" href="#creating-a-frontendaction" title="Permalink to this headline">¶</a></h2>
+<p>When writing a clang based tool like a Clang Plugin or a standalone tool
+based on LibTooling, the common entry point is the FrontendAction.
+FrontendAction is an interface that allows execution of user specific
+actions as part of the compilation. To run tools over the AST clang
+provides the convenience interface ASTFrontendAction, which takes care
+of executing the action. The only part left is to implement the
+CreateASTConsumer method that returns an ASTConsumer per translation
+unit.</p>
+<div class="highlight-python"><div class="highlight"><pre>class FindNamedClassAction : public clang::ASTFrontendAction {
+public:
+  virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
+    clang::CompilerInstance &Compiler, llvm::StringRef InFile) {
+    return std::unique_ptr<clang::ASTConsumer>(
+        new FindNamedClassConsumer);
+  }
+};
+</pre></div>
+</div>
+</div>
+<div class="section" id="creating-an-astconsumer">
+<h2>Creating an ASTConsumer<a class="headerlink" href="#creating-an-astconsumer" title="Permalink to this headline">¶</a></h2>
+<p>ASTConsumer is an interface used to write generic actions on an AST,
+regardless of how the AST was produced. ASTConsumer provides many
+different entry points, but for our use case the only one needed is
+HandleTranslationUnit, which is called with the ASTContext for the
+translation unit.</p>
+<div class="highlight-python"><div class="highlight"><pre>class FindNamedClassConsumer : public clang::ASTConsumer {
+public:
+  virtual void HandleTranslationUnit(clang::ASTContext &Context) {
+    // Traversing the translation unit decl via a RecursiveASTVisitor
+    // will visit all nodes in the AST.
+    Visitor.TraverseDecl(Context.getTranslationUnitDecl());
+  }
+private:
+  // A RecursiveASTVisitor implementation.
+  FindNamedClassVisitor Visitor;
+};
+</pre></div>
+</div>
+</div>
+<div class="section" id="using-the-recursiveastvisitor">
+<h2>Using the RecursiveASTVisitor<a class="headerlink" href="#using-the-recursiveastvisitor" title="Permalink to this headline">¶</a></h2>
+<p>Now that everything is hooked up, the next step is to implement a
+RecursiveASTVisitor to extract the relevant information from the AST.</p>
+<p>The RecursiveASTVisitor provides hooks of the form bool
+VisitNodeType(NodeType *) for most AST nodes; the exception are TypeLoc
+nodes, which are passed by-value. We only need to implement the methods
+for the relevant node types.</p>
+<p>Let’s start by writing a RecursiveASTVisitor that visits all
+CXXRecordDecl’s.</p>
+<div class="highlight-python"><div class="highlight"><pre>class FindNamedClassVisitor
+  : public RecursiveASTVisitor<FindNamedClassVisitor> {
+public:
+  bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+    // For debugging, dumping the AST nodes will show which nodes are already
+    // being visited.
+    Declaration->dump();
+
+    // The return value indicates whether we want the visitation to proceed.
+    // Return false to stop the traversal of the AST.
+    return true;
+  }
+};
+</pre></div>
+</div>
+<p>In the methods of our RecursiveASTVisitor we can now use the full power
+of the Clang AST to drill through to the parts that are interesting for
+us. For example, to find all class declaration with a certain name, we
+can check for a specific qualified name:</p>
+<div class="highlight-python"><div class="highlight"><pre>bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+  if (Declaration->getQualifiedNameAsString() == "n::m::C")
+    Declaration->dump();
+  return true;
+}
+</pre></div>
+</div>
+</div>
+<div class="section" id="accessing-the-sourcemanager-and-astcontext">
+<h2>Accessing the SourceManager and ASTContext<a class="headerlink" href="#accessing-the-sourcemanager-and-astcontext" title="Permalink to this headline">¶</a></h2>
+<p>Some of the information about the AST, like source locations and global
+identifier information, are not stored in the AST nodes themselves, but
+in the ASTContext and its associated source manager. To retrieve them we
+need to hand the ASTContext into our RecursiveASTVisitor implementation.</p>
+<p>The ASTContext is available from the CompilerInstance during the call to
+CreateASTConsumer. We can thus extract it there and hand it into our
+freshly created FindNamedClassConsumer:</p>
+<div class="highlight-python"><div class="highlight"><pre>virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
+  clang::CompilerInstance &Compiler, llvm::StringRef InFile) {
+  return std::unique_ptr<clang::ASTConsumer>(
+      new FindNamedClassConsumer(&Compiler.getASTContext()));
+}
+</pre></div>
+</div>
+<p>Now that the ASTContext is available in the RecursiveASTVisitor, we can
+do more interesting things with AST nodes, like looking up their source
+locations:</p>
+<div class="highlight-python"><div class="highlight"><pre>bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+  if (Declaration->getQualifiedNameAsString() == "n::m::C") {
+    // getFullLoc uses the ASTContext's SourceManager to resolve the source
+    // location and break it up into its line and column parts.
+    FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart());
+    if (FullLocation.isValid())
+      llvm::outs() << "Found declaration at "
+                   << FullLocation.getSpellingLineNumber() << ":"
+                   << FullLocation.getSpellingColumnNumber() << "\n";
+  }
+  return true;
+}
+</pre></div>
+</div>
+</div>
+<div class="section" id="putting-it-all-together">
+<h2>Putting it all together<a class="headerlink" href="#putting-it-all-together" title="Permalink to this headline">¶</a></h2>
+<p>Now we can combine all of the above into a small example program:</p>
+<div class="highlight-python"><div class="highlight"><pre>#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Tooling/Tooling.h"
+
+using namespace clang;
+
+class FindNamedClassVisitor
+  : public RecursiveASTVisitor<FindNamedClassVisitor> {
+public:
+  explicit FindNamedClassVisitor(ASTContext *Context)
+    : Context(Context) {}
+
+  bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+    if (Declaration->getQualifiedNameAsString() == "n::m::C") {
+      FullSourceLoc FullLocation = Context->getFullLoc(Declaration->getLocStart());
+      if (FullLocation.isValid())
+        llvm::outs() << "Found declaration at "
+                     << FullLocation.getSpellingLineNumber() << ":"
+                     << FullLocation.getSpellingColumnNumber() << "\n";
+    }
+    return true;
+  }
+
+private:
+  ASTContext *Context;
+};
+
+class FindNamedClassConsumer : public clang::ASTConsumer {
+public:
+  explicit FindNamedClassConsumer(ASTContext *Context)
+    : Visitor(Context) {}
+
+  virtual void HandleTranslationUnit(clang::ASTContext &Context) {
+    Visitor.TraverseDecl(Context.getTranslationUnitDecl());
+  }
+private:
+  FindNamedClassVisitor Visitor;
+};
+
+class FindNamedClassAction : public clang::ASTFrontendAction {
+public:
+  virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
+    clang::CompilerInstance &Compiler, llvm::StringRef InFile) {
+    return std::unique_ptr<clang::ASTConsumer>(
+        new FindNamedClassConsumer(&Compiler.getASTContext()));
+  }
+};
+
+int main(int argc, char **argv) {
+  if (argc > 1) {
+    clang::tooling::runToolOnCode(new FindNamedClassAction, argv[1]);
+  }
+}
+</pre></div>
+</div>
+<p>We store this into a file called FindClassDecls.cpp and create the
+following CMakeLists.txt to link it:</p>
+<div class="highlight-python"><div class="highlight"><pre>set(LLVM_USED_LIBS clangTooling)
+
+add_clang_executable(find-class-decls FindClassDecls.cpp)
+</pre></div>
+</div>
+<p>When running this tool over a small code snippet it will output all
+declarations of a class n::m::C it found:</p>
+<div class="highlight-python"><div class="highlight"><pre>$ ./bin/find-class-decls "namespace n { namespace m { class C {}; } }"
+Found declaration at 1:29
+</pre></div>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="ClangPlugins.html">Clang Plugins</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LibASTMatchersTutorial.html">Tutorial for building tools using LibTooling and LibASTMatchers</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/ReleaseNotes.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/ReleaseNotes.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/ReleaseNotes.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,270 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Clang 3.6 Release Notes — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Clang Compiler User’s Manual" href="UsersManual.html" />
+    <link rel="prev" title="Using Clang as a Compiler" href="index.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Clang 3.6 Release Notes</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="index.html">Using Clang as a Compiler</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="UsersManual.html">Clang Compiler User’s Manual</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="clang-3-6-release-notes">
+<h1>Clang 3.6 Release Notes<a class="headerlink" href="#clang-3-6-release-notes" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id2">Introduction</a></li>
+<li><a class="reference internal" href="#what-s-new-in-clang-3-6" id="id3">What’s New in Clang 3.6?</a><ul>
+<li><a class="reference internal" href="#major-new-features" id="id4">Major New Features</a></li>
+<li><a class="reference internal" href="#improvements-to-clang-s-diagnostics" id="id5">Improvements to Clang’s diagnostics</a></li>
+<li><a class="reference internal" href="#new-compiler-flags" id="id6">New Compiler Flags</a></li>
+<li><a class="reference internal" href="#the-exceptions-macro" id="id7">The __EXCEPTIONS macro</a></li>
+<li><a class="reference internal" href="#new-pragmas-in-clang" id="id8">New Pragmas in Clang</a></li>
+<li><a class="reference internal" href="#windows-support" id="id9">Windows Support</a></li>
+<li><a class="reference internal" href="#c-language-changes-in-clang" id="id10">C Language Changes in Clang</a></li>
+<li><a class="reference internal" href="#id1" id="id11">C++ Language Changes in Clang</a></li>
+<li><a class="reference internal" href="#openmp-language-changes-in-clang" id="id12">OpenMP Language Changes in Clang</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#additional-information" id="id13">Additional Information</a></li>
+</ul>
+</div>
+<p>Written by the <a class="reference external" href="http://llvm.org/">LLVM Team</a></p>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id2">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>This document contains the release notes for the Clang C/C++/Objective-C
+frontend, part of the LLVM Compiler Infrastructure, release 3.6. Here we
+describe the status of Clang in some detail, including major
+improvements from the previous release and new feature work. For the
+general LLVM release notes, see <a class="reference external" href="http://llvm.org/releases/3.6.0/docs/ReleaseNotes.html">the LLVM
+documentation</a>.
+All LLVM releases may be downloaded from the <a class="reference external" href="http://llvm.org/releases/">LLVM releases web
+site</a>.</p>
+<p>For more information about Clang or LLVM, including information about
+the latest release, please check out the main please see the <a class="reference external" href="http://clang.llvm.org">Clang Web
+Site</a> or the <a class="reference external" href="http://llvm.org">LLVM Web
+Site</a>.</p>
+</div>
+<div class="section" id="what-s-new-in-clang-3-6">
+<h2><a class="toc-backref" href="#id3">What’s New in Clang 3.6?</a><a class="headerlink" href="#what-s-new-in-clang-3-6" title="Permalink to this headline">¶</a></h2>
+<p>Some of the major new features and improvements to Clang are listed
+here. Generic improvements to Clang as a whole or to its underlying
+infrastructure are described first, followed by language-specific
+sections with improvements to Clang’s support for those languages.</p>
+<div class="section" id="major-new-features">
+<h3><a class="toc-backref" href="#id4">Major New Features</a><a class="headerlink" href="#major-new-features" title="Permalink to this headline">¶</a></h3>
+<ul class="simple">
+<li>The __has_attribute built-in macro no longer queries for attributes across
+multiple attribute syntaxes (GNU, C++11, __declspec, etc). Instead, it only
+queries GNU-style attributes. With the addition of __has_cpp_attribute and
+__has_declspec_attribute, this allows for more precise coverage of attribute
+syntax querying.</li>
+<li>clang-format now supports formatting Java code.</li>
+</ul>
+</div>
+<div class="section" id="improvements-to-clang-s-diagnostics">
+<h3><a class="toc-backref" href="#id5">Improvements to Clang’s diagnostics</a><a class="headerlink" href="#improvements-to-clang-s-diagnostics" title="Permalink to this headline">¶</a></h3>
+<p>Clang’s diagnostics are constantly being improved to catch more issues,
+explain them more clearly, and provide more accurate source information
+about them. The improvements since the 3.5 release include:</p>
+<ul class="simple">
+<li>Smarter typo correction. Clang now tries a bit harder to give a usable
+suggestion in more cases, and can now successfully recover in more
+situations where the suggestion changes how an expression is parsed.</li>
+</ul>
+</div>
+<div class="section" id="new-compiler-flags">
+<h3><a class="toc-backref" href="#id6">New Compiler Flags</a><a class="headerlink" href="#new-compiler-flags" title="Permalink to this headline">¶</a></h3>
+<p>The <tt class="docutils literal"><span class="pre">-fpic</span></tt> option now uses small pic on PowerPC.</p>
+</div>
+<div class="section" id="the-exceptions-macro">
+<h3><a class="toc-backref" href="#id7">The __EXCEPTIONS macro</a><a class="headerlink" href="#the-exceptions-macro" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">__EXCEPTIONS</span></tt> is now defined when landing pads are emitted, not when
+C++ exceptions are enabled. The two can be different in Objective-C files:
+If C++ exceptions are disabled but Objective-C exceptions are enabled,
+landing pads will be emitted. Clang 3.6 is switching the behavior of
+<tt class="docutils literal"><span class="pre">__EXCEPTIONS</span></tt>. Clang 3.5 confusingly changed the behavior of
+<tt class="docutils literal"><span class="pre">has_feature(cxx_exceptions)</span></tt>, which used to be set if landing pads were
+emitted, but is now set if C++ exceptions are enabled. So there are 3 cases:</p>
+<dl class="docutils">
+<dt>Clang before 3.5:</dt>
+<dd><tt class="docutils literal"><span class="pre">__EXCEPTIONS</span></tt> is set if C++ exceptions are enabled, <tt class="docutils literal"><span class="pre">cxx_exceptions</span></tt>
+enabled if C++ or ObjC exceptions are enabled</dd>
+<dt>Clang 3.5:</dt>
+<dd><tt class="docutils literal"><span class="pre">__EXCEPTIONS</span></tt> is set if C++ exceptions are enabled, <tt class="docutils literal"><span class="pre">cxx_exceptions</span></tt>
+enabled if C++ exceptions are enabled</dd>
+<dt>Clang 3.6:</dt>
+<dd><tt class="docutils literal"><span class="pre">__EXCEPTIONS</span></tt> is set if C++ or ObjC exceptions are enabled,
+<tt class="docutils literal"><span class="pre">cxx_exceptions</span></tt> enabled if C++ exceptions are enabled</dd>
+</dl>
+<p>To reliably test if C++ exceptions are enabled, use
+<tt class="docutils literal"><span class="pre">__EXCEPTIONS</span> <span class="pre">&&</span> <span class="pre">__has_feature(cxx_exceptions)</span></tt>, else things won’t work in
+all versions of Clang in Objective-C++ files.</p>
+</div>
+<div class="section" id="new-pragmas-in-clang">
+<h3><a class="toc-backref" href="#id8">New Pragmas in Clang</a><a class="headerlink" href="#new-pragmas-in-clang" title="Permalink to this headline">¶</a></h3>
+<p>Clang now supports the <cite>#pragma unroll</cite> and <cite>#pragma nounroll</cite> directives to
+specify loop unrolling optimization hints.  Placed just prior to the desired
+loop, <cite>#pragma unroll</cite> directs the loop unroller to attempt to fully unroll the
+loop.  The pragma may also be specified with a positive integer parameter
+indicating the desired unroll count: <cite>#pragma unroll _value_</cite>.  The unroll count
+parameter can be optionally enclosed in parentheses. The directive <cite>#pragma
+nounroll</cite> indicates that the loop should not be unrolled.  These unrolling hints
+may also be expressed using the <cite>#pragma clang loop</cite> directive.  See the Clang
+<a class="reference external" href="http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations">language extensions</a>
+for details.</p>
+</div>
+<div class="section" id="windows-support">
+<h3><a class="toc-backref" href="#id9">Windows Support</a><a class="headerlink" href="#windows-support" title="Permalink to this headline">¶</a></h3>
+<ul class="simple">
+<li>Many, many bug fixes.</li>
+<li>Clang can now self-host using the <tt class="docutils literal"><span class="pre">msvc</span></tt> environment on x86 and x64
+Windows. This means that Microsoft C++ ABI is more or less feature-complete,
+minus exception support.</li>
+<li>Added more MSVC compatibility hacks, such as allowing more lookup into
+dependent bases of class templates when there is a known template pattern.
+As a result, applications using Active Template Library (ATL) or Windows
+Runtime Library (WRL) headers should compile correctly.</li>
+<li>Added support for the Visual C++ <tt class="docutils literal"><span class="pre">__super</span></tt> keyword.</li>
+<li>Added support for MSVC’s <tt class="docutils literal"><span class="pre">__vectorcall</span></tt> calling convention, which is used
+in the upcoming Visual Studio 2015 STL.</li>
+<li>Added basic support for DWARF debug information in COFF files.</li>
+</ul>
+</div>
+<div class="section" id="c-language-changes-in-clang">
+<h3><a class="toc-backref" href="#id10">C Language Changes in Clang</a><a class="headerlink" href="#c-language-changes-in-clang" title="Permalink to this headline">¶</a></h3>
+<ul class="simple">
+<li>The default language mode for C compilations with Clang has been changed from
+C99 with GNU extensions to C11 with GNU extensions. C11 is largely
+backwards-compatible with C99, but if you want to restore the former behavior
+you can do so with the <cite>-std=gnu99</cite> flag.</li>
+</ul>
+<div class="section" id="c11-feature-support">
+<h4>C11 Feature Support<a class="headerlink" href="#c11-feature-support" title="Permalink to this headline">¶</a></h4>
+<ul class="simple">
+<li>Clang now provides an implementation of the standard C11 header <cite><stdatomic.h></cite>.</li>
+</ul>
+</div>
+</div>
+<div class="section" id="id1">
+<h3><a class="toc-backref" href="#id11">C++ Language Changes in Clang</a><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
+<ul class="simple">
+<li>An <cite>upcoming change to C++ <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3922.html>_</cite>
+changes the semantics of certain deductions of <cite>auto</cite> from a braced initializer
+list. Following the intent of the C++ committee, this change will be applied to
+our C++11 and C++14 modes as well as our experimental C++17 mode. Clang 3.6
+does not yet implement this change, but to provide a transition period, it
+warns on constructs whose meaning will change. The fix in all cases is to
+add an <cite>=</cite> prior to the left brace.</li>
+<li>Clang now supports putting identical constructors and destructors in
+the C5/D5 comdat, reducing code duplication.</li>
+<li>Clang will put individual <tt class="docutils literal"><span class="pre">.init_array/.ctors</span></tt> sections in
+comdats, reducing code duplication and speeding up startup.</li>
+</ul>
+<div class="section" id="c-17-feature-support">
+<h4>C++17 Feature Support<a class="headerlink" href="#c-17-feature-support" title="Permalink to this headline">¶</a></h4>
+<p>Clang has experimental support for some proposed C++1z (tentatively, C++17)
+features. This support can be enabled using the <cite>-std=c++1z</cite> flag.</p>
+<p>New in Clang 3.6 is support for:</p>
+<ul class="simple">
+<li>Fold expressions</li>
+<li><cite>u8</cite> character literals</li>
+<li>Nested namespace definitions: <cite>namespace A::B { ... }</cite> as a shorthand for
+<cite>namespace A { namespace B { ... } }</cite></li>
+<li>Attributes for namespaces and enumerators</li>
+<li>Constant evaluation for all non-type template arguments</li>
+</ul>
+<p>Note that these features may be changed or removed in future Clang releases
+without notice.</p>
+<p>Support for <cite>for (identifier : range)</cite> as a synonym for
+<cite>for (auto &&identifier : range)</cite> has been removed as it is no longer currently
+considered for C++17.</p>
+<p>For more details on C++ feature support, see
+<a class="reference external" href="http://clang.llvm.org/cxx_status.html">the C++ status page</a>.</p>
+</div>
+</div>
+<div class="section" id="openmp-language-changes-in-clang">
+<h3><a class="toc-backref" href="#id12">OpenMP Language Changes in Clang</a><a class="headerlink" href="#openmp-language-changes-in-clang" title="Permalink to this headline">¶</a></h3>
+<p>Clang 3.6 contains codegen for many individual OpenMP pragmas, but combinations are not completed yet.
+We plan to continue codegen code drop aiming for completion in 3.7. Please see this link for up-to-date
+<cite>status <https://github.com/clang-omp/clang/wiki/Status-of-supported-OpenMP-constructs>_</cite>.
+LLVM’s OpenMP runtime library, originally developed by Intel, has been modified to work on ARM, PowerPC,
+as well as X86. The Runtime Library’s compatibility with GCC 4.9 is improved
+- missed entry points added, barrier and fork/join code improved, one more type of barrier enabled.
+Support for ppc64le architecture is now available and automatically detected when using cmake system.
+Using makefile the new “ppc64le” arch type is available.
+Contributors to this work include AMD, Argonne National Lab., IBM, Intel, Texas Instruments, University of Houston and many others.</p>
+</div>
+</div>
+<div class="section" id="additional-information">
+<h2><a class="toc-backref" href="#id13">Additional Information</a><a class="headerlink" href="#additional-information" title="Permalink to this headline">¶</a></h2>
+<p>A wide variety of additional information is available on the <a class="reference external" href="http://clang.llvm.org/">Clang web
+page</a>. The web page contains versions of the
+API documentation which are up-to-date with the Subversion version of
+the source code. You can access versions of these documents specific to
+this release by going into the “<tt class="docutils literal"><span class="pre">clang/docs/</span></tt>” directory in the Clang
+tree.</p>
+<p>If you have any questions or comments about Clang, please feel free to
+contact us via the <a class="reference external" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">mailing
+list</a>.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="index.html">Using Clang as a Compiler</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="UsersManual.html">Clang Compiler User’s Manual</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/SanitizerSpecialCaseList.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/SanitizerSpecialCaseList.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/SanitizerSpecialCaseList.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/SanitizerSpecialCaseList.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,149 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Sanitizer special case list — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Modules" href="Modules.html" />
+    <link rel="prev" title="LeakSanitizer" href="LeakSanitizer.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Sanitizer special case list</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="LeakSanitizer.html">LeakSanitizer</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="Modules.html">Modules</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="sanitizer-special-case-list">
+<h1>Sanitizer special case list<a class="headerlink" href="#sanitizer-special-case-list" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id1">Introduction</a></li>
+<li><a class="reference internal" href="#goal-and-usage" id="id2">Goal and usage</a></li>
+<li><a class="reference internal" href="#example" id="id3">Example</a></li>
+<li><a class="reference internal" href="#format" id="id4">Format</a></li>
+</ul>
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id1">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>This document describes the way to disable or alter the behavior of
+sanitizer tools for certain source-level entities by providing a special
+file at compile-time.</p>
+</div>
+<div class="section" id="goal-and-usage">
+<h2><a class="toc-backref" href="#id2">Goal and usage</a><a class="headerlink" href="#goal-and-usage" title="Permalink to this headline">¶</a></h2>
+<p>User of sanitizer tools, such as <a class="reference internal" href="AddressSanitizer.html"><em>AddressSanitizer</em></a>, <a class="reference internal" href="ThreadSanitizer.html"><em>ThreadSanitizer</em></a>
+or <a class="reference internal" href="MemorySanitizer.html"><em>MemorySanitizer</em></a> may want to disable or alter some checks for
+certain source-level entities to:</p>
+<ul class="simple">
+<li>speedup hot function, which is known to be correct;</li>
+<li>ignore a function that does some low-level magic (e.g. walks through the
+thread stack, bypassing the frame boundaries);</li>
+<li>ignore a known problem.</li>
+</ul>
+<p>To achieve this, user may create a file listing the entities they want to
+ignore, and pass it to clang at compile-time using
+<tt class="docutils literal"><span class="pre">-fsanitize-blacklist</span></tt> flag. See <a class="reference internal" href="UsersManual.html"><em>Clang Compiler User’s Manual</em></a> for details.</p>
+</div>
+<div class="section" id="example">
+<h2><a class="toc-backref" href="#id3">Example</a><a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
+<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>cat foo.c
+<span class="c">#include <stdlib.h></span>
+void bad_foo<span class="o">()</span> <span class="o">{</span>
+  int *a <span class="o">=</span> <span class="o">(</span>int*<span class="o">)</span>malloc<span class="o">(</span>40<span class="o">)</span>;
+  a<span class="o">[</span>10<span class="o">]</span> <span class="o">=</span> 1;
+<span class="o">}</span>
+int main<span class="o">()</span> <span class="o">{</span> bad_foo<span class="o">()</span>; <span class="o">}</span>
+<span class="nv">$ </span>cat blacklist.txt
+<span class="c"># Ignore reports from bad_foo function.</span>
+fun:bad_foo
+<span class="nv">$ </span>clang -fsanitize<span class="o">=</span>address foo.c ; ./a.out
+<span class="c"># AddressSanitizer prints an error report.</span>
+<span class="nv">$ </span>clang -fsanitize<span class="o">=</span>address -fsanitize-blacklist<span class="o">=</span>blacklist.txt foo.c ; ./a.out
+<span class="c"># No error report here.</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="format">
+<h2><a class="toc-backref" href="#id4">Format</a><a class="headerlink" href="#format" title="Permalink to this headline">¶</a></h2>
+<p>Each line contains an entity type, followed by a colon and a regular
+expression, specifying the names of the entities, optionally followed by
+an equals sign and a tool-specific category. Empty lines and lines starting
+with “#” are ignored. The meanining of <tt class="docutils literal"><span class="pre">*</span></tt> in regular expression for entity
+names is different - it is treated as in shell wildcarding. Two generic
+entity types are <tt class="docutils literal"><span class="pre">src</span></tt> and <tt class="docutils literal"><span class="pre">fun</span></tt>, which allow user to add, respectively,
+source files and functions to special case list. Some sanitizer tools may
+introduce custom entity types - refer to tool-specific docs.</p>
+<div class="highlight-bash"><div class="highlight"><pre><span class="c"># Lines starting with # are ignored.</span>
+<span class="c"># Turn off checks for the source file (use absolute path or path relative</span>
+<span class="c"># to the current working directory):</span>
+src:/path/to/source/file.c
+<span class="c"># Turn off checks for a particular functions (use mangled names):</span>
+fun:MyFooBar
+fun:_Z8MyFooBarv
+<span class="c"># Extended regular expressions are supported:</span>
+fun:bad_<span class="o">(</span>foo|bar<span class="o">)</span>
+src:bad_source<span class="o">[</span>1-9<span class="o">]</span>.c
+<span class="c"># Shell like usage of * is supported (* is treated as .*):</span>
+src:bad/sources/*
+fun:*BadFunction*
+<span class="c"># Specific sanitizer tools may introduce categories.</span>
+src:/special/path/*<span class="o">=</span>special_sources
+</pre></div>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="LeakSanitizer.html">LeakSanitizer</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="Modules.html">Modules</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/ThreadSafetyAnalysis.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/ThreadSafetyAnalysis.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/ThreadSafetyAnalysis.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/ThreadSafetyAnalysis.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,911 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Thread Safety Analysis — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="AddressSanitizer" href="AddressSanitizer.html" />
+    <link rel="prev" title="Cross-compilation using Clang" href="CrossCompilation.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Thread Safety Analysis</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="CrossCompilation.html">Cross-compilation using Clang</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="AddressSanitizer.html">AddressSanitizer</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="thread-safety-analysis">
+<h1>Thread Safety Analysis<a class="headerlink" href="#thread-safety-analysis" title="Permalink to this headline">¶</a></h1>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>Clang Thread Safety Analysis is a C++ language extension which warns about
+potential race conditions in code.  The analysis is completely static (i.e.
+compile-time); there is no run-time overhead.  The analysis is still
+under active development, but it is mature enough to be deployed in an
+industrial setting.  It is being developed by Google, in collaboration with
+CERT/SEI, and is used extensively in Google’s internal code base.</p>
+<p>Thread safety analysis works very much like a type system for multi-threaded
+programs.  In addition to declaring the <em>type</em> of data (e.g. <tt class="docutils literal"><span class="pre">int</span></tt>, <tt class="docutils literal"><span class="pre">float</span></tt>,
+etc.), the programmer can (optionally) declare how access to that data is
+controlled in a multi-threaded environment.  For example, if <tt class="docutils literal"><span class="pre">foo</span></tt> is
+<em>guarded by</em> the mutex <tt class="docutils literal"><span class="pre">mu</span></tt>, then the analysis will issue a warning whenever
+a piece of code reads or writes to <tt class="docutils literal"><span class="pre">foo</span></tt> without first locking <tt class="docutils literal"><span class="pre">mu</span></tt>.
+Similarly, if there are particular routines that should only be called by
+the GUI thread, then the analysis will warn if other threads call those
+routines.</p>
+<div class="section" id="getting-started">
+<h3>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h3>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#include "mutex.h"</span>
+
+<span class="k">class</span> <span class="nc">BankAccount</span> <span class="p">{</span>
+<span class="nl">private:</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+  <span class="kt">int</span>   <span class="n">balance</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+
+  <span class="kt">void</span> <span class="nf">depositImpl</span><span class="p">(</span><span class="kt">int</span> <span class="n">amount</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">balance</span> <span class="o">+=</span> <span class="n">amount</span><span class="p">;</span>       <span class="c1">// WARNING! Cannot write balance without locking mu.</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">withdrawImpl</span><span class="p">(</span><span class="kt">int</span> <span class="n">amount</span><span class="p">)</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">balance</span> <span class="o">-=</span> <span class="n">amount</span><span class="p">;</span>       <span class="c1">// OK. Caller must have locked mu.</span>
+  <span class="p">}</span>
+
+<span class="nl">public:</span>
+  <span class="kt">void</span> <span class="nf">withdraw</span><span class="p">(</span><span class="kt">int</span> <span class="n">amount</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+    <span class="n">withdrawImpl</span><span class="p">(</span><span class="n">amount</span><span class="p">);</span>    <span class="c1">// OK.  We've locked mu.</span>
+  <span class="p">}</span>                          <span class="c1">// WARNING!  Failed to unlock mu.</span>
+
+  <span class="kt">void</span> <span class="nf">transferFrom</span><span class="p">(</span><span class="n">BankAccount</span><span class="o">&</span> <span class="n">b</span><span class="p">,</span> <span class="kt">int</span> <span class="n">amount</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+    <span class="n">b</span><span class="p">.</span><span class="n">withdrawImpl</span><span class="p">(</span><span class="n">amount</span><span class="p">);</span>  <span class="c1">// WARNING!  Calling withdrawImpl() requires locking b.mu.</span>
+    <span class="n">depositImpl</span><span class="p">(</span><span class="n">amount</span><span class="p">);</span>     <span class="c1">// OK.  depositImpl() has no requirements.</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="p">}</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>This example demonstrates the basic concepts behind the analysis.  The
+<tt class="docutils literal"><span class="pre">GUARDED_BY</span></tt> attribute declares that a thread must lock <tt class="docutils literal"><span class="pre">mu</span></tt> before it can
+read or write to <tt class="docutils literal"><span class="pre">balance</span></tt>, thus ensuring that the increment and decrement
+operations are atomic.  Similarly, <tt class="docutils literal"><span class="pre">REQUIRES</span></tt> declares that
+the calling thread must lock <tt class="docutils literal"><span class="pre">mu</span></tt> before calling <tt class="docutils literal"><span class="pre">withdrawImpl</span></tt>.
+Because the caller is assumed to have locked <tt class="docutils literal"><span class="pre">mu</span></tt>, it is safe to modify
+<tt class="docutils literal"><span class="pre">balance</span></tt> within the body of the method.</p>
+<p>The <tt class="docutils literal"><span class="pre">depositImpl()</span></tt> method does not have <tt class="docutils literal"><span class="pre">REQUIRES</span></tt>, so the
+analysis issues a warning.  Thread safety analysis is not inter-procedural, so
+caller requirements must be explicitly declared.
+There is also a warning in <tt class="docutils literal"><span class="pre">transferFrom()</span></tt>, because although the method
+locks <tt class="docutils literal"><span class="pre">this->mu</span></tt>, it does not lock <tt class="docutils literal"><span class="pre">b.mu</span></tt>.  The analysis understands
+that these are two separate mutexes, in two different objects.</p>
+<p>Finally, there is a warning in the <tt class="docutils literal"><span class="pre">withdraw()</span></tt> method, because it fails to
+unlock <tt class="docutils literal"><span class="pre">mu</span></tt>.  Every lock must have a corresponding unlock, and the analysis
+will detect both double locks, and double unlocks.  A function is allowed to
+acquire a lock without releasing it, (or vice versa), but it must be annotated
+as such (using <tt class="docutils literal"><span class="pre">ACQUIRE</span></tt>/<tt class="docutils literal"><span class="pre">RELEASE</span></tt>).</p>
+</div>
+<div class="section" id="running-the-analysis">
+<h3>Running The Analysis<a class="headerlink" href="#running-the-analysis" title="Permalink to this headline">¶</a></h3>
+<p>To run the analysis, simply compile with the <tt class="docutils literal"><span class="pre">-Wthread-safety</span></tt> flag, e.g.</p>
+<div class="highlight-bash"><div class="highlight"><pre>clang -c -Wthread-safety example.cpp
+</pre></div>
+</div>
+<p>Note that this example assumes the presence of a suitably annotated
+<a class="reference internal" href="#mutexheader"><em>mutex.h</em></a> that declares which methods perform locking,
+unlocking, and so on.</p>
+</div>
+</div>
+<div class="section" id="basic-concepts-capabilities">
+<h2>Basic Concepts: Capabilities<a class="headerlink" href="#basic-concepts-capabilities" title="Permalink to this headline">¶</a></h2>
+<p>Thread safety analysis provides a way of protecting <em>resources</em> with
+<em>capabilities</em>.  A resource is either a data member, or a function/method
+that provides access to some underlying resource.  The analysis ensures that
+the calling thread cannot access the <em>resource</em> (i.e. call the function, or
+read/write the data) unless it has the <em>capability</em> to do so.</p>
+<p>Capabilities are associated with named C++ objects which declare specific
+methods to acquire and release the capability.  The name of the object serves
+to identify the capability.  The most common example is a mutex.  For example,
+if <tt class="docutils literal"><span class="pre">mu</span></tt> is a mutex, then calling <tt class="docutils literal"><span class="pre">mu.Lock()</span></tt> causes the calling thread
+to acquire the capability to access data that is protected by <tt class="docutils literal"><span class="pre">mu</span></tt>. Similarly,
+calling <tt class="docutils literal"><span class="pre">mu.Unlock()</span></tt> releases that capability.</p>
+<p>A thread may hold a capability either <em>exclusively</em> or <em>shared</em>.  An exclusive
+capability can be held by only one thread at a time, while a shared capability
+can be held by many threads at the same time.  This mechanism enforces a
+multiple-reader, single-writer pattern.  Write operations to protected data
+require exclusive access, while read operations require only shared access.</p>
+<p>At any given moment during program execution, a thread holds a specific set of
+capabilities (e.g. the set of mutexes that it has locked.)  These act like keys
+or tokens that allow the thread to access a given resource.  Just like physical
+security keys, a thread cannot make copy of a capability, nor can it destroy
+one.  A thread can only release a capability to another thread, or acquire one
+from another thread.  The annotations are deliberately agnostic about the
+exact mechanism used to acquire and release capabilities; it assumes that the
+underlying implementation (e.g. the Mutex implementation) does the handoff in
+an appropriate manner.</p>
+<p>The set of capabilities that are actually held by a given thread at a given
+point in program execution is a run-time concept.  The static analysis works
+by calculating an approximation of that set, called the <em>capability
+environment</em>.  The capability environment is calculated for every program point,
+and describes the set of capabilities that are statically known to be held, or
+not held, at that particular point.  This environment is a conservative
+approximation of the full set of capabilities that will actually held by a
+thread at run-time.</p>
+</div>
+<div class="section" id="reference-guide">
+<h2>Reference Guide<a class="headerlink" href="#reference-guide" title="Permalink to this headline">¶</a></h2>
+<p>The thread safety analysis uses attributes to declare threading constraints.
+Attributes must be attached to named declarations, such as classes, methods,
+and data members. Users are <em>strongly advised</em> to define macros for the various
+attributes; example definitions can be found in <a class="reference internal" href="#mutexheader"><em>mutex.h</em></a>, below.
+The following documentation assumes the use of macros.</p>
+<p>For historical reasons, prior versions of thread safety used macro names that
+were very lock-centric.  These macros have since been renamed to fit a more
+general capability model.  The prior names are still in use, and will be
+mentioned under the tag <em>previously</em> where appropriate.</p>
+<div class="section" id="guarded-by-c-and-pt-guarded-by-c">
+<h3>GUARDED_BY(c) and PT_GUARDED_BY(c)<a class="headerlink" href="#guarded-by-c-and-pt-guarded-by-c" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">GUARDED_BY</span></tt> is an attribute on data members, which declares that the data
+member is protected by the given capability.  Read operations on the data
+require shared access, while write operations require exclusive access.</p>
+<p><tt class="docutils literal"><span class="pre">PT_GUARDED_BY</span></tt> is similar, but is intended for use on pointers and smart
+pointers. There is no constraint on the data member itself, but the <em>data that
+it points to</em> is protected by the given capability.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+<span class="kt">int</span> <span class="o">*</span><span class="n">p1</span>             <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+<span class="kt">int</span> <span class="o">*</span><span class="n">p2</span>             <span class="nf">PT_GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+<span class="n">unique_ptr</span><span class="o"><</span><span class="kt">int</span><span class="o">></span> <span class="n">p3</span>  <span class="n">PT_GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+
+<span class="kt">void</span> <span class="nf">test</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">p1</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>             <span class="c1">// Warning!</span>
+
+  <span class="o">*</span><span class="n">p2</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>           <span class="c1">// Warning!</span>
+  <span class="n">p2</span> <span class="o">=</span> <span class="k">new</span> <span class="kt">int</span><span class="p">;</span>       <span class="c1">// OK.</span>
+
+  <span class="o">*</span><span class="n">p3</span> <span class="o">=</span> <span class="mi">42</span><span class="p">;</span>           <span class="c1">// Warning!</span>
+  <span class="n">p3</span><span class="p">.</span><span class="n">reset</span><span class="p">(</span><span class="k">new</span> <span class="kt">int</span><span class="p">);</span>  <span class="c1">// OK.</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="requires-requires-shared">
+<h3>REQUIRES(...), REQUIRES_SHARED(...)<a class="headerlink" href="#requires-requires-shared" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously</em>: <tt class="docutils literal"><span class="pre">EXCLUSIVE_LOCKS_REQUIRED</span></tt>, <tt class="docutils literal"><span class="pre">SHARED_LOCKS_REQUIRED</span></tt></p>
+<p><tt class="docutils literal"><span class="pre">REQUIRES</span></tt> is an attribute on functions or methods, which
+declares that the calling thread must have exclusive access to the given
+capabilities.  More than one capability may be specified.  The capabilities
+must be held on entry to the function, <em>and must still be held on exit</em>.</p>
+<p><tt class="docutils literal"><span class="pre">REQUIRES_SHARED</span></tt> is similar, but requires only shared access.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Mutex</span> <span class="n">mu1</span><span class="p">,</span> <span class="n">mu2</span><span class="p">;</span>
+<span class="kt">int</span> <span class="n">a</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu1</span><span class="p">);</span>
+<span class="kt">int</span> <span class="n">b</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu2</span><span class="p">);</span>
+
+<span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">mu1</span><span class="p">,</span> <span class="n">mu2</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">a</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+  <span class="n">b</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+<span class="p">}</span>
+
+<span class="kt">void</span> <span class="nf">test</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">mu1</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="n">foo</span><span class="p">();</span>         <span class="c1">// Warning!  Requires mu2.</span>
+  <span class="n">mu1</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="acquire-acquire-shared-release-release-shared">
+<h3>ACQUIRE(...), ACQUIRE_SHARED(...), RELEASE(...), RELEASE_SHARED(...)<a class="headerlink" href="#acquire-acquire-shared-release-release-shared" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously</em>: <tt class="docutils literal"><span class="pre">EXCLUSIVE_LOCK_FUNCTION</span></tt>, <tt class="docutils literal"><span class="pre">SHARED_LOCK_FUNCTION</span></tt>,
+<tt class="docutils literal"><span class="pre">UNLOCK_FUNCTION</span></tt></p>
+<p><tt class="docutils literal"><span class="pre">ACQUIRE</span></tt> is an attribute on functions or methods, which
+declares that the function acquires a capability, but does not release it.  The
+caller must not hold the given capability on entry, and it will hold the
+capability on exit.  <tt class="docutils literal"><span class="pre">ACQUIRE_SHARED</span></tt> is similar.</p>
+<p><tt class="docutils literal"><span class="pre">RELEASE</span></tt> and <tt class="docutils literal"><span class="pre">RELEASE_SHARED</span></tt> declare that the function releases the given
+capability.  The caller must hold the capability on entry, and will no longer
+hold it on exit. It does not matter whether the given capability is shared or
+exclusive.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+<span class="n">MyClass</span> <span class="n">myObject</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+
+<span class="kt">void</span> <span class="nf">lockAndInit</span><span class="p">()</span> <span class="n">ACQUIRE</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="n">myObject</span><span class="p">.</span><span class="n">init</span><span class="p">();</span>
+<span class="p">}</span>
+
+<span class="kt">void</span> <span class="nf">cleanupAndUnlock</span><span class="p">()</span> <span class="n">RELEASE</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">myObject</span><span class="p">.</span><span class="n">cleanup</span><span class="p">();</span>
+<span class="p">}</span>                          <span class="c1">// Warning!  Need to unlock mu.</span>
+
+<span class="kt">void</span> <span class="nf">test</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">lockAndInit</span><span class="p">();</span>
+  <span class="n">myObject</span><span class="p">.</span><span class="n">doSomething</span><span class="p">();</span>
+  <span class="n">cleanupAndUnlock</span><span class="p">();</span>
+  <span class="n">myObject</span><span class="p">.</span><span class="n">doSomething</span><span class="p">();</span>  <span class="c1">// Warning, mu is not locked.</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>If no argument is passed to <tt class="docutils literal"><span class="pre">ACQUIRE</span></tt> or <tt class="docutils literal"><span class="pre">RELEASE</span></tt>, then the argument is
+assumed to be <tt class="docutils literal"><span class="pre">this</span></tt>, and the analysis will not check the body of the
+function.  This pattern is intended for use by classes which hide locking
+details behind an abstract interface.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o"><</span><span class="k">class</span> <span class="nc">T</span><span class="o">></span>
+<span class="k">class</span> <span class="nc">CAPABILITY</span><span class="p">(</span><span class="s">"mutex"</span><span class="p">)</span> <span class="n">Container</span> <span class="p">{</span>
+<span class="nl">private:</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+  <span class="n">T</span><span class="o">*</span> <span class="n">data</span><span class="p">;</span>
+
+<span class="nl">public:</span>
+  <span class="c1">// Hide mu from public interface.</span>
+  <span class="kt">void</span> <span class="nf">Lock</span><span class="p">()</span>   <span class="n">ACQUIRE</span><span class="p">()</span> <span class="p">{</span> <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span> <span class="p">}</span>
+  <span class="kt">void</span> <span class="nf">Unlock</span><span class="p">()</span> <span class="n">RELEASE</span><span class="p">()</span> <span class="p">{</span> <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span> <span class="p">}</span>
+
+  <span class="n">T</span><span class="o">&</span> <span class="n">getElem</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">];</span> <span class="p">}</span>
+<span class="p">};</span>
+
+<span class="kt">void</span> <span class="nf">test</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">Container</span><span class="o"><</span><span class="kt">int</span><span class="o">></span> <span class="n">c</span><span class="p">;</span>
+  <span class="n">c</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">c</span><span class="p">.</span><span class="n">getElem</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
+  <span class="n">c</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="excludes">
+<h3>EXCLUDES(...)<a class="headerlink" href="#excludes" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously</em>: <tt class="docutils literal"><span class="pre">LOCKS_EXCLUDED</span></tt></p>
+<p><tt class="docutils literal"><span class="pre">EXCLUDES</span></tt> is an attribute on functions or methods, which declares that
+the caller must <em>not</em> hold the given capabilities.  This annotation is
+used to prevent deadlock.  Many mutex implementations are not re-entrant, so
+deadlock can occur if the function acquires the mutex a second time.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+<span class="kt">int</span> <span class="n">a</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+
+<span class="kt">void</span> <span class="nf">clear</span><span class="p">()</span> <span class="n">EXCLUDES</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span>
+  <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="n">a</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
+  <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+<span class="p">}</span>
+
+<span class="kt">void</span> <span class="nf">reset</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="n">clear</span><span class="p">();</span>     <span class="c1">// Warning!  Caller cannot hold 'mu'.</span>
+  <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>Unlike <tt class="docutils literal"><span class="pre">REQUIRES</span></tt>, <tt class="docutils literal"><span class="pre">EXCLUDES</span></tt> is optional.  The analysis will not issue a
+warning if the attribute is missing, which can lead to false negatives in some
+cases.  This issue is discussed further in <a class="reference internal" href="#negative"><em>Negative Capabilities</em></a>.</p>
+</div>
+<div class="section" id="no-thread-safety-analysis">
+<h3>NO_THREAD_SAFETY_ANALYSIS<a class="headerlink" href="#no-thread-safety-analysis" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">NO_THREAD_SAFETY_ANALYSIS</span></tt> is an attribute on functions or methods, which
+turns off thread safety checking for that method.  It provides an escape hatch
+for functions which are either (1) deliberately thread-unsafe, or (2) are
+thread-safe, but too complicated for the analysis to understand.  Reasons for
+(2) will be described in the <a class="reference internal" href="#limitations"><em>Known Limitations</em></a>, below.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Counter</span> <span class="p">{</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+  <span class="kt">int</span> <span class="n">a</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+
+  <span class="kt">void</span> <span class="n">unsafeIncrement</span><span class="p">()</span> <span class="n">NO_THREAD_SAFETY_ANALYSIS</span> <span class="p">{</span> <span class="n">a</span><span class="o">++</span><span class="p">;</span> <span class="p">}</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>Unlike the other attributes, NO_THREAD_SAFETY_ANALYSIS is not part of the
+interface of a function, and should thus be placed on the function definition
+(in the <tt class="docutils literal"><span class="pre">.cc</span></tt> or <tt class="docutils literal"><span class="pre">.cpp</span></tt> file) rather than on the function declaration
+(in the header).</p>
+</div>
+<div class="section" id="return-capability-c">
+<h3>RETURN_CAPABILITY(c)<a class="headerlink" href="#return-capability-c" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously</em>: <tt class="docutils literal"><span class="pre">LOCK_RETURNED</span></tt></p>
+<p><tt class="docutils literal"><span class="pre">RETURN_CAPABILITY</span></tt> is an attribute on functions or methods, which declares
+that the function returns a reference to the given capability.  It is used to
+annotate getter methods that return mutexes.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyClass</span> <span class="p">{</span>
+<span class="nl">private:</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+  <span class="kt">int</span> <span class="n">a</span> <span class="nf">GUARDED_BY</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+
+<span class="nl">public:</span>
+  <span class="n">Mutex</span><span class="o">*</span> <span class="nf">getMu</span><span class="p">()</span> <span class="n">RETURN_CAPABILITY</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="o">&</span><span class="n">mu</span><span class="p">;</span> <span class="p">}</span>
+
+  <span class="c1">// analysis knows that getMu() == mu</span>
+  <span class="kt">void</span> <span class="nf">clear</span><span class="p">()</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">getMu</span><span class="p">())</span> <span class="p">{</span> <span class="n">a</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="acquired-before-acquired-after">
+<h3>ACQUIRED_BEFORE(...), ACQUIRED_AFTER(...)<a class="headerlink" href="#acquired-before-acquired-after" title="Permalink to this headline">¶</a></h3>
+<p><tt class="docutils literal"><span class="pre">ACQUIRED_BEFORE</span></tt> and <tt class="docutils literal"><span class="pre">ACQUIRED_AFTER</span></tt> are attributes on member
+declarations, specifically declarations of mutexes or other capabilities.
+These declarations enforce a particular order in which the mutexes must be
+acquired, in order to prevent deadlock.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="n">Mutex</span> <span class="n">m1</span><span class="p">;</span>
+<span class="n">Mutex</span> <span class="n">m2</span> <span class="nf">ACQUIRED_AFTER</span><span class="p">(</span><span class="n">m1</span><span class="p">);</span>
+
+<span class="c1">// Alternative declaration</span>
+<span class="c1">// Mutex m2;</span>
+<span class="c1">// Mutex m1 ACQUIRED_BEFORE(m2);</span>
+
+<span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">m2</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="n">m1</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>  <span class="c1">// Warning!  m2 must be acquired after m1.</span>
+  <span class="n">m1</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="n">m2</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="capability-string">
+<h3>CAPABILITY(<string>)<a class="headerlink" href="#capability-string" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously</em>: <tt class="docutils literal"><span class="pre">LOCKABLE</span></tt></p>
+<p><tt class="docutils literal"><span class="pre">CAPABILITY</span></tt> is an attribute on classes, which specifies that objects of the
+class can be used as a capability.  The string argument specifies the kind of
+capability in error messages, e.g. <tt class="docutils literal"><span class="pre">"mutex"</span></tt>.  See the <tt class="docutils literal"><span class="pre">Container</span></tt> example
+given above, or the <tt class="docutils literal"><span class="pre">Mutex</span></tt> class in <a class="reference internal" href="#mutexheader"><em>mutex.h</em></a>.</p>
+</div>
+<div class="section" id="scoped-capability">
+<h3>SCOPED_CAPABILITY<a class="headerlink" href="#scoped-capability" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously</em>: <tt class="docutils literal"><span class="pre">SCOPED_LOCKABLE</span></tt></p>
+<p><tt class="docutils literal"><span class="pre">SCOPED_CAPABILITY</span></tt> is an attribute on classes that implement RAII-style
+locking, in which a capability is acquired in the constructor, and released in
+the destructor.  Such classes require special handling because the constructor
+and destructor refer to the capability via different names; see the
+<tt class="docutils literal"><span class="pre">MutexLocker</span></tt> class in <a class="reference internal" href="#mutexheader"><em>mutex.h</em></a>, below.</p>
+</div>
+<div class="section" id="try-acquire-bool-try-acquire-shared-bool">
+<h3>TRY_ACQUIRE(<bool>, ...), TRY_ACQUIRE_SHARED(<bool>, ...)<a class="headerlink" href="#try-acquire-bool-try-acquire-shared-bool" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously:</em> <tt class="docutils literal"><span class="pre">EXCLUSIVE_TRYLOCK_FUNCTION</span></tt>, <tt class="docutils literal"><span class="pre">SHARED_TRYLOCK_FUNCTION</span></tt></p>
+<p>These are attributes on a function or method that tries to acquire the given
+capability, and returns a boolean value indicating success or failure.
+The first argument must be <tt class="docutils literal"><span class="pre">true</span></tt> or <tt class="docutils literal"><span class="pre">false</span></tt>, to specify which return value
+indicates success, and the remaining arguments are interpreted in the same way
+as <tt class="docutils literal"><span class="pre">ACQUIRE</span></tt>.  See <a class="reference internal" href="#mutexheader"><em>mutex.h</em></a>, below, for example uses.</p>
+</div>
+<div class="section" id="assert-capability-and-assert-shared-capability">
+<h3>ASSERT_CAPABILITY(...) and ASSERT_SHARED_CAPABILITY(...)<a class="headerlink" href="#assert-capability-and-assert-shared-capability" title="Permalink to this headline">¶</a></h3>
+<p><em>Previously:</em>  <tt class="docutils literal"><span class="pre">ASSERT_EXCLUSIVE_LOCK</span></tt>, <tt class="docutils literal"><span class="pre">ASSERT_SHARED_LOCK</span></tt></p>
+<p>These are attributes on a function or method that does a run-time test to see
+whether the calling thread holds the given capability.  The function is assumed
+to fail (no return) if the capability is not held.  See <a class="reference internal" href="#mutexheader"><em>mutex.h</em></a>,
+below, for example uses.</p>
+</div>
+<div class="section" id="guarded-var-and-pt-guarded-var">
+<h3>GUARDED_VAR and PT_GUARDED_VAR<a class="headerlink" href="#guarded-var-and-pt-guarded-var" title="Permalink to this headline">¶</a></h3>
+<p>Use of these attributes has been deprecated.</p>
+</div>
+<div class="section" id="warning-flags">
+<h3>Warning flags<a class="headerlink" href="#warning-flags" title="Permalink to this headline">¶</a></h3>
+<ul>
+<li><p class="first"><tt class="docutils literal"><span class="pre">-Wthread-safety</span></tt>:  Umbrella flag which turns on the following three:</p>
+<ul>
+<li><p class="first"><tt class="docutils literal"><span class="pre">-Wthread-safety-attributes</span></tt>: Sanity checks on attribute syntax.</p>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">-Wthread-safety-analysis</span></tt>: The core analysis.</p>
+</li>
+<li><dl class="first docutils">
+<dt><tt class="docutils literal"><span class="pre">-Wthread-safety-precise</span></tt>: Requires that mutex expressions match precisely.</dt>
+<dd><p class="first last">This warning can be disabled for code which has a lot of aliases.</p>
+</dd>
+</dl>
+</li>
+<li><p class="first"><tt class="docutils literal"><span class="pre">-Wthread-safety-reference</span></tt>: Checks when guarded members are passed by reference.</p>
+</li>
+</ul>
+</li>
+</ul>
+<p><a class="reference internal" href="#negative"><em>Negative Capabilities</em></a> are an experimental feature, which are enabled with:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">-Wthread-safety-negative</span></tt>:  Negative capabilities.  Off by default.</li>
+</ul>
+<p>When new features and checks are added to the analysis, they can often introduce
+additional warnings.  Those warnings are initially released as <em>beta</em> warnings
+for a period of time, after which they are migrated into the standard analysis.</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">-Wthread-safety-beta</span></tt>:  New features.  Off by default.</li>
+</ul>
+</div>
+</div>
+<div class="section" id="negative-capabilities">
+<span id="negative"></span><h2>Negative Capabilities<a class="headerlink" href="#negative-capabilities" title="Permalink to this headline">¶</a></h2>
+<p>Thread Safety Analysis is designed to prevent both race conditions and
+deadlock.  The GUARDED_BY and REQUIRES attributes prevent race conditions, by
+ensuring that a capability is held before reading or writing to guarded data,
+and the EXCLUDES attribute prevents deadlock, by making sure that a mutex is
+<em>not</em> held.</p>
+<p>However, EXCLUDES is an optional attribute, and does not provide the same
+safety guarantee as REQUIRES.  In particular:</p>
+<blockquote>
+<div><ul class="simple">
+<li>A function which acquires a capability does not have to exclude it.</li>
+<li>A function which calls a function that excludes a capability does not
+have transitively exclude that capability.</li>
+</ul>
+</div></blockquote>
+<p>As a result, EXCLUDES can easily produce false negatives:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Foo</span> <span class="p">{</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+
+  <span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+    <span class="n">bar</span><span class="p">();</span>           <span class="c1">// No warning.</span>
+    <span class="n">baz</span><span class="p">();</span>           <span class="c1">// No warning.</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">bar</span><span class="p">()</span> <span class="p">{</span>       <span class="c1">// No warning.  (Should have EXCLUDES(mu)).</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+    <span class="c1">// ...</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">baz</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">bif</span><span class="p">();</span>           <span class="c1">// No warning.  (Should have EXCLUDES(mu)).</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">bif</span><span class="p">()</span> <span class="n">EXCLUDES</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>Negative requirements are an alternative EXCLUDES that provide
+a stronger safety guarantee.  A negative requirement uses the  REQUIRES
+attribute, in conjunction with the <tt class="docutils literal"><span class="pre">!</span></tt> operator, to indicate that a capability
+should <em>not</em> be held.</p>
+<p>For example, using <tt class="docutils literal"><span class="pre">REQUIRES(!mu)</span></tt> instead of <tt class="docutils literal"><span class="pre">EXCLUDES(mu)</span></tt> will produce
+the appropriate warnings:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">FooNeg</span> <span class="p">{</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+
+  <span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="o">!</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span>   <span class="c1">// foo() now requires !mu.</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+    <span class="n">bar</span><span class="p">();</span>
+    <span class="n">baz</span><span class="p">();</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">bar</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>       <span class="c1">// WARNING!  Missing REQUIRES(!mu).</span>
+    <span class="c1">// ...</span>
+    <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">baz</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">bif</span><span class="p">();</span>           <span class="c1">// WARNING!  Missing REQUIRES(!mu).</span>
+  <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">bif</span><span class="p">()</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="o">!</span><span class="n">mu</span><span class="p">);</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+<p>Negative requirements are an experimental feature which is off by default,
+because it will produce many warnings in existing code.  It can be enabled
+by passing <tt class="docutils literal"><span class="pre">-Wthread-safety-negative</span></tt>.</p>
+</div>
+<div class="section" id="frequently-asked-questions">
+<span id="faq"></span><h2>Frequently Asked Questions<a class="headerlink" href="#frequently-asked-questions" title="Permalink to this headline">¶</a></h2>
+<ol class="upperalpha simple" start="17">
+<li>Should I put attributes in the header file, or in the .cc/.cpp/.cxx file?</li>
+</ol>
+<p>(A) Attributes are part of the formal interface of a function, and should
+always go in the header, where they are visible to anything that includes
+the header.  Attributes in the .cpp file are not visible outside of the
+immediate translation unit, which leads to false negatives and false positives.</p>
+<ol class="upperalpha simple" start="17">
+<li>“<em>Mutex is not locked on every path through here?</em>”  What does that mean?</li>
+</ol>
+<ol class="upperalpha simple">
+<li>See <a class="reference internal" href="#conditional-locks"><em>No conditionally held locks.</em></a>, below.</li>
+</ol>
+</div>
+<div class="section" id="known-limitations">
+<span id="limitations"></span><h2>Known Limitations<a class="headerlink" href="#known-limitations" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="lexical-scope">
+<h3>Lexical scope<a class="headerlink" href="#lexical-scope" title="Permalink to this headline">¶</a></h3>
+<p>Thread safety attributes contain ordinary C++ expressions, and thus follow
+ordinary C++ scoping rules.  In particular, this means that mutexes and other
+capabilities must be declared before they can be used in an attribute.
+Use-before-declaration is okay within a single class, because attributes are
+parsed at the same time as method bodies. (C++ delays parsing of method bodies
+until the end of the class.)  However, use-before-declaration is not allowed
+between classes, as illustrated below.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Foo</span><span class="p">;</span>
+
+<span class="k">class</span> <span class="nc">Bar</span> <span class="p">{</span>
+  <span class="kt">void</span> <span class="n">bar</span><span class="p">(</span><span class="n">Foo</span><span class="o">*</span> <span class="n">f</span><span class="p">)</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">f</span><span class="o">-></span><span class="n">mu</span><span class="p">);</span>  <span class="c1">// Error: mu undeclared.</span>
+<span class="p">};</span>
+
+<span class="k">class</span> <span class="nc">Foo</span> <span class="p">{</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+<span class="p">};</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="private-mutexes">
+<h3>Private Mutexes<a class="headerlink" href="#private-mutexes" title="Permalink to this headline">¶</a></h3>
+<p>Good software engineering practice dictates that mutexes should be private
+members, because the locking mechanism used by a thread-safe class is part of
+its internal implementation.  However, private mutexes can sometimes leak into
+the public interface of a class.
+Thread safety attributes follow normal C++ access restrictions, so if <tt class="docutils literal"><span class="pre">mu</span></tt>
+is a private member of <tt class="docutils literal"><span class="pre">c</span></tt>, then it is an error to write <tt class="docutils literal"><span class="pre">c.mu</span></tt> in an
+attribute.</p>
+<p>One workaround is to (ab)use the <tt class="docutils literal"><span class="pre">RETURN_CAPABILITY</span></tt> attribute to provide a
+public <em>name</em> for a private mutex, without actually exposing the underlying
+mutex.  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MyClass</span> <span class="p">{</span>
+<span class="nl">private:</span>
+  <span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+
+<span class="nl">public:</span>
+  <span class="c1">// For thread safety analysis only.  Does not actually return mu.</span>
+  <span class="n">Mutex</span><span class="o">*</span> <span class="nf">getMu</span><span class="p">()</span> <span class="n">RETURN_CAPABILITY</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">}</span>
+
+  <span class="kt">void</span> <span class="nf">doSomething</span><span class="p">()</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">mu</span><span class="p">);</span>
+<span class="p">};</span>
+
+<span class="kt">void</span> <span class="nf">doSomethingTwice</span><span class="p">(</span><span class="n">MyClass</span><span class="o">&</span> <span class="n">c</span><span class="p">)</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">c</span><span class="p">.</span><span class="n">getMu</span><span class="p">())</span> <span class="p">{</span>
+  <span class="c1">// The analysis thinks that c.getMu() == c.mu</span>
+  <span class="n">c</span><span class="p">.</span><span class="n">doSomething</span><span class="p">();</span>
+  <span class="n">c</span><span class="p">.</span><span class="n">doSomething</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>In the above example, <tt class="docutils literal"><span class="pre">doSomethingTwice()</span></tt> is an external routine that
+requires <tt class="docutils literal"><span class="pre">c.mu</span></tt> to be locked, which cannot be declared directly because <tt class="docutils literal"><span class="pre">mu</span></tt>
+is private.  This pattern is discouraged because it
+violates encapsulation, but it is sometimes necessary, especially when adding
+annotations to an existing code base.  The workaround is to define <tt class="docutils literal"><span class="pre">getMu()</span></tt>
+as a fake getter method, which is provided only for the benefit of thread
+safety analysis.</p>
+</div>
+<div class="section" id="no-conditionally-held-locks">
+<span id="conditional-locks"></span><h3>No conditionally held locks.<a class="headerlink" href="#no-conditionally-held-locks" title="Permalink to this headline">¶</a></h3>
+<p>The analysis must be able to determine whether a lock is held, or not held, at
+every program point.  Thus, sections of code where a lock <em>might be held</em> will
+generate spurious warnings (false positives).  For example:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span> <span class="p">{</span>
+  <span class="kt">bool</span> <span class="n">b</span> <span class="o">=</span> <span class="n">needsToLock</span><span class="p">();</span>
+  <span class="k">if</span> <span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="p">...</span>  <span class="c1">// Warning!  Mutex 'mu' is not held on every path through here.</span>
+  <span class="k">if</span> <span class="p">(</span><span class="n">b</span><span class="p">)</span> <span class="n">mu</span><span class="p">.</span><span class="n">Unlock</span><span class="p">();</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="no-checking-inside-constructors-and-destructors">
+<h3>No checking inside constructors and destructors.<a class="headerlink" href="#no-checking-inside-constructors-and-destructors" title="Permalink to this headline">¶</a></h3>
+<p>The analysis currently does not do any checking inside constructors or
+destructors.  In other words, every constructor and destructor is treated as
+if it was annotated with <tt class="docutils literal"><span class="pre">NO_THREAD_SAFETY_ANALYSIS</span></tt>.
+The reason for this is that during initialization, only one thread typically
+has access to the object which is being initialized, and it is thus safe (and
+common practice) to initialize guarded members without acquiring any locks.
+The same is true of destructors.</p>
+<p>Ideally, the analysis would allow initialization of guarded members inside the
+object being initialized or destroyed, while still enforcing the usual access
+restrictions on everything else.  However, this is difficult to enforce in
+practice, because in complex pointer-based data structures, it is hard to
+determine what data is owned by the enclosing object.</p>
+</div>
+<div class="section" id="no-inlining">
+<h3>No inlining.<a class="headerlink" href="#no-inlining" title="Permalink to this headline">¶</a></h3>
+<p>Thread safety analysis is strictly intra-procedural, just like ordinary type
+checking.  It relies only on the declared attributes of a function, and will
+not attempt to inline any method calls.  As a result, code such as the
+following will not work:</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span><span class="o"><</span><span class="k">class</span> <span class="nc">T</span><span class="o">></span>
+<span class="k">class</span> <span class="nc">AutoCleanup</span> <span class="p">{</span>
+  <span class="n">T</span><span class="o">*</span> <span class="n">object</span><span class="p">;</span>
+  <span class="kt">void</span> <span class="p">(</span><span class="n">T</span><span class="o">::*</span><span class="n">mp</span><span class="p">)();</span>
+
+<span class="nl">public:</span>
+  <span class="n">AutoCleanup</span><span class="p">(</span><span class="n">T</span><span class="o">*</span> <span class="n">obj</span><span class="p">,</span> <span class="kt">void</span> <span class="p">(</span><span class="n">T</span><span class="o">::*</span><span class="n">imp</span><span class="p">)())</span> <span class="o">:</span> <span class="n">object</span><span class="p">(</span><span class="n">obj</span><span class="p">),</span> <span class="n">mp</span><span class="p">(</span><span class="n">imp</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span>
+  <span class="o">~</span><span class="n">AutoCleanup</span><span class="p">()</span> <span class="p">{</span> <span class="p">(</span><span class="n">object</span><span class="o">->*</span><span class="n">mp</span><span class="p">)();</span> <span class="p">}</span>
+<span class="p">};</span>
+
+<span class="n">Mutex</span> <span class="n">mu</span><span class="p">;</span>
+<span class="kt">void</span> <span class="nf">foo</span><span class="p">()</span> <span class="p">{</span>
+  <span class="n">mu</span><span class="p">.</span><span class="n">Lock</span><span class="p">();</span>
+  <span class="n">AutoCleanup</span><span class="o"><</span><span class="n">Mutex</span><span class="o">></span><span class="p">(</span><span class="o">&</span><span class="n">mu</span><span class="p">,</span> <span class="o">&</span><span class="n">Mutex</span><span class="o">::</span><span class="n">Unlock</span><span class="p">);</span>
+  <span class="c1">// ...</span>
+<span class="p">}</span>  <span class="c1">// Warning, mu is not unlocked.</span>
+</pre></div>
+</div>
+<p>In this case, the destructor of <tt class="docutils literal"><span class="pre">Autocleanup</span></tt> calls <tt class="docutils literal"><span class="pre">mu.Unlock()</span></tt>, so
+the warning is bogus.  However,
+thread safety analysis cannot see the unlock, because it does not attempt to
+inline the destructor.  Moreover, there is no way to annotate the destructor,
+because the destructor is calling a function that is not statically known.
+This pattern is simply not supported.</p>
+</div>
+<div class="section" id="no-alias-analysis">
+<h3>No alias analysis.<a class="headerlink" href="#no-alias-analysis" title="Permalink to this headline">¶</a></h3>
+<p>The analysis currently does not track pointer aliases.  Thus, there can be
+false positives if two pointers both point to the same mutex.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">MutexUnlocker</span> <span class="p">{</span>
+  <span class="n">Mutex</span><span class="o">*</span> <span class="n">mu</span><span class="p">;</span>
+
+<span class="nl">public:</span>
+  <span class="n">MutexUnlocker</span><span class="p">(</span><span class="n">Mutex</span><span class="o">*</span> <span class="n">m</span><span class="p">)</span> <span class="n">RELEASE</span><span class="p">(</span><span class="n">m</span><span class="p">)</span> <span class="o">:</span> <span class="n">mu</span><span class="p">(</span><span class="n">m</span><span class="p">)</span>  <span class="p">{</span> <span class="n">mu</span><span class="o">-></span><span class="n">Unlock</span><span class="p">();</span> <span class="p">}</span>
+  <span class="o">~</span><span class="n">MutexUnlocker</span><span class="p">()</span> <span class="n">ACQUIRE</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span> <span class="n">mu</span><span class="o">-></span><span class="n">Lock</span><span class="p">();</span> <span class="p">}</span>
+<span class="p">};</span>
+
+<span class="n">Mutex</span> <span class="n">mutex</span><span class="p">;</span>
+<span class="kt">void</span> <span class="nf">test</span><span class="p">()</span> <span class="n">REQUIRES</span><span class="p">(</span><span class="n">mutex</span><span class="p">)</span> <span class="p">{</span>
+  <span class="p">{</span>
+    <span class="n">MutexUnlocker</span> <span class="n">munl</span><span class="p">(</span><span class="o">&</span><span class="n">mutex</span><span class="p">);</span>  <span class="c1">// unlocks mutex</span>
+    <span class="n">doSomeIO</span><span class="p">();</span>
+  <span class="p">}</span>                              <span class="c1">// Warning: locks munl.mu</span>
+<span class="p">}</span>
+</pre></div>
+</div>
+<p>The MutexUnlocker class is intended to be the dual of the MutexLocker class,
+defined in <a class="reference internal" href="#mutexheader"><em>mutex.h</em></a>.  However, it doesn’t work because the analysis
+doesn’t know that munl.mu == mutex.  The SCOPED_CAPABILITY attribute handles
+aliasing for MutexLocker, but does so only for that particular pattern.</p>
+</div>
+<div class="section" id="acquired-before-and-acquired-after-are-currently-unimplemented">
+<h3>ACQUIRED_BEFORE(...) and ACQUIRED_AFTER(...) are currently unimplemented.<a class="headerlink" href="#acquired-before-and-acquired-after-are-currently-unimplemented" title="Permalink to this headline">¶</a></h3>
+<p>To be fixed in a future update.</p>
+</div>
+</div>
+<div class="section" id="mutex-h">
+<span id="mutexheader"></span><h2>mutex.h<a class="headerlink" href="#mutex-h" title="Permalink to this headline">¶</a></h2>
+<p>Thread safety analysis can be used with any threading library, but it does
+require that the threading API be wrapped in classes and methods which have the
+appropriate annotations.  The following code provides <tt class="docutils literal"><span class="pre">mutex.h</span></tt> as an example;
+these methods should be filled in to call the appropriate underlying
+implementation.</p>
+<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#ifndef THREAD_SAFETY_ANALYSIS_MUTEX_H</span>
+<span class="cp">#define THREAD_SAFETY_ANALYSIS_MUTEX_H</span>
+
+<span class="c1">// Enable thread safety attributes only with clang.</span>
+<span class="c1">// The attributes can be safely erased when compiling with other compilers.</span>
+<span class="cp">#if defined(__clang__) && (!defined(SWIG))</span>
+<span class="cp">#define THREAD_ANNOTATION_ATTRIBUTE__(x)   __attribute__((x))</span>
+<span class="cp">#else</span>
+<span class="cp">#define THREAD_ANNOTATION_ATTRIBUTE__(x)   </span><span class="c1">// no-op</span>
+<span class="cp">#endif</span>
+
+<span class="cp">#define THREAD_ANNOTATION_ATTRIBUTE__(x)   __attribute__((x))</span>
+
+<span class="cp">#define CAPABILITY(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(capability(x))</span>
+
+<span class="cp">#define SCOPED_CAPABILITY \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)</span>
+
+<span class="cp">#define GUARDED_BY(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))</span>
+
+<span class="cp">#define PT_GUARDED_BY(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))</span>
+
+<span class="cp">#define ACQUIRED_BEFORE(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))</span>
+
+<span class="cp">#define ACQUIRED_AFTER(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))</span>
+
+<span class="cp">#define REQUIRES(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define REQUIRES_SHARED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define ACQUIRE(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define ACQUIRE_SHARED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define RELEASE(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define RELEASE_SHARED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define TRY_ACQUIRE(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define TRY_ACQUIRE_SHARED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))</span>
+
+<span class="cp">#define EXCLUDES(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))</span>
+
+<span class="cp">#define ASSERT_CAPABILITY(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))</span>
+
+<span class="cp">#define ASSERT_SHARED_CAPABILITY(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))</span>
+
+<span class="cp">#define RETURN_CAPABILITY(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))</span>
+
+<span class="cp">#define NO_THREAD_SAFETY_ANALYSIS \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)</span>
+
+
+<span class="c1">// Defines an annotated interface for mutexes.</span>
+<span class="c1">// These methods can be implemented to use any internal mutex implementation.</span>
+<span class="k">class</span> <span class="nf">CAPABILITY</span><span class="p">(</span><span class="s">"mutex"</span><span class="p">)</span> <span class="n">Mutex</span> <span class="p">{</span>
+<span class="nl">public:</span>
+  <span class="c1">// Acquire/lock this mutex exclusively.  Only one thread can have exclusive</span>
+  <span class="c1">// access at any one time.  Write operations to guarded data require an</span>
+  <span class="c1">// exclusive lock.</span>
+  <span class="kt">void</span> <span class="n">Lock</span><span class="p">()</span> <span class="n">ACQUIRE</span><span class="p">();</span>
+
+  <span class="c1">// Acquire/lock this mutex for read operations, which require only a shared</span>
+  <span class="c1">// lock.  This assumes a multiple-reader, single writer semantics.  Multiple</span>
+  <span class="c1">// threads may acquire the mutex simultaneously as readers, but a writer</span>
+  <span class="c1">// must wait for all of them to release the mutex before it can acquire it</span>
+  <span class="c1">// exclusively.</span>
+  <span class="kt">void</span> <span class="nf">ReaderLock</span><span class="p">()</span> <span class="n">ACQUIRE_SHARED</span><span class="p">();</span>
+
+  <span class="c1">// Release/unlock an exclusive mutex.</span>
+  <span class="kt">void</span> <span class="nf">Unlock</span><span class="p">()</span> <span class="n">RELEASE</span><span class="p">();</span>
+
+  <span class="c1">// Release/unlock a shared mutex.</span>
+  <span class="kt">void</span> <span class="nf">ReaderUnlock</span><span class="p">()</span> <span class="n">RELEASE_SHARED</span><span class="p">();</span>
+
+  <span class="c1">// Try to acquire the mutex.  Returns true on success, and false on failure.</span>
+  <span class="kt">bool</span> <span class="nf">TryLock</span><span class="p">()</span> <span class="n">TRY_ACQUIRE</span><span class="p">(</span><span class="nb">true</span><span class="p">);</span>
+
+  <span class="c1">// Try to acquire the mutex for read operations.</span>
+  <span class="kt">bool</span> <span class="nf">ReaderTryLock</span><span class="p">()</span> <span class="n">TRY_ACQUIRE_SHARED</span><span class="p">(</span><span class="nb">true</span><span class="p">);</span>
+
+  <span class="c1">// Assert that this mutex is currently held by the calling thread.</span>
+  <span class="kt">void</span> <span class="nf">AssertHeld</span><span class="p">()</span> <span class="n">ASSERT_CAPABILITY</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
+
+  <span class="c1">// Assert that is mutex is currently held for read operations.</span>
+  <span class="kt">void</span> <span class="nf">AssertReaderHeld</span><span class="p">()</span> <span class="n">ASSERT_SHARED_CAPABILITY</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
+<span class="p">};</span>
+
+
+<span class="c1">// MutexLocker is an RAII class that acquires a mutex in its constructor, and</span>
+<span class="c1">// releases it in its destructor.</span>
+<span class="k">class</span> <span class="nc">SCOPED_CAPABILITY</span> <span class="n">MutexLocker</span> <span class="p">{</span>
+<span class="nl">private:</span>
+  <span class="n">Mutex</span><span class="o">*</span> <span class="n">mut</span><span class="p">;</span>
+
+<span class="nl">public:</span>
+  <span class="n">MutexLocker</span><span class="p">(</span><span class="n">Mutex</span> <span class="o">*</span><span class="n">mu</span><span class="p">)</span> <span class="n">ACQUIRE</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="o">:</span> <span class="n">mut</span><span class="p">(</span><span class="n">mu</span><span class="p">)</span> <span class="p">{</span>
+    <span class="n">mu</span><span class="o">-></span><span class="n">Lock</span><span class="p">();</span>
+  <span class="p">}</span>
+  <span class="o">~</span><span class="n">MutexLocker</span><span class="p">()</span> <span class="n">RELEASE</span><span class="p">()</span> <span class="p">{</span>
+    <span class="n">mut</span><span class="o">-></span><span class="n">Unlock</span><span class="p">();</span>
+  <span class="p">}</span>
+<span class="p">};</span>
+
+
+<span class="cp">#ifdef USE_LOCK_STYLE_THREAD_SAFETY_ATTRIBUTES</span>
+<span class="c1">// The original version of thread safety analysis the following attribute</span>
+<span class="c1">// definitions.  These use a lock-based terminology.  They are still in use</span>
+<span class="c1">// by existing thread safety code, and will continue to be supported.</span>
+
+<span class="c1">// Deprecated.</span>
+<span class="cp">#define PT_GUARDED_VAR \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded)</span>
+
+<span class="c1">// Deprecated.</span>
+<span class="cp">#define GUARDED_VAR \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(guarded)</span>
+
+<span class="c1">// Replaced by REQUIRES</span>
+<span class="cp">#define EXCLUSIVE_LOCKS_REQUIRED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by REQUIRES_SHARED</span>
+<span class="cp">#define SHARED_LOCKS_REQUIRED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by CAPABILITY</span>
+<span class="cp">#define LOCKABLE \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(lockable)</span>
+
+<span class="c1">// Replaced by SCOPED_CAPABILITY</span>
+<span class="cp">#define SCOPED_LOCKABLE \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)</span>
+
+<span class="c1">// Replaced by ACQUIRE</span>
+<span class="cp">#define EXCLUSIVE_LOCK_FUNCTION(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by ACQUIRE_SHARED</span>
+<span class="cp">#define SHARED_LOCK_FUNCTION(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by RELEASE and RELEASE_SHARED</span>
+<span class="cp">#define UNLOCK_FUNCTION(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by TRY_ACQUIRE</span>
+<span class="cp">#define EXCLUSIVE_TRYLOCK_FUNCTION(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by TRY_ACQUIRE_SHARED</span>
+<span class="cp">#define SHARED_TRYLOCK_FUNCTION(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by ASSERT_CAPABILITY</span>
+<span class="cp">#define ASSERT_EXCLUSIVE_LOCK(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(assert_exclusive_lock(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by ASSERT_SHARED_CAPABILITY</span>
+<span class="cp">#define ASSERT_SHARED_LOCK(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_lock(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by EXCLUDE_CAPABILITY.</span>
+<span class="cp">#define LOCKS_EXCLUDED(...) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))</span>
+
+<span class="c1">// Replaced by RETURN_CAPABILITY</span>
+<span class="cp">#define LOCK_RETURNED(x) \</span>
+<span class="cp">  THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))</span>
+
+<span class="cp">#endif  </span><span class="c1">// USE_LOCK_STYLE_THREAD_SAFETY_ATTRIBUTES</span>
+
+<span class="cp">#endif  </span><span class="c1">// THREAD_SAFETY_ANALYSIS_MUTEX_H</span>
+</pre></div>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="CrossCompilation.html">Cross-compilation using Clang</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="AddressSanitizer.html">AddressSanitizer</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/ThreadSanitizer.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/ThreadSanitizer.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/ThreadSanitizer.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/ThreadSanitizer.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,196 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>ThreadSanitizer — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="MemorySanitizer" href="MemorySanitizer.html" />
+    <link rel="prev" title="AddressSanitizer" href="AddressSanitizer.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>ThreadSanitizer</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="AddressSanitizer.html">AddressSanitizer</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="MemorySanitizer.html">MemorySanitizer</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="threadsanitizer">
+<h1>ThreadSanitizer<a class="headerlink" href="#threadsanitizer" title="Permalink to this headline">¶</a></h1>
+<div class="section" id="introduction">
+<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>ThreadSanitizer is a tool that detects data races.  It consists of a compiler
+instrumentation module and a run-time library.  Typical slowdown introduced by
+ThreadSanitizer is about <strong>5x-15x</strong>.  Typical memory overhead introduced by
+ThreadSanitizer is about <strong>5x-10x</strong>.</p>
+</div>
+<div class="section" id="how-to-build">
+<h2>How to build<a class="headerlink" href="#how-to-build" title="Permalink to this headline">¶</a></h2>
+<p>Follow the <a class="reference external" href="../get_started.html">Clang build instructions</a>.  CMake build is
+supported.</p>
+</div>
+<div class="section" id="supported-platforms">
+<h2>Supported Platforms<a class="headerlink" href="#supported-platforms" title="Permalink to this headline">¶</a></h2>
+<p>ThreadSanitizer is supported on Linux x86_64 (tested on Ubuntu 12.04).
+Support for other 64-bit architectures is possible, contributions are welcome.
+Support for 32-bit platforms is problematic and is not planned.</p>
+</div>
+<div class="section" id="usage">
+<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
+<p>Simply compile and link your program with <tt class="docutils literal"><span class="pre">-fsanitize=thread</span></tt>.  To get a
+reasonable performance add <tt class="docutils literal"><span class="pre">-O1</span></tt> or higher.  Use <tt class="docutils literal"><span class="pre">-g</span></tt> to get file names
+and line numbers in the warning messages.</p>
+<p>Example:</p>
+<div class="highlight-c++"><div class="highlight"><pre>% cat projects/compiler-rt/lib/tsan/lit_tests/tiny_race.c
+#include <pthread.h>
+int Global;
+void *Thread1(void *x) {
+  Global = 42;
+  return x;
+}
+int main() {
+  pthread_t t;
+  pthread_create(&t, NULL, Thread1, NULL);
+  Global = 43;
+  pthread_join(t, NULL);
+  return Global;
+}
+
+$ clang -fsanitize=thread -g -O1 tiny_race.c
+</pre></div>
+</div>
+<p>If a bug is detected, the program will print an error message to stderr.
+Currently, ThreadSanitizer symbolizes its output using an external
+<tt class="docutils literal"><span class="pre">addr2line</span></tt> process (this will be fixed in future).</p>
+<div class="highlight-bash"><div class="highlight"><pre>% ./a.out
+WARNING: ThreadSanitizer: data race <span class="o">(</span><span class="nv">pid</span><span class="o">=</span>19219<span class="o">)</span>
+  Write of size 4 at 0x7fcf47b21bc0 by thread T1:
+    <span class="c">#0 Thread1 tiny_race.c:4 (exe+0x00000000a360)</span>
+
+  Previous write of size 4 at 0x7fcf47b21bc0 by main thread:
+    <span class="c">#0 main tiny_race.c:10 (exe+0x00000000a3b4)</span>
+
+  Thread T1 <span class="o">(</span>running<span class="o">)</span> created at:
+    <span class="c">#0 pthread_create tsan_interceptors.cc:705 (exe+0x00000000c790)</span>
+    <span class="c">#1 main tiny_race.c:9 (exe+0x00000000a3a4)</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="has-feature-thread-sanitizer">
+<h2><tt class="docutils literal"><span class="pre">__has_feature(thread_sanitizer)</span></tt><a class="headerlink" href="#has-feature-thread-sanitizer" title="Permalink to this headline">¶</a></h2>
+<p>In some cases one may need to execute different code depending on whether
+ThreadSanitizer is enabled.
+<a class="reference internal" href="LanguageExtensions.html#langext-has-feature-has-extension"><em>__has_feature</em></a> can be used for
+this purpose.</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cp">#if defined(__has_feature)</span>
+<span class="cp">#  if __has_feature(thread_sanitizer)</span>
+<span class="c1">// code that builds only under ThreadSanitizer</span>
+<span class="cp">#  endif</span>
+<span class="cp">#endif</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="attribute-no-sanitize-thread">
+<h2><tt class="docutils literal"><span class="pre">__attribute__((no_sanitize_thread))</span></tt><a class="headerlink" href="#attribute-no-sanitize-thread" title="Permalink to this headline">¶</a></h2>
+<p>Some code should not be instrumented by ThreadSanitizer.
+One may use the function attribute
+<a class="reference internal" href="AttributeReference.html#langext-thread-sanitizer"><em>no_sanitize_thread</em></a>
+to disable instrumentation of plain (non-atomic) loads/stores in a particular function.
+ThreadSanitizer still instruments such functions to avoid false positives and
+provide meaningful stack traces.
+This attribute may not be
+supported by other compilers, so we suggest to use it together with
+<tt class="docutils literal"><span class="pre">__has_feature(thread_sanitizer)</span></tt>.</p>
+</div>
+<div class="section" id="blacklist">
+<h2>Blacklist<a class="headerlink" href="#blacklist" title="Permalink to this headline">¶</a></h2>
+<p>ThreadSanitizer supports <tt class="docutils literal"><span class="pre">src</span></tt> and <tt class="docutils literal"><span class="pre">fun</span></tt> entity types in
+<a class="reference internal" href="SanitizerSpecialCaseList.html"><em>Sanitizer special case list</em></a>, that can be used to suppress data race reports in
+the specified source files or functions. Unlike functions marked with
+<a class="reference internal" href="AttributeReference.html#langext-thread-sanitizer"><em>no_sanitize_thread</em></a> attribute,
+blacklisted functions are not instrumented at all. This can lead to false positives
+due to missed synchronization via atomic operations and missed stack frames in reports.</p>
+</div>
+<div class="section" id="limitations">
+<h2>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h2>
+<ul class="simple">
+<li>ThreadSanitizer uses more real memory than a native run. At the default
+settings the memory overhead is 5x plus 1Mb per each thread. Settings with 3x
+(less accurate analysis) and 9x (more accurate analysis) overhead are also
+available.</li>
+<li>ThreadSanitizer maps (but does not reserve) a lot of virtual address space.
+This means that tools like <tt class="docutils literal"><span class="pre">ulimit</span></tt> may not work as usually expected.</li>
+<li>Libc/libstdc++ static linking is not supported.</li>
+<li>Non-position-independent executables are not supported.  Therefore, the
+<tt class="docutils literal"><span class="pre">fsanitize=thread</span></tt> flag will cause Clang to act as though the <tt class="docutils literal"><span class="pre">-fPIE</span></tt>
+flag had been supplied if compiling without <tt class="docutils literal"><span class="pre">-fPIC</span></tt>, and as though the
+<tt class="docutils literal"><span class="pre">-pie</span></tt> flag had been supplied if linking an executable.</li>
+</ul>
+</div>
+<div class="section" id="current-status">
+<h2>Current Status<a class="headerlink" href="#current-status" title="Permalink to this headline">¶</a></h2>
+<p>ThreadSanitizer is in beta stage.  It is known to work on large C++ programs
+using pthreads, but we do not promise anything (yet).  C++11 threading is
+supported with llvm libc++.  The test suite is integrated into CMake build
+and can be run with <tt class="docutils literal"><span class="pre">make</span> <span class="pre">check-tsan</span></tt> command.</p>
+<p>We are actively working on enhancing the tool — stay tuned.  Any help,
+especially in the form of minimized standalone tests is more than welcome.</p>
+</div>
+<div class="section" id="more-information">
+<h2>More Information<a class="headerlink" href="#more-information" title="Permalink to this headline">¶</a></h2>
+<p><a class="reference external" href="http://code.google.com/p/thread-sanitizer/">http://code.google.com/p/thread-sanitizer</a>.</p>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="AddressSanitizer.html">AddressSanitizer</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="MemorySanitizer.html">MemorySanitizer</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/Tooling.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/Tooling.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/Tooling.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/Tooling.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,162 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Choosing the Right Interface for Your Application — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="External Clang Examples" href="ExternalClangExamples.html" />
+    <link rel="prev" title="Frequently Asked Questions (FAQ)" href="FAQ.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Choosing the Right Interface for Your Application</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="FAQ.html">Frequently Asked Questions (FAQ)</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ExternalClangExamples.html">External Clang Examples</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="choosing-the-right-interface-for-your-application">
+<h1>Choosing the Right Interface for Your Application<a class="headerlink" href="#choosing-the-right-interface-for-your-application" title="Permalink to this headline">¶</a></h1>
+<p>Clang provides infrastructure to write tools that need syntactic and semantic
+information about a program.  This document will give a short introduction of
+the different ways to write clang tools, and their pros and cons.</p>
+<div class="section" id="libclang">
+<h2>LibClang<a class="headerlink" href="#libclang" title="Permalink to this headline">¶</a></h2>
+<p><a class="reference external" href="http://clang.llvm.org/doxygen/group__CINDEX.html">LibClang</a> is a stable high
+level C interface to clang.  When in doubt LibClang is probably the interface
+you want to use.  Consider the other interfaces only when you have a good
+reason not to use LibClang.</p>
+<p>Canonical examples of when to use LibClang:</p>
+<ul class="simple">
+<li>Xcode</li>
+<li>Clang Python Bindings</li>
+</ul>
+<p>Use LibClang when you...:</p>
+<ul class="simple">
+<li>want to interface with clang from other languages than C++</li>
+<li>need a stable interface that takes care to be backwards compatible</li>
+<li>want powerful high-level abstractions, like iterating through an AST with a
+cursor, and don’t want to learn all the nitty gritty details of Clang’s AST.</li>
+</ul>
+<p>Do not use LibClang when you...:</p>
+<ul class="simple">
+<li>want full control over the Clang AST</li>
+</ul>
+</div>
+<div class="section" id="clang-plugins">
+<h2>Clang Plugins<a class="headerlink" href="#clang-plugins" title="Permalink to this headline">¶</a></h2>
+<p><a class="reference internal" href="ClangPlugins.html"><em>Clang Plugins</em></a> allow you to run additional actions on the
+AST as part of a compilation.  Plugins are dynamic libraries that are loaded at
+runtime by the compiler, and they’re easy to integrate into your build
+environment.</p>
+<p>Canonical examples of when to use Clang Plugins:</p>
+<ul class="simple">
+<li>special lint-style warnings or errors for your project</li>
+<li>creating additional build artifacts from a single compile step</li>
+</ul>
+<p>Use Clang Plugins when you...:</p>
+<ul class="simple">
+<li>need your tool to rerun if any of the dependencies change</li>
+<li>want your tool to make or break a build</li>
+<li>need full control over the Clang AST</li>
+</ul>
+<p>Do not use Clang Plugins when you...:</p>
+<ul class="simple">
+<li>want to run tools outside of your build environment</li>
+<li>want full control on how Clang is set up, including mapping of in-memory
+virtual files</li>
+<li>need to run over a specific subset of files in your project which is not
+necessarily related to any changes which would trigger rebuilds</li>
+</ul>
+</div>
+<div class="section" id="libtooling">
+<h2>LibTooling<a class="headerlink" href="#libtooling" title="Permalink to this headline">¶</a></h2>
+<p><a class="reference internal" href="LibTooling.html"><em>LibTooling</em></a> is a C++ interface aimed at writing standalone
+tools, as well as integrating into services that run clang tools.  Canonical
+examples of when to use LibTooling:</p>
+<ul class="simple">
+<li>a simple syntax checker</li>
+<li>refactoring tools</li>
+</ul>
+<p>Use LibTooling when you...:</p>
+<ul class="simple">
+<li>want to run tools over a single file, or a specific subset of files,
+independently of the build system</li>
+<li>want full control over the Clang AST</li>
+<li>want to share code with Clang Plugins</li>
+</ul>
+<p>Do not use LibTooling when you...:</p>
+<ul class="simple">
+<li>want to run as part of the build triggered by dependency changes</li>
+<li>want a stable interface so you don’t need to change your code when the AST API
+changes</li>
+<li>want high level abstractions like cursors and code completion out of the box</li>
+<li>do not want to write your tools in C++</li>
+</ul>
+<p><a class="reference internal" href="ClangTools.html"><em>Clang tools</em></a> are a collection of specific developer tools
+built on top of the LibTooling infrastructure as part of the Clang project.
+They are targeted at automating and improving core development activities of
+C/C++ developers.</p>
+<p>Examples of tools we are building or planning as part of the Clang project:</p>
+<ul class="simple">
+<li>Syntax checking (<strong class="program">clang-check</strong>)</li>
+<li>Automatic fixing of compile errors (<strong class="program">clang-fixit</strong>)</li>
+<li>Automatic code formatting (<strong class="program">clang-format</strong>)</li>
+<li>Migration tools for new features in new language standards</li>
+<li>Core refactoring tools</li>
+</ul>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="FAQ.html">Frequently Asked Questions (FAQ)</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="ExternalClangExamples.html">External Clang Examples</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/UsersManual.html
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/UsersManual.html?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/UsersManual.html (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/UsersManual.html Fri Feb 27 12:44:09 2015
@@ -0,0 +1,1965 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    
+    <title>Clang Compiler User’s Manual — Clang 3.6 documentation</title>
+    
+    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
+    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
+    
+    <script type="text/javascript">
+      var DOCUMENTATION_OPTIONS = {
+        URL_ROOT:    './',
+        VERSION:     '3.6',
+        COLLAPSE_INDEX: false,
+        FILE_SUFFIX: '.html',
+        HAS_SOURCE:  true
+      };
+    </script>
+    <script type="text/javascript" src="_static/jquery.js"></script>
+    <script type="text/javascript" src="_static/underscore.js"></script>
+    <script type="text/javascript" src="_static/doctools.js"></script>
+    <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+    <link rel="top" title="Clang 3.6 documentation" href="index.html" />
+    <link rel="next" title="Clang Language Extensions" href="LanguageExtensions.html" />
+    <link rel="prev" title="Clang 3.6 (In-Progress) Release Notes" href="ReleaseNotes.html" /> 
+  </head>
+  <body>
+      <div class="header"><h1 class="heading"><a href="index.html">
+          <span>Clang 3.6 documentation</span></a></h1>
+        <h2 class="heading"><span>Clang Compiler User’s Manual</span></h2>
+      </div>
+      <div class="topnav">
+      
+        <p>
+        «  <a href="ReleaseNotes.html">Clang 3.6 (In-Progress) Release Notes</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LanguageExtensions.html">Clang Language Extensions</a>  Â»
+        </p>
+
+      </div>
+      <div class="content">
+        
+        
+  <div class="section" id="clang-compiler-user-s-manual">
+<h1>Clang Compiler User’s Manual<a class="headerlink" href="#clang-compiler-user-s-manual" title="Permalink to this headline">¶</a></h1>
+<div class="contents local topic" id="contents">
+<ul class="simple">
+<li><a class="reference internal" href="#introduction" id="id6">Introduction</a><ul>
+<li><a class="reference internal" href="#terminology" id="id7">Terminology</a></li>
+<li><a class="reference internal" href="#basic-usage" id="id8">Basic Usage</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#command-line-options" id="id9">Command Line Options</a><ul>
+<li><a class="reference internal" href="#options-to-control-error-and-warning-messages" id="id10">Options to Control Error and Warning Messages</a><ul>
+<li><a class="reference internal" href="#formatting-of-diagnostics" id="id11">Formatting of Diagnostics</a></li>
+<li><a class="reference internal" href="#individual-warning-groups" id="id12">Individual Warning Groups</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#options-to-control-clang-crash-diagnostics" id="id13">Options to Control Clang Crash Diagnostics</a></li>
+<li><a class="reference internal" href="#options-to-emit-optimization-reports" id="id14">Options to Emit Optimization Reports</a><ul>
+<li><a class="reference internal" href="#current-limitations" id="id15">Current limitations</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li><a class="reference internal" href="#language-and-target-independent-features" id="id16">Language and Target-Independent Features</a><ul>
+<li><a class="reference internal" href="#controlling-errors-and-warnings" id="id17">Controlling Errors and Warnings</a><ul>
+<li><a class="reference internal" href="#controlling-how-clang-displays-diagnostics" id="id18">Controlling How Clang Displays Diagnostics</a></li>
+<li><a class="reference internal" href="#diagnostic-mappings" id="id19">Diagnostic Mappings</a></li>
+<li><a class="reference internal" href="#diagnostic-categories" id="id20">Diagnostic Categories</a></li>
+<li><a class="reference internal" href="#controlling-diagnostics-via-command-line-flags" id="id21">Controlling Diagnostics via Command Line Flags</a></li>
+<li><a class="reference internal" href="#controlling-diagnostics-via-pragmas" id="id22">Controlling Diagnostics via Pragmas</a></li>
+<li><a class="reference internal" href="#controlling-diagnostics-in-system-headers" id="id23">Controlling Diagnostics in System Headers</a></li>
+<li><a class="reference internal" href="#enabling-all-diagnostics" id="id24">Enabling All Diagnostics</a></li>
+<li><a class="reference internal" href="#controlling-static-analyzer-diagnostics" id="id25">Controlling Static Analyzer Diagnostics</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#precompiled-headers" id="id26">Precompiled Headers</a><ul>
+<li><a class="reference internal" href="#generating-a-pch-file" id="id27">Generating a PCH File</a></li>
+<li><a class="reference internal" href="#using-a-pch-file" id="id28">Using a PCH File</a></li>
+<li><a class="reference internal" href="#relocatable-pch-files" id="id29">Relocatable PCH Files</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#controlling-code-generation" id="id30">Controlling Code Generation</a></li>
+<li><a class="reference internal" href="#profile-guided-optimization" id="id31">Profile Guided Optimization</a><ul>
+<li><a class="reference internal" href="#using-sampling-profilers" id="id32">Using Sampling Profilers</a><ul>
+<li><a class="reference internal" href="#sample-profile-format" id="id33">Sample Profile Format</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#profiling-with-instrumentation" id="id34">Profiling with Instrumentation</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#controlling-size-of-debug-information" id="id35">Controlling Size of Debug Information</a></li>
+<li><a class="reference internal" href="#comment-parsing-options" id="id36">Comment Parsing Options</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#c-language-features" id="id37">C Language Features</a><ul>
+<li><a class="reference internal" href="#extensions-supported-by-clang" id="id38">Extensions supported by clang</a></li>
+<li><a class="reference internal" href="#differences-between-various-standard-modes" id="id39">Differences between various standard modes</a></li>
+<li><a class="reference internal" href="#gcc-extensions-not-implemented-yet" id="id40">GCC extensions not implemented yet</a></li>
+<li><a class="reference internal" href="#intentionally-unsupported-gcc-extensions" id="id41">Intentionally unsupported GCC extensions</a></li>
+<li><a class="reference internal" href="#microsoft-extensions" id="id42">Microsoft extensions</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#cxx" id="id43">C++ Language Features</a><ul>
+<li><a class="reference internal" href="#controlling-implementation-limits" id="id44">Controlling implementation limits</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#objective-c-language-features" id="id45">Objective-C Language Features</a></li>
+<li><a class="reference internal" href="#objcxx" id="id46">Objective-C++ Language Features</a></li>
+<li><a class="reference internal" href="#target-specific-features-and-limitations" id="id47">Target-Specific Features and Limitations</a><ul>
+<li><a class="reference internal" href="#cpu-architectures-features-and-limitations" id="id48">CPU Architectures Features and Limitations</a><ul>
+<li><a class="reference internal" href="#x86" id="id49">X86</a></li>
+<li><a class="reference internal" href="#arm" id="id50">ARM</a></li>
+<li><a class="reference internal" href="#powerpc" id="id51">PowerPC</a></li>
+<li><a class="reference internal" href="#other-platforms" id="id52">Other platforms</a></li>
+</ul>
+</li>
+<li><a class="reference internal" href="#operating-system-features-and-limitations" id="id53">Operating System Features and Limitations</a><ul>
+<li><a class="reference internal" href="#darwin-mac-os-x" id="id54">Darwin (Mac OS X)</a></li>
+<li><a class="reference internal" href="#windows" id="id55">Windows</a><ul>
+<li><a class="reference internal" href="#cygwin" id="id56">Cygwin</a></li>
+<li><a class="reference internal" href="#mingw32" id="id57">MinGW32</a></li>
+<li><a class="reference internal" href="#mingw-w64" id="id58">MinGW-w64</a></li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+</li>
+<li><a class="reference internal" href="#clang-cl" id="id59">clang-cl</a><ul>
+<li><a class="reference internal" href="#id5" id="id60">Command-Line Options</a><ul>
+<li><a class="reference internal" href="#the-fallback-option" id="id61">The /fallback Option</a></li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+</div>
+<div class="section" id="introduction">
+<h2><a class="toc-backref" href="#id6">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
+<p>The Clang Compiler is an open-source compiler for the C family of
+programming languages, aiming to be the best in class implementation of
+these languages. Clang builds on the LLVM optimizer and code generator,
+allowing it to provide high-quality optimization and code generation
+support for many targets. For more general information, please see the
+<a class="reference external" href="http://clang.llvm.org">Clang Web Site</a> or the <a class="reference external" href="http://llvm.org">LLVM Web
+Site</a>.</p>
+<p>This document describes important notes about using Clang as a compiler
+for an end-user, documenting the supported features, command line
+options, etc. If you are interested in using Clang to build a tool that
+processes code, please see <a class="reference internal" href="InternalsManual.html"><em>“Clang” CFE Internals Manual</em></a>. If you are interested in the
+<a class="reference external" href="http://clang-analyzer.llvm.org">Clang Static Analyzer</a>, please see its web
+page.</p>
+<p>Clang is designed to support the C family of programming languages,
+which includes <a class="reference internal" href="#c"><em>C</em></a>, <a class="reference internal" href="#objc"><em>Objective-C</em></a>, <a class="reference internal" href="#cxx"><em>C++</em></a>, and
+<a class="reference internal" href="#objcxx"><em>Objective-C++</em></a> as well as many dialects of those. For
+language-specific information, please see the corresponding language
+specific section:</p>
+<ul class="simple">
+<li><a class="reference internal" href="#c"><em>C Language</em></a>: K&R C, ANSI C89, ISO C90, ISO C94 (C89+AMD1), ISO
+C99 (+TC1, TC2, TC3).</li>
+<li><a class="reference internal" href="#objc"><em>Objective-C Language</em></a>: ObjC 1, ObjC 2, ObjC 2.1, plus
+variants depending on base language.</li>
+<li><a class="reference internal" href="#cxx"><em>C++ Language</em></a></li>
+<li><a class="reference internal" href="#objcxx"><em>Objective C++ Language</em></a></li>
+</ul>
+<p>In addition to these base languages and their dialects, Clang supports a
+broad variety of language extensions, which are documented in the
+corresponding language section. These extensions are provided to be
+compatible with the GCC, Microsoft, and other popular compilers as well
+as to improve functionality through Clang-specific features. The Clang
+driver and language features are intentionally designed to be as
+compatible with the GNU GCC compiler as reasonably possible, easing
+migration from GCC to Clang. In most cases, code “just works”.
+Clang also provides an alternative driver, <a class="reference internal" href="#clang-cl"><em>clang-cl</em></a>, that is designed
+to be compatible with the Visual C++ compiler, cl.exe.</p>
+<p>In addition to language specific features, Clang has a variety of
+features that depend on what CPU architecture or operating system is
+being compiled for. Please see the <a class="reference internal" href="#target-features"><em>Target-Specific Features and
+Limitations</em></a> section for more details.</p>
+<p>The rest of the introduction introduces some basic <a class="reference internal" href="#terminology"><em>compiler
+terminology</em></a> that is used throughout this manual and
+contains a basic <a class="reference internal" href="#basicusage"><em>introduction to using Clang</em></a> as a
+command line compiler.</p>
+<div class="section" id="terminology">
+<span id="id1"></span><h3><a class="toc-backref" href="#id7">Terminology</a><a class="headerlink" href="#terminology" title="Permalink to this headline">¶</a></h3>
+<p>Front end, parser, backend, preprocessor, undefined behavior,
+diagnostic, optimizer</p>
+</div>
+<div class="section" id="basic-usage">
+<span id="basicusage"></span><h3><a class="toc-backref" href="#id8">Basic Usage</a><a class="headerlink" href="#basic-usage" title="Permalink to this headline">¶</a></h3>
+<p>Intro to how to use a C compiler for newbies.</p>
+<p>compile + link compile then link debug info enabling optimizations
+picking a language to use, defaults to C11 by default. Autosenses based
+on extension. using a makefile</p>
+</div>
+</div>
+<div class="section" id="command-line-options">
+<h2><a class="toc-backref" href="#id9">Command Line Options</a><a class="headerlink" href="#command-line-options" title="Permalink to this headline">¶</a></h2>
+<p>This section is generally an index into other sections. It does not go
+into depth on the ones that are covered by other sections. However, the
+first part introduces the language selection and other high level
+options like <em class="xref std std-option">-c</em>, <a class="reference internal" href="#cmdoption-g"><em class="xref std std-option">-g</em></a>, etc.</p>
+<div class="section" id="options-to-control-error-and-warning-messages">
+<h3><a class="toc-backref" href="#id10">Options to Control Error and Warning Messages</a><a class="headerlink" href="#options-to-control-error-and-warning-messages" title="Permalink to this headline">¶</a></h3>
+<dl class="option">
+<dt id="cmdoption-Werror">
+<tt class="descname">-Werror</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Werror" title="Permalink to this definition">¶</a></dt>
+<dd><p>Turn warnings into errors.</p>
+</dd></dl>
+
+<p><tt class="docutils literal"><span class="pre">-Werror=foo</span></tt></p>
+<blockquote>
+<div>Turn warning “foo” into an error.</div></blockquote>
+<dl class="option">
+<dt id="cmdoption-Wno-error">
+<tt class="descname">-Wno-error</tt><tt class="descclassname">=foo</tt><a class="headerlink" href="#cmdoption-Wno-error" title="Permalink to this definition">¶</a></dt>
+<dd><p>Turn warning “foo” into an warning even if <a class="reference internal" href="#cmdoption-Werror"><em class="xref std std-option">-Werror</em></a> is specified.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Wfoo">
+<tt class="descname">-Wfoo</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wfoo" title="Permalink to this definition">¶</a></dt>
+<dd><p>Enable warning “foo”.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Wno-foo">
+<tt class="descname">-Wno-foo</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wno-foo" title="Permalink to this definition">¶</a></dt>
+<dd><p>Disable warning “foo”.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-w">
+<tt class="descname">-w</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-w" title="Permalink to this definition">¶</a></dt>
+<dd><p>Disable all diagnostics.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Weverything">
+<tt class="descname">-Weverything</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Weverything" title="Permalink to this definition">¶</a></dt>
+<dd><p><a class="reference internal" href="#diagnostics-enable-everything"><em>Enable all diagnostics.</em></a></p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-pedantic">
+<tt class="descname">-pedantic</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-pedantic" title="Permalink to this definition">¶</a></dt>
+<dd><p>Warn on language extensions.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-pedantic-errors">
+<tt class="descname">-pedantic-errors</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-pedantic-errors" title="Permalink to this definition">¶</a></dt>
+<dd><p>Error on language extensions.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Wsystem-headers">
+<tt class="descname">-Wsystem-headers</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wsystem-headers" title="Permalink to this definition">¶</a></dt>
+<dd><p>Enable warnings from system headers.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-ferror-limit">
+<tt class="descname">-ferror-limit</tt><tt class="descclassname">=123</tt><a class="headerlink" href="#cmdoption-ferror-limit" title="Permalink to this definition">¶</a></dt>
+<dd><p>Stop emitting diagnostics after 123 errors have been produced. The default is
+20, and the error limit can be disabled with <em class="xref std std-option">-ferror-limit=0</em>.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-ftemplate-backtrace-limit">
+<tt class="descname">-ftemplate-backtrace-limit</tt><tt class="descclassname">=123</tt><a class="headerlink" href="#cmdoption-ftemplate-backtrace-limit" title="Permalink to this definition">¶</a></dt>
+<dd><p>Only emit up to 123 template instantiation notes within the template
+instantiation backtrace for a single warning or error. The default is 10, and
+the limit can be disabled with <em class="xref std std-option">-ftemplate-backtrace-limit=0</em>.</p>
+</dd></dl>
+
+<div class="section" id="formatting-of-diagnostics">
+<span id="cl-diag-formatting"></span><h4><a class="toc-backref" href="#id11">Formatting of Diagnostics</a><a class="headerlink" href="#formatting-of-diagnostics" title="Permalink to this headline">¶</a></h4>
+<p>Clang aims to produce beautiful diagnostics by default, particularly for
+new users that first come to Clang. However, different people have
+different preferences, and sometimes Clang is driven by another program
+that wants to parse simple and consistent output, not a person. For
+these cases, Clang provides a wide range of options to control the exact
+output format of the diagnostics that it generates.</p>
+<dl class="docutils" id="opt-fshow-column">
+<dt><strong>-f[no-]show-column</strong></dt>
+<dd><p class="first">Print column number in diagnostic.</p>
+<p>This option, which defaults to on, controls whether or not Clang
+prints the column number of a diagnostic. For example, when this is
+enabled, Clang will print something like:</p>
+<div class="highlight-python"><div class="highlight"><pre>test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+       //
+</pre></div>
+</div>
+<p>When this is disabled, Clang will print “test.c:28: warning...” with
+no column number.</p>
+<p class="last">The printed column numbers count bytes from the beginning of the
+line; take care if your source contains multibyte characters.</p>
+</dd>
+</dl>
+<dl class="docutils" id="opt-fshow-source-location">
+<dt><strong>-f[no-]show-source-location</strong></dt>
+<dd><p class="first">Print source file/line/column information in diagnostic.</p>
+<p>This option, which defaults to on, controls whether or not Clang
+prints the filename, line number and column number of a diagnostic.
+For example, when this is enabled, Clang will print something like:</p>
+<div class="highlight-python"><div class="highlight"><pre>test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+       //
+</pre></div>
+</div>
+<p class="last">When this is disabled, Clang will not print the “test.c:28:8: ”
+part.</p>
+</dd>
+</dl>
+<dl class="docutils" id="opt-fcaret-diagnostics">
+<dt><strong>-f[no-]caret-diagnostics</strong></dt>
+<dd><p class="first">Print source line and ranges from source code in diagnostic.
+This option, which defaults to on, controls whether or not Clang
+prints the source line, source ranges, and caret when emitting a
+diagnostic. For example, when this is enabled, Clang will print
+something like:</p>
+<div class="last highlight-python"><div class="highlight"><pre>test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+       //
+</pre></div>
+</div>
+</dd>
+<dt><strong>-f[no-]color-diagnostics</strong></dt>
+<dd><p class="first">This option, which defaults to on when a color-capable terminal is
+detected, controls whether or not Clang prints diagnostics in color.</p>
+<p>When this option is enabled, Clang will use colors to highlight
+specific parts of the diagnostic, e.g.,</p>
+<pre>
+  <b><span style="color:black">test.c:28:8: <span style="color:magenta">warning</span>: extra tokens at end of #endif directive [-Wextra-tokens]</span></b>
+  #endif bad
+         <span style="color:green">^</span>
+         <span style="color:green">//</span>
+</pre><p>When this is disabled, Clang will just print:</p>
+<div class="last highlight-python"><div class="highlight"><pre>test.c:2:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+       //
+</pre></div>
+</div>
+</dd>
+<dt><strong>-fansi-escape-codes</strong></dt>
+<dd>Controls whether ANSI escape codes are used instead of the Windows Console
+API to output colored diagnostics. This option is only used on Windows and
+defaults to off.</dd>
+</dl>
+<dl class="option">
+<dt id="cmdoption-fdiagnostics-format">
+<tt class="descname">-fdiagnostics-format</tt><tt class="descclassname">=clang/msvc/vi</tt><a class="headerlink" href="#cmdoption-fdiagnostics-format" title="Permalink to this definition">¶</a></dt>
+<dd><p>Changes diagnostic output format to better match IDEs and command line tools.</p>
+<p>This option controls the output format of the filename, line number,
+and column printed in diagnostic messages. The options, and their
+affect on formatting a simple conversion diagnostic, follow:</p>
+<dl class="docutils">
+<dt><strong>clang</strong> (default)</dt>
+<dd><div class="first last highlight-python"><div class="highlight"><pre>t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int'
+</pre></div>
+</div>
+</dd>
+<dt><strong>msvc</strong></dt>
+<dd><div class="first last highlight-python"><div class="highlight"><pre>t.c(3,11) : warning: conversion specifies type 'char *' but the argument has type 'int'
+</pre></div>
+</div>
+</dd>
+<dt><strong>vi</strong></dt>
+<dd><div class="first last highlight-python"><div class="highlight"><pre>t.c +3:11: warning: conversion specifies type 'char *' but the argument has type 'int'
+</pre></div>
+</div>
+</dd>
+</dl>
+</dd></dl>
+
+<dl class="docutils" id="opt-fdiagnostics-show-option">
+<dt><strong>-f[no-]diagnostics-show-option</strong></dt>
+<dd><p class="first">Enable <tt class="docutils literal"><span class="pre">[-Woption]</span></tt> information in diagnostic line.</p>
+<p>This option, which defaults to on, controls whether or not Clang
+prints the associated <a class="reference internal" href="#cl-diag-warning-groups"><em>warning group</em></a>
+option name when outputting a warning diagnostic. For example, in
+this output:</p>
+<div class="highlight-python"><div class="highlight"><pre>test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+       //
+</pre></div>
+</div>
+<p class="last">Passing <strong>-fno-diagnostics-show-option</strong> will prevent Clang from
+printing the [<a class="reference internal" href="#opt-wextra-tokens"><em>-Wextra-tokens</em></a>] information in
+the diagnostic. This information tells you the flag needed to enable
+or disable the diagnostic, either from the command line or through
+<a class="reference internal" href="#pragma-gcc-diagnostic"><em>#pragma GCC diagnostic</em></a>.</p>
+</dd>
+</dl>
+<span class="target" id="opt-fdiagnostics-show-category"></span><dl class="option">
+<dt id="cmdoption-fdiagnostics-show-category">
+<tt class="descname">-fdiagnostics-show-category</tt><tt class="descclassname">=none/id/name</tt><a class="headerlink" href="#cmdoption-fdiagnostics-show-category" title="Permalink to this definition">¶</a></dt>
+<dd><p>Enable printing category information in diagnostic line.</p>
+<p>This option, which defaults to “none”, controls whether or not Clang
+prints the category associated with a diagnostic when emitting it.
+Each diagnostic may or many not have an associated category, if it
+has one, it is listed in the diagnostic categorization field of the
+diagnostic line (in the []’s).</p>
+<p>For example, a format string warning will produce these three
+renditions based on the setting of this option:</p>
+<div class="highlight-python"><div class="highlight"><pre>t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat]
+t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,1]
+t.c:3:11: warning: conversion specifies type 'char *' but the argument has type 'int' [-Wformat,Format String]
+</pre></div>
+</div>
+<p>This category can be used by clients that want to group diagnostics
+by category, so it should be a high level category. We want dozens
+of these, not hundreds or thousands of them.</p>
+</dd></dl>
+
+<dl class="docutils" id="opt-fdiagnostics-fixit-info">
+<dt><strong>-f[no-]diagnostics-fixit-info</strong></dt>
+<dd><p class="first">Enable “FixIt” information in the diagnostics output.</p>
+<p>This option, which defaults to on, controls whether or not Clang
+prints the information on how to fix a specific diagnostic
+underneath it when it knows. For example, in this output:</p>
+<div class="highlight-python"><div class="highlight"><pre>test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+       //
+</pre></div>
+</div>
+<p class="last">Passing <strong>-fno-diagnostics-fixit-info</strong> will prevent Clang from
+printing the “//” line at the end of the message. This information
+is useful for users who may not understand what is wrong, but can be
+confusing for machine parsing.</p>
+</dd>
+</dl>
+<dl class="docutils" id="opt-fdiagnostics-print-source-range-info">
+<dt><strong>-fdiagnostics-print-source-range-info</strong></dt>
+<dd><p class="first">Print machine parsable information about source ranges.
+This option makes Clang print information about source ranges in a machine
+parsable format after the file/line/column number information. The
+information is a simple sequence of brace enclosed ranges, where each range
+lists the start and end line/column locations. For example, in this output:</p>
+<div class="highlight-python"><div class="highlight"><pre>exprs.c:47:15:{47:8-47:14}{47:17-47:24}: error: invalid operands to binary expression ('int *' and '_Complex float')
+   P = (P-42) + Gamma*4;
+       ~~~~~~ ^ ~~~~~~~
+</pre></div>
+</div>
+<p>The {}’s are generated by -fdiagnostics-print-source-range-info.</p>
+<p class="last">The printed column numbers count bytes from the beginning of the
+line; take care if your source contains multibyte characters.</p>
+</dd>
+</dl>
+<dl class="option">
+<dt id="cmdoption-fdiagnostics-parseable-fixits">
+<tt class="descname">-fdiagnostics-parseable-fixits</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fdiagnostics-parseable-fixits" title="Permalink to this definition">¶</a></dt>
+<dd><p>Print Fix-Its in a machine parseable form.</p>
+<p>This option makes Clang print available Fix-Its in a machine
+parseable format at the end of diagnostics. The following example
+illustrates the format:</p>
+<div class="highlight-python"><div class="highlight"><pre>fix-it:"t.cpp":{7:25-7:29}:"Gamma"
+</pre></div>
+</div>
+<p>The range printed is a half-open range, so in this example the
+characters at column 25 up to but not including column 29 on line 7
+in t.cpp should be replaced with the string “Gamma”. Either the
+range or the replacement string may be empty (representing strict
+insertions and strict erasures, respectively). Both the file name
+and the insertion string escape backslash (as “\\”), tabs (as
+“\t”), newlines (as “\n”), double quotes(as “\””) and
+non-printable characters (as octal “\xxx”).</p>
+<p>The printed column numbers count bytes from the beginning of the
+line; take care if your source contains multibyte characters.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fno-elide-type">
+<tt class="descname">-fno-elide-type</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fno-elide-type" title="Permalink to this definition">¶</a></dt>
+<dd><p>Turns off elision in template type printing.</p>
+<p>The default for template type printing is to elide as many template
+arguments as possible, removing those which are the same in both
+template types, leaving only the differences. Adding this flag will
+print all the template arguments. If supported by the terminal,
+highlighting will still appear on differing arguments.</p>
+<p>Default:</p>
+<div class="highlight-python"><div class="highlight"><pre>t.cc:4:5: note: candidate function not viable: no known conversion from 'vector<map<[...], map<float, [...]>>>' to 'vector<map<[...], map<double, [...]>>>' for 1st argument;
+</pre></div>
+</div>
+<p>-fno-elide-type:</p>
+<div class="highlight-python"><div class="highlight"><pre>t.cc:4:5: note: candidate function not viable: no known conversion from 'vector<map<int, map<float, int>>>' to 'vector<map<int, map<double, int>>>' for 1st argument;
+</pre></div>
+</div>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fdiagnostics-show-template-tree">
+<tt class="descname">-fdiagnostics-show-template-tree</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fdiagnostics-show-template-tree" title="Permalink to this definition">¶</a></dt>
+<dd><p>Template type diffing prints a text tree.</p>
+<p>For diffing large templated types, this option will cause Clang to
+display the templates as an indented text tree, one argument per
+line, with differences marked inline. This is compatible with
+-fno-elide-type.</p>
+<p>Default:</p>
+<div class="highlight-python"><div class="highlight"><pre>t.cc:4:5: note: candidate function not viable: no known conversion from 'vector<map<[...], map<float, [...]>>>' to 'vector<map<[...], map<double, [...]>>>' for 1st argument;
+</pre></div>
+</div>
+<p>With <a class="reference internal" href="#cmdoption-fdiagnostics-show-template-tree"><em class="xref std std-option">-fdiagnostics-show-template-tree</em></a>:</p>
+<div class="highlight-python"><div class="highlight"><pre>t.cc:4:5: note: candidate function not viable: no known conversion for 1st argument;
+  vector<
+    map<
+      [...],
+      map<
+        [float != double],
+        [...]>>>
+</pre></div>
+</div>
+</dd></dl>
+
+</div>
+<div class="section" id="individual-warning-groups">
+<span id="cl-diag-warning-groups"></span><h4><a class="toc-backref" href="#id12">Individual Warning Groups</a><a class="headerlink" href="#individual-warning-groups" title="Permalink to this headline">¶</a></h4>
+<p>TODO: Generate this from tblgen. Define one anchor per warning group.</p>
+<span class="target" id="opt-wextra-tokens"></span><dl class="option">
+<dt id="cmdoption-Wextra-tokens">
+<tt class="descname">-Wextra-tokens</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wextra-tokens" title="Permalink to this definition">¶</a></dt>
+<dd><p>Warn about excess tokens at the end of a preprocessor directive.</p>
+<p>This option, which defaults to on, enables warnings about extra
+tokens at the end of preprocessor directives. For example:</p>
+<div class="highlight-python"><div class="highlight"><pre>test.c:28:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
+#endif bad
+       ^
+</pre></div>
+</div>
+<p>These extra tokens are not strictly conforming, and are usually best
+handled by commenting them out.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Wambiguous-member-template">
+<tt class="descname">-Wambiguous-member-template</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wambiguous-member-template" title="Permalink to this definition">¶</a></dt>
+<dd><p>Warn about unqualified uses of a member template whose name resolves to
+another template at the location of the use.</p>
+<p>This option, which defaults to on, enables a warning in the
+following code:</p>
+<div class="highlight-python"><div class="highlight"><pre>template<typename T> struct set{};
+template<typename T> struct trait { typedef const T& type; };
+struct Value {
+  template<typename T> void set(typename trait<T>::type value) {}
+};
+void foo() {
+  Value v;
+  v.set<double>(3.2);
+}
+</pre></div>
+</div>
+<p>C++ [basic.lookup.classref] requires this to be an error, but,
+because it’s hard to work around, Clang downgrades it to a warning
+as an extension.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Wbind-to-temporary-copy">
+<tt class="descname">-Wbind-to-temporary-copy</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wbind-to-temporary-copy" title="Permalink to this definition">¶</a></dt>
+<dd><p>Warn about an unusable copy constructor when binding a reference to a
+temporary.</p>
+<p>This option enables warnings about binding a
+reference to a temporary when the temporary doesn’t have a usable
+copy constructor. For example:</p>
+<div class="highlight-python"><div class="highlight"><pre>struct NonCopyable {
+  NonCopyable();
+private:
+  NonCopyable(const NonCopyable&);
+};
+void foo(const NonCopyable&);
+void bar() {
+  foo(NonCopyable());  // Disallowed in C++98; allowed in C++11.
+}
+</pre></div>
+</div>
+<div class="highlight-python"><div class="highlight"><pre>struct NonCopyable2 {
+  NonCopyable2();
+  NonCopyable2(NonCopyable2&);
+};
+void foo(const NonCopyable2&);
+void bar() {
+  foo(NonCopyable2());  // Disallowed in C++98; allowed in C++11.
+}
+</pre></div>
+</div>
+<p>Note that if <tt class="docutils literal"><span class="pre">NonCopyable2::NonCopyable2()</span></tt> has a default argument
+whose instantiation produces a compile error, that error will still
+be a hard error in C++98 mode even if this warning is turned off.</p>
+</dd></dl>
+
+</div>
+</div>
+<div class="section" id="options-to-control-clang-crash-diagnostics">
+<h3><a class="toc-backref" href="#id13">Options to Control Clang Crash Diagnostics</a><a class="headerlink" href="#options-to-control-clang-crash-diagnostics" title="Permalink to this headline">¶</a></h3>
+<p>As unbelievable as it may sound, Clang does crash from time to time.
+Generally, this only occurs to those living on the <a class="reference external" href="http://llvm.org/releases/download.html#svn">bleeding
+edge</a>. Clang goes to great
+lengths to assist you in filing a bug report. Specifically, Clang
+generates preprocessed source file(s) and associated run script(s) upon
+a crash. These files should be attached to a bug report to ease
+reproducibility of the failure. Below are the command line options to
+control the crash diagnostics.</p>
+<dl class="option">
+<dt id="cmdoption-fno-crash-diagnostics">
+<tt class="descname">-fno-crash-diagnostics</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fno-crash-diagnostics" title="Permalink to this definition">¶</a></dt>
+<dd><p>Disable auto-generation of preprocessed source files during a clang crash.</p>
+</dd></dl>
+
+<p>The -fno-crash-diagnostics flag can be helpful for speeding the process
+of generating a delta reduced test case.</p>
+</div>
+<div class="section" id="options-to-emit-optimization-reports">
+<h3><a class="toc-backref" href="#id14">Options to Emit Optimization Reports</a><a class="headerlink" href="#options-to-emit-optimization-reports" title="Permalink to this headline">¶</a></h3>
+<p>Optimization reports trace, at a high-level, all the major decisions
+done by compiler transformations. For instance, when the inliner
+decides to inline function <tt class="docutils literal"><span class="pre">foo()</span></tt> into <tt class="docutils literal"><span class="pre">bar()</span></tt>, or the loop unroller
+decides to unroll a loop N times, or the vectorizer decides to
+vectorize a loop body.</p>
+<p>Clang offers a family of flags which the optimizers can use to emit
+a diagnostic in three cases:</p>
+<ol class="arabic simple">
+<li>When the pass makes a transformation (<em class="xref std std-option">-Rpass</em>).</li>
+<li>When the pass fails to make a transformation (<em class="xref std std-option">-Rpass-missed</em>).</li>
+<li>When the pass determines whether or not to make a transformation
+(<em class="xref std std-option">-Rpass-analysis</em>).</li>
+</ol>
+<p>NOTE: Although the discussion below focuses on <em class="xref std std-option">-Rpass</em>, the exact
+same options apply to <em class="xref std std-option">-Rpass-missed</em> and <em class="xref std std-option">-Rpass-analysis</em>.</p>
+<p>Since there are dozens of passes inside the compiler, each of these flags
+take a regular expression that identifies the name of the pass which should
+emit the associated diagnostic. For example, to get a report from the inliner,
+compile the code with:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang -O2 -Rpass<span class="o">=</span>inline code.cc -o code
+<span class="go">code.cc:4:25: remark: foo inlined into bar [-Rpass=inline]</span>
+<span class="go">int bar(int j) { return foo(j, j - 2); }</span>
+<span class="go">                        ^</span>
+</pre></div>
+</div>
+<p>Note that remarks from the inliner are identified with <cite>[-Rpass=inline]</cite>.
+To request a report from every optimization pass, you should use
+<em class="xref std std-option">-Rpass=.*</em> (in fact, you can use any valid POSIX regular
+expression). However, do not expect a report from every transformation
+made by the compiler. Optimization remarks do not really make sense
+outside of the major transformations (e.g., inlining, vectorization,
+loop optimizations) and not every optimization pass supports this
+feature.</p>
+<div class="section" id="current-limitations">
+<h4><a class="toc-backref" href="#id15">Current limitations</a><a class="headerlink" href="#current-limitations" title="Permalink to this headline">¶</a></h4>
+<ol class="arabic simple">
+<li>Optimization remarks that refer to function names will display the
+mangled name of the function. Since these remarks are emitted by the
+back end of the compiler, it does not know anything about the input
+language, nor its mangling rules.</li>
+<li>Some source locations are not displayed correctly. The front end has
+a more detailed source location tracking than the locations included
+in the debug info (e.g., the front end can locate code inside macro
+expansions). However, the locations used by <em class="xref std std-option">-Rpass</em> are
+translated from debug annotations. That translation can be lossy,
+which results in some remarks having no location information.</li>
+</ol>
+</div>
+</div>
+</div>
+<div class="section" id="language-and-target-independent-features">
+<h2><a class="toc-backref" href="#id16">Language and Target-Independent Features</a><a class="headerlink" href="#language-and-target-independent-features" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="controlling-errors-and-warnings">
+<h3><a class="toc-backref" href="#id17">Controlling Errors and Warnings</a><a class="headerlink" href="#controlling-errors-and-warnings" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides a number of ways to control which code constructs cause
+it to emit errors and warning messages, and how they are displayed to
+the console.</p>
+<div class="section" id="controlling-how-clang-displays-diagnostics">
+<h4><a class="toc-backref" href="#id18">Controlling How Clang Displays Diagnostics</a><a class="headerlink" href="#controlling-how-clang-displays-diagnostics" title="Permalink to this headline">¶</a></h4>
+<p>When Clang emits a diagnostic, it includes rich information in the
+output, and gives you fine-grain control over which information is
+printed. Clang has the ability to print this information, and these are
+the options that control it:</p>
+<ol class="arabic simple">
+<li>A file/line/column indicator that shows exactly where the diagnostic
+occurs in your code [<a class="reference internal" href="#opt-fshow-column"><em>-fshow-column</em></a>,
+<a class="reference internal" href="#opt-fshow-source-location"><em>-fshow-source-location</em></a>].</li>
+<li>A categorization of the diagnostic as a note, warning, error, or
+fatal error.</li>
+<li>A text string that describes what the problem is.</li>
+<li>An option that indicates how to control the diagnostic (for
+diagnostics that support it)
+[<a class="reference internal" href="#opt-fdiagnostics-show-option"><em>-fdiagnostics-show-option</em></a>].</li>
+<li>A <a class="reference internal" href="#diagnostics-categories"><em>high-level category</em></a> for the diagnostic
+for clients that want to group diagnostics by class (for diagnostics
+that support it)
+[<a class="reference internal" href="#opt-fdiagnostics-show-category"><em>-fdiagnostics-show-category</em></a>].</li>
+<li>The line of source code that the issue occurs on, along with a caret
+and ranges that indicate the important locations
+[<a class="reference internal" href="#opt-fcaret-diagnostics"><em>-fcaret-diagnostics</em></a>].</li>
+<li>“FixIt” information, which is a concise explanation of how to fix the
+problem (when Clang is certain it knows)
+[<a class="reference internal" href="#opt-fdiagnostics-fixit-info"><em>-fdiagnostics-fixit-info</em></a>].</li>
+<li>A machine-parsable representation of the ranges involved (off by
+default)
+[<a class="reference internal" href="#opt-fdiagnostics-print-source-range-info"><em>-fdiagnostics-print-source-range-info</em></a>].</li>
+</ol>
+<p>For more information please see <a class="reference internal" href="#cl-diag-formatting"><em>Formatting of
+Diagnostics</em></a>.</p>
+</div>
+<div class="section" id="diagnostic-mappings">
+<h4><a class="toc-backref" href="#id19">Diagnostic Mappings</a><a class="headerlink" href="#diagnostic-mappings" title="Permalink to this headline">¶</a></h4>
+<p>All diagnostics are mapped into one of these 5 classes:</p>
+<ul class="simple">
+<li>Ignored</li>
+<li>Note</li>
+<li>Remark</li>
+<li>Warning</li>
+<li>Error</li>
+<li>Fatal</li>
+</ul>
+</div>
+<div class="section" id="diagnostic-categories">
+<span id="diagnostics-categories"></span><h4><a class="toc-backref" href="#id20">Diagnostic Categories</a><a class="headerlink" href="#diagnostic-categories" title="Permalink to this headline">¶</a></h4>
+<p>Though not shown by default, diagnostics may each be associated with a
+high-level category. This category is intended to make it possible to
+triage builds that produce a large number of errors or warnings in a
+grouped way.</p>
+<p>Categories are not shown by default, but they can be turned on with the
+<a class="reference internal" href="#opt-fdiagnostics-show-category"><em>-fdiagnostics-show-category</em></a> option.
+When set to “<tt class="docutils literal"><span class="pre">name</span></tt>”, the category is printed textually in the
+diagnostic output. When it is set to “<tt class="docutils literal"><span class="pre">id</span></tt>”, a category number is
+printed. The mapping of category names to category id’s can be obtained
+by running ‘<tt class="docutils literal"><span class="pre">clang</span>   <span class="pre">--print-diagnostic-categories</span></tt>‘.</p>
+</div>
+<div class="section" id="controlling-diagnostics-via-command-line-flags">
+<h4><a class="toc-backref" href="#id21">Controlling Diagnostics via Command Line Flags</a><a class="headerlink" href="#controlling-diagnostics-via-command-line-flags" title="Permalink to this headline">¶</a></h4>
+<p>TODO: -W flags, -pedantic, etc</p>
+</div>
+<div class="section" id="controlling-diagnostics-via-pragmas">
+<span id="pragma-gcc-diagnostic"></span><h4><a class="toc-backref" href="#id22">Controlling Diagnostics via Pragmas</a><a class="headerlink" href="#controlling-diagnostics-via-pragmas" title="Permalink to this headline">¶</a></h4>
+<p>Clang can also control what diagnostics are enabled through the use of
+pragmas in the source code. This is useful for turning off specific
+warnings in a section of source code. Clang supports GCC’s pragma for
+compatibility with existing source code, as well as several extensions.</p>
+<p>The pragma may control any warning that can be used from the command
+line. Warnings may be set to ignored, warning, error, or fatal. The
+following example code will tell Clang or GCC to ignore the -Wall
+warnings:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cp">#pragma GCC diagnostic ignored "-Wall"</span>
+</pre></div>
+</div>
+<p>In addition to all of the functionality provided by GCC’s pragma, Clang
+also allows you to push and pop the current warning state. This is
+particularly useful when writing a header file that will be compiled by
+other people, because you don’t know what warning flags they build with.</p>
+<p>In the below example <em class="xref std std-option">-Wmultichar</em> is ignored for only a single line of
+code, after which the diagnostics return to whatever state had previously
+existed.</p>
+<div class="highlight-c"><div class="highlight"><pre>#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmultichar"
+
+char b = 'df'; // no warning.
+
+#pragma clang diagnostic pop
+</pre></div>
+</div>
+<p>The push and pop pragmas will save and restore the full diagnostic state
+of the compiler, regardless of how it was set. That means that it is
+possible to use push and pop around GCC compatible diagnostics and Clang
+will push and pop them appropriately, while GCC will ignore the pushes
+and pops as unknown pragmas. It should be noted that while Clang
+supports the GCC pragma, Clang and GCC do not support the exact same set
+of warnings, so even when using GCC compatible #pragmas there is no
+guarantee that they will have identical behaviour on both compilers.</p>
+<p>In addition to controlling warnings and errors generated by the compiler, it is
+possible to generate custom warning and error messages through the following
+pragmas:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="c1">// The following will produce warning messages</span>
+<span class="cp">#pragma message "some diagnostic message"</span>
+<span class="cp">#pragma GCC warning "TODO: replace deprecated feature"</span>
+
+<span class="c1">// The following will produce an error message</span>
+<span class="cp">#pragma GCC error "Not supported"</span>
+</pre></div>
+</div>
+<p>These pragmas operate similarly to the <tt class="docutils literal"><span class="pre">#warning</span></tt> and <tt class="docutils literal"><span class="pre">#error</span></tt> preprocessor
+directives, except that they may also be embedded into preprocessor macros via
+the C99 <tt class="docutils literal"><span class="pre">_Pragma</span></tt> operator, for example:</p>
+<div class="highlight-c"><div class="highlight"><pre><span class="cp">#define STR(X) #X</span>
+<span class="cp">#define DEFER(M,...) M(__VA_ARGS__)</span>
+<span class="cp">#define CUSTOM_ERROR(X) _Pragma(STR(GCC error(X " at line " DEFER(STR,__LINE__))))</span>
+
+<span class="n">CUSTOM_ERROR</span><span class="p">(</span><span class="s">"Feature not available"</span><span class="p">);</span>
+</pre></div>
+</div>
+</div>
+<div class="section" id="controlling-diagnostics-in-system-headers">
+<h4><a class="toc-backref" href="#id23">Controlling Diagnostics in System Headers</a><a class="headerlink" href="#controlling-diagnostics-in-system-headers" title="Permalink to this headline">¶</a></h4>
+<p>Warnings are suppressed when they occur in system headers. By default,
+an included file is treated as a system header if it is found in an
+include path specified by <tt class="docutils literal"><span class="pre">-isystem</span></tt>, but this can be overridden in
+several ways.</p>
+<p>The <tt class="docutils literal"><span class="pre">system_header</span></tt> pragma can be used to mark the current file as
+being a system header. No warnings will be produced from the location of
+the pragma onwards within the same file.</p>
+<div class="highlight-c"><div class="highlight"><pre>char a = 'xy'; // warning
+
+#pragma clang system_header
+
+char b = 'ab'; // no warning
+</pre></div>
+</div>
+<p>The <em class="xref std std-option">--system-header-prefix=</em> and <em class="xref std std-option">--no-system-header-prefix=</em>
+command-line arguments can be used to override whether subsets of an include
+path are treated as system headers. When the name in a <tt class="docutils literal"><span class="pre">#include</span></tt> directive
+is found within a header search path and starts with a system prefix, the
+header is treated as a system header. The last prefix on the
+command-line which matches the specified header name takes precedence.
+For instance:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang -Ifoo -isystem bar --system-header-prefix<span class="o">=</span>x/ <span class="se">\</span>
+<span class="go">    --no-system-header-prefix=x/y/</span>
+</pre></div>
+</div>
+<p>Here, <tt class="docutils literal"><span class="pre">#include</span> <span class="pre">"x/a.h"</span></tt> is treated as including a system header, even
+if the header is found in <tt class="docutils literal"><span class="pre">foo</span></tt>, and <tt class="docutils literal"><span class="pre">#include</span> <span class="pre">"x/y/b.h"</span></tt> is treated
+as not including a system header, even if the header is found in
+<tt class="docutils literal"><span class="pre">bar</span></tt>.</p>
+<p>A <tt class="docutils literal"><span class="pre">#include</span></tt> directive which finds a file relative to the current
+directory is treated as including a system header if the including file
+is treated as a system header.</p>
+</div>
+<div class="section" id="enabling-all-diagnostics">
+<span id="diagnostics-enable-everything"></span><h4><a class="toc-backref" href="#id24">Enabling All Diagnostics</a><a class="headerlink" href="#enabling-all-diagnostics" title="Permalink to this headline">¶</a></h4>
+<p>In addition to the traditional <tt class="docutils literal"><span class="pre">-W</span></tt> flags, one can enable <strong>all</strong>
+diagnostics by passing <a class="reference internal" href="#cmdoption-Weverything"><em class="xref std std-option">-Weverything</em></a>. This works as expected
+with
+<a class="reference internal" href="#cmdoption-Werror"><em class="xref std std-option">-Werror</em></a>, and also includes the warnings from <a class="reference internal" href="#cmdoption-pedantic"><em class="xref std std-option">-pedantic</em></a>.</p>
+<p>Note that when combined with <a class="reference internal" href="#cmdoption-w"><em class="xref std std-option">-w</em></a> (which disables all warnings), that
+flag wins.</p>
+</div>
+<div class="section" id="controlling-static-analyzer-diagnostics">
+<h4><a class="toc-backref" href="#id25">Controlling Static Analyzer Diagnostics</a><a class="headerlink" href="#controlling-static-analyzer-diagnostics" title="Permalink to this headline">¶</a></h4>
+<p>While not strictly part of the compiler, the diagnostics from Clang’s
+<a class="reference external" href="http://clang-analyzer.llvm.org">static analyzer</a> can also be
+influenced by the user via changes to the source code. See the available
+<a class="reference external" href="http://clang-analyzer.llvm.org/annotations.html">annotations</a> and the
+analyzer’s <a class="reference external" href="http://clang-analyzer.llvm.org/faq.html#exclude_code">FAQ
+page</a> for more
+information.</p>
+</div>
+</div>
+<div class="section" id="precompiled-headers">
+<span id="usersmanual-precompiled-headers"></span><h3><a class="toc-backref" href="#id26">Precompiled Headers</a><a class="headerlink" href="#precompiled-headers" title="Permalink to this headline">¶</a></h3>
+<p><a class="reference external" href="http://en.wikipedia.org/wiki/Precompiled_header">Precompiled headers</a>
+are a general approach employed by many compilers to reduce compilation
+time. The underlying motivation of the approach is that it is common for
+the same (and often large) header files to be included by multiple
+source files. Consequently, compile times can often be greatly improved
+by caching some of the (redundant) work done by a compiler to process
+headers. Precompiled header files, which represent one of many ways to
+implement this optimization, are literally files that represent an
+on-disk cache that contains the vital information necessary to reduce
+some of the work needed to process a corresponding header file. While
+details of precompiled headers vary between compilers, precompiled
+headers have been shown to be highly effective at speeding up program
+compilation on systems with very large system headers (e.g., Mac OS X).</p>
+<div class="section" id="generating-a-pch-file">
+<h4><a class="toc-backref" href="#id27">Generating a PCH File</a><a class="headerlink" href="#generating-a-pch-file" title="Permalink to this headline">¶</a></h4>
+<p>To generate a PCH file using Clang, one invokes Clang with the
+<em class="xref std std-option">-x <language>-header</em> option. This mirrors the interface in GCC
+for generating PCH files:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> gcc -x c-header test.h -o test.h.gch
+<span class="gp">$</span> clang -x c-header test.h -o test.h.pch
+</pre></div>
+</div>
+</div>
+<div class="section" id="using-a-pch-file">
+<h4><a class="toc-backref" href="#id28">Using a PCH File</a><a class="headerlink" href="#using-a-pch-file" title="Permalink to this headline">¶</a></h4>
+<p>A PCH file can then be used as a prefix header when a <em class="xref std std-option">-include</em>
+option is passed to <tt class="docutils literal"><span class="pre">clang</span></tt>:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang -include test.h test.c -o <span class="nb">test</span>
+</pre></div>
+</div>
+<p>The <tt class="docutils literal"><span class="pre">clang</span></tt> driver will first check if a PCH file for <tt class="docutils literal"><span class="pre">test.h</span></tt> is
+available; if so, the contents of <tt class="docutils literal"><span class="pre">test.h</span></tt> (and the files it includes)
+will be processed from the PCH file. Otherwise, Clang falls back to
+directly processing the content of <tt class="docutils literal"><span class="pre">test.h</span></tt>. This mirrors the behavior
+of GCC.</p>
+<div class="admonition note">
+<p class="first admonition-title">Note</p>
+<p>Clang does <em>not</em> automatically use PCH files for headers that are directly
+included within a source file. For example:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang -x c-header test.h -o test.h.pch
+<span class="gp">$</span> cat test.c
+<span class="gp">#</span>include <span class="s2">"test.h"</span>
+<span class="gp">$</span> clang test.c -o <span class="nb">test</span>
+</pre></div>
+</div>
+<p class="last">In this example, <tt class="docutils literal"><span class="pre">clang</span></tt> will not automatically use the PCH file for
+<tt class="docutils literal"><span class="pre">test.h</span></tt> since <tt class="docutils literal"><span class="pre">test.h</span></tt> was included directly in the source file and not
+specified on the command line using <em class="xref std std-option">-include</em>.</p>
+</div>
+</div>
+<div class="section" id="relocatable-pch-files">
+<h4><a class="toc-backref" href="#id29">Relocatable PCH Files</a><a class="headerlink" href="#relocatable-pch-files" title="Permalink to this headline">¶</a></h4>
+<p>It is sometimes necessary to build a precompiled header from headers
+that are not yet in their final, installed locations. For example, one
+might build a precompiled header within the build tree that is then
+meant to be installed alongside the headers. Clang permits the creation
+of “relocatable” precompiled headers, which are built with a given path
+(into the build directory) and can later be used from an installed
+location.</p>
+<p>To build a relocatable precompiled header, place your headers into a
+subdirectory whose structure mimics the installed location. For example,
+if you want to build a precompiled header for the header <tt class="docutils literal"><span class="pre">mylib.h</span></tt>
+that will be installed into <tt class="docutils literal"><span class="pre">/usr/include</span></tt>, create a subdirectory
+<tt class="docutils literal"><span class="pre">build/usr/include</span></tt> and place the header <tt class="docutils literal"><span class="pre">mylib.h</span></tt> into that
+subdirectory. If <tt class="docutils literal"><span class="pre">mylib.h</span></tt> depends on other headers, then they can be
+stored within <tt class="docutils literal"><span class="pre">build/usr/include</span></tt> in a way that mimics the installed
+location.</p>
+<p>Building a relocatable precompiled header requires two additional
+arguments. First, pass the <tt class="docutils literal"><span class="pre">--relocatable-pch</span></tt> flag to indicate that
+the resulting PCH file should be relocatable. Second, pass
+<em class="xref std std-option">-isysroot /path/to/build</em>, which makes all includes for your library
+relative to the build directory. For example:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">#</span> clang -x c-header --relocatable-pch -isysroot /path/to/build /path/to/build/mylib.h mylib.h.pch
+</pre></div>
+</div>
+<p>When loading the relocatable PCH file, the various headers used in the
+PCH file are found from the system header root. For example, <tt class="docutils literal"><span class="pre">mylib.h</span></tt>
+can be found in <tt class="docutils literal"><span class="pre">/usr/include/mylib.h</span></tt>. If the headers are installed
+in some other system root, the <em class="xref std std-option">-isysroot</em> option can be used provide
+a different system root from which the headers will be based. For
+example, <em class="xref std std-option">-isysroot /Developer/SDKs/MacOSX10.4u.sdk</em> will look for
+<tt class="docutils literal"><span class="pre">mylib.h</span></tt> in <tt class="docutils literal"><span class="pre">/Developer/SDKs/MacOSX10.4u.sdk/usr/include/mylib.h</span></tt>.</p>
+<p>Relocatable precompiled headers are intended to be used in a limited
+number of cases where the compilation environment is tightly controlled
+and the precompiled header cannot be generated after headers have been
+installed.</p>
+</div>
+</div>
+<div class="section" id="controlling-code-generation">
+<h3><a class="toc-backref" href="#id30">Controlling Code Generation</a><a class="headerlink" href="#controlling-code-generation" title="Permalink to this headline">¶</a></h3>
+<p>Clang provides a number of ways to control code generation. The options
+are listed below.</p>
+<dl class="docutils">
+<dt><strong>-f[no-]sanitize=check1,check2,...</strong></dt>
+<dd><p class="first">Turn on runtime checks for various forms of undefined or suspicious
+behavior.</p>
+<p>This option controls whether Clang adds runtime checks for various
+forms of undefined or suspicious behavior, and is disabled by
+default. If a check fails, a diagnostic message is produced at
+runtime explaining the problem. The main checks are:</p>
+<ul class="simple">
+<li><p id="opt-fsanitize-address"><tt class="docutils literal"><span class="pre">-fsanitize=address</span></tt>:
+<a class="reference internal" href="AddressSanitizer.html"><em>AddressSanitizer</em></a>, a memory error
+detector.</p>
+</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=integer</span></tt>: Enables checks for undefined or
+suspicious integer behavior.</li>
+<li><p id="opt-fsanitize-thread"><tt class="docutils literal"><span class="pre">-fsanitize=thread</span></tt>: <a class="reference internal" href="ThreadSanitizer.html"><em>ThreadSanitizer</em></a>, a data race detector.</p>
+</li>
+<li><p id="opt-fsanitize-memory"><tt class="docutils literal"><span class="pre">-fsanitize=memory</span></tt>: <a class="reference internal" href="MemorySanitizer.html"><em>MemorySanitizer</em></a>,
+an <em>experimental</em> detector of uninitialized reads. Not ready for
+widespread use.</p>
+</li>
+<li><p id="opt-fsanitize-undefined"><tt class="docutils literal"><span class="pre">-fsanitize=undefined</span></tt>: Fast and compatible undefined behavior
+checker. Enables the undefined behavior checks that have small
+runtime cost and no impact on address space layout or ABI. This
+includes all of the checks listed below other than
+<tt class="docutils literal"><span class="pre">unsigned-integer-overflow</span></tt>.</p>
+</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=undefined-trap</span></tt>: This includes all sanitizers
+included by <tt class="docutils literal"><span class="pre">-fsanitize=undefined</span></tt>, except those that require
+runtime support. This group of sanitizers is intended to be
+used in conjunction with the <tt class="docutils literal"><span class="pre">-fsanitize-undefined-trap-on-error</span></tt>
+flag. This includes all of the checks listed below other than
+<tt class="docutils literal"><span class="pre">unsigned-integer-overflow</span></tt> and <tt class="docutils literal"><span class="pre">vptr</span></tt>.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=dataflow</span></tt>: <a class="reference internal" href="DataFlowSanitizer.html"><em>DataFlowSanitizer</em></a>, a general data
+flow analysis.</li>
+</ul>
+<p>The following more fine-grained checks are also available:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">-fsanitize=alignment</span></tt>: Use of a misaligned pointer or creation
+of a misaligned reference.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=bool</span></tt>: Load of a <tt class="docutils literal"><span class="pre">bool</span></tt> value which is neither
+<tt class="docutils literal"><span class="pre">true</span></tt> nor <tt class="docutils literal"><span class="pre">false</span></tt>.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=bounds</span></tt>: Out of bounds array indexing, in cases
+where the array bound can be statically determined.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=enum</span></tt>: Load of a value of an enumerated type which
+is not in the range of representable values for that enumerated
+type.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=float-cast-overflow</span></tt>: Conversion to, from, or
+between floating-point types which would overflow the
+destination.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=float-divide-by-zero</span></tt>: Floating point division by
+zero.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=function</span></tt>: Indirect call of a function through a
+function pointer of the wrong type (Linux, C++ and x86/x86_64 only).</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=integer-divide-by-zero</span></tt>: Integer division by zero.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=nonnull-attribute</span></tt>: Passing null pointer as a function
+parameter which is declared to never be null.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=null</span></tt>: Use of a null pointer or creation of a null
+reference.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=object-size</span></tt>: An attempt to use bytes which the
+optimizer can determine are not part of the object being
+accessed. The sizes of objects are determined using
+<tt class="docutils literal"><span class="pre">__builtin_object_size</span></tt>, and consequently may be able to detect
+more problems at higher optimization levels.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=return</span></tt>: In C++, reaching the end of a
+value-returning function without returning a value.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=returns-nonnull-attribute</span></tt>: Returning null pointer
+from a function which is declared to never return null.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=shift</span></tt>: Shift operators where the amount shifted is
+greater or equal to the promoted bit-width of the left hand side
+or less than zero, or where the left hand side is negative. For a
+signed left shift, also checks for signed overflow in C, and for
+unsigned overflow in C++.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=signed-integer-overflow</span></tt>: Signed integer overflow,
+including all the checks added by <tt class="docutils literal"><span class="pre">-ftrapv</span></tt>, and checking for
+overflow in signed division (<tt class="docutils literal"><span class="pre">INT_MIN</span> <span class="pre">/</span> <span class="pre">-1</span></tt>).</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=unreachable</span></tt>: If control flow reaches
+<tt class="docutils literal"><span class="pre">__builtin_unreachable</span></tt>.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=unsigned-integer-overflow</span></tt>: Unsigned integer
+overflows.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=vla-bound</span></tt>: A variable-length array whose bound
+does not evaluate to a positive value.</li>
+<li><tt class="docutils literal"><span class="pre">-fsanitize=vptr</span></tt>: Use of an object whose vptr indicates that
+it is of the wrong dynamic type, or that its lifetime has not
+begun or has ended. Incompatible with <tt class="docutils literal"><span class="pre">-fno-rtti</span></tt>.</li>
+</ul>
+<p>You can turn off or modify checks for certain source files, functions
+or even variables by providing a special file:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">-fsanitize-blacklist=/path/to/blacklist/file</span></tt>: disable or modify
+sanitizer checks for objects listed in the file. See
+<a class="reference internal" href="SanitizerSpecialCaseList.html"><em>Sanitizer special case list</em></a> for file format description.</li>
+<li><tt class="docutils literal"><span class="pre">-fno-sanitize-blacklist</span></tt>: don’t use blacklist file, if it was
+specified earlier in the command line.</li>
+</ul>
+<p>Extra features of MemorySanitizer (require explicit
+<tt class="docutils literal"><span class="pre">-fsanitize=memory</span></tt>):</p>
+<ul>
+<li><p class="first"><tt class="docutils literal"><span class="pre">-fsanitize-memory-track-origins[=level]</span></tt>: Enables origin tracking in
+MemorySanitizer. Adds a second section to MemorySanitizer
+reports pointing to the heap or stack allocation the
+uninitialized bits came from. Slows down execution by additional
+1.5x-2x.</p>
+<p>Possible values for level are 0 (off), 1 (default), 2. Level 2 adds more
+sections to MemorySanitizer reports describing the order of memory stores
+the uninitialized value went through. Beware, this mode may use a lot of
+extra memory.</p>
+</li>
+</ul>
+<p>Extra features of UndefinedBehaviorSanitizer:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">-fsanitize-undefined-trap-on-error</span></tt>: Causes traps to be emitted
+rather than calls to runtime libraries when a problem is detected.
+This option is intended for use in cases where the sanitizer runtime
+cannot be used (for instance, when building libc or a kernel module).
+This is only compatible with the sanitizers in the <tt class="docutils literal"><span class="pre">undefined-trap</span></tt>
+group.</li>
+</ul>
+<p>The <tt class="docutils literal"><span class="pre">-fsanitize=</span></tt> argument must also be provided when linking, in
+order to link to the appropriate runtime library. When using
+<tt class="docutils literal"><span class="pre">-fsanitize=vptr</span></tt> (or a group that includes it, such as
+<tt class="docutils literal"><span class="pre">-fsanitize=undefined</span></tt>) with a C++ program, the link must be
+performed by <tt class="docutils literal"><span class="pre">clang++</span></tt>, not <tt class="docutils literal"><span class="pre">clang</span></tt>, in order to link against the
+C++-specific parts of the runtime library.</p>
+<p class="last">It is not possible to combine more than one of the <tt class="docutils literal"><span class="pre">-fsanitize=address</span></tt>,
+<tt class="docutils literal"><span class="pre">-fsanitize=thread</span></tt>, and <tt class="docutils literal"><span class="pre">-fsanitize=memory</span></tt> checkers in the same
+program. The <tt class="docutils literal"><span class="pre">-fsanitize=undefined</span></tt> checks can be combined with other
+sanitizers.</p>
+</dd>
+</dl>
+<p><strong>-f[no-]sanitize-recover=check1,check2,...</strong></p>
+<blockquote>
+<div><p>Controls which checks enabled by <tt class="docutils literal"><span class="pre">-fsanitize=</span></tt> flag are non-fatal.
+If the check is fatal, program will halt after the first error
+of this kind is detected and error report is printed.</p>
+<p>By default, non-fatal checks are those enabled by UndefinedBehaviorSanitizer,
+except for <tt class="docutils literal"><span class="pre">-fsanitize=return</span></tt> and <tt class="docutils literal"><span class="pre">-fsanitize=unreachable</span></tt>. Some
+sanitizers (e.g. <a class="reference internal" href="AddressSanitizer.html"><em>AddressSanitizer</em></a>) may not support recovery,
+and always crash the program after the issue is detected.</p>
+</div></blockquote>
+<dl class="option">
+<dt id="cmdoption-fno-assume-sane-operator-new">
+<tt class="descname">-fno-assume-sane-operator-new</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fno-assume-sane-operator-new" title="Permalink to this definition">¶</a></dt>
+<dd><p>Don’t assume that the C++’s new operator is sane.</p>
+<p>This option tells the compiler to do not assume that C++’s global
+new operator will always return a pointer that does not alias any
+other pointer when the function returns.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-ftrap-function">
+<tt class="descname">-ftrap-function</tt><tt class="descclassname">=[name]</tt><a class="headerlink" href="#cmdoption-ftrap-function" title="Permalink to this definition">¶</a></dt>
+<dd><p>Instruct code generator to emit a function call to the specified
+function name for <tt class="docutils literal"><span class="pre">__builtin_trap()</span></tt>.</p>
+<p>LLVM code generator translates <tt class="docutils literal"><span class="pre">__builtin_trap()</span></tt> to a trap
+instruction if it is supported by the target ISA. Otherwise, the
+builtin is translated into a call to <tt class="docutils literal"><span class="pre">abort</span></tt>. If this option is
+set, then the code generator will always lower the builtin to a call
+to the specified function regardless of whether the target ISA has a
+trap instruction. This option is useful for environments (e.g.
+deeply embedded) where a trap cannot be properly handled, or when
+some custom behavior is desired.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-ftls-model">
+<tt class="descname">-ftls-model</tt><tt class="descclassname">=[model]</tt><a class="headerlink" href="#cmdoption-ftls-model" title="Permalink to this definition">¶</a></dt>
+<dd><p>Select which TLS model to use.</p>
+<p>Valid values are: <tt class="docutils literal"><span class="pre">global-dynamic</span></tt>, <tt class="docutils literal"><span class="pre">local-dynamic</span></tt>,
+<tt class="docutils literal"><span class="pre">initial-exec</span></tt> and <tt class="docutils literal"><span class="pre">local-exec</span></tt>. The default value is
+<tt class="docutils literal"><span class="pre">global-dynamic</span></tt>. The compiler may use a different model if the
+selected model is not supported by the target, or if a more
+efficient model can be used. The TLS model can be overridden per
+variable using the <tt class="docutils literal"><span class="pre">tls_model</span></tt> attribute.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-mhwdiv">
+<tt class="descname">-mhwdiv</tt><tt class="descclassname">=[values]</tt><a class="headerlink" href="#cmdoption-mhwdiv" title="Permalink to this definition">¶</a></dt>
+<dd><p>Select the ARM modes (arm or thumb) that support hardware division
+instructions.</p>
+<p>Valid values are: <tt class="docutils literal"><span class="pre">arm</span></tt>, <tt class="docutils literal"><span class="pre">thumb</span></tt> and <tt class="docutils literal"><span class="pre">arm,thumb</span></tt>.
+This option is used to indicate which mode (arm or thumb) supports
+hardware division instructions. This only applies to the ARM
+architecture.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-m">
+<tt class="descname">-m</tt><tt class="descclassname">[no-]crc</tt><a class="headerlink" href="#cmdoption-m" title="Permalink to this definition">¶</a></dt>
+<dd><p>Enable or disable CRC instructions.</p>
+<p>This option is used to indicate whether CRC instructions are to
+be generated. This only applies to the ARM architecture.</p>
+<p>CRC instructions are enabled by default on ARMv8.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-mgeneral-regs-only">
+<tt class="descname">-mgeneral-regs-only</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-mgeneral-regs-only" title="Permalink to this definition">¶</a></dt>
+<dd><p>Generate code which only uses the general purpose registers.</p>
+<p>This option restricts the generated code to use general registers
+only. This only applies to the AArch64 architecture.</p>
+</dd></dl>
+
+<dl class="docutils">
+<dt><strong>-f[no-]max-unknown-pointer-align=[number]</strong></dt>
+<dd><p class="first">Instruct the code generator to not enforce a higher alignment than the given
+number (of bytes) when accessing memory via an opaque pointer or reference.
+This cap is ignored when directly accessing a variable or when the pointee
+type has an explicit “aligned” attribute.</p>
+<p>The value should usually be determined by the properties of the system allocator.
+Some builtin types, especially vector types, have very high natural alignments;
+when working with values of those types, Clang usually wants to use instructions
+that take advantage of that alignment.  However, many system allocators do
+not promise to return memory that is more than 8-byte or 16-byte-aligned.  Use
+this option to limit the alignment that the compiler can assume for an arbitrary
+pointer, which may point onto the heap.</p>
+<p>This option does not affect the ABI alignment of types; the layout of structs and
+unions and the value returned by the alignof operator remain the same.</p>
+<p>This option can be overridden on a case-by-case basis by putting an explicit
+“aligned” alignment on a struct, union, or typedef.  For example:</p>
+<div class="last highlight-console"><div class="highlight"><pre><span class="gp">#</span>include <immintrin.h>
+<span class="go">// Make an aligned typedef of the AVX-512 16-int vector type.</span>
+<span class="go">typedef __v16si __aligned_v16si __attribute__((aligned(64)));</span>
+
+<span class="go">void initialize_vector(__aligned_v16si *v) {</span>
+<span class="go">  // The compiler may assume that ‘v’ is 64-byte aligned, regardless of the</span>
+<span class="go">  // value of -fmax-unknown-pointer-align.</span>
+<span class="go">}</span>
+</pre></div>
+</div>
+</dd>
+</dl>
+</div>
+<div class="section" id="profile-guided-optimization">
+<h3><a class="toc-backref" href="#id31">Profile Guided Optimization</a><a class="headerlink" href="#profile-guided-optimization" title="Permalink to this headline">¶</a></h3>
+<p>Profile information enables better optimization. For example, knowing that a
+branch is taken very frequently helps the compiler make better decisions when
+ordering basic blocks. Knowing that a function <tt class="docutils literal"><span class="pre">foo</span></tt> is called more
+frequently than another function <tt class="docutils literal"><span class="pre">bar</span></tt> helps the inliner.</p>
+<p>Clang supports profile guided optimization with two different kinds of
+profiling. A sampling profiler can generate a profile with very low runtime
+overhead, or you can build an instrumented version of the code that collects
+more detailed profile information. Both kinds of profiles can provide execution
+counts for instructions in the code and information on branches taken and
+function invocation.</p>
+<p>Regardless of which kind of profiling you use, be careful to collect profiles
+by running your code with inputs that are representative of the typical
+behavior. Code that is not exercised in the profile will be optimized as if it
+is unimportant, and the compiler may make poor optimization choices for code
+that is disproportionately used while profiling.</p>
+<div class="section" id="using-sampling-profilers">
+<h4><a class="toc-backref" href="#id32">Using Sampling Profilers</a><a class="headerlink" href="#using-sampling-profilers" title="Permalink to this headline">¶</a></h4>
+<p>Sampling profilers are used to collect runtime information, such as
+hardware counters, while your application executes. They are typically
+very efficient and do not incur a large runtime overhead. The
+sample data collected by the profiler can be used during compilation
+to determine what the most executed areas of the code are.</p>
+<p>Using the data from a sample profiler requires some changes in the way
+a program is built. Before the compiler can use profiling information,
+the code needs to execute under the profiler. The following is the
+usual build cycle when using sample profilers for optimization:</p>
+<ol class="arabic">
+<li><p class="first">Build the code with source line table information. You can use all the
+usual build flags that you always build your application with. The only
+requirement is that you add <tt class="docutils literal"><span class="pre">-gline-tables-only</span></tt> or <tt class="docutils literal"><span class="pre">-g</span></tt> to the
+command line. This is important for the profiler to be able to map
+instructions back to source line locations.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang++ -O2 -gline-tables-only code.cc -o code
+</pre></div>
+</div>
+</li>
+<li><p class="first">Run the executable under a sampling profiler. The specific profiler
+you use does not really matter, as long as its output can be converted
+into the format that the LLVM optimizer understands. Currently, there
+exists a conversion tool for the Linux Perf profiler
+(<a class="reference external" href="https://perf.wiki.kernel.org/">https://perf.wiki.kernel.org/</a>), so these examples assume that you
+are using Linux Perf to profile your code.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> perf record -b ./code
+</pre></div>
+</div>
+<p>Note the use of the <tt class="docutils literal"><span class="pre">-b</span></tt> flag. This tells Perf to use the Last Branch
+Record (LBR) to record call chains. While this is not strictly required,
+it provides better call information, which improves the accuracy of
+the profile data.</p>
+</li>
+<li><p class="first">Convert the collected profile data to LLVM’s sample profile format.
+This is currently supported via the AutoFDO converter <tt class="docutils literal"><span class="pre">create_llvm_prof</span></tt>.
+It is available at <a class="reference external" href="http://github.com/google/autofdo">http://github.com/google/autofdo</a>. Once built and
+installed, you can convert the <tt class="docutils literal"><span class="pre">perf.data</span></tt> file to LLVM using
+the command:</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> create_llvm_prof --binary<span class="o">=</span>./code --out<span class="o">=</span>code.prof
+</pre></div>
+</div>
+<p>This will read <tt class="docutils literal"><span class="pre">perf.data</span></tt> and the binary file <tt class="docutils literal"><span class="pre">./code</span></tt> and emit
+the profile data in <tt class="docutils literal"><span class="pre">code.prof</span></tt>. Note that if you ran <tt class="docutils literal"><span class="pre">perf</span></tt>
+without the <tt class="docutils literal"><span class="pre">-b</span></tt> flag, you need to use <tt class="docutils literal"><span class="pre">--use_lbr=false</span></tt> when
+calling <tt class="docutils literal"><span class="pre">create_llvm_prof</span></tt>.</p>
+</li>
+<li><p class="first">Build the code again using the collected profile. This step feeds
+the profile back to the optimizers. This should result in a binary
+that executes faster than the original one. Note that you are not
+required to build the code with the exact same arguments that you
+used in the first step. The only requirement is that you build the code
+with <tt class="docutils literal"><span class="pre">-gline-tables-only</span></tt> and <tt class="docutils literal"><span class="pre">-fprofile-sample-use</span></tt>.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang++ -O2 -gline-tables-only -fprofile-sample-use<span class="o">=</span>code.prof code.cc -o code
+</pre></div>
+</div>
+</li>
+</ol>
+<div class="section" id="sample-profile-format">
+<h5><a class="toc-backref" href="#id33">Sample Profile Format</a><a class="headerlink" href="#sample-profile-format" title="Permalink to this headline">¶</a></h5>
+<p>If you are not using Linux Perf to collect profiles, you will need to
+write a conversion tool from your profiler to LLVM’s format. This section
+explains the file format expected by the backend.</p>
+<p>Sample profiles are written as ASCII text. The file is divided into sections,
+which correspond to each of the functions executed at runtime. Each
+section has the following format (taken from
+<a class="reference external" href="https://github.com/google/autofdo/blob/master/profile_writer.h">https://github.com/google/autofdo/blob/master/profile_writer.h</a>):</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">function1:total_samples:total_head_samples</span>
+<span class="go">offset1[.discriminator]: number_of_samples [fn1:num fn2:num ... ]</span>
+<span class="go">offset2[.discriminator]: number_of_samples [fn3:num fn4:num ... ]</span>
+<span class="go">...</span>
+<span class="go">offsetN[.discriminator]: number_of_samples [fn5:num fn6:num ... ]</span>
+</pre></div>
+</div>
+<p>The file may contain blank lines between sections and within a
+section. However, the spacing within a single line is fixed. Additional
+spaces will result in an error while reading the file.</p>
+<p>Function names must be mangled in order for the profile loader to
+match them in the current translation unit. The two numbers in the
+function header specify how many total samples were accumulated in the
+function (first number), and the total number of samples accumulated
+in the prologue of the function (second number). This head sample
+count provides an indicator of how frequently the function is invoked.</p>
+<p>Each sampled line may contain several items. Some are optional (marked
+below):</p>
+<ol class="loweralpha">
+<li><p class="first">Source line offset. This number represents the line number
+in the function where the sample was collected. The line number is
+always relative to the line where symbol of the function is
+defined. So, if the function has its header at line 280, the offset
+13 is at line 293 in the file.</p>
+<p>Note that this offset should never be a negative number. This could
+happen in cases like macros. The debug machinery will register the
+line number at the point of macro expansion. So, if the macro was
+expanded in a line before the start of the function, the profile
+converter should emit a 0 as the offset (this means that the optimizers
+will not be able to associate a meaningful weight to the instructions
+in the macro).</p>
+</li>
+<li><p class="first">[OPTIONAL] Discriminator. This is used if the sampled program
+was compiled with DWARF discriminator support
+(<a class="reference external" href="http://wiki.dwarfstd.org/index.php?title=Path_Discriminators">http://wiki.dwarfstd.org/index.php?title=Path_Discriminators</a>).
+DWARF discriminators are unsigned integer values that allow the
+compiler to distinguish between multiple execution paths on the
+same source line location.</p>
+<p>For example, consider the line of code <tt class="docutils literal"><span class="pre">if</span> <span class="pre">(cond)</span> <span class="pre">foo();</span> <span class="pre">else</span> <span class="pre">bar();</span></tt>.
+If the predicate <tt class="docutils literal"><span class="pre">cond</span></tt> is true 80% of the time, then the edge
+into function <tt class="docutils literal"><span class="pre">foo</span></tt> should be considered to be taken most of the
+time. But both calls to <tt class="docutils literal"><span class="pre">foo</span></tt> and <tt class="docutils literal"><span class="pre">bar</span></tt> are at the same source
+line, so a sample count at that line is not sufficient. The
+compiler needs to know which part of that line is taken more
+frequently.</p>
+<p>This is what discriminators provide. In this case, the calls to
+<tt class="docutils literal"><span class="pre">foo</span></tt> and <tt class="docutils literal"><span class="pre">bar</span></tt> will be at the same line, but will have
+different discriminator values. This allows the compiler to correctly
+set edge weights into <tt class="docutils literal"><span class="pre">foo</span></tt> and <tt class="docutils literal"><span class="pre">bar</span></tt>.</p>
+</li>
+<li><p class="first">Number of samples. This is an integer quantity representing the
+number of samples collected by the profiler at this source
+location.</p>
+</li>
+<li><p class="first">[OPTIONAL] Potential call targets and samples. If present, this
+line contains a call instruction. This models both direct and
+number of samples. For example,</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="go">130: 7  foo:3  bar:2  baz:7</span>
+</pre></div>
+</div>
+<p>The above means that at relative line offset 130 there is a call
+instruction that calls one of <tt class="docutils literal"><span class="pre">foo()</span></tt>, <tt class="docutils literal"><span class="pre">bar()</span></tt> and <tt class="docutils literal"><span class="pre">baz()</span></tt>,
+with <tt class="docutils literal"><span class="pre">baz()</span></tt> being the relatively more frequently called target.</p>
+</li>
+</ol>
+</div>
+</div>
+<div class="section" id="profiling-with-instrumentation">
+<h4><a class="toc-backref" href="#id34">Profiling with Instrumentation</a><a class="headerlink" href="#profiling-with-instrumentation" title="Permalink to this headline">¶</a></h4>
+<p>Clang also supports profiling via instrumentation. This requires building a
+special instrumented version of the code and has some runtime
+overhead during the profiling, but it provides more detailed results than a
+sampling profiler. It also provides reproducible results, at least to the
+extent that the code behaves consistently across runs.</p>
+<p>Here are the steps for using profile guided optimization with
+instrumentation:</p>
+<ol class="arabic">
+<li><p class="first">Build an instrumented version of the code by compiling and linking with the
+<tt class="docutils literal"><span class="pre">-fprofile-instr-generate</span></tt> option.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang++ -O2 -fprofile-instr-generate code.cc -o code
+</pre></div>
+</div>
+</li>
+<li><p class="first">Run the instrumented executable with inputs that reflect the typical usage.
+By default, the profile data will be written to a <tt class="docutils literal"><span class="pre">default.profraw</span></tt> file
+in the current directory. You can override that default by setting the
+<tt class="docutils literal"><span class="pre">LLVM_PROFILE_FILE</span></tt> environment variable to specify an alternate file.
+Any instance of <tt class="docutils literal"><span class="pre">%p</span></tt> in that file name will be replaced by the process
+ID, so that you can easily distinguish the profile output from multiple
+runs.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> <span class="nv">LLVM_PROFILE_FILE</span><span class="o">=</span><span class="s2">"code-%p.profraw"</span> ./code
+</pre></div>
+</div>
+</li>
+<li><p class="first">Combine profiles from multiple runs and convert the “raw” profile format to
+the input expected by clang. Use the <tt class="docutils literal"><span class="pre">merge</span></tt> command of the llvm-profdata
+tool to do this.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> llvm-profdata merge -output<span class="o">=</span>code.profdata code-*.profraw
+</pre></div>
+</div>
+<p>Note that this step is necessary even when there is only one “raw” profile,
+since the merge operation also changes the file format.</p>
+</li>
+<li><p class="first">Build the code again using the <tt class="docutils literal"><span class="pre">-fprofile-instr-use</span></tt> option to specify the
+collected profile data.</p>
+<div class="highlight-console"><div class="highlight"><pre><span class="gp">$</span> clang++ -O2 -fprofile-instr-use<span class="o">=</span>code.profdata code.cc -o code
+</pre></div>
+</div>
+<p>You can repeat step 4 as often as you like without regenerating the
+profile. As you make changes to your code, clang may no longer be able to
+use the profile data. It will warn you when this happens.</p>
+</li>
+</ol>
+</div>
+</div>
+<div class="section" id="controlling-size-of-debug-information">
+<h3><a class="toc-backref" href="#id35">Controlling Size of Debug Information</a><a class="headerlink" href="#controlling-size-of-debug-information" title="Permalink to this headline">¶</a></h3>
+<p>Debug info kind generated by Clang can be set by one of the flags listed
+below. If multiple flags are present, the last one is used.</p>
+<dl class="option">
+<dt id="cmdoption-g0">
+<tt class="descname">-g0</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-g0" title="Permalink to this definition">¶</a></dt>
+<dd><p>Don’t generate any debug info (default).</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-gline-tables-only">
+<tt class="descname">-gline-tables-only</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-gline-tables-only" title="Permalink to this definition">¶</a></dt>
+<dd><p>Generate line number tables only.</p>
+<p>This kind of debug info allows to obtain stack traces with function names,
+file names and line numbers (by such tools as <tt class="docutils literal"><span class="pre">gdb</span></tt> or <tt class="docutils literal"><span class="pre">addr2line</span></tt>).  It
+doesn’t contain any other data (e.g. description of local variables or
+function parameters).</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fstandalone-debug">
+<tt class="descname">-fstandalone-debug</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fstandalone-debug" title="Permalink to this definition">¶</a></dt>
+<dd><p>Clang supports a number of optimizations to reduce the size of debug
+information in the binary. They work based on the assumption that
+the debug type information can be spread out over multiple
+compilation units.  For instance, Clang will not emit type
+definitions for types that are not needed by a module and could be
+replaced with a forward declaration.  Further, Clang will only emit
+type info for a dynamic C++ class in the module that contains the
+vtable for the class.</p>
+<p>The <strong>-fstandalone-debug</strong> option turns off these optimizations.
+This is useful when working with 3rd-party libraries that don’t come
+with debug information.  Note that Clang will never emit type
+information for types that are not referenced at all by the program.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fno-standalone-debug">
+<tt class="descname">-fno-standalone-debug</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fno-standalone-debug" title="Permalink to this definition">¶</a></dt>
+<dd><p>On Darwin <strong>-fstandalone-debug</strong> is enabled by default. The
+<strong>-fno-standalone-debug</strong> option can be used to get to turn on the
+vtable-based optimization described above.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-g">
+<tt class="descname">-g</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-g" title="Permalink to this definition">¶</a></dt>
+<dd><p>Generate complete debug info.</p>
+</dd></dl>
+
+</div>
+<div class="section" id="comment-parsing-options">
+<h3><a class="toc-backref" href="#id36">Comment Parsing Options</a><a class="headerlink" href="#comment-parsing-options" title="Permalink to this headline">¶</a></h3>
+<p>Clang parses Doxygen and non-Doxygen style documentation comments and attaches
+them to the appropriate declaration nodes.  By default, it only parses
+Doxygen-style comments and ignores ordinary comments starting with <tt class="docutils literal"><span class="pre">//</span></tt> and
+<tt class="docutils literal"><span class="pre">/*</span></tt>.</p>
+<dl class="option">
+<dt id="cmdoption-Wdocumentation">
+<tt class="descname">-Wdocumentation</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wdocumentation" title="Permalink to this definition">¶</a></dt>
+<dd><p>Emit warnings about use of documentation comments.  This warning group is off
+by default.</p>
+<p>This includes checking that <tt class="docutils literal"><span class="pre">\param</span></tt> commands name parameters that actually
+present in the function signature, checking that <tt class="docutils literal"><span class="pre">\returns</span></tt> is used only on
+functions that actually return a value etc.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-Wno-documentation-unknown-command">
+<tt class="descname">-Wno-documentation-unknown-command</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-Wno-documentation-unknown-command" title="Permalink to this definition">¶</a></dt>
+<dd><p>Don’t warn when encountering an unknown Doxygen command.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fparse-all-comments">
+<tt class="descname">-fparse-all-comments</tt><tt class="descclassname"></tt><a class="headerlink" href="#cmdoption-fparse-all-comments" title="Permalink to this definition">¶</a></dt>
+<dd><p>Parse all comments as documentation comments (including ordinary comments
+starting with <tt class="docutils literal"><span class="pre">//</span></tt> and <tt class="docutils literal"><span class="pre">/*</span></tt>).</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fcomment-block-commands">
+<tt class="descname">-fcomment-block-commands</tt><tt class="descclassname">=[commands]</tt><a class="headerlink" href="#cmdoption-fcomment-block-commands" title="Permalink to this definition">¶</a></dt>
+<dd><p>Define custom documentation commands as block commands.  This allows Clang to
+construct the correct AST for these custom commands, and silences warnings
+about unknown commands.  Several commands must be separated by a comma
+<em>without trailing space</em>; e.g. <tt class="docutils literal"><span class="pre">-fcomment-block-commands=foo,bar</span></tt> defines
+custom commands <tt class="docutils literal"><span class="pre">\foo</span></tt> and <tt class="docutils literal"><span class="pre">\bar</span></tt>.</p>
+<p>It is also possible to use <tt class="docutils literal"><span class="pre">-fcomment-block-commands</span></tt> several times; e.g.
+<tt class="docutils literal"><span class="pre">-fcomment-block-commands=foo</span> <span class="pre">-fcomment-block-commands=bar</span></tt> does the same
+as above.</p>
+</dd></dl>
+
+</div>
+</div>
+<div class="section" id="c-language-features">
+<span id="c"></span><h2><a class="toc-backref" href="#id37">C Language Features</a><a class="headerlink" href="#c-language-features" title="Permalink to this headline">¶</a></h2>
+<p>The support for standard C in clang is feature-complete except for the
+C99 floating-point pragmas.</p>
+<div class="section" id="extensions-supported-by-clang">
+<h3><a class="toc-backref" href="#id38">Extensions supported by clang</a><a class="headerlink" href="#extensions-supported-by-clang" title="Permalink to this headline">¶</a></h3>
+<p>See <a class="reference internal" href="LanguageExtensions.html"><em>Clang Language Extensions</em></a>.</p>
+</div>
+<div class="section" id="differences-between-various-standard-modes">
+<h3><a class="toc-backref" href="#id39">Differences between various standard modes</a><a class="headerlink" href="#differences-between-various-standard-modes" title="Permalink to this headline">¶</a></h3>
+<p>clang supports the -std option, which changes what language mode clang
+uses. The supported modes for C are c89, gnu89, c94, c99, gnu99, c11,
+gnu11, and various aliases for those modes. If no -std option is
+specified, clang defaults to gnu11 mode. Many C99 and C11 features are
+supported in earlier modes as a conforming extension, with a warning. Use
+<tt class="docutils literal"><span class="pre">-pedantic-errors</span></tt> to request an error if a feature from a later standard
+revision is used in an earlier mode.</p>
+<p>Differences between all <tt class="docutils literal"><span class="pre">c*</span></tt> and <tt class="docutils literal"><span class="pre">gnu*</span></tt> modes:</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">c*</span></tt> modes define “<tt class="docutils literal"><span class="pre">__STRICT_ANSI__</span></tt>”.</li>
+<li>Target-specific defines not prefixed by underscores, like “linux”,
+are defined in <tt class="docutils literal"><span class="pre">gnu*</span></tt> modes.</li>
+<li>Trigraphs default to being off in <tt class="docutils literal"><span class="pre">gnu*</span></tt> modes; they can be enabled by
+the -trigraphs option.</li>
+<li>The parser recognizes “asm” and “typeof” as keywords in <tt class="docutils literal"><span class="pre">gnu*</span></tt> modes;
+the variants “<tt class="docutils literal"><span class="pre">__asm__</span></tt>” and “<tt class="docutils literal"><span class="pre">__typeof__</span></tt>” are recognized in all
+modes.</li>
+<li>The Apple “blocks” extension is recognized by default in <tt class="docutils literal"><span class="pre">gnu*</span></tt> modes
+on some platforms; it can be enabled in any mode with the “-fblocks”
+option.</li>
+<li>Arrays that are VLA’s according to the standard, but which can be
+constant folded by the frontend are treated as fixed size arrays.
+This occurs for things like “int X[(1, 2)];”, which is technically a
+VLA. <tt class="docutils literal"><span class="pre">c*</span></tt> modes are strictly compliant and treat these as VLAs.</li>
+</ul>
+<p>Differences between <tt class="docutils literal"><span class="pre">*89</span></tt> and <tt class="docutils literal"><span class="pre">*99</span></tt> modes:</p>
+<ul class="simple">
+<li>The <tt class="docutils literal"><span class="pre">*99</span></tt> modes default to implementing “inline” as specified in C99,
+while the <tt class="docutils literal"><span class="pre">*89</span></tt> modes implement the GNU version. This can be
+overridden for individual functions with the <tt class="docutils literal"><span class="pre">__gnu_inline__</span></tt>
+attribute.</li>
+<li>Digraphs are not recognized in c89 mode.</li>
+<li>The scope of names defined inside a “for”, “if”, “switch”, “while”,
+or “do” statement is different. (example: “<tt class="docutils literal"><span class="pre">if</span> <span class="pre">((struct</span> <span class="pre">x</span> <span class="pre">{int</span>
+<span class="pre">x;}*)0)</span> <span class="pre">{}</span></tt>”.)</li>
+<li><tt class="docutils literal"><span class="pre">__STDC_VERSION__</span></tt> is not defined in <tt class="docutils literal"><span class="pre">*89</span></tt> modes.</li>
+<li>“inline” is not recognized as a keyword in c89 mode.</li>
+<li>“restrict” is not recognized as a keyword in <tt class="docutils literal"><span class="pre">*89</span></tt> modes.</li>
+<li>Commas are allowed in integer constant expressions in <tt class="docutils literal"><span class="pre">*99</span></tt> modes.</li>
+<li>Arrays which are not lvalues are not implicitly promoted to pointers
+in <tt class="docutils literal"><span class="pre">*89</span></tt> modes.</li>
+<li>Some warnings are different.</li>
+</ul>
+<p>Differences between <tt class="docutils literal"><span class="pre">*99</span></tt> and <tt class="docutils literal"><span class="pre">*11</span></tt> modes:</p>
+<ul class="simple">
+<li>Warnings for use of C11 features are disabled.</li>
+<li><tt class="docutils literal"><span class="pre">__STDC_VERSION__</span></tt> is defined to <tt class="docutils literal"><span class="pre">201112L</span></tt> rather than <tt class="docutils literal"><span class="pre">199901L</span></tt>.</li>
+</ul>
+<p>c94 mode is identical to c89 mode except that digraphs are enabled in
+c94 mode (FIXME: And <tt class="docutils literal"><span class="pre">__STDC_VERSION__</span></tt> should be defined!).</p>
+</div>
+<div class="section" id="gcc-extensions-not-implemented-yet">
+<h3><a class="toc-backref" href="#id40">GCC extensions not implemented yet</a><a class="headerlink" href="#gcc-extensions-not-implemented-yet" title="Permalink to this headline">¶</a></h3>
+<p>clang tries to be compatible with gcc as much as possible, but some gcc
+extensions are not implemented yet:</p>
+<ul>
+<li><p class="first">clang does not support #pragma weak (<a class="reference external" href="http://llvm.org/bugs/show_bug.cgi?id=3679">bug
+3679</a>). Due to the uses
+described in the bug, this is likely to be implemented at some point,
+at least partially.</p>
+</li>
+<li><p class="first">clang does not support decimal floating point types (<tt class="docutils literal"><span class="pre">_Decimal32</span></tt> and
+friends) or fixed-point types (<tt class="docutils literal"><span class="pre">_Fract</span></tt> and friends); nobody has
+expressed interest in these features yet, so it’s hard to say when
+they will be implemented.</p>
+</li>
+<li><p class="first">clang does not support nested functions; this is a complex feature
+which is infrequently used, so it is unlikely to be implemented
+anytime soon. In C++11 it can be emulated by assigning lambda
+functions to local variables, e.g:</p>
+<div class="highlight-cpp"><div class="highlight"><pre><span class="k">auto</span> <span class="k">const</span> <span class="n">local_function</span> <span class="o">=</span> <span class="p">[</span><span class="o">&</span><span class="p">](</span><span class="kt">int</span> <span class="n">parameter</span><span class="p">)</span> <span class="p">{</span>
+  <span class="c1">// Do something</span>
+<span class="p">};</span>
+<span class="p">...</span>
+<span class="n">local_function</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
+</pre></div>
+</div>
+</li>
+<li><p class="first">clang does not support global register variables; this is unlikely to
+be implemented soon because it requires additional LLVM backend
+support.</p>
+</li>
+<li><p class="first">clang does not support static initialization of flexible array
+members. This appears to be a rarely used extension, but could be
+implemented pending user demand.</p>
+</li>
+<li><p class="first">clang does not support
+<tt class="docutils literal"><span class="pre">__builtin_va_arg_pack</span></tt>/<tt class="docutils literal"><span class="pre">__builtin_va_arg_pack_len</span></tt>. This is
+used rarely, but in some potentially interesting places, like the
+glibc headers, so it may be implemented pending user demand. Note
+that because clang pretends to be like GCC 4.2, and this extension
+was introduced in 4.3, the glibc headers will not try to use this
+extension with clang at the moment.</p>
+</li>
+<li><p class="first">clang does not support the gcc extension for forward-declaring
+function parameters; this has not shown up in any real-world code
+yet, though, so it might never be implemented.</p>
+</li>
+</ul>
+<p>This is not a complete list; if you find an unsupported extension
+missing from this list, please send an e-mail to cfe-dev. This list
+currently excludes C++; see <a class="reference internal" href="#cxx"><em>C++ Language Features</em></a>. Also, this
+list does not include bugs in mostly-implemented features; please see
+the <a class="reference external" href="http://llvm.org/bugs/buglist.cgi?quicksearch=product%3Aclang+component%3A-New%2BBugs%2CAST%2CBasic%2CDriver%2CHeaders%2CLLVM%2BCodeGen%2Cparser%2Cpreprocessor%2CSemantic%2BAnalyzer">bug
+tracker</a>
+for known existing bugs (FIXME: Is there a section for bug-reporting
+guidelines somewhere?).</p>
+</div>
+<div class="section" id="intentionally-unsupported-gcc-extensions">
+<h3><a class="toc-backref" href="#id41">Intentionally unsupported GCC extensions</a><a class="headerlink" href="#intentionally-unsupported-gcc-extensions" title="Permalink to this headline">¶</a></h3>
+<ul class="simple">
+<li>clang does not support the gcc extension that allows variable-length
+arrays in structures. This is for a few reasons: one, it is tricky to
+implement, two, the extension is completely undocumented, and three,
+the extension appears to be rarely used. Note that clang <em>does</em>
+support flexible array members (arrays with a zero or unspecified
+size at the end of a structure).</li>
+<li>clang does not have an equivalent to gcc’s “fold”; this means that
+clang doesn’t accept some constructs gcc might accept in contexts
+where a constant expression is required, like “x-x” where x is a
+variable.</li>
+<li>clang does not support <tt class="docutils literal"><span class="pre">__builtin_apply</span></tt> and friends; this extension
+is extremely obscure and difficult to implement reliably.</li>
+</ul>
+</div>
+<div class="section" id="microsoft-extensions">
+<span id="c-ms"></span><h3><a class="toc-backref" href="#id42">Microsoft extensions</a><a class="headerlink" href="#microsoft-extensions" title="Permalink to this headline">¶</a></h3>
+<p>clang has some experimental support for extensions from Microsoft Visual
+C++; to enable it, use the <tt class="docutils literal"><span class="pre">-fms-extensions</span></tt> command-line option. This is
+the default for Windows targets. Note that the support is incomplete.
+Some constructs such as <tt class="docutils literal"><span class="pre">dllexport</span></tt> on classes are ignored with a warning,
+and others such as <a class="reference external" href="http://msdn.microsoft.com/en-us/library/8tesw2eh.aspx">Microsoft IDL annotations</a> are silently
+ignored.</p>
+<p>clang has a <tt class="docutils literal"><span class="pre">-fms-compatibility</span></tt> flag that makes clang accept enough
+invalid C++ to be able to parse most Microsoft headers. For example, it
+allows <a class="reference external" href="http://clang.llvm.org/compatibility.html#dep_lookup_bases">unqualified lookup of dependent base class members</a>, which is
+a common compatibility issue with clang. This flag is enabled by default
+for Windows targets.</p>
+<p><tt class="docutils literal"><span class="pre">-fdelayed-template-parsing</span></tt> lets clang delay parsing of function template
+definitions until the end of a translation unit. This flag is enabled by
+default for Windows targets.</p>
+<ul class="simple">
+<li>clang allows setting <tt class="docutils literal"><span class="pre">_MSC_VER</span></tt> with <tt class="docutils literal"><span class="pre">-fmsc-version=</span></tt>. It defaults to
+1700 which is the same as Visual C/C++ 2012. Any number is supported
+and can greatly affect what Windows SDK and c++stdlib headers clang
+can compile.</li>
+<li>clang does not support the Microsoft extension where anonymous record
+members can be declared using user defined typedefs.</li>
+<li>clang supports the Microsoft <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">pack</span></tt> feature for controlling
+record layout. GCC also contains support for this feature, however
+where MSVC and GCC are incompatible clang follows the MSVC
+definition.</li>
+<li>clang supports the Microsoft <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">comment(lib,</span> <span class="pre">"foo.lib")</span></tt> feature for
+automatically linking against the specified library.  Currently this feature
+only works with the Visual C++ linker.</li>
+<li>clang supports the Microsoft <tt class="docutils literal"><span class="pre">#pragma</span> <span class="pre">comment(linker,</span> <span class="pre">"/flag:foo")</span></tt> feature
+for adding linker flags to COFF object files.  The user is responsible for
+ensuring that the linker understands the flags.</li>
+<li>clang defaults to C++11 for Windows targets.</li>
+</ul>
+</div>
+</div>
+<div class="section" id="cxx">
+<span id="id2"></span><h2><a class="toc-backref" href="#id43">C++ Language Features</a><a class="headerlink" href="#cxx" title="Permalink to this headline">¶</a></h2>
+<p>clang fully implements all of standard C++98 except for exported
+templates (which were removed in C++11), and all of standard C++11
+and the current draft standard for C++1y.</p>
+<div class="section" id="controlling-implementation-limits">
+<h3><a class="toc-backref" href="#id44">Controlling implementation limits</a><a class="headerlink" href="#controlling-implementation-limits" title="Permalink to this headline">¶</a></h3>
+<dl class="option">
+<dt id="cmdoption-fbracket-depth">
+<tt class="descname">-fbracket-depth</tt><tt class="descclassname">=N</tt><a class="headerlink" href="#cmdoption-fbracket-depth" title="Permalink to this definition">¶</a></dt>
+<dd><p>Sets the limit for nested parentheses, brackets, and braces to N.  The
+default is 256.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-fconstexpr-depth">
+<tt class="descname">-fconstexpr-depth</tt><tt class="descclassname">=N</tt><a class="headerlink" href="#cmdoption-fconstexpr-depth" title="Permalink to this definition">¶</a></dt>
+<dd><p>Sets the limit for recursive constexpr function invocations to N.  The
+default is 512.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-ftemplate-depth">
+<tt class="descname">-ftemplate-depth</tt><tt class="descclassname">=N</tt><a class="headerlink" href="#cmdoption-ftemplate-depth" title="Permalink to this definition">¶</a></dt>
+<dd><p>Sets the limit for recursively nested template instantiations to N.  The
+default is 256.</p>
+</dd></dl>
+
+<dl class="option">
+<dt id="cmdoption-foperator-arrow-depth">
+<tt class="descname">-foperator-arrow-depth</tt><tt class="descclassname">=N</tt><a class="headerlink" href="#cmdoption-foperator-arrow-depth" title="Permalink to this definition">¶</a></dt>
+<dd><p>Sets the limit for iterative calls to ‘operator->’ functions to N.  The
+default is 256.</p>
+</dd></dl>
+
+</div>
+</div>
+<div class="section" id="objective-c-language-features">
+<span id="objc"></span><h2><a class="toc-backref" href="#id45">Objective-C Language Features</a><a class="headerlink" href="#objective-c-language-features" title="Permalink to this headline">¶</a></h2>
+</div>
+<div class="section" id="objcxx">
+<span id="id3"></span><h2><a class="toc-backref" href="#id46">Objective-C++ Language Features</a><a class="headerlink" href="#objcxx" title="Permalink to this headline">¶</a></h2>
+</div>
+<div class="section" id="target-specific-features-and-limitations">
+<span id="target-features"></span><h2><a class="toc-backref" href="#id47">Target-Specific Features and Limitations</a><a class="headerlink" href="#target-specific-features-and-limitations" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="cpu-architectures-features-and-limitations">
+<h3><a class="toc-backref" href="#id48">CPU Architectures Features and Limitations</a><a class="headerlink" href="#cpu-architectures-features-and-limitations" title="Permalink to this headline">¶</a></h3>
+<div class="section" id="x86">
+<h4><a class="toc-backref" href="#id49">X86</a><a class="headerlink" href="#x86" title="Permalink to this headline">¶</a></h4>
+<p>The support for X86 (both 32-bit and 64-bit) is considered stable on
+Darwin (Mac OS X), Linux, FreeBSD, and Dragonfly BSD: it has been tested
+to correctly compile many large C, C++, Objective-C, and Objective-C++
+codebases.</p>
+<p>On <tt class="docutils literal"><span class="pre">x86_64-mingw32</span></tt>, passing i128(by value) is incompatible with the
+Microsoft x64 calling convention. You might need to tweak
+<tt class="docutils literal"><span class="pre">WinX86_64ABIInfo::classify()</span></tt> in lib/CodeGen/TargetInfo.cpp.</p>
+<p>For the X86 target, clang supports the <em class="xref std std-option">-m16</em> command line
+argument which enables 16-bit code output. This is broadly similar to
+using <tt class="docutils literal"><span class="pre">asm(".code16gcc")</span></tt> with the GNU toolchain. The generated code
+and the ABI remains 32-bit but the assembler emits instructions
+appropriate for a CPU running in 16-bit mode, with address-size and
+operand-size prefixes to enable 32-bit addressing and operations.</p>
+</div>
+<div class="section" id="arm">
+<h4><a class="toc-backref" href="#id50">ARM</a><a class="headerlink" href="#arm" title="Permalink to this headline">¶</a></h4>
+<p>The support for ARM (specifically ARMv6 and ARMv7) is considered stable
+on Darwin (iOS): it has been tested to correctly compile many large C,
+C++, Objective-C, and Objective-C++ codebases. Clang only supports a
+limited number of ARM architectures. It does not yet fully support
+ARMv5, for example.</p>
+</div>
+<div class="section" id="powerpc">
+<h4><a class="toc-backref" href="#id51">PowerPC</a><a class="headerlink" href="#powerpc" title="Permalink to this headline">¶</a></h4>
+<p>The support for PowerPC (especially PowerPC64) is considered stable
+on Linux and FreeBSD: it has been tested to correctly compile many
+large C and C++ codebases. PowerPC (32bit) is still missing certain
+features (e.g. PIC code on ELF platforms).</p>
+</div>
+<div class="section" id="other-platforms">
+<h4><a class="toc-backref" href="#id52">Other platforms</a><a class="headerlink" href="#other-platforms" title="Permalink to this headline">¶</a></h4>
+<p>clang currently contains some support for other architectures (e.g. Sparc);
+however, significant pieces of code generation are still missing, and they
+haven’t undergone significant testing.</p>
+<p>clang contains limited support for the MSP430 embedded processor, but
+both the clang support and the LLVM backend support are highly
+experimental.</p>
+<p>Other platforms are completely unsupported at the moment. Adding the
+minimal support needed for parsing and semantic analysis on a new
+platform is quite easy; see <tt class="docutils literal"><span class="pre">lib/Basic/Targets.cpp</span></tt> in the clang source
+tree. This level of support is also sufficient for conversion to LLVM IR
+for simple programs. Proper support for conversion to LLVM IR requires
+adding code to <tt class="docutils literal"><span class="pre">lib/CodeGen/CGCall.cpp</span></tt> at the moment; this is likely to
+change soon, though. Generating assembly requires a suitable LLVM
+backend.</p>
+</div>
+</div>
+<div class="section" id="operating-system-features-and-limitations">
+<h3><a class="toc-backref" href="#id53">Operating System Features and Limitations</a><a class="headerlink" href="#operating-system-features-and-limitations" title="Permalink to this headline">¶</a></h3>
+<div class="section" id="darwin-mac-os-x">
+<h4><a class="toc-backref" href="#id54">Darwin (Mac OS X)</a><a class="headerlink" href="#darwin-mac-os-x" title="Permalink to this headline">¶</a></h4>
+<p>Thread Sanitizer is not supported.</p>
+</div>
+<div class="section" id="windows">
+<h4><a class="toc-backref" href="#id55">Windows</a><a class="headerlink" href="#windows" title="Permalink to this headline">¶</a></h4>
+<p>Clang has experimental support for targeting “Cygming” (Cygwin / MinGW)
+platforms.</p>
+<p>See also <a class="reference internal" href="#c-ms"><em>Microsoft Extensions</em></a>.</p>
+<div class="section" id="cygwin">
+<h5><a class="toc-backref" href="#id56">Cygwin</a><a class="headerlink" href="#cygwin" title="Permalink to this headline">¶</a></h5>
+<p>Clang works on Cygwin-1.7.</p>
+</div>
+<div class="section" id="mingw32">
+<h5><a class="toc-backref" href="#id57">MinGW32</a><a class="headerlink" href="#mingw32" title="Permalink to this headline">¶</a></h5>
+<p>Clang works on some mingw32 distributions. Clang assumes directories as
+below;</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">C:/mingw/include</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">C:/mingw/lib</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">C:/mingw/lib/gcc/mingw32/4.[3-5].0/include/c++</span></tt></li>
+</ul>
+<p>On MSYS, a few tests might fail.</p>
+</div>
+<div class="section" id="mingw-w64">
+<h5><a class="toc-backref" href="#id58">MinGW-w64</a><a class="headerlink" href="#mingw-w64" title="Permalink to this headline">¶</a></h5>
+<p>For 32-bit (i686-w64-mingw32), and 64-bit (x86_64-w64-mingw32), Clang
+assumes as below;</p>
+<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">GCC</span> <span class="pre">versions</span> <span class="pre">4.5.0</span> <span class="pre">to</span> <span class="pre">4.5.3,</span> <span class="pre">4.6.0</span> <span class="pre">to</span> <span class="pre">4.6.2,</span> <span class="pre">or</span> <span class="pre">4.7.0</span> <span class="pre">(for</span> <span class="pre">the</span> <span class="pre">C++</span> <span class="pre">header</span> <span class="pre">search</span> <span class="pre">path)</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/gcc.exe</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/clang.exe</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/clang++.exe</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../include/c++/GCC_version</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../include/c++/GCC_version/x86_64-w64-mingw32</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../include/c++/GCC_version/i686-w64-mingw32</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../include/c++/GCC_version/backward</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../x86_64-w64-mingw32/include</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../i686-w64-mingw32/include</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">some_directory/bin/../include</span></tt></li>
+</ul>
+<p>This directory layout is standard for any toolchain you will find on the
+official <a class="reference external" href="http://mingw-w64.sourceforge.net">MinGW-w64 website</a>.</p>
+<p>Clang expects the GCC executable “gcc.exe” compiled for
+<tt class="docutils literal"><span class="pre">i686-w64-mingw32</span></tt> (or <tt class="docutils literal"><span class="pre">x86_64-w64-mingw32</span></tt>) to be present on PATH.</p>
+<p><a class="reference external" href="http://llvm.org/bugs/show_bug.cgi?id=9072">Some tests might fail</a> on
+<tt class="docutils literal"><span class="pre">x86_64-w64-mingw32</span></tt>.</p>
+</div>
+</div>
+</div>
+</div>
+<div class="section" id="clang-cl">
+<span id="id4"></span><h2><a class="toc-backref" href="#id59">clang-cl</a><a class="headerlink" href="#clang-cl" title="Permalink to this headline">¶</a></h2>
+<p>clang-cl is an alternative command-line interface to Clang driver, designed for
+compatibility with the Visual C++ compiler, cl.exe.</p>
+<p>To enable clang-cl to find system headers, libraries, and the linker when run
+from the command-line, it should be executed inside a Visual Studio Native Tools
+Command Prompt or a regular Command Prompt where the environment has been set
+up using e.g. <a class="reference external" href="http://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx">vcvars32.bat</a>.</p>
+<p>clang-cl can also be used from inside Visual Studio  by using an LLVM Platform
+Toolset.</p>
+<div class="section" id="id5">
+<h3><a class="toc-backref" href="#id60">Command-Line Options</a><a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3>
+<p>To be compatible with cl.exe, clang-cl supports most of the same command-line
+options. Those options can start with either <tt class="docutils literal"><span class="pre">/</span></tt> or <tt class="docutils literal"><span class="pre">-</span></tt>. It also supports
+some of Clang’s core options, such as the <tt class="docutils literal"><span class="pre">-W</span></tt> options.</p>
+<p>Options that are known to clang-cl, but not currently supported, are ignored
+with a warning. For example:</p>
+<blockquote>
+<div><div class="highlight-python"><div class="highlight"><pre>clang-cl.exe: warning: argument unused during compilation: '/Zi'
+</pre></div>
+</div>
+</div></blockquote>
+<p>To suppress warnings about unused arguments, use the <tt class="docutils literal"><span class="pre">-Qunused-arguments</span></tt> option.</p>
+<p>Options that are not known to clang-cl will cause errors. If they are spelled with a
+leading <tt class="docutils literal"><span class="pre">/</span></tt>, they will be mistaken for a filename:</p>
+<blockquote>
+<div><div class="highlight-python"><div class="highlight"><pre>clang-cl.exe: error: no such file or directory: '/foobar'
+</pre></div>
+</div>
+</div></blockquote>
+<p>Please <a class="reference external" href="http://llvm.org/bugs/enter_bug.cgi?product=clang&component=Driver">file a bug</a>
+for any valid cl.exe flags that clang-cl does not understand.</p>
+<p>Execute <tt class="docutils literal"><span class="pre">clang-cl</span> <span class="pre">/?</span></tt> to see a list of supported options:</p>
+<blockquote>
+<div><div class="highlight-python"><div class="highlight"><pre>CL.EXE COMPATIBILITY OPTIONS:
+  /?                     Display available options
+  /arch:<value>          Set architecture for code generation
+  /C                     Don't discard comments when preprocessing
+  /c                     Compile only
+  /D <macro[=value]>     Define macro
+  /EH<value>             Exception handling model
+  /EP                    Disable linemarker output and preprocess to stdout
+  /E                     Preprocess to stdout
+  /fallback              Fall back to cl.exe if clang-cl fails to compile
+  /FA                    Output assembly code file during compilation
+  /Fa<file or directory> Output assembly code to this file during compilation
+  /Fe<file or directory> Set output executable file or directory (ends in / or \)
+  /FI <value>            Include file before parsing
+  /Fi<file>              Set preprocess output file name
+  /Fo<file or directory> Set output object file, or directory (ends in / or \)
+  /GF-                   Disable string pooling
+  /GR-                   Disable emission of RTTI data
+  /GR                    Enable emission of RTTI data
+  /Gw-                   Don't put each data item in its own section
+  /Gw                    Put each data item in its own section
+  /Gy-                   Don't put each function in its own section
+  /Gy                    Put each function in its own section
+  /help                  Display available options
+  /I <dir>               Add directory to include search path
+  /J                     Make char type unsigned
+  /LDd                   Create debug DLL
+  /LD                    Create DLL
+  /link <options>        Forward options to the linker
+  /MDd                   Use DLL debug run-time
+  /MD                    Use DLL run-time
+  /MTd                   Use static debug run-time
+  /MT                    Use static run-time
+  /Ob0                   Disable inlining
+  /Od                    Disable optimization
+  /Oi-                   Disable use of builtin functions
+  /Oi                    Enable use of builtin functions
+  /Os                    Optimize for size
+  /Ot                    Optimize for speed
+  /Ox                    Maximum optimization
+  /Oy-                   Disable frame pointer omission
+  /Oy                    Enable frame pointer omission
+  /O<n>                  Optimization level
+  /P                     Preprocess to file
+  /showIncludes          Print info about included files to stderr
+  /TC                    Treat all source files as C
+  /Tc <filename>         Specify a C source file
+  /TP                    Treat all source files as C++
+  /Tp <filename>         Specify a C++ source file
+  /U <macro>             Undefine macro
+  /vd<value>             Control vtordisp placement
+  /vmb                   Use a best-case representation method for member pointers
+  /vmg                   Use a most-general representation for member pointers
+  /vmm                   Set the default most-general representation to multiple inheritance
+  /vms                   Set the default most-general representation to single inheritance
+  /vmv                   Set the default most-general representation to virtual inheritance
+  /W0                    Disable all warnings
+  /W1                    Enable -Wall
+  /W2                    Enable -Wall
+  /W3                    Enable -Wall
+  /W4                    Enable -Wall
+  /Wall                  Enable -Wall
+  /WX-                   Do not treat warnings as errors
+  /WX                    Treat warnings as errors
+  /w                     Disable all warnings
+  /Zi                    Enable debug information
+  /Zp                    Set the default maximum struct packing alignment to 1
+  /Zp<value>             Specify the default maximum struct packing alignment
+  /Zs                    Syntax-check only
+
+OPTIONS:
+  -###                  Print (but do not run) the commands to run for this compilation
+  -fms-compatibility-version=<value>
+                        Dot-separated value representing the Microsoft compiler version
+                        number to report in _MSC_VER (0 = don't define it (default))
+  -fmsc-version=<value> Microsoft compiler version number to report in _MSC_VER (0 = don't
+                        define it (default))
+  -fsanitize-blacklist=<value>
+                        Path to blacklist file for sanitizers
+  -fsanitize=<check>    Enable runtime instrumentation for bug detection: address (memory
+                        errors) | thread (race detection) | undefined (miscellaneous
+                        undefined behavior)
+  -mllvm <value>        Additional arguments to forward to LLVM's option processing
+  -Qunused-arguments    Don't emit warning for unused driver arguments
+  --target=<value>      Generate code for the given target
+  -v                    Show commands to run and use verbose output
+  -W<warning>           Enable the specified warning
+  -Xclang <arg>         Pass <arg> to the clang compiler
+</pre></div>
+</div>
+</div></blockquote>
+<div class="section" id="the-fallback-option">
+<h4><a class="toc-backref" href="#id61">The /fallback Option</a><a class="headerlink" href="#the-fallback-option" title="Permalink to this headline">¶</a></h4>
+<p>When clang-cl is run with the <tt class="docutils literal"><span class="pre">/fallback</span></tt> option, it will first try to
+compile files itself. For any file that it fails to compile, it will fall back
+and try to compile the file by invoking cl.exe.</p>
+<p>This option is intended to be used as a temporary means to build projects where
+clang-cl cannot successfully compile all the files. clang-cl may fail to compile
+a file either because it cannot generate code for some C++ feature, or because
+it cannot parse some Microsoft language extension.</p>
+</div>
+</div>
+</div>
+</div>
+
+
+      </div>
+      <div class="bottomnav">
+      
+        <p>
+        «  <a href="ReleaseNotes.html">Clang 3.6 (In-Progress) Release Notes</a>
+          ::  
+        <a class="uplink" href="index.html">Contents</a>
+          ::  
+        <a href="LanguageExtensions.html">Clang Language Extensions</a>  Â»
+        </p>
+
+      </div>
+
+    <div class="footer">
+        © Copyright 2007-2014, The Clang Team.
+      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
+    </div>
+  </body>
+</html>
\ No newline at end of file

Added: www-releases/trunk/3.6.0/tools/clang/docs/_images/DriverArchitecture.png
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/_images/DriverArchitecture.png?rev=230777&view=auto
==============================================================================
Binary file - no diff available.

Propchange: www-releases/trunk/3.6.0/tools/clang/docs/_images/DriverArchitecture.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: www-releases/trunk/3.6.0/tools/clang/docs/_images/PCHLayout.png
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/_images/PCHLayout.png?rev=230777&view=auto
==============================================================================
Binary file - no diff available.

Propchange: www-releases/trunk/3.6.0/tools/clang/docs/_images/PCHLayout.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: www-releases/trunk/3.6.0/tools/clang/docs/_sources/AddressSanitizer.txt
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/_sources/AddressSanitizer.txt?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/_sources/AddressSanitizer.txt (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/_sources/AddressSanitizer.txt Fri Feb 27 12:44:09 2015
@@ -0,0 +1,217 @@
+================
+AddressSanitizer
+================
+
+.. contents::
+   :local:
+
+Introduction
+============
+
+AddressSanitizer is a fast memory error detector. It consists of a compiler
+instrumentation module and a run-time library. The tool can detect the
+following types of bugs:
+
+* Out-of-bounds accesses to heap, stack and globals
+* Use-after-free
+* Use-after-return (to some extent)
+* Double-free, invalid free
+* Memory leaks (experimental)
+
+Typical slowdown introduced by AddressSanitizer is **2x**.
+
+How to build
+============
+
+Follow the `clang build instructions <../get_started.html>`_. CMake build is
+supported.
+
+Usage
+=====
+
+Simply compile and link your program with ``-fsanitize=address`` flag.  The
+AddressSanitizer run-time library should be linked to the final executable, so
+make sure to use ``clang`` (not ``ld``) for the final link step.  When linking
+shared libraries, the AddressSanitizer run-time is not linked, so
+``-Wl,-z,defs`` may cause link errors (don't use it with AddressSanitizer).  To
+get a reasonable performance add ``-O1`` or higher.  To get nicer stack traces
+in error messages add ``-fno-omit-frame-pointer``.  To get perfect stack traces
+you may need to disable inlining (just use ``-O1``) and tail call elimination
+(``-fno-optimize-sibling-calls``).
+
+.. code-block:: console
+
+    % cat example_UseAfterFree.cc
+    int main(int argc, char **argv) {
+      int *array = new int[100];
+      delete [] array;
+      return array[argc];  // BOOM
+    }
+
+    # Compile and link
+    % clang -O1 -g -fsanitize=address -fno-omit-frame-pointer example_UseAfterFree.cc
+
+or:
+
+.. code-block:: console
+
+    # Compile
+    % clang -O1 -g -fsanitize=address -fno-omit-frame-pointer -c example_UseAfterFree.cc
+    # Link
+    % clang -g -fsanitize=address example_UseAfterFree.o
+
+If a bug is detected, the program will print an error message to stderr and
+exit with a non-zero exit code. To make AddressSanitizer symbolize its output
+you need to set the ``ASAN_SYMBOLIZER_PATH`` environment variable to point to
+the ``llvm-symbolizer`` binary (or make sure ``llvm-symbolizer`` is in your
+``$PATH``):
+
+.. code-block:: console
+
+    % ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer ./a.out
+    ==9442== ERROR: AddressSanitizer heap-use-after-free on address 0x7f7ddab8c084 at pc 0x403c8c bp 0x7fff87fb82d0 sp 0x7fff87fb82c8
+    READ of size 4 at 0x7f7ddab8c084 thread T0
+        #0 0x403c8c in main example_UseAfterFree.cc:4
+        #1 0x7f7ddabcac4d in __libc_start_main ??:0
+    0x7f7ddab8c084 is located 4 bytes inside of 400-byte region [0x7f7ddab8c080,0x7f7ddab8c210)
+    freed by thread T0 here:
+        #0 0x404704 in operator delete[](void*) ??:0
+        #1 0x403c53 in main example_UseAfterFree.cc:4
+        #2 0x7f7ddabcac4d in __libc_start_main ??:0
+    previously allocated by thread T0 here:
+        #0 0x404544 in operator new[](unsigned long) ??:0
+        #1 0x403c43 in main example_UseAfterFree.cc:2
+        #2 0x7f7ddabcac4d in __libc_start_main ??:0
+    ==9442== ABORTING
+
+If that does not work for you (e.g. your process is sandboxed), you can use a
+separate script to symbolize the result offline (online symbolization can be
+force disabled by setting ``ASAN_OPTIONS=symbolize=0``):
+
+.. code-block:: console
+
+    % ASAN_OPTIONS=symbolize=0 ./a.out 2> log
+    % projects/compiler-rt/lib/asan/scripts/asan_symbolize.py / < log | c++filt
+    ==9442== ERROR: AddressSanitizer heap-use-after-free on address 0x7f7ddab8c084 at pc 0x403c8c bp 0x7fff87fb82d0 sp 0x7fff87fb82c8
+    READ of size 4 at 0x7f7ddab8c084 thread T0
+        #0 0x403c8c in main example_UseAfterFree.cc:4
+        #1 0x7f7ddabcac4d in __libc_start_main ??:0
+    ...
+
+Note that on OS X you may need to run ``dsymutil`` on your binary to have the
+file\:line info in the AddressSanitizer reports.
+
+AddressSanitizer exits on the first detected error. This is by design.
+One reason: it makes the generated code smaller and faster (both by
+~5%). Another reason: this makes fixing bugs unavoidable. With Valgrind,
+it is often the case that users treat Valgrind warnings as false
+positives (which they are not) and don't fix them.
+
+``__has_feature(address_sanitizer)``
+------------------------------------
+
+In some cases one may need to execute different code depending on whether
+AddressSanitizer is enabled.
+:ref:`\_\_has\_feature <langext-__has_feature-__has_extension>` can be used for
+this purpose.
+
+.. code-block:: c
+
+    #if defined(__has_feature)
+    #  if __has_feature(address_sanitizer)
+    // code that builds only under AddressSanitizer
+    #  endif
+    #endif
+
+``__attribute__((no_sanitize_address))``
+-----------------------------------------------
+
+Some code should not be instrumented by AddressSanitizer. One may use the
+function attribute
+:ref:`no_sanitize_address <langext-address_sanitizer>`
+(or a deprecated synonym `no_address_safety_analysis`)
+to disable instrumentation of a particular function. This attribute may not be
+supported by other compilers, so we suggest to use it together with
+``__has_feature(address_sanitizer)``.
+
+Initialization order checking
+-----------------------------
+
+AddressSanitizer can optionally detect dynamic initialization order problems,
+when initialization of globals defined in one translation unit uses
+globals defined in another translation unit. To enable this check at runtime,
+you should set environment variable
+``ASAN_OPTIONS=check_initialization_order=1``.
+
+Blacklist
+---------
+
+AddressSanitizer supports ``src`` and ``fun`` entity types in
+:doc:`SanitizerSpecialCaseList`, that can be used to suppress error reports
+in the specified source files or functions. Additionally, AddressSanitizer
+introduces ``global`` and ``type`` entity types that can be used to
+suppress error reports for out-of-bound access to globals with certain
+names and types (you may only specify class or struct types).
+
+You may use an ``init`` category to suppress reports about initialization-order
+problems happening in certain source files or with certain global variables.
+
+.. code-block:: bash
+
+    # Suppress error reports for code in a file or in a function:
+    src:bad_file.cpp
+    # Ignore all functions with names containing MyFooBar:
+    fun:*MyFooBar*
+    # Disable out-of-bound checks for global:
+    global:bad_array
+    # Disable out-of-bound checks for global instances of a given class ...
+    type:Namespace::BadClassName
+    # ... or a given struct. Use wildcard to deal with anonymous namespace.
+    type:Namespace2::*::BadStructName
+    # Disable initialization-order checks for globals:
+    global:bad_init_global=init
+    type:*BadInitClassSubstring*=init
+    src:bad/init/files/*=init
+
+Memory leak detection
+---------------------
+
+For the experimental memory leak detector in AddressSanitizer, see
+:doc:`LeakSanitizer`.
+
+Supported Platforms
+===================
+
+AddressSanitizer is supported on
+
+* Linux i386/x86\_64 (tested on Ubuntu 12.04);
+* MacOS 10.6 - 10.9 (i386/x86\_64).
+* Android ARM
+* FreeBSD i386/x86\_64 (tested on FreeBSD 11-current)
+
+Ports to various other platforms are in progress.
+
+Limitations
+===========
+
+* AddressSanitizer uses more real memory than a native run. Exact overhead
+  depends on the allocations sizes. The smaller the allocations you make the
+  bigger the overhead is.
+* AddressSanitizer uses more stack memory. We have seen up to 3x increase.
+* On 64-bit platforms AddressSanitizer maps (but not reserves) 16+ Terabytes of
+  virtual address space. This means that tools like ``ulimit`` may not work as
+  usually expected.
+* Static linking is not supported.
+
+Current Status
+==============
+
+AddressSanitizer is fully functional on supported platforms starting from LLVM
+3.1. The test suite is integrated into CMake build and can be run with ``make
+check-asan`` command.
+
+More Information
+================
+
+`http://code.google.com/p/address-sanitizer <http://code.google.com/p/address-sanitizer/>`_
+

Added: www-releases/trunk/3.6.0/tools/clang/docs/_sources/AttributeReference.txt
URL: http://llvm.org/viewvc/llvm-project/www-releases/trunk/3.6.0/tools/clang/docs/_sources/AttributeReference.txt?rev=230777&view=auto
==============================================================================
--- www-releases/trunk/3.6.0/tools/clang/docs/_sources/AttributeReference.txt (added)
+++ www-releases/trunk/3.6.0/tools/clang/docs/_sources/AttributeReference.txt Fri Feb 27 12:44:09 2015
@@ -0,0 +1,1116 @@
+..
+  -------------------------------------------------------------------
+  NOTE: This file is automatically generated by running clang-tblgen
+  -gen-attr-docs. Do not edit this file by hand!!
+  -------------------------------------------------------------------
+
+===================
+Attributes in Clang
+===================
+.. contents::
+   :local:
+
+Introduction
+============
+
+This page lists the attributes currently supported by Clang.
+
+Function Attributes
+===================
+
+
+interrupt
+---------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Clang supports the GNU style ``__attribute__((interrupt("TYPE")))`` attribute on
+ARM targets. This attribute may be attached to a function definition and
+instructs the backend to generate appropriate function entry/exit code so that
+it can be used directly as an interrupt service routine.
+
+The parameter passed to the interrupt attribute is optional, but if
+provided it must be a string literal with one of the following values: "IRQ",
+"FIQ", "SWI", "ABORT", "UNDEF".
+
+The semantics are as follows:
+
+- If the function is AAPCS, Clang instructs the backend to realign the stack to
+  8 bytes on entry. This is a general requirement of the AAPCS at public
+  interfaces, but may not hold when an exception is taken. Doing this allows
+  other AAPCS functions to be called.
+- If the CPU is M-class this is all that needs to be done since the architecture
+  itself is designed in such a way that functions obeying the normal AAPCS ABI
+  constraints are valid exception handlers.
+- If the CPU is not M-class, the prologue and epilogue are modified to save all
+  non-banked registers that are used, so that upon return the user-mode state
+  will not be corrupted. Note that to avoid unnecessary overhead, only
+  general-purpose (integer) registers are saved in this way. If VFP operations
+  are needed, that state must be saved manually.
+
+  Specifically, interrupt kinds other than "FIQ" will save all core registers
+  except "lr" and "sp". "FIQ" interrupts will save r0-r7.
+- If the CPU is not M-class, the return instruction is changed to one of the
+  canonical sequences permitted by the architecture for exception return. Where
+  possible the function itself will make the necessary "lr" adjustments so that
+  the "preferred return address" is selected.
+
+  Unfortunately the compiler is unable to make this guarantee for an "UNDEF"
+  handler, where the offset from "lr" to the preferred return address depends on
+  the execution state of the code which generated the exception. In this case
+  a sequence equivalent to "movs pc, lr" will be used.
+
+
+acquire_capability (acquire_shared_capability, clang::acquire_capability, clang::acquire_shared_capability)
+-----------------------------------------------------------------------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+Marks a function as acquiring a capability.
+
+
+assert_capability (assert_shared_capability, clang::assert_capability, clang::assert_shared_capability)
+-------------------------------------------------------------------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+Marks a function that dynamically tests whether a capability is held, and halts
+the program if it is not held.
+
+
+availability
+------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+The ``availability`` attribute can be placed on declarations to describe the
+lifecycle of that declaration relative to operating system versions.  Consider
+the function declaration for a hypothetical function ``f``:
+
+.. code-block:: c++
+
+  void f(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6,obsoleted=10.7)));
+
+The availability attribute states that ``f`` was introduced in Mac OS X 10.4,
+deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
+is used by Clang to determine when it is safe to use ``f``: for example, if
+Clang is instructed to compile code for Mac OS X 10.5, a call to ``f()``
+succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
+succeeds but Clang emits a warning specifying that the function is deprecated.
+Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
+fails because ``f()`` is no longer available.
+
+The availability attribute is a comma-separated list starting with the
+platform name and then including clauses specifying important milestones in the
+declaration's lifetime (in any order) along with additional information.  Those
+clauses can be:
+
+introduced=\ *version*
+  The first version in which this declaration was introduced.
+
+deprecated=\ *version*
+  The first version in which this declaration was deprecated, meaning that
+  users should migrate away from this API.
+
+obsoleted=\ *version*
+  The first version in which this declaration was obsoleted, meaning that it
+  was removed completely and can no longer be used.
+
+unavailable
+  This declaration is never available on this platform.
+
+message=\ *string-literal*
+  Additional message text that Clang will provide when emitting a warning or
+  error about use of a deprecated or obsoleted declaration.  Useful to direct
+  users to replacement APIs.
+
+Multiple availability attributes can be placed on a declaration, which may
+correspond to different platforms.  Only the availability attribute with the
+platform corresponding to the target platform will be used; any others will be
+ignored.  If no availability attribute specifies availability for the current
+target platform, the availability attributes are ignored.  Supported platforms
+are:
+
+``ios``
+  Apple's iOS operating system.  The minimum deployment target is specified by
+  the ``-mios-version-min=*version*`` or ``-miphoneos-version-min=*version*``
+  command-line arguments.
+
+``macosx``
+  Apple's Mac OS X operating system.  The minimum deployment target is
+  specified by the ``-mmacosx-version-min=*version*`` command-line argument.
+
+A declaration can be used even when deploying back to a platform version prior
+to when the declaration was introduced.  When this happens, the declaration is
+`weakly linked
+<https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html>`_,
+as if the ``weak_import`` attribute were added to the declaration.  A
+weakly-linked declaration may or may not be present a run-time, and a program
+can determine whether the declaration is present by checking whether the
+address of that declaration is non-NULL.
+
+If there are multiple declarations of the same entity, the availability
+attributes must either match on a per-platform basis or later
+declarations must not have availability attributes for that
+platform. For example:
+
+.. code-block:: c
+
+  void g(void) __attribute__((availability(macosx,introduced=10.4)));
+  void g(void) __attribute__((availability(macosx,introduced=10.4))); // okay, matches
+  void g(void) __attribute__((availability(ios,introduced=4.0))); // okay, adds a new platform
+  void g(void); // okay, inherits both macosx and ios availability from above.
+  void g(void) __attribute__((availability(macosx,introduced=10.5))); // error: mismatch
+
+When one method overrides another, the overriding method can be more widely available than the overridden method, e.g.,:
+
+.. code-block:: objc
+
+  @interface A
+  - (id)method __attribute__((availability(macosx,introduced=10.4)));
+  - (id)method2 __attribute__((availability(macosx,introduced=10.4)));
+  @end
+
+  @interface B : A
+  - (id)method __attribute__((availability(macosx,introduced=10.3))); // okay: method moved into base class later
+  - (id)method __attribute__((availability(macosx,introduced=10.5))); // error: this method was available via the base class in 10.4
+  @end
+
+
+_Noreturn
+---------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "","","","X"
+
+A function declared as ``_Noreturn`` shall not return to its caller. The
+compiler will generate a diagnostic for a function declared as ``_Noreturn``
+that appears to be capable of returning to its caller.
+
+
+noreturn
+--------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "","X","",""
+
+A function declared as ``[[noreturn]]`` shall not return to its caller. The
+compiler will generate a diagnostic for a function declared as ``[[noreturn]]``
+that appears to be capable of returning to its caller.
+
+
+carries_dependency
+------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+The ``carries_dependency`` attribute specifies dependency propagation into and
+out of functions.
+
+When specified on a function or Objective-C method, the ``carries_dependency``
+attribute means that the return value carries a dependency out of the function, 
+so that the implementation need not constrain ordering upon return from that
+function. Implementations of the function and its caller may choose to preserve
+dependencies instead of emitting memory ordering instructions such as fences.
+
+Note, this attribute does not change the meaning of the program, but may result
+in generation of more efficient code.
+
+
+enable_if
+---------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+.. Note:: Some features of this attribute are experimental. The meaning of
+  multiple enable_if attributes on a single declaration is subject to change in
+  a future version of clang. Also, the ABI is not standardized and the name
+  mangling may change in future versions. To avoid that, use asm labels.
+
+The ``enable_if`` attribute can be placed on function declarations to control
+which overload is selected based on the values of the function's arguments.
+When combined with the ``overloadable`` attribute, this feature is also
+available in C.
+
+.. code-block:: c++
+
+  int isdigit(int c);
+  int isdigit(int c) __attribute__((enable_if(c <= -1 || c > 255, "chosen when 'c' is out of range"))) __attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
+  
+  void foo(char c) {
+    isdigit(c);
+    isdigit(10);
+    isdigit(-10);  // results in a compile-time error.
+  }
+
+The enable_if attribute takes two arguments, the first is an expression written
+in terms of the function parameters, the second is a string explaining why this
+overload candidate could not be selected to be displayed in diagnostics. The
+expression is part of the function signature for the purposes of determining
+whether it is a redeclaration (following the rules used when determining
+whether a C++ template specialization is ODR-equivalent), but is not part of
+the type.
+
+The enable_if expression is evaluated as if it were the body of a
+bool-returning constexpr function declared with the arguments of the function
+it is being applied to, then called with the parameters at the callsite. If the
+result is false or could not be determined through constant expression
+evaluation, then this overload will not be chosen and the provided string may
+be used in a diagnostic if the compile fails as a result.
+
+Because the enable_if expression is an unevaluated context, there are no global
+state changes, nor the ability to pass information from the enable_if
+expression to the function body. For example, suppose we want calls to
+strnlen(strbuf, maxlen) to resolve to strnlen_chk(strbuf, maxlen, size of
+strbuf) only if the size of strbuf can be determined:
+
+.. code-block:: c++
+
+  __attribute__((always_inline))
+  static inline size_t strnlen(const char *s, size_t maxlen)
+    __attribute__((overloadable))
+    __attribute__((enable_if(__builtin_object_size(s, 0) != -1))),
+                             "chosen when the buffer size is known but 'maxlen' is not")))
+  {
+    return strnlen_chk(s, maxlen, __builtin_object_size(s, 0));
+  }
+
+Multiple enable_if attributes may be applied to a single declaration. In this
+case, the enable_if expressions are evaluated from left to right in the
+following manner. First, the candidates whose enable_if expressions evaluate to
+false or cannot be evaluated are discarded. If the remaining candidates do not
+share ODR-equivalent enable_if expressions, the overload resolution is
+ambiguous. Otherwise, enable_if overload resolution continues with the next
+enable_if attribute on the candidates that have not been discarded and have
+remaining enable_if attributes. In this way, we pick the most specific
+overload out of a number of viable overloads using enable_if.
+
+.. code-block:: c++
+
+  void f() __attribute__((enable_if(true, "")));  // #1
+  void f() __attribute__((enable_if(true, ""))) __attribute__((enable_if(true, "")));  // #2
+  
+  void g(int i, int j) __attribute__((enable_if(i, "")));  // #1
+  void g(int i, int j) __attribute__((enable_if(j, ""))) __attribute__((enable_if(true)));  // #2
+
+In this example, a call to f() is always resolved to #2, as the first enable_if
+expression is ODR-equivalent for both declarations, but #1 does not have another
+enable_if expression to continue evaluating, so the next round of evaluation has
+only a single candidate. In a call to g(1, 1), the call is ambiguous even though
+#2 has more enable_if attributes, because the first enable_if expressions are
+not ODR-equivalent.
+
+Query for this feature with ``__has_attribute(enable_if)``.
+
+
+flatten (gnu::flatten)
+----------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+The ``flatten`` attribute causes calls within the attributed function to
+be inlined unless it is impossible to do so, for example if the body of the
+callee is unavailable or if the callee has the ``noinline`` attribute.
+
+
+format (gnu::format)
+--------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+Clang supports the ``format`` attribute, which indicates that the function
+accepts a ``printf`` or ``scanf``-like format string and corresponding
+arguments or a ``va_list`` that contains these arguments.
+
+Please see `GCC documentation about format attribute
+<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ to find details
+about attribute syntax.
+
+Clang implements two kinds of checks with this attribute.
+
+#. Clang checks that the function with the ``format`` attribute is called with
+   a format string that uses format specifiers that are allowed, and that
+   arguments match the format string.  This is the ``-Wformat`` warning, it is
+   on by default.
+
+#. Clang checks that the format string argument is a literal string.  This is
+   the ``-Wformat-nonliteral`` warning, it is off by default.
+
+   Clang implements this mostly the same way as GCC, but there is a difference
+   for functions that accept a ``va_list`` argument (for example, ``vprintf``).
+   GCC does not emit ``-Wformat-nonliteral`` warning for calls to such
+   fuctions.  Clang does not warn if the format string comes from a function
+   parameter, where the function is annotated with a compatible attribute,
+   otherwise it warns.  For example:
+
+   .. code-block:: c
+
+     __attribute__((__format__ (__scanf__, 1, 3)))
+     void foo(const char* s, char *buf, ...) {
+       va_list ap;
+       va_start(ap, buf);
+
+       vprintf(s, ap); // warning: format string is not a string literal
+     }
+
+   In this case we warn because ``s`` contains a format string for a
+   ``scanf``-like function, but it is passed to a ``printf``-like function.
+
+   If the attribute is removed, clang still warns, because the format string is
+   not a string literal.
+
+   Another example:
+
+   .. code-block:: c
+
+     __attribute__((__format__ (__printf__, 1, 3)))
+     void foo(const char* s, char *buf, ...) {
+       va_list ap;
+       va_start(ap, buf);
+
+       vprintf(s, ap); // warning
+     }
+
+   In this case Clang does not warn because the format string ``s`` and
+   the corresponding arguments are annotated.  If the arguments are
+   incorrect, the caller of ``foo`` will receive a warning.
+
+
+noduplicate (clang::noduplicate)
+--------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+The ``noduplicate`` attribute can be placed on function declarations to control
+whether function calls to this function can be duplicated or not as a result of
+optimizations. This is required for the implementation of functions with
+certain special requirements, like the OpenCL "barrier" function, that might
+need to be run concurrently by all the threads that are executing in lockstep
+on the hardware. For example this attribute applied on the function
+"nodupfunc" in the code below avoids that:
+
+.. code-block:: c
+
+  void nodupfunc() __attribute__((noduplicate));
+  // Setting it as a C++11 attribute is also valid
+  // void nodupfunc() [[clang::noduplicate]];
+  void foo();
+  void bar();
+
+  nodupfunc();
+  if (a > n) {
+    foo();
+  } else {
+    bar();
+  }
+
+gets possibly modified by some optimizations into code similar to this:
+
+.. code-block:: c
+
+  if (a > n) {
+    nodupfunc();
+    foo();
+  } else {
+    nodupfunc();
+    bar();
+  }
+
+where the call to "nodupfunc" is duplicated and sunk into the two branches
+of the condition.
+
+
+no_sanitize_address (no_address_safety_analysis, gnu::no_address_safety_analysis, gnu::no_sanitize_address)
+-----------------------------------------------------------------------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+.. _langext-address_sanitizer:
+
+Use ``__attribute__((no_sanitize_address))`` on a function declaration to
+specify that address safety instrumentation (e.g. AddressSanitizer) should
+not be applied to that function.
+
+
+no_sanitize_memory
+------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+.. _langext-memory_sanitizer:
+
+Use ``__attribute__((no_sanitize_memory))`` on a function declaration to
+specify that checks for uninitialized memory should not be inserted 
+(e.g. by MemorySanitizer). The function may still be instrumented by the tool
+to avoid false positives in other places.
+
+
+no_sanitize_thread
+------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+.. _langext-thread_sanitizer:
+
+Use ``__attribute__((no_sanitize_thread))`` on a function declaration to
+specify that checks for data races on plain (non-atomic) memory accesses should
+not be inserted by ThreadSanitizer. The function is still instrumented by the
+tool to avoid false positives and provide meaningful stack traces.
+
+
+no_split_stack (gnu::no_split_stack)
+------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+The ``no_split_stack`` attribute disables the emission of the split stack
+preamble for a particular function. It has no effect if ``-fsplit-stack``
+is not specified.
+
+
+objc_method_family
+------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Many methods in Objective-C have conventional meanings determined by their
+selectors. It is sometimes useful to be able to mark a method as having a
+particular conventional meaning despite not having the right selector, or as
+not having the conventional meaning that its selector would suggest. For these
+use cases, we provide an attribute to specifically describe the "method family"
+that a method belongs to.
+
+**Usage**: ``__attribute__((objc_method_family(X)))``, where ``X`` is one of
+``none``, ``alloc``, ``copy``, ``init``, ``mutableCopy``, or ``new``.  This
+attribute can only be placed at the end of a method declaration:
+
+.. code-block:: objc
+
+  - (NSString *)initMyStringValue __attribute__((objc_method_family(none)));
+
+Users who do not wish to change the conventional meaning of a method, and who
+merely want to document its non-standard retain and release semantics, should
+use the retaining behavior attributes (``ns_returns_retained``,
+``ns_returns_not_retained``, etc).
+
+Query for this feature with ``__has_attribute(objc_method_family)``.
+
+
+objc_requires_super
+-------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Some Objective-C classes allow a subclass to override a particular method in a
+parent class but expect that the overriding method also calls the overridden
+method in the parent class. For these cases, we provide an attribute to
+designate that a method requires a "call to ``super``" in the overriding
+method in the subclass.
+
+**Usage**: ``__attribute__((objc_requires_super))``.  This attribute can only
+be placed at the end of a method declaration:
+
+.. code-block:: objc
+
+  - (void)foo __attribute__((objc_requires_super));
+
+This attribute can only be applied the method declarations within a class, and
+not a protocol.  Currently this attribute does not enforce any placement of
+where the call occurs in the overriding method (such as in the case of
+``-dealloc`` where the call must appear at the end).  It checks only that it
+exists.
+
+Note that on both OS X and iOS that the Foundation framework provides a
+convenience macro ``NS_REQUIRES_SUPER`` that provides syntactic sugar for this
+attribute:
+
+.. code-block:: objc
+
+  - (void)foo NS_REQUIRES_SUPER;
+
+This macro is conditionally defined depending on the compiler's support for
+this attribute.  If the compiler does not support the attribute the macro
+expands to nothing.
+
+Operationally, when a method has this annotation the compiler will warn if the
+implementation of an override in a subclass does not call super.  For example:
+
+.. code-block:: objc
+
+   warning: method possibly missing a [super AnnotMeth] call
+   - (void) AnnotMeth{};
+                      ^
+
+
+optnone (clang::optnone)
+------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+The ``optnone`` attribute suppresses essentially all optimizations
+on a function or method, regardless of the optimization level applied to
+the compilation unit as a whole.  This is particularly useful when you
+need to debug a particular function, but it is infeasible to build the
+entire application without optimization.  Avoiding optimization on the
+specified function can improve the quality of the debugging information
+for that function.
+
+This attribute is incompatible with the ``always_inline`` attribute.
+
+
+overloadable
+------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Clang provides support for C++ function overloading in C.  Function overloading
+in C is introduced using the ``overloadable`` attribute.  For example, one
+might provide several overloaded versions of a ``tgsin`` function that invokes
+the appropriate standard function computing the sine of a value with ``float``,
+``double``, or ``long double`` precision:
+
+.. code-block:: c
+
+  #include <math.h>
+  float __attribute__((overloadable)) tgsin(float x) { return sinf(x); }
+  double __attribute__((overloadable)) tgsin(double x) { return sin(x); }
+  long double __attribute__((overloadable)) tgsin(long double x) { return sinl(x); }
+
+Given these declarations, one can call ``tgsin`` with a ``float`` value to
+receive a ``float`` result, with a ``double`` to receive a ``double`` result,
+etc.  Function overloading in C follows the rules of C++ function overloading
+to pick the best overload given the call arguments, with a few C-specific
+semantics:
+
+* Conversion from ``float`` or ``double`` to ``long double`` is ranked as a
+  floating-point promotion (per C99) rather than as a floating-point conversion
+  (as in C++).
+
+* A conversion from a pointer of type ``T*`` to a pointer of type ``U*`` is
+  considered a pointer conversion (with conversion rank) if ``T`` and ``U`` are
+  compatible types.
+
+* A conversion from type ``T`` to a value of type ``U`` is permitted if ``T``
+  and ``U`` are compatible types.  This conversion is given "conversion" rank.
+
+The declaration of ``overloadable`` functions is restricted to function
+declarations and definitions.  Most importantly, if any function with a given
+name is given the ``overloadable`` attribute, then all function declarations
+and definitions with that name (and in that scope) must have the
+``overloadable`` attribute.  This rule even applies to redeclarations of
+functions whose original declaration had the ``overloadable`` attribute, e.g.,
+
+.. code-block:: c
+
+  int f(int) __attribute__((overloadable));
+  float f(float); // error: declaration of "f" must have the "overloadable" attribute
+
+  int g(int) __attribute__((overloadable));
+  int g(int) { } // error: redeclaration of "g" must also have the "overloadable" attribute
+
+Functions marked ``overloadable`` must have prototypes.  Therefore, the
+following code is ill-formed:
+
+.. code-block:: c
+
+  int h() __attribute__((overloadable)); // error: h does not have a prototype
+
+However, ``overloadable`` functions are allowed to use a ellipsis even if there
+are no named parameters (as is permitted in C++).  This feature is particularly
+useful when combined with the ``unavailable`` attribute:
+
+.. code-block:: c++
+
+  void honeypot(...) __attribute__((overloadable, unavailable)); // calling me is an error
+
+Functions declared with the ``overloadable`` attribute have their names mangled
+according to the same rules as C++ function names.  For example, the three
+``tgsin`` functions in our motivating example get the mangled names
+``_Z5tgsinf``, ``_Z5tgsind``, and ``_Z5tgsine``, respectively.  There are two
+caveats to this use of name mangling:
+
+* Future versions of Clang may change the name mangling of functions overloaded
+  in C, so you should not depend on an specific mangling.  To be completely
+  safe, we strongly urge the use of ``static inline`` with ``overloadable``
+  functions.
+
+* The ``overloadable`` attribute has almost no meaning when used in C++,
+  because names will already be mangled and functions are already overloadable.
+  However, when an ``overloadable`` function occurs within an ``extern "C"``
+  linkage specification, it's name *will* be mangled in the same way as it
+  would in C.
+
+Query for this feature with ``__has_extension(attribute_overloadable)``.
+
+
+pcs (gnu::pcs)
+--------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+On ARM targets, this can attribute can be used to select calling conventions,
+similar to ``stdcall`` on x86. Valid parameter values are "aapcs" and
+"aapcs-vfp".
+
+
+release_capability (release_shared_capability, clang::release_capability, clang::release_shared_capability)
+-----------------------------------------------------------------------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+Marks a function as releasing a capability.
+
+
+try_acquire_capability (try_acquire_shared_capability, clang::try_acquire_capability, clang::try_acquire_shared_capability)
+---------------------------------------------------------------------------------------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+Marks a function that attempts to acquire a capability. This function may fail to
+actually acquire the capability; they accept a Boolean value determining
+whether acquiring the capability means success (true), or failing to acquire
+the capability means success (false).
+
+
+Variable Attributes
+===================
+
+
+section (gnu::section, __declspec(allocate))
+--------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","X",""
+
+The ``section`` attribute allows you to specify a specific section a
+global variable or function should be in after translation.
+
+
+tls_model (gnu::tls_model)
+--------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","X","",""
+
+The ``tls_model`` attribute allows you to specify which thread-local storage
+model to use. It accepts the following strings:
+
+* global-dynamic
+* local-dynamic
+* initial-exec
+* local-exec
+
+TLS models are mutually exclusive.
+
+
+thread
+------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "","","X",""
+
+The ``__declspec(thread)`` attribute declares a variable with thread local
+storage.  It is available under the ``-fms-extensions`` flag for MSVC
+compatibility.  Documentation for the Visual C++ attribute is available on MSDN_.
+
+.. _MSDN: http://msdn.microsoft.com/en-us/library/9w1sdazb.aspx
+
+In Clang, ``__declspec(thread)`` is generally equivalent in functionality to the
+GNU ``__thread`` keyword.  The variable must not have a destructor and must have
+a constant initializer, if any.  The attribute only applies to variables
+declared with static storage duration, such as globals, class static data
+members, and static locals.
+
+
+Type Attributes
+===============
+
+
+__single_inhertiance, __multiple_inheritance, __virtual_inheritance
+-------------------------------------------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "","","","X"
+
+This collection of keywords is enabled under ``-fms-extensions`` and controls
+the pointer-to-member representation used on ``*-*-win32`` targets.
+
+The ``*-*-win32`` targets utilize a pointer-to-member representation which
+varies in size and alignment depending on the definition of the underlying
+class.
+
+However, this is problematic when a forward declaration is only available and
+no definition has been made yet.  In such cases, Clang is forced to utilize the
+most general representation that is available to it.
+
+These keywords make it possible to use a pointer-to-member representation other
+than the most general one regardless of whether or not the definition will ever
+be present in the current translation unit.
+
+This family of keywords belong between the ``class-key`` and ``class-name``:
+
+.. code-block:: c++
+
+  struct __single_inheritance S;
+  int S::*i;
+  struct S {};
+
+This keyword can be applied to class templates but only has an effect when used
+on full specializations:
+
+.. code-block:: c++
+
+  template <typename T, typename U> struct __single_inheritance A; // warning: inheritance model ignored on primary template
+  template <typename T> struct __multiple_inheritance A<T, T>; // warning: inheritance model ignored on partial specialization
+  template <> struct __single_inheritance A<int, float>;
+
+Note that choosing an inheritance model less general than strictly necessary is
+an error:
+
+.. code-block:: c++
+
+  struct __multiple_inheritance S; // error: inheritance model does not match definition
+  int S::*i;
+  struct S {};
+
+
+Statement Attributes
+====================
+
+
+fallthrough (clang::fallthrough)
+--------------------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "","X","",""
+
+The ``clang::fallthrough`` attribute is used along with the
+``-Wimplicit-fallthrough`` argument to annotate intentional fall-through
+between switch labels.  It can only be applied to a null statement placed at a
+point of execution between any statement and the next switch label.  It is
+common to mark these places with a specific comment, but this attribute is
+meant to replace comments with a more strict annotation, which can be checked
+by the compiler.  This attribute doesn't change semantics of the code and can
+be used wherever an intended fall-through occurs.  It is designed to mimic
+control-flow statements like ``break;``, so it can be placed in most places
+where ``break;`` can, but only if there are no statements on the execution path
+between it and the next switch label.
+
+Here is an example:
+
+.. code-block:: c++
+
+  // compile with -Wimplicit-fallthrough
+  switch (n) {
+  case 22:
+  case 33:  // no warning: no statements between case labels
+    f();
+  case 44:  // warning: unannotated fall-through
+    g();
+    [[clang::fallthrough]];
+  case 55:  // no warning
+    if (x) {
+      h();
+      break;
+    }
+    else {
+      i();
+      [[clang::fallthrough]];
+    }
+  case 66:  // no warning
+    p();
+    [[clang::fallthrough]]; // warning: fallthrough annotation does not
+                            //          directly precede case label
+    q();
+  case 77:  // warning: unannotated fall-through
+    r();
+  }
+
+
+Consumed Annotation Checking
+============================
+Clang supports additional attributes for checking basic resource management
+properties, specifically for unique objects that have a single owning reference.
+The following attributes are currently supported, although **the implementation
+for these annotations is currently in development and are subject to change.**
+
+callable_when
+-------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Use ``__attribute__((callable_when(...)))`` to indicate what states a method
+may be called in.  Valid states are unconsumed, consumed, or unknown.  Each
+argument to this attribute must be a quoted string.  E.g.:
+
+``__attribute__((callable_when("unconsumed", "unknown")))``
+
+
+consumable
+----------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Each ``class`` that uses any of the typestate annotations must first be marked
+using the ``consumable`` attribute.  Failure to do so will result in a warning.
+
+This attribute accepts a single parameter that must be one of the following:
+``unknown``, ``consumed``, or ``unconsumed``.
+
+
+param_typestate
+---------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+This attribute specifies expectations about function parameters.  Calls to an
+function with annotated parameters will issue a warning if the corresponding
+argument isn't in the expected state.  The attribute is also used to set the
+initial state of the parameter when analyzing the function's body.
+
+
+return_typestate
+----------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+The ``return_typestate`` attribute can be applied to functions or parameters.
+When applied to a function the attribute specifies the state of the returned
+value.  The function's body is checked to ensure that it always returns a value
+in the specified state.  On the caller side, values returned by the annotated
+function are initialized to the given state.
+
+When applied to a function parameter it modifies the state of an argument after
+a call to the function returns.  The function's body is checked to ensure that
+the parameter is in the expected state before returning.
+
+
+set_typestate
+-------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Annotate methods that transition an object into a new state with
+``__attribute__((set_typestate(new_state)))``.  The new new state must be
+unconsumed, consumed, or unknown.
+
+
+test_typestate
+--------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Use ``__attribute__((test_typestate(tested_state)))`` to indicate that a method
+returns true if the object is in the specified state..
+
+
+Type Safety Checking
+====================
+Clang supports additional attributes to enable checking type safety properties
+that can't be enforced by the C type system.  Use cases include:
+
+* MPI library implementations, where these attributes enable checking that
+  the buffer type matches the passed ``MPI_Datatype``;
+* for HDF5 library there is a similar use case to MPI;
+* checking types of variadic functions' arguments for functions like
+  ``fcntl()`` and ``ioctl()``.
+
+You can detect support for these attributes with ``__has_attribute()``.  For
+example:
+
+.. code-block:: c++
+
+  #if defined(__has_attribute)
+  #  if __has_attribute(argument_with_type_tag) && \
+        __has_attribute(pointer_with_type_tag) && \
+        __has_attribute(type_tag_for_datatype)
+  #    define ATTR_MPI_PWT(buffer_idx, type_idx) __attribute__((pointer_with_type_tag(mpi,buffer_idx,type_idx)))
+  /* ... other macros ...  */
+  #  endif
+  #endif
+
+  #if !defined(ATTR_MPI_PWT)
+  # define ATTR_MPI_PWT(buffer_idx, type_idx)
+  #endif
+
+  int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */)
+      ATTR_MPI_PWT(1,3);
+
+argument_with_type_tag
+----------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Use ``__attribute__((argument_with_type_tag(arg_kind, arg_idx,
+type_tag_idx)))`` on a function declaration to specify that the function
+accepts a type tag that determines the type of some other argument.
+``arg_kind`` is an identifier that should be used when annotating all
+applicable type tags.
+
+This attribute is primarily useful for checking arguments of variadic functions
+(``pointer_with_type_tag`` can be used in most non-variadic cases).
+
+For example:
+
+.. code-block:: c++
+
+  int fcntl(int fd, int cmd, ...)
+      __attribute__(( argument_with_type_tag(fcntl,3,2) ));
+
+
+pointer_with_type_tag
+---------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Use ``__attribute__((pointer_with_type_tag(ptr_kind, ptr_idx, type_tag_idx)))``
+on a function declaration to specify that the function accepts a type tag that
+determines the pointee type of some other pointer argument.
+
+For example:
+
+.. code-block:: c++
+
+  int MPI_Send(void *buf, int count, MPI_Datatype datatype /*, other args omitted */)
+      __attribute__(( pointer_with_type_tag(mpi,1,3) ));
+
+
+type_tag_for_datatype
+---------------------
+.. csv-table:: Supported Syntaxes
+   :header: "GNU", "C++11", "__declspec", "Keyword"
+
+   "X","","",""
+
+Clang supports annotating type tags of two forms.
+
+* **Type tag that is an expression containing a reference to some declared
+  identifier.** Use ``__attribute__((type_tag_for_datatype(kind, type)))`` on a
+  declaration with that identifier:
+
+  .. code-block:: c++
+
+    extern struct mpi_datatype mpi_datatype_int
+        __attribute__(( type_tag_for_datatype(mpi,int) ));
+    #define MPI_INT ((MPI_Datatype) &mpi_datatype_int)
+
+* **Type tag that is an integral literal.** Introduce a ``static const``
+  variable with a corresponding initializer value and attach
+  ``__attribute__((type_tag_for_datatype(kind, type)))`` on that declaration,
+  for example:
+
+  .. code-block:: c++
+
+    #define MPI_INT ((MPI_Datatype) 42)
+    static const MPI_Datatype mpi_datatype_int
+        __attribute__(( type_tag_for_datatype(mpi,int) )) = 42
+
+The attribute also accepts an optional third argument that determines how the
+expression is compared to the type tag.  There are two supported flags:
+
+* ``layout_compatible`` will cause types to be compared according to
+  layout-compatibility rules (C++11 [class.mem] p 17, 18).  This is
+  implemented to support annotating types like ``MPI_DOUBLE_INT``.
+
+  For example:
+
+  .. code-block:: c++
+
+    /* In mpi.h */
+    struct internal_mpi_double_int { double d; int i; };
+    extern struct mpi_datatype mpi_datatype_double_int
+        __attribute__(( type_tag_for_datatype(mpi, struct internal_mpi_double_int, layout_compatible) ));
+
+    #define MPI_DOUBLE_INT ((MPI_Datatype) &mpi_datatype_double_int)
+
+    /* In user code */
+    struct my_pair { double a; int b; };
+    struct my_pair *buffer;
+    MPI_Send(buffer, 1, MPI_DOUBLE_INT /*, ...  */); // no warning
+
+    struct my_int_pair { int a; int b; }
+    struct my_int_pair *buffer2;
+    MPI_Send(buffer2, 1, MPI_DOUBLE_INT /*, ...  */); // warning: actual buffer element
+                                                      // type 'struct my_int_pair'
+                                                      // doesn't match specified MPI_Datatype
+
+* ``must_be_null`` specifies that the expression should be a null pointer
+  constant, for example:
+
+  .. code-block:: c++
+
+    /* In mpi.h */
+    extern struct mpi_datatype mpi_datatype_null
+        __attribute__(( type_tag_for_datatype(mpi, void, must_be_null) ));
+
+    #define MPI_DATATYPE_NULL ((MPI_Datatype) &mpi_datatype_null)
+
+    /* In user code */
+    MPI_Send(buffer, 1, MPI_DATATYPE_NULL /*, ...  */); // warning: MPI_DATATYPE_NULL
+                                                        // was specified but buffer
+                                                        // is not a null pointer
+
+






More information about the llvm-commits mailing list