xref: /minix3/external/bsd/llvm/dist/clang/www/features.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<html>
4f4a2713aSLionel Sambuc<head>
5f4a2713aSLionel Sambuc  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6f4a2713aSLionel Sambuc  <title>Clang - Features and Goals</title>
7f4a2713aSLionel Sambuc  <link type="text/css" rel="stylesheet" href="menu.css">
8f4a2713aSLionel Sambuc  <link type="text/css" rel="stylesheet" href="content.css">
9f4a2713aSLionel Sambuc  <style type="text/css">
10f4a2713aSLionel Sambuc</style>
11f4a2713aSLionel Sambuc</head>
12f4a2713aSLionel Sambuc<body>
13f4a2713aSLionel Sambuc
14f4a2713aSLionel Sambuc<!--#include virtual="menu.html.incl"-->
15f4a2713aSLionel Sambuc
16f4a2713aSLionel Sambuc<div id="content">
17f4a2713aSLionel Sambuc
18f4a2713aSLionel Sambuc<!--*************************************************************************-->
19f4a2713aSLionel Sambuc<h1>Clang - Features and Goals</h1>
20f4a2713aSLionel Sambuc<!--*************************************************************************-->
21f4a2713aSLionel Sambuc
22f4a2713aSLionel Sambuc<p>
23f4a2713aSLionel SambucThis page describes the <a href="index.html#goals">features and goals</a> of
24f4a2713aSLionel SambucClang in more detail and gives a more broad explanation about what we mean.
25f4a2713aSLionel SambucThese features are:
26f4a2713aSLionel Sambuc</p>
27f4a2713aSLionel Sambuc
28f4a2713aSLionel Sambuc<p>End-User Features:</p>
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc<ul>
31f4a2713aSLionel Sambuc<li><a href="#performance">Fast compiles and low memory use</a></li>
32f4a2713aSLionel Sambuc<li><a href="#expressivediags">Expressive diagnostics</a></li>
33f4a2713aSLionel Sambuc<li><a href="#gcccompat">GCC compatibility</a></li>
34f4a2713aSLionel Sambuc</ul>
35f4a2713aSLionel Sambuc
36f4a2713aSLionel Sambuc<p>Utility and Applications:</p>
37f4a2713aSLionel Sambuc
38f4a2713aSLionel Sambuc<ul>
39f4a2713aSLionel Sambuc<li><a href="#libraryarch">Library based architecture</a></li>
40f4a2713aSLionel Sambuc<li><a href="#diverseclients">Support diverse clients</a></li>
41f4a2713aSLionel Sambuc<li><a href="#ideintegration">Integration with IDEs</a></li>
42f4a2713aSLionel Sambuc<li><a href="#license">Use the LLVM 'BSD' License</a></li>
43f4a2713aSLionel Sambuc</ul>
44f4a2713aSLionel Sambuc
45f4a2713aSLionel Sambuc<p>Internal Design and Implementation:</p>
46f4a2713aSLionel Sambuc
47f4a2713aSLionel Sambuc<ul>
48f4a2713aSLionel Sambuc<li><a href="#real">A real-world, production quality compiler</a></li>
49f4a2713aSLionel Sambuc<li><a href="#simplecode">A simple and hackable code base</a></li>
50f4a2713aSLionel Sambuc<li><a href="#unifiedparser">A single unified parser for C, Objective C, C++,
51f4a2713aSLionel Sambuc    and Objective C++</a></li>
52f4a2713aSLionel Sambuc<li><a href="#conformance">Conformance with C/C++/ObjC and their
53f4a2713aSLionel Sambuc    variants</a></li>
54f4a2713aSLionel Sambuc</ul>
55f4a2713aSLionel Sambuc
56f4a2713aSLionel Sambuc<!--*************************************************************************-->
57f4a2713aSLionel Sambuc<h2><a name="enduser">End-User Features</a></h2>
58f4a2713aSLionel Sambuc<!--*************************************************************************-->
59f4a2713aSLionel Sambuc
60f4a2713aSLionel Sambuc
61f4a2713aSLionel Sambuc<!--=======================================================================-->
62f4a2713aSLionel Sambuc<h3><a name="performance">Fast compiles and Low Memory Use</a></h3>
63f4a2713aSLionel Sambuc<!--=======================================================================-->
64f4a2713aSLionel Sambuc
65f4a2713aSLionel Sambuc<p>A major focus of our work on clang is to make it fast, light and scalable.
66f4a2713aSLionel SambucThe library-based architecture of clang makes it straight-forward to time and
67f4a2713aSLionel Sambucprofile the cost of each layer of the stack, and the driver has a number of
68*0a6a1f1dSLionel Sambucoptions for performance analysis. Many detailed benchmarks can be found online.</p>
69f4a2713aSLionel Sambuc
70f4a2713aSLionel Sambuc<p>Compile time performance is important, but when using clang as an API, often
71f4a2713aSLionel Sambucmemory use is even moreso: the less memory the code takes the more code you can
72f4a2713aSLionel Sambucfit into memory at a time (useful for whole program analysis tools, for
73f4a2713aSLionel Sambucexample).</p>
74f4a2713aSLionel Sambuc
75f4a2713aSLionel Sambuc<p>In addition to being efficient when pitted head-to-head against GCC in batch
76f4a2713aSLionel Sambucmode, clang is built with a <a href="#libraryarch">library based
77f4a2713aSLionel Sambucarchitecture</a> that makes it relatively easy to adapt it and build new tools
78f4a2713aSLionel Sambucwith it.  This means that it is often possible to apply out-of-the-box thinking
79f4a2713aSLionel Sambucand novel techniques to improve compilation in various ways.</p>
80f4a2713aSLionel Sambuc
81f4a2713aSLionel Sambuc
82f4a2713aSLionel Sambuc<!--=======================================================================-->
83f4a2713aSLionel Sambuc<h3><a name="expressivediags">Expressive Diagnostics</a></h3>
84f4a2713aSLionel Sambuc<!--=======================================================================-->
85f4a2713aSLionel Sambuc
86f4a2713aSLionel Sambuc<p>In addition to being fast and functional, we aim to make Clang extremely user
87f4a2713aSLionel Sambucfriendly.  As far as a command-line compiler goes, this basically boils down to
88f4a2713aSLionel Sambucmaking the diagnostics (error and warning messages) generated by the compiler
89f4a2713aSLionel Sambucbe as useful as possible.  There are several ways that we do this, but the
90f4a2713aSLionel Sambucmost important are pinpointing exactly what is wrong in the program,
91f4a2713aSLionel Sambuchighlighting related information so that it is easy to understand at a glance,
92f4a2713aSLionel Sambucand making the wording as clear as possible.</p>
93f4a2713aSLionel Sambuc
94f4a2713aSLionel Sambuc<p>Here is one simple example that illustrates the difference between a typical
95f4a2713aSLionel SambucGCC and Clang diagnostic:</p>
96f4a2713aSLionel Sambuc
97f4a2713aSLionel Sambuc<pre>
98f4a2713aSLionel Sambuc  $ <b>gcc-4.2 -fsyntax-only t.c</b>
99f4a2713aSLionel Sambuc  t.c:7: error: invalid operands to binary + (have 'int' and 'struct A')
100f4a2713aSLionel Sambuc  $ <b>clang -fsyntax-only t.c</b>
101f4a2713aSLionel Sambuc  t.c:7:39: error: invalid operands to binary expression ('int' and 'struct A')
102f4a2713aSLionel Sambuc  <span style="color:darkgreen">  return y + func(y ? ((SomeA.X + 40) + SomeA) / 42 + SomeA.X : SomeA.X);</span>
103f4a2713aSLionel Sambuc  <span style="color:blue">                       ~~~~~~~~~~~~~~ ^ ~~~~~</span>
104f4a2713aSLionel Sambuc</pre>
105f4a2713aSLionel Sambuc
106f4a2713aSLionel Sambuc<p>Here you can see that you don't even need to see the original source code to
107*0a6a1f1dSLionel Sambucunderstand what is wrong based on the Clang error: Because Clang prints a
108f4a2713aSLionel Sambuccaret, you know exactly <em>which</em> plus it is complaining about.  The range
109f4a2713aSLionel Sambucinformation highlights the left and right side of the plus which makes it
110f4a2713aSLionel Sambucimmediately obvious what the compiler is talking about, which is very useful for
111f4a2713aSLionel Sambuccases involving precedence issues and many other situations.</p>
112f4a2713aSLionel Sambuc
113f4a2713aSLionel Sambuc<p>Clang diagnostics are very polished and have many features.  For more
114f4a2713aSLionel Sambucinformation and examples, please see the <a href="diagnostics.html">Expressive
115f4a2713aSLionel SambucDiagnostics</a> page.</p>
116f4a2713aSLionel Sambuc
117f4a2713aSLionel Sambuc<!--=======================================================================-->
118f4a2713aSLionel Sambuc<h3><a name="gcccompat">GCC Compatibility</a></h3>
119f4a2713aSLionel Sambuc<!--=======================================================================-->
120f4a2713aSLionel Sambuc
121f4a2713aSLionel Sambuc<p>GCC is currently the defacto-standard open source compiler today, and it
122f4a2713aSLionel Sambucroutinely compiles a huge volume of code.  GCC supports a huge number of
123f4a2713aSLionel Sambucextensions and features (many of which are undocumented) and a lot of
124f4a2713aSLionel Sambuccode and header files depend on these features in order to build.</p>
125f4a2713aSLionel Sambuc
126f4a2713aSLionel Sambuc<p>While it would be nice to be able to ignore these extensions and focus on
127f4a2713aSLionel Sambucimplementing the language standards to the letter, pragmatics force us to
128f4a2713aSLionel Sambucsupport the GCC extensions that see the most use.  Many users just want their
129f4a2713aSLionel Sambuccode to compile, they don't care to argue about whether it is pedantically C99
130f4a2713aSLionel Sambucor not.</p>
131f4a2713aSLionel Sambuc
132f4a2713aSLionel Sambuc<p>As mentioned above, all
133f4a2713aSLionel Sambucextensions are explicitly recognized as such and marked with extension
134f4a2713aSLionel Sambucdiagnostics, which can be mapped to warnings, errors, or just ignored.
135f4a2713aSLionel Sambuc</p>
136f4a2713aSLionel Sambuc
137f4a2713aSLionel Sambuc
138f4a2713aSLionel Sambuc<!--*************************************************************************-->
139f4a2713aSLionel Sambuc<h2><a name="applications">Utility and Applications</a></h2>
140f4a2713aSLionel Sambuc<!--*************************************************************************-->
141f4a2713aSLionel Sambuc
142f4a2713aSLionel Sambuc<!--=======================================================================-->
143f4a2713aSLionel Sambuc<h3><a name="libraryarch">Library Based Architecture</a></h3>
144f4a2713aSLionel Sambuc<!--=======================================================================-->
145f4a2713aSLionel Sambuc
146f4a2713aSLionel Sambuc<p>A major design concept for clang is its use of a library-based
147f4a2713aSLionel Sambucarchitecture.  In this design, various parts of the front-end can be cleanly
148f4a2713aSLionel Sambucdivided into separate libraries which can then be mixed up for different needs
149f4a2713aSLionel Sambucand uses.  In addition, the library-based approach encourages good interfaces
150f4a2713aSLionel Sambucand makes it easier for new developers to get involved (because they only need
151f4a2713aSLionel Sambucto understand small pieces of the big picture).</p>
152f4a2713aSLionel Sambuc
153f4a2713aSLionel Sambuc<blockquote><p>
154f4a2713aSLionel Sambuc"The world needs better compiler tools, tools which are built as libraries.
155f4a2713aSLionel SambucThis design point allows reuse of the tools in new and novel ways. However,
156f4a2713aSLionel Sambucbuilding the tools as libraries isn't enough: they must have clean APIs, be as
157f4a2713aSLionel Sambucdecoupled from each other as possible, and be easy to modify/extend. This
158f4a2713aSLionel Sambucrequires clean layering, decent design, and keeping the libraries independent of
159f4a2713aSLionel Sambucany specific client."</p></blockquote>
160f4a2713aSLionel Sambuc
161f4a2713aSLionel Sambuc<p>
162f4a2713aSLionel SambucCurrently, clang is divided into the following libraries and tool:
163f4a2713aSLionel Sambuc</p>
164f4a2713aSLionel Sambuc
165f4a2713aSLionel Sambuc<ul>
166f4a2713aSLionel Sambuc<li><b>libsupport</b> - Basic support library, from LLVM.</li>
167f4a2713aSLionel Sambuc<li><b>libsystem</b> - System abstraction library, from LLVM.</li>
168f4a2713aSLionel Sambuc<li><b>libbasic</b> - Diagnostics, SourceLocations, SourceBuffer abstraction,
169f4a2713aSLionel Sambuc    file system caching for input source files.</li>
170f4a2713aSLionel Sambuc<li><b>libast</b> - Provides classes to represent the C AST, the C type system,
171f4a2713aSLionel Sambuc    builtin functions, and various helpers for analyzing and manipulating the
172f4a2713aSLionel Sambuc    AST (visitors, pretty printers, etc).</li>
173f4a2713aSLionel Sambuc<li><b>liblex</b> - Lexing and preprocessing, identifier hash table, pragma
174f4a2713aSLionel Sambuc    handling, tokens, and macro expansion.</li>
175f4a2713aSLionel Sambuc<li><b>libparse</b> - Parsing. This library invokes coarse-grained 'Actions'
176f4a2713aSLionel Sambuc    provided by the client (e.g. libsema builds ASTs) but knows nothing about
177f4a2713aSLionel Sambuc    ASTs or other client-specific data structures.</li>
178f4a2713aSLionel Sambuc<li><b>libsema</b> - Semantic Analysis.  This provides a set of parser actions
179f4a2713aSLionel Sambuc    to build a standardized AST for programs.</li>
180f4a2713aSLionel Sambuc<li><b>libcodegen</b> - Lower the AST to LLVM IR for optimization &amp; code
181f4a2713aSLionel Sambuc    generation.</li>
182f4a2713aSLionel Sambuc<li><b>librewrite</b> - Editing of text buffers (important for code rewriting
183f4a2713aSLionel Sambuc    transformation, like refactoring).</li>
184f4a2713aSLionel Sambuc<li><b>libanalysis</b> - Static analysis support.</li>
185f4a2713aSLionel Sambuc<li><b>clang</b> - A driver program, client of the libraries at various
186f4a2713aSLionel Sambuc    levels.</li>
187f4a2713aSLionel Sambuc</ul>
188f4a2713aSLionel Sambuc
189f4a2713aSLionel Sambuc<p>As an example of the power of this library based design....  If you wanted to
190f4a2713aSLionel Sambucbuild a preprocessor, you would take the Basic and Lexer libraries. If you want
191f4a2713aSLionel Sambucan indexer, you would take the previous two and add the Parser library and
192f4a2713aSLionel Sambucsome actions for indexing. If you want a refactoring, static analysis, or
193f4a2713aSLionel Sambucsource-to-source compiler tool, you would then add the AST building and
194f4a2713aSLionel Sambucsemantic analyzer libraries.</p>
195f4a2713aSLionel Sambuc
196f4a2713aSLionel Sambuc<p>For more information about the low-level implementation details of the
197f4a2713aSLionel Sambucvarious clang libraries, please see the <a href="docs/InternalsManual.html">
198f4a2713aSLionel Sambucclang Internals Manual</a>.</p>
199f4a2713aSLionel Sambuc
200f4a2713aSLionel Sambuc<!--=======================================================================-->
201f4a2713aSLionel Sambuc<h3><a name="diverseclients">Support Diverse Clients</a></h3>
202f4a2713aSLionel Sambuc<!--=======================================================================-->
203f4a2713aSLionel Sambuc
204f4a2713aSLionel Sambuc<p>Clang is designed and built with many grand plans for how we can use it.  The
205f4a2713aSLionel Sambucdriving force is the fact that we use C and C++ daily, and have to suffer due to
206f4a2713aSLionel Sambuca lack of good tools available for it.  We believe that the C and C++ tools
207f4a2713aSLionel Sambucecosystem has been significantly limited by how difficult it is to parse and
208f4a2713aSLionel Sambucrepresent the source code for these languages, and we aim to rectify this
209f4a2713aSLionel Sambucproblem in clang.</p>
210f4a2713aSLionel Sambuc
211f4a2713aSLionel Sambuc<p>The problem with this goal is that different clients have very different
212f4a2713aSLionel Sambucrequirements.  Consider code generation, for example: a simple front-end that
213f4a2713aSLionel Sambucparses for code generation must analyze the code for validity and emit code
214f4a2713aSLionel Sambucin some intermediate form to pass off to a optimizer or backend.  Because
215f4a2713aSLionel Sambucvalidity analysis and code generation can largely be done on the fly, there is
216f4a2713aSLionel Sambucnot hard requirement that the front-end actually build up a full AST for all
217f4a2713aSLionel Sambucthe expressions and statements in the code.  TCC and GCC are examples of
218f4a2713aSLionel Sambuccompilers that either build no real AST (in the former case) or build a stripped
219f4a2713aSLionel Sambucdown and simplified AST (in the later case) because they focus primarily on
220f4a2713aSLionel Sambuccodegen.</p>
221f4a2713aSLionel Sambuc
222f4a2713aSLionel Sambuc<p>On the opposite side of the spectrum, some clients (like refactoring) want
223f4a2713aSLionel Sambuchighly detailed information about the original source code and want a complete
224f4a2713aSLionel SambucAST to describe it with.  Refactoring wants to have information about macro
225f4a2713aSLionel Sambucexpansions, the location of every paren expression '(((x)))' vs 'x', full
226f4a2713aSLionel Sambucposition information, and much more.  Further, refactoring wants to look
227f4a2713aSLionel Sambuc<em>across the whole program</em> to ensure that it is making transformations
228f4a2713aSLionel Sambucthat are safe.  Making this efficient and getting this right requires a
229f4a2713aSLionel Sambucsignificant amount of engineering and algorithmic work that simply are
230f4a2713aSLionel Sambucunnecessary for a simple static compiler.</p>
231f4a2713aSLionel Sambuc
232f4a2713aSLionel Sambuc<p>The beauty of the clang approach is that it does not restrict how you use it.
233f4a2713aSLionel SambucIn particular, it is possible to use the clang preprocessor and parser to build
234f4a2713aSLionel Sambucan extremely quick and light-weight on-the-fly code generator (similar to TCC)
235f4a2713aSLionel Sambucthat does not build an AST at all.   As an intermediate step, clang supports
236f4a2713aSLionel Sambucusing the current AST generation and semantic analysis code and having a code
237f4a2713aSLionel Sambucgeneration client free the AST for each function after code generation. Finally,
238f4a2713aSLionel Sambucclang provides support for building and retaining fully-fledged ASTs, and even
239f4a2713aSLionel Sambucsupports writing them out to disk.</p>
240f4a2713aSLionel Sambuc
241f4a2713aSLionel Sambuc<p>Designing the libraries with clean and simple APIs allows these high-level
242f4a2713aSLionel Sambucpolicy decisions to be determined in the client, instead of forcing "one true
243f4a2713aSLionel Sambucway" in the implementation of any of these libraries.  Getting this right is
244f4a2713aSLionel Sambuchard, and we don't always get it right the first time, but we fix any problems
245f4a2713aSLionel Sambucwhen we realize we made a mistake.</p>
246f4a2713aSLionel Sambuc
247f4a2713aSLionel Sambuc<!--=======================================================================-->
248f4a2713aSLionel Sambuc<h3 id="ideintegration">Integration with IDEs</h3>
249f4a2713aSLionel Sambuc<!--=======================================================================-->
250f4a2713aSLionel Sambuc
251f4a2713aSLionel Sambuc<p>
252f4a2713aSLionel SambucWe believe that Integrated Development Environments (IDE's) are a great way
253f4a2713aSLionel Sambucto pull together various pieces of the development puzzle, and aim to make clang
254f4a2713aSLionel Sambucwork well in such an environment.  The chief advantage of an IDE is that they
255f4a2713aSLionel Sambuctypically have visibility across your entire project and are long-lived
256f4a2713aSLionel Sambucprocesses, whereas stand-alone compiler tools are typically invoked on each
257f4a2713aSLionel Sambucindividual file in the project, and thus have limited scope.</p>
258f4a2713aSLionel Sambuc
259f4a2713aSLionel Sambuc<p>There are many implications of this difference, but a significant one has to
260f4a2713aSLionel Sambucdo with efficiency and caching: sharing an address space across different files
261f4a2713aSLionel Sambucin a project, means that you can use intelligent caching and other techniques to
262f4a2713aSLionel Sambucdramatically reduce analysis/compilation time.</p>
263f4a2713aSLionel Sambuc
264f4a2713aSLionel Sambuc<p>A further difference between IDEs and batch compiler is that they often
265f4a2713aSLionel Sambucimpose very different requirements on the front-end: they depend on high
266f4a2713aSLionel Sambucperformance in order to provide a "snappy" experience, and thus really want
267f4a2713aSLionel Sambuctechniques like "incremental compilation", "fuzzy parsing", etc.  Finally, IDEs
268f4a2713aSLionel Sambucoften have very different requirements than code generation, often requiring
269f4a2713aSLionel Sambucinformation that a codegen-only frontend can throw away.  Clang is
270f4a2713aSLionel Sambucspecifically designed and built to capture this information.
271f4a2713aSLionel Sambuc</p>
272f4a2713aSLionel Sambuc
273f4a2713aSLionel Sambuc
274f4a2713aSLionel Sambuc<!--=======================================================================-->
275f4a2713aSLionel Sambuc<h3><a name="license">Use the LLVM 'BSD' License</a></h3>
276f4a2713aSLionel Sambuc<!--=======================================================================-->
277f4a2713aSLionel Sambuc
278f4a2713aSLionel Sambuc<p>We actively intend for clang (and LLVM as a whole) to be used for
279f4a2713aSLionel Sambuccommercial projects, not only as a stand-alone compiler but also as a library
280f4a2713aSLionel Sambucembedded inside a proprietary application.  The BSD license is the simplest way
281f4a2713aSLionel Sambucto allow this.  We feel that the license encourages contributors to pick up the
282f4a2713aSLionel Sambucsource and work with it, and believe that those individuals and organizations
283f4a2713aSLionel Sambucwill contribute back their work if they do not want to have to maintain a fork
284f4a2713aSLionel Sambucforever (which is time consuming and expensive when merges are involved).
285f4a2713aSLionel SambucFurther, nobody makes money on compilers these days, but many people need them
286f4a2713aSLionel Sambucto get bigger goals accomplished: it makes sense for everyone to work
287f4a2713aSLionel Sambuctogether.</p>
288f4a2713aSLionel Sambuc
289f4a2713aSLionel Sambuc<p>For more information about the LLVM/clang license, please see the <a
290f4a2713aSLionel Sambuchref="http://llvm.org/docs/DeveloperPolicy.html#license">LLVM License
291f4a2713aSLionel SambucDescription</a> for more information.</p>
292f4a2713aSLionel Sambuc
293f4a2713aSLionel Sambuc
294f4a2713aSLionel Sambuc
295f4a2713aSLionel Sambuc<!--*************************************************************************-->
296f4a2713aSLionel Sambuc<h2><a name="design">Internal Design and Implementation</a></h2>
297f4a2713aSLionel Sambuc<!--*************************************************************************-->
298f4a2713aSLionel Sambuc
299f4a2713aSLionel Sambuc<!--=======================================================================-->
300f4a2713aSLionel Sambuc<h3><a name="real">A real-world, production quality compiler</a></h3>
301f4a2713aSLionel Sambuc<!--=======================================================================-->
302f4a2713aSLionel Sambuc
303f4a2713aSLionel Sambuc<p>
304f4a2713aSLionel SambucClang is designed and built by experienced compiler developers who
305f4a2713aSLionel Sambucare increasingly frustrated with the problems that <a
306f4a2713aSLionel Sambuchref="comparison.html">existing open source compilers</a> have.  Clang is
307f4a2713aSLionel Sambuccarefully and thoughtfully designed and built to provide the foundation of a
308f4a2713aSLionel Sambucwhole new generation of C/C++/Objective C development tools, and we intend for
309f4a2713aSLionel Sambucit to be production quality.</p>
310f4a2713aSLionel Sambuc
311f4a2713aSLionel Sambuc<p>Being a production quality compiler means many things: it means being high
312f4a2713aSLionel Sambucperformance, being solid and (relatively) bug free, and it means eventually
313f4a2713aSLionel Sambucbeing used and depended on by a broad range of people.  While we are still in
314f4a2713aSLionel Sambucthe early development stages, we strongly believe that this will become a
315f4a2713aSLionel Sambucreality.</p>
316f4a2713aSLionel Sambuc
317f4a2713aSLionel Sambuc<!--=======================================================================-->
318f4a2713aSLionel Sambuc<h3><a name="simplecode">A simple and hackable code base</a></h3>
319f4a2713aSLionel Sambuc<!--=======================================================================-->
320f4a2713aSLionel Sambuc
321f4a2713aSLionel Sambuc<p>Our goal is to make it possible for anyone with a basic understanding
322f4a2713aSLionel Sambucof compilers and working knowledge of the C/C++/ObjC languages to understand and
323f4a2713aSLionel Sambucextend the clang source base.  A large part of this falls out of our decision to
324f4a2713aSLionel Sambucmake the AST mirror the languages as closely as possible: you have your friendly
325f4a2713aSLionel Sambucif statement, for statement, parenthesis expression, structs, unions, etc, all
326f4a2713aSLionel Sambucrepresented in a simple and explicit way.</p>
327f4a2713aSLionel Sambuc
328f4a2713aSLionel Sambuc<p>In addition to a simple design, we work to make the source base approachable
329f4a2713aSLionel Sambucby commenting it well, including citations of the language standards where
330f4a2713aSLionel Sambucappropriate, and designing the code for simplicity.  Beyond that, clang offers
331f4a2713aSLionel Sambuca set of AST dumpers, printers, and visualizers that make it easy to put code in
332f4a2713aSLionel Sambucand see how it is represented.</p>
333f4a2713aSLionel Sambuc
334f4a2713aSLionel Sambuc<!--=======================================================================-->
335f4a2713aSLionel Sambuc<h3><a name="unifiedparser">A single unified parser for C, Objective C, C++,
336f4a2713aSLionel Sambucand Objective C++</a></h3>
337f4a2713aSLionel Sambuc<!--=======================================================================-->
338f4a2713aSLionel Sambuc
339f4a2713aSLionel Sambuc<p>Clang is the "C Language Family Front-end", which means we intend to support
340f4a2713aSLionel Sambucthe most popular members of the C family.  We are convinced that the right
341f4a2713aSLionel Sambucparsing technology for this class of languages is a hand-built recursive-descent
342f4a2713aSLionel Sambucparser.  Because it is plain C++ code, recursive descent makes it very easy for
343f4a2713aSLionel Sambucnew developers to understand the code, it easily supports ad-hoc rules and other
344f4a2713aSLionel Sambucstrange hacks required by C/C++, and makes it straight-forward to implement
345f4a2713aSLionel Sambucexcellent diagnostics and error recovery.</p>
346f4a2713aSLionel Sambuc
347f4a2713aSLionel Sambuc<p>We believe that implementing C/C++/ObjC in a single unified parser makes the
348f4a2713aSLionel Sambucend result easier to maintain and evolve than maintaining a separate C and C++
349f4a2713aSLionel Sambucparser which must be bugfixed and maintained independently of each other.</p>
350f4a2713aSLionel Sambuc
351f4a2713aSLionel Sambuc<!--=======================================================================-->
352f4a2713aSLionel Sambuc<h3><a name="conformance">Conformance with C/C++/ObjC and their
353f4a2713aSLionel Sambuc variants</a></h3>
354f4a2713aSLionel Sambuc<!--=======================================================================-->
355f4a2713aSLionel Sambuc
356f4a2713aSLionel Sambuc<p>When you start work on implementing a language, you find out that there is a
357f4a2713aSLionel Sambuchuge gap between how the language works and how most people understand it to
358f4a2713aSLionel Sambucwork.  This gap is the difference between a normal programmer and a (scary?
359f4a2713aSLionel Sambucsuper-natural?) "language lawyer", who knows the ins and outs of the language
360f4a2713aSLionel Sambucand can grok standardese with ease.</p>
361f4a2713aSLionel Sambuc
362f4a2713aSLionel Sambuc<p>In practice, being conformant with the languages means that we aim to support
363f4a2713aSLionel Sambucthe full language, including the dark and dusty corners (like trigraphs,
364f4a2713aSLionel Sambucpreprocessor arcana, C99 VLAs, etc).  Where we support extensions above and
365f4a2713aSLionel Sambucbeyond what the standard officially allows, we make an effort to explicitly call
366f4a2713aSLionel Sambucthis out in the code and emit warnings about it (which are disabled by default,
367f4a2713aSLionel Sambucbut can optionally be mapped to either warnings or errors), allowing you to use
368f4a2713aSLionel Sambucclang in "strict" mode if you desire.</p>
369f4a2713aSLionel Sambuc
370f4a2713aSLionel Sambuc<p>We also intend to support "dialects" of these languages, such as C89, K&amp;R
371f4a2713aSLionel SambucC, C++'03, Objective-C 2, etc.</p>
372f4a2713aSLionel Sambuc
373f4a2713aSLionel Sambuc</div>
374f4a2713aSLionel Sambuc</body>
375f4a2713aSLionel Sambuc</html>
376