xref: /minix3/external/bsd/llvm/dist/clang/www/hacking.html (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2f4a2713aSLionel Sambuc          "http://www.w3.org/TR/html4/strict.dtd">
3f4a2713aSLionel Sambuc<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
4f4a2713aSLionel Sambuc<html>
5f4a2713aSLionel Sambuc<head>
6f4a2713aSLionel Sambuc  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
7f4a2713aSLionel Sambuc  <title>Hacking on clang</title>
8f4a2713aSLionel Sambuc  <link type="text/css" rel="stylesheet" href="menu.css">
9f4a2713aSLionel Sambuc  <link type="text/css" rel="stylesheet" href="content.css">
10f4a2713aSLionel Sambuc  <style type="text/css">
11f4a2713aSLionel Sambuc  pre { margin-left: 1.5em; }
12f4a2713aSLionel Sambuc  </style>
13f4a2713aSLionel Sambuc</head>
14f4a2713aSLionel Sambuc<body>
15f4a2713aSLionel Sambuc<!--#include virtual="menu.html.incl"-->
16f4a2713aSLionel Sambuc<div id="content">
17f4a2713aSLionel Sambuc  <!--*********************************************************************-->
18f4a2713aSLionel Sambuc  <h1>Hacking on Clang</h1>
19f4a2713aSLionel Sambuc  <!--*********************************************************************-->
20f4a2713aSLionel Sambuc
21f4a2713aSLionel Sambuc  <p>This document provides some hints for how to get started hacking
22f4a2713aSLionel Sambuc  on Clang for developers who are new to the Clang and/or LLVM
23f4a2713aSLionel Sambuc  codebases.</p>
24f4a2713aSLionel Sambuc    <ul>
25f4a2713aSLionel Sambuc      <li><a href="#style">Coding Standards</a></li>
26f4a2713aSLionel Sambuc      <li><a href="#docs">Developer Documentation</a></li>
27f4a2713aSLionel Sambuc      <li><a href="#debugging">Debugging</a></li>
28f4a2713aSLionel Sambuc      <li><a href="#testing">Testing</a>
29f4a2713aSLionel Sambuc      <ul>
30f4a2713aSLionel Sambuc        <li><a href="#testingNonWindows">Testing on Unix-like Systems</a></li>
31f4a2713aSLionel Sambuc        <li><a href="#testingWindows">Testing using Visual Studio on Windows</a></li>
32f4a2713aSLionel Sambuc        <li><a href="#testingCommands">Testing on the Command Line</a></li>
33f4a2713aSLionel Sambuc      </ul>
34f4a2713aSLionel Sambuc      </li>
35f4a2713aSLionel Sambuc      <li><a href="#patches">Creating Patch Files</a></li>
36f4a2713aSLionel Sambuc      <li><a href="#irgen">LLVM IR Generation</a></li>
37f4a2713aSLionel Sambuc    </ul>
38f4a2713aSLionel Sambuc
39f4a2713aSLionel Sambuc  <!--=====================================================================-->
40f4a2713aSLionel Sambuc  <h2 id="style">Coding Standards</h2>
41f4a2713aSLionel Sambuc  <!--=====================================================================-->
42f4a2713aSLionel Sambuc
43f4a2713aSLionel Sambuc  <p>Clang follows the
44f4a2713aSLionel Sambuc  LLVM <a href="http://llvm.org/docs/CodingStandards.html">Coding
45f4a2713aSLionel Sambuc  Standards</a>. When submitting patches, please take care to follow these standards
46f4a2713aSLionel Sambuc  and to match the style of the code to that present in Clang (for example, in
47f4a2713aSLionel Sambuc  terms of indentation, bracing, and statement spacing).</p>
48f4a2713aSLionel Sambuc
49f4a2713aSLionel Sambuc  <p>Clang has a few additional coding standards:</p>
50f4a2713aSLionel Sambuc  <ul>
51f4a2713aSLionel Sambuc    <li><i>cstdio is forbidden</i>: library code should not output diagnostics
52f4a2713aSLionel Sambuc      or other information using <tt>cstdio</tt>; debugging routines should
53f4a2713aSLionel Sambuc      use <tt>llvm::errs()</tt>. Other uses of <tt>cstdio</tt> impose behavior
54f4a2713aSLionel Sambuc      upon clients and block integrating Clang as a library. Libraries should
55f4a2713aSLionel Sambuc      support <tt>raw_ostream</tt> based interfaces for textual
56f4a2713aSLionel Sambuc      output. See <a href="http://llvm.org/docs/CodingStandards.html#ll_raw_ostream">Coding
57f4a2713aSLionel Sambuc      Standards</a>.</li>
58f4a2713aSLionel Sambuc  </ul>
59f4a2713aSLionel Sambuc
60f4a2713aSLionel Sambuc  <!--=====================================================================-->
61f4a2713aSLionel Sambuc  <h2 id="docs">Developer Documentation</h2>
62f4a2713aSLionel Sambuc  <!--=====================================================================-->
63f4a2713aSLionel Sambuc
64f4a2713aSLionel Sambuc  <p>Both Clang and LLVM use doxygen to provide API documentation. Their
65f4a2713aSLionel Sambuc  respective web pages (generated nightly) are here:</p>
66f4a2713aSLionel Sambuc    <ul>
67f4a2713aSLionel Sambuc      <li><a href="http://clang.llvm.org/doxygen">Clang</a></li>
68f4a2713aSLionel Sambuc      <li><a href="http://llvm.org/doxygen">LLVM</a></li>
69f4a2713aSLionel Sambuc    </ul>
70f4a2713aSLionel Sambuc
71f4a2713aSLionel Sambuc  <p>For work on the LLVM IR generation, the LLVM assembly language
72f4a2713aSLionel Sambuc  <a href="http://llvm.org/docs/LangRef.html">reference manual</a> is
73f4a2713aSLionel Sambuc  also useful.</p>
74f4a2713aSLionel Sambuc
75f4a2713aSLionel Sambuc  <!--=====================================================================-->
76f4a2713aSLionel Sambuc  <h2 id="debugging">Debugging</h2>
77f4a2713aSLionel Sambuc  <!--=====================================================================-->
78f4a2713aSLionel Sambuc
79f4a2713aSLionel Sambuc  <p>Inspecting data structures in a debugger:</p>
80f4a2713aSLionel Sambuc    <ul>
81f4a2713aSLionel Sambuc      <li>Many LLVM and Clang data structures provide
82f4a2713aSLionel Sambuc        a <tt>dump()</tt> method which will print a description of the
83f4a2713aSLionel Sambuc        data structure to <tt>stderr</tt>.</li>
84f4a2713aSLionel Sambuc      <li>The <a href="docs/InternalsManual.html#QualType"><tt>QualType</tt></a>
85f4a2713aSLionel Sambuc      structure is used pervasively. This is a simple value class for
86f4a2713aSLionel Sambuc      wrapping types with qualifiers; you can use
87f4a2713aSLionel Sambuc      the <tt>isConstQualified()</tt>, for example, to get one of the
88f4a2713aSLionel Sambuc      qualifiers, and the <tt>getTypePtr()</tt> method to get the
89f4a2713aSLionel Sambuc      wrapped <tt>Type*</tt> which you can then dump.</li>
90f4a2713aSLionel Sambuc      <li>For <a href="http://lldb.llvm.org"> <tt>LLDB</tt></a> users there are
91f4a2713aSLionel Sambuc      data formatters for clang data structures in
92f4a2713aSLionel Sambuc      <a href="http://llvm.org/svn/llvm-project/cfe/trunk/utils/ClangDataFormat.py">
93f4a2713aSLionel Sambuc      <tt>utils/ClangDataFormat.py</tt></a>.</li>
94f4a2713aSLionel Sambuc    </ul>
95f4a2713aSLionel Sambuc
96f4a2713aSLionel Sambuc  <!--=====================================================================-->
97f4a2713aSLionel Sambuc  <h3 id="debuggingVisualStudio">Debugging using Visual Studio</h3>
98f4a2713aSLionel Sambuc  <!--=====================================================================-->
99f4a2713aSLionel Sambuc
100*0a6a1f1dSLionel Sambuc  <p>The files
101*0a6a1f1dSLionel Sambuc    <a href="http://llvm.org/svn/llvm-project/llvm/trunk/utils/llvm.natvis">
102*0a6a1f1dSLionel Sambuc      <tt>utils/llvm.natvis</tt></a> and
103*0a6a1f1dSLionel Sambuc    <a href="http://llvm.org/svn/llvm-project/cfe/trunk/utils/clang.natvis">
104*0a6a1f1dSLionel Sambuc      <tt>utils/clang.natvis</tt></a> provide debugger visualizers
105*0a6a1f1dSLionel Sambuc      that make debugging of more complex data types much easier.</p>
106*0a6a1f1dSLionel Sambuc  <p>Put the files into
107*0a6a1f1dSLionel Sambuc    <tt>%USERPROFILE%\Documents\Visual Studio 2012\Visualizers</tt> or
108*0a6a1f1dSLionel Sambuc    create a symbolic link so they update automatically.</p>
109f4a2713aSLionel Sambuc
110f4a2713aSLionel Sambuc  <!--=====================================================================-->
111f4a2713aSLionel Sambuc  <h2 id="testing">Testing</h2>
112f4a2713aSLionel Sambuc  <!--=====================================================================-->
113f4a2713aSLionel Sambuc
114f4a2713aSLionel Sambuc  <!--=====================================================================-->
115f4a2713aSLionel Sambuc  <h3 id="testingNonWindows">Testing on Unix-like Systems</h3>
116f4a2713aSLionel Sambuc  <!--=====================================================================-->
117f4a2713aSLionel Sambuc
118f4a2713aSLionel Sambuc  <p>Clang includes a basic regression suite in the tree which can be
119f4a2713aSLionel Sambuc  run with <tt>make test</tt> from the top-level clang directory, or
120f4a2713aSLionel Sambuc  just <tt>make</tt> in the <em>test</em> sub-directory.
121f4a2713aSLionel Sambuc  <tt>make VERBOSE=1</tt> can be used to show more detail
122f4a2713aSLionel Sambuc  about what is being run.</p>
123f4a2713aSLionel Sambuc
124f4a2713aSLionel Sambuc  <p>If you built LLVM and Clang using CMake, the test suite can be run
125f4a2713aSLionel Sambuc  with <tt>make clang-test</tt> from the top-level LLVM directory.</p>
126f4a2713aSLionel Sambuc
127f4a2713aSLionel Sambuc  <p>The tests primarily consist of a test runner script running the compiler
128f4a2713aSLionel Sambuc  under test on individual test files grouped in the directories under the
129f4a2713aSLionel Sambuc  test directory.  The individual test files include comments at the
130f4a2713aSLionel Sambuc  beginning indicating the Clang compile options to use, to be read
131f4a2713aSLionel Sambuc  by the test runner. Embedded comments also can do things like telling
132f4a2713aSLionel Sambuc  the test runner that an error is expected at the current line.
133f4a2713aSLionel Sambuc  Any output files produced by the test will be placed under
134f4a2713aSLionel Sambuc  a created Output directory.</p>
135f4a2713aSLionel Sambuc
136f4a2713aSLionel Sambuc  <p>During the run of <tt>make test</tt>, the terminal output will
137f4a2713aSLionel Sambuc  display a line similar to the following:</p>
138f4a2713aSLionel Sambuc
139f4a2713aSLionel Sambuc  <pre>--- Running clang tests for i686-pc-linux-gnu ---</pre>
140f4a2713aSLionel Sambuc
141f4a2713aSLionel Sambuc  <p>followed by a line continually overwritten with the current test
142f4a2713aSLionel Sambuc  file being compiled, and an overall completion percentage.</p>
143f4a2713aSLionel Sambuc
144f4a2713aSLionel Sambuc  <p>After the <tt>make test</tt> run completes, the absence of any
145f4a2713aSLionel Sambuc  <tt>Failing Tests (count):</tt> message indicates that no tests
146f4a2713aSLionel Sambuc  failed unexpectedly.  If any tests did fail, the
147f4a2713aSLionel Sambuc  <tt>Failing Tests (count):</tt> message will be followed by a list
148f4a2713aSLionel Sambuc  of the test source file paths that failed.  For example:</p>
149f4a2713aSLionel Sambuc
150f4a2713aSLionel Sambuc  <pre>
151f4a2713aSLionel Sambuc  Failing Tests (3):
152f4a2713aSLionel Sambuc      /home/john/llvm/tools/clang/test/SemaCXX/member-name-lookup.cpp
153f4a2713aSLionel Sambuc      /home/john/llvm/tools/clang/test/SemaCXX/namespace-alias.cpp
154f4a2713aSLionel Sambuc      /home/john/llvm/tools/clang/test/SemaCXX/using-directive.cpp
155f4a2713aSLionel Sambuc</pre>
156f4a2713aSLionel Sambuc
157f4a2713aSLionel Sambuc  <p>If you used the <tt>make VERBOSE=1</tt> option, the terminal
158f4a2713aSLionel Sambuc  output will reflect the error messages from the compiler and
159f4a2713aSLionel Sambuc  test runner.</p>
160f4a2713aSLionel Sambuc
161f4a2713aSLionel Sambuc  <p>The regression suite can also be run with Valgrind by running
162f4a2713aSLionel Sambuc  <tt>make test VG=1</tt> in the top-level clang directory.</p>
163f4a2713aSLionel Sambuc
164f4a2713aSLionel Sambuc  <p>For more intensive changes, running
165f4a2713aSLionel Sambuc  the <a href="http://llvm.org/docs/TestingGuide.html#testsuiterun">LLVM
166f4a2713aSLionel Sambuc  Test Suite</a> with clang is recommended. Currently the best way to
167f4a2713aSLionel Sambuc  override LLVMGCC, as in: <tt>make LLVMGCC="clang -std=gnu89"
168f4a2713aSLionel Sambuc  TEST=nightly report</tt> (make sure <tt>clang</tt> is in your PATH or use the
169f4a2713aSLionel Sambuc  full path).</p>
170f4a2713aSLionel Sambuc
171f4a2713aSLionel Sambuc  <!--=====================================================================-->
172f4a2713aSLionel Sambuc  <h3 id="testingWindows">Testing using Visual Studio on Windows</h3>
173f4a2713aSLionel Sambuc  <!--=====================================================================-->
174f4a2713aSLionel Sambuc
175f4a2713aSLionel Sambuc  <p>The Clang test suite can be run from either Visual Studio or
176f4a2713aSLionel Sambuc  the command line.</p>
177f4a2713aSLionel Sambuc
178f4a2713aSLionel Sambuc  <p>Note that the test runner is based on
179f4a2713aSLionel Sambuc  Python, which must be installed.  Find Python at:
180f4a2713aSLionel Sambuc  <a href="http://www.python.org/download/">http://www.python.org/download/</a>.
181f4a2713aSLionel Sambuc  Download the latest stable version (2.6.2 at the time of this writing).</p>
182f4a2713aSLionel Sambuc
183f4a2713aSLionel Sambuc  <p>The GnuWin32 tools are also necessary for running the tests.
184f4a2713aSLionel Sambuc  Get them from <a href="http://getgnuwin32.sourceforge.net/">
185f4a2713aSLionel Sambuc  http://getgnuwin32.sourceforge.net/</a>.
186f4a2713aSLionel Sambuc  If the environment variable <tt>%PATH%</tt> does not have GnuWin32,
187f4a2713aSLionel Sambuc  or if other grep(s) supercedes GnuWin32 on <tt>%PATH%,</tt>
188f4a2713aSLionel Sambuc  you should specify <tt>LLVM_LIT_TOOLS_DIR</tt>
189f4a2713aSLionel Sambuc  to CMake explicitly.</p>
190f4a2713aSLionel Sambuc
191f4a2713aSLionel Sambuc  <p>The cmake build tool is set up to create Visual Studio project files
192f4a2713aSLionel Sambuc  for running the tests, "clang-test" being the root.  Therefore, to
193f4a2713aSLionel Sambuc  run the test from Visual Studio, right-click the clang-test project
194f4a2713aSLionel Sambuc  and select "Build".</p>
195f4a2713aSLionel Sambuc
196f4a2713aSLionel Sambuc  <p>
197f4a2713aSLionel Sambuc    Please see also
198f4a2713aSLionel Sambuc    <a href="http://llvm.org/docs/GettingStartedVS.html">Getting Started
199f4a2713aSLionel Sambuc    with the LLVM System using Microsoft Visual Studio</a> and
200f4a2713aSLionel Sambuc    <a href="http://llvm.org/docs/CMake.html">Building LLVM with CMake</a>.
201f4a2713aSLionel Sambuc  </p>
202f4a2713aSLionel Sambuc
203f4a2713aSLionel Sambuc  <!--=====================================================================-->
204f4a2713aSLionel Sambuc  <h3 id="testingCommands">Testing on the Command Line</h3>
205f4a2713aSLionel Sambuc  <!--=====================================================================-->
206f4a2713aSLionel Sambuc
207f4a2713aSLionel Sambuc  <p>If you want more control over how the tests are run, it may
208f4a2713aSLionel Sambuc  be convenient to run the test harness on the command-line directly. Before
209f4a2713aSLionel Sambuc  running tests from the command line, you will need to ensure that
210f4a2713aSLionel Sambuc  <tt>lit.site.cfg</tt> files have been created for your build.  You can do
211f4a2713aSLionel Sambuc  this by running the tests as described in the previous sections. Once the
212f4a2713aSLionel Sambuc  tests have started running, you can stop them with control+C, as the
213f4a2713aSLionel Sambuc  files are generated before running any tests.</p>
214f4a2713aSLionel Sambuc
215f4a2713aSLionel Sambuc  <p>Once that is done, to run all the tests from the command line,
216f4a2713aSLionel Sambuc  execute a command like the following:</p>
217f4a2713aSLionel Sambuc
218f4a2713aSLionel Sambuc  <pre>
219f4a2713aSLionel Sambuc  python (path to llvm)\llvm\utils\lit\lit.py -sv
220f4a2713aSLionel Sambuc  --param=build_mode=Win32 --param=build_config=Debug
221f4a2713aSLionel Sambuc  --param=clang_site_config=(build dir)\tools\clang\test\lit.site.cfg
222f4a2713aSLionel Sambuc (path to llvm)\llvm\tools\clang\test
223f4a2713aSLionel Sambuc</pre>
224f4a2713aSLionel Sambuc
225f4a2713aSLionel Sambuc  <p>For CMake builds e.g. on Windows with Visual Studio, you will need
226f4a2713aSLionel Sambuc  to specify your build configuration (Debug, Release, etc.) via
227f4a2713aSLionel Sambuc  <tt>--param=build_config=(build config)</tt>.  You may also need to specify
228f4a2713aSLionel Sambuc  the build mode (Win32, etc) via <tt>--param=build_mode=(build mode)</tt>.</p>
229f4a2713aSLionel Sambuc
230f4a2713aSLionel Sambuc  <p>Additionally, you will need to specify the lit site configuration which
231f4a2713aSLionel Sambuc  lives in (build dir)\tools\clang\test, via
232f4a2713aSLionel Sambuc  <tt>--param=clang_site_config=(build dir)\tools\clang\test\lit.site.cfg</tt>.
233f4a2713aSLionel Sambuc  </p>
234f4a2713aSLionel Sambuc
235f4a2713aSLionel Sambuc  <p>To run a single test:</p>
236f4a2713aSLionel Sambuc
237f4a2713aSLionel Sambuc  <pre>
238f4a2713aSLionel Sambuc  python (path to llvm)\llvm\utils\lit\lit.py -sv
239f4a2713aSLionel Sambuc  --param=build_mode=Win32 --param=build_config=Debug
240f4a2713aSLionel Sambuc  --param=clang_site_config=(build dir)\tools\clang\test\lit.site.cfg
241f4a2713aSLionel Sambuc  (path to llvm)\llvm\tools\clang\test\(dir)\(test)
242f4a2713aSLionel Sambuc</pre>
243f4a2713aSLionel Sambuc
244f4a2713aSLionel Sambuc  <p>For example:</p>
245f4a2713aSLionel Sambuc
246f4a2713aSLionel Sambuc  <pre>
247f4a2713aSLionel Sambuc  python C:\Tool\llvm\utils\lit\lit.py -sv
248f4a2713aSLionel Sambuc  --param=build_mode=Win32 --param=build_config=Debug
249f4a2713aSLionel Sambuc  --param=clang_site_config=c:\Tools\build\tools\clang\test\lit.site.cfg
250f4a2713aSLionel Sambuc  C:\Tools\llvm\tools\clang\test\Sema\wchar.c
251f4a2713aSLionel Sambuc</pre>
252f4a2713aSLionel Sambuc
253f4a2713aSLionel Sambuc  <p>The -sv option above tells the runner to show the test output if
254f4a2713aSLionel Sambuc  any tests failed, to help you determine the cause of failure.</p>
255f4a2713aSLionel Sambuc
256f4a2713aSLionel Sambuc  <p>You can also pass in the --no-progress-bar option if you wish to disable
257f4a2713aSLionel Sambuc  progress indications while the tests are running.</p>
258f4a2713aSLionel Sambuc
259f4a2713aSLionel Sambuc  <p>Your output might look something like this:</p>
260f4a2713aSLionel Sambuc
261f4a2713aSLionel Sambuc  <pre>lit.py: lit.cfg:152: note: using clang: 'C:\Tools\llvm\bin\Release\clang.EXE'
262f4a2713aSLionel Sambuc-- Testing: Testing: 2534 tests, 4 threads --
263f4a2713aSLionel SambucTesting: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
264f4a2713aSLionel SambucTesting Time: 81.52s
265f4a2713aSLionel Sambuc  Expected Passes    : 2503
266f4a2713aSLionel Sambuc  Expected Failures  : 28
267f4a2713aSLionel Sambuc  Unsupported Tests  : 3
268f4a2713aSLionel Sambuc</pre>
269f4a2713aSLionel Sambuc
270f4a2713aSLionel Sambuc  <p>The statistic, "Unexpected Failures" (not shown if all tests pass), is the important one.</p>
271f4a2713aSLionel Sambuc
272f4a2713aSLionel Sambuc  <!--=====================================================================-->
273f4a2713aSLionel Sambuc  <h2 id="patches">Creating Patch Files</h2>
274f4a2713aSLionel Sambuc  <!--=====================================================================-->
275f4a2713aSLionel Sambuc
276f4a2713aSLionel Sambuc  <p>To return changes to the Clang team, unless you have checkin
277f4a2713aSLionel Sambuc  privileges, the preferred way is to send patch files to the
278f4a2713aSLionel Sambuc  cfe-commits mailing list, with an explanation of what the patch is
279*0a6a1f1dSLionel Sambuc  for.  clang follows <a
280*0a6a1f1dSLionel Sambuc  href="http://llvm.org/docs/DeveloperPolicy.html">LLVM's developer policy</a>.
281*0a6a1f1dSLionel Sambuc  If your patch requires a wider discussion (for example, because it is an
282*0a6a1f1dSLionel Sambuc  architectural change), you can use the cfe-dev mailing list.</p>
283f4a2713aSLionel Sambuc
284f4a2713aSLionel Sambuc  <p>To create these patch files, change directory
285f4a2713aSLionel Sambuc  to the llvm/tools/clang root and run:</p>
286f4a2713aSLionel Sambuc
287f4a2713aSLionel Sambuc  <pre>svn diff (relative path) >(patch file name)</pre>
288f4a2713aSLionel Sambuc
289f4a2713aSLionel Sambuc  <p>For example, for getting the diffs of all of clang:</p>
290f4a2713aSLionel Sambuc
291f4a2713aSLionel Sambuc  <pre>svn diff . >~/mypatchfile.patch</pre>
292f4a2713aSLionel Sambuc
293f4a2713aSLionel Sambuc  <p>For example, for getting the diffs of a single file:</p>
294f4a2713aSLionel Sambuc
295f4a2713aSLionel Sambuc  <pre>svn diff lib/Parse/ParseDeclCXX.cpp >~/ParseDeclCXX.patch</pre>
296f4a2713aSLionel Sambuc
297f4a2713aSLionel Sambuc  <p>Note that the paths embedded in the patch depend on where you run it,
298f4a2713aSLionel Sambuc  so changing directory to the llvm/tools/clang directory is recommended.</p>
299f4a2713aSLionel Sambuc
300f4a2713aSLionel Sambuc  <!--=====================================================================-->
301f4a2713aSLionel Sambuc  <h2 id="irgen">LLVM IR Generation</h2>
302f4a2713aSLionel Sambuc  <!--=====================================================================-->
303f4a2713aSLionel Sambuc
304f4a2713aSLionel Sambuc  <p>The LLVM IR generation part of clang handles conversion of the
305f4a2713aSLionel Sambuc    AST nodes output by the Sema module to the LLVM Intermediate
306f4a2713aSLionel Sambuc    Representation (IR). Historically, this was referred to as
307f4a2713aSLionel Sambuc    "codegen", and the Clang code for this lives
308f4a2713aSLionel Sambuc    in <tt>lib/CodeGen</tt>.</p>
309f4a2713aSLionel Sambuc
310f4a2713aSLionel Sambuc  <p>The output is most easily inspected using the <tt>-emit-llvm</tt>
311f4a2713aSLionel Sambuc    option to clang (possibly in conjunction with <tt>-o -</tt>). You
312f4a2713aSLionel Sambuc    can also use <tt>-emit-llvm-bc</tt> to write an LLVM bitcode file
313f4a2713aSLionel Sambuc    which can be processed by the suite of LLVM tools
314f4a2713aSLionel Sambuc    like <tt>llvm-dis</tt>, <tt>llvm-nm</tt>, etc. See the LLVM
315f4a2713aSLionel Sambuc    <a href="http://llvm.org/docs/CommandGuide/">Command Guide</a>
316f4a2713aSLionel Sambuc    for more information.</p>
317f4a2713aSLionel Sambuc
318f4a2713aSLionel Sambuc</div>
319f4a2713aSLionel Sambuc</body>
320f4a2713aSLionel Sambuc</html>
321