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