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