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