Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
| 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 | <!--*********************************************************************-->
|
| 17 |
|
| 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
|
Daniel Dunbar | 2f06417 | 2008-11-13 23:01:34 +0000 | [diff] [blame] | 20 | codebases.</p>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 21 | <ul>
|
| 22 | <li><a href="#docs">Developer Documentation</a></li>
|
| 23 | <li><a href="#debugging">Debugging</a></li>
|
| 24 | <li><a href="#irgen">LLVM IR Generation</a></li>
|
| 25 | </ul>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 26 |
|
| 27 | <!--=====================================================================-->
|
Daniel Dunbar | 2f06417 | 2008-11-13 23:01:34 +0000 | [diff] [blame] | 28 | <h2 id="docs">Developer Documentation</h2>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 29 | <!--=====================================================================-->
|
| 30 |
|
| 31 | <p>Both Clang and LLVM use doxygen to provide API documentation. Their
|
Daniel Dunbar | 2f06417 | 2008-11-13 23:01:34 +0000 | [diff] [blame] | 32 | respective web pages (generated nightly) are here:</p>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 33 | <ul>
|
| 34 | <li><a href="http://clang.llvm.org/doxygen">Clang</a></li>
|
| 35 | <li><a href="http://llvm.org/doxygen">LLVM</a></li>
|
| 36 | </ul>
|
Daniel Dunbar | 2f06417 | 2008-11-13 23:01:34 +0000 | [diff] [blame] | 37 |
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 38 | <p>For work on the LLVM IR generation, the LLVM assembly language
|
| 39 | <a href="http://llvm.org/docs/LangRef.html">reference manual</a> is
|
| 40 | also useful.</p>
|
| 41 |
|
| 42 | <!--=====================================================================-->
|
| 43 | <h2 id="debugging">Debugging</h2>
|
| 44 | <!--=====================================================================-->
|
| 45 |
|
Daniel Dunbar | 2f06417 | 2008-11-13 23:01:34 +0000 | [diff] [blame] | 46 | <p>Inspecting data structures in a debugger:</p>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 47 | <ul>
|
| 48 | <li>Many LLVM and Clang data structures provide
|
| 49 | a <tt>dump()</tt> method which will print a description of the
|
| 50 | data structure to <tt>stderr</tt>.</li>
|
| 51 | <li>The <a href="docs/InternalsManual.html#QualType"><tt>QualType</tt></a>
|
| 52 | structure is used pervasively. This is a simple value class for
|
| 53 | wrapping types with qualifiers; you can use
|
| 54 | the <tt>isConstQualified()</tt>, for example, to get one of the
|
| 55 | qualifiers, and the <tt>getTypePtr()</tt> method to get the
|
| 56 | wrapped <tt>Type*</tt> which you can then dump.</li>
|
| 57 | </ul>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 58 |
|
| 59 | <!--=====================================================================-->
|
| 60 | <h2 id="irgen">LLVM IR Generation</h2>
|
| 61 | <!--=====================================================================-->
|
| 62 |
|
| 63 | <p>The LLVM IR generation part of clang handles conversion of the
|
| 64 | AST nodes output by the Sema module to the LLVM Intermediate
|
| 65 | Representation (IR). Historically, this was referred to as
|
| 66 | "codegen", and the Clang code for this lives
|
| 67 | in <tt>lib/CodeGen</tt>.</p>
|
| 68 |
|
| 69 | <p>The output is most easily inspected using the <tt>-emit-llvm</tt>
|
| 70 | option to clang (possibly in conjunction with <tt>-o -</tt>). You
|
| 71 | can also use <tt>-emit-llvm-bc</tt> to write an LLVM bitcode file
|
| 72 | which can be processed by the suite of LLVM tools
|
| 73 | like <tt>llvm-dis</tt>, <tt>llvm-nm</tt>, etc. See the LLVM
|
Daniel Dunbar | 2f06417 | 2008-11-13 23:01:34 +0000 | [diff] [blame] | 74 | <a href="http://llvm.org/docs/CommandGuide/">Command Guide</a>
|
Daniel Dunbar | 0d7c3f9 | 2008-11-13 22:49:41 +0000 | [diff] [blame] | 75 | for more information.</p>
|
| 76 |
|
| 77 | </div>
|
| 78 | </body>
|
| 79 | </html>
|