git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72815 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Douglas Gregor 2009-06-03 22:37:00 +00:00
Родитель 58921741c9
Коммит f4d5953135
1 изменённых файлов: 10 добавлений и 17 удалений

Просмотреть файл

@ -431,50 +431,43 @@ headers vary between compilers, precompiled headers have been shown to be a
highly effective at speeding up program compilation on systems with very large
system headers (e.g., Mac OS/X).</p>
<p>Clang supports an implementation of precompiled headers known as
<em>pre-tokenized headers</em> (PTH). Clang's pre-tokenized headers support most
of same interfaces as GCC's pre-compiled headers (as well as others) but are
completely different in their implementation. If you are interested in how
PTH is implemented, please see the <a href="PTHInternals.html">PTH Internals
document</a>.</p>
<h4>Generating a PCH File</h4>
<h4>Generating a PTH File</h4>
<p>To generate a PTH file using Clang, one invokes Clang with
<p>To generate a PCH file using Clang, one invokes Clang with
the <b><tt>-x <i>&lt;language&gt;</i>-header</tt></b> option. This mirrors the
interface in GCC for generating PCH files:</p>
<pre>
$ gcc -x c-header test.h -o test.h.gch
$ clang -x c-header test.h -o test.h.pth
$ clang -x c-header test.h -o test.h.pch
</pre>
<h4>Using a PTH File</h4>
<h4>Using a PCH File</h4>
<p>A PTH file can then be used as a prefix header when a
<p>A PCH file can then be used as a prefix header when a
<b><tt>-include</tt></b> option is passed to <tt>clang</tt>:</p>
<pre>
$ clang -include test.h test.c -o test
</pre>
<p>The <tt>clang</tt> driver will first check if a PTH file for <tt>test.h</tt>
<p>The <tt>clang</tt> driver will first check if a PCH file for <tt>test.h</tt>
is available; if so, the contents of <tt>test.h</tt> (and the files it includes)
will be processed from the PTH file. Otherwise, Clang falls back to
will be processed from the PCH file. Otherwise, Clang falls back to
directly processing the content of <tt>test.h</tt>. This mirrors the behavior of
GCC.</p>
<p><b>NOTE:</b> Clang does <em>not</em> automatically use PTH files
<p><b>NOTE:</b> Clang does <em>not</em> automatically use PCH files
for headers that are directly included within a source file. For example:</p>
<pre>
$ clang -x c-header test.h -o test.h.pth
$ clang -x c-header test.h -o test.h.cth
$ cat test.c
#include "test.h"
$ clang test.c -o test
</pre>
<p>In this example, <tt>clang</tt> will not automatically use the PTH file for
<p>In this example, <tt>clang</tt> will not automatically use the PCH file for
<tt>test.h</tt> since <tt>test.h</tt> was included directly in the source file
and not specified on the command line using <tt>-include</tt>.</p>