forked from chapuni/clang
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInternalsManual.html
2017 lines (1748 loc) · 97.3 KB
/
InternalsManual.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>"Clang" CFE Internals Manual</title>
<link type="text/css" rel="stylesheet" href="../menu.css">
<link type="text/css" rel="stylesheet" href="../content.css">
<style type="text/css">
td {
vertical-align: top;
}
</style>
</head>
<body>
<!--#include virtual="../menu.html.incl"-->
<div id="content">
<h1>"Clang" CFE Internals Manual</h1>
<ul>
<li><a href="#intro">Introduction</a></li>
<li><a href="#libsupport">LLVM Support Library</a></li>
<li><a href="#libbasic">The Clang 'Basic' Library</a>
<ul>
<li><a href="#Diagnostics">The Diagnostics Subsystem</a></li>
<li><a href="#SourceLocation">The SourceLocation and SourceManager
classes</a></li>
<li><a href="#SourceRange">SourceRange and CharSourceRange</a></li>
</ul>
</li>
<li><a href="#libdriver">The Driver Library</a>
</li>
<li><a href="#pch">Precompiled Headers</a>
<li><a href="#libfrontend">The Frontend Library</a>
</li>
<li><a href="#liblex">The Lexer and Preprocessor Library</a>
<ul>
<li><a href="#Token">The Token class</a></li>
<li><a href="#Lexer">The Lexer class</a></li>
<li><a href="#AnnotationToken">Annotation Tokens</a></li>
<li><a href="#TokenLexer">The TokenLexer class</a></li>
<li><a href="#MultipleIncludeOpt">The MultipleIncludeOpt class</a></li>
</ul>
</li>
<li><a href="#libparse">The Parser Library</a>
</li>
<li><a href="#libast">The AST Library</a>
<ul>
<li><a href="#Type">The Type class and its subclasses</a></li>
<li><a href="#QualType">The QualType class</a></li>
<li><a href="#DeclarationName">Declaration names</a></li>
<li><a href="#DeclContext">Declaration contexts</a>
<ul>
<li><a href="#Redeclarations">Redeclarations and Overloads</a></li>
<li><a href="#LexicalAndSemanticContexts">Lexical and Semantic
Contexts</a></li>
<li><a href="#TransparentContexts">Transparent Declaration Contexts</a></li>
<li><a href="#MultiDeclContext">Multiply-Defined Declaration Contexts</a></li>
</ul>
</li>
<li><a href="#CFG">The CFG class</a></li>
<li><a href="#Constants">Constant Folding in the Clang AST</a></li>
</ul>
</li>
<li><a href="#Howtos">Howto guides</a>
<ul>
<li><a href="#AddingAttributes">How to add an attribute</a></li>
<li><a href="#AddingExprStmt">How to add a new expression or statement</a></li>
</ul>
</li>
</ul>
<!-- ======================================================================= -->
<h2 id="intro">Introduction</h2>
<!-- ======================================================================= -->
<p>This document describes some of the more important APIs and internal design
decisions made in the Clang C front-end. The purpose of this document is to
both capture some of this high level information and also describe some of the
design decisions behind it. This is meant for people interested in hacking on
Clang, not for end-users. The description below is categorized by
libraries, and does not describe any of the clients of the libraries.</p>
<!-- ======================================================================= -->
<h2 id="libsupport">LLVM Support Library</h2>
<!-- ======================================================================= -->
<p>The LLVM libsupport library provides many underlying libraries and
<a href="http://llvm.org/docs/ProgrammersManual.html">data-structures</a>,
including command line option processing, various containers and a system
abstraction layer, which is used for file system access.</p>
<!-- ======================================================================= -->
<h2 id="libbasic">The Clang 'Basic' Library</h2>
<!-- ======================================================================= -->
<p>This library certainly needs a better name. The 'basic' library contains a
number of low-level utilities for tracking and manipulating source buffers,
locations within the source buffers, diagnostics, tokens, target abstraction,
and information about the subset of the language being compiled for.</p>
<p>Part of this infrastructure is specific to C (such as the TargetInfo class),
other parts could be reused for other non-C-based languages (SourceLocation,
SourceManager, Diagnostics, FileManager). When and if there is future demand
we can figure out if it makes sense to introduce a new library, move the general
classes somewhere else, or introduce some other solution.</p>
<p>We describe the roles of these classes in order of their dependencies.</p>
<!-- ======================================================================= -->
<h3 id="Diagnostics">The Diagnostics Subsystem</h3>
<!-- ======================================================================= -->
<p>The Clang Diagnostics subsystem is an important part of how the compiler
communicates with the human. Diagnostics are the warnings and errors produced
when the code is incorrect or dubious. In Clang, each diagnostic produced has
(at the minimum) a unique ID, an English translation associated with it, a <a
href="#SourceLocation">SourceLocation</a> to "put the caret", and a severity (e.g.
<tt>WARNING</tt> or <tt>ERROR</tt>). They can also optionally include a number
of arguments to the dianostic (which fill in "%0"'s in the string) as well as a
number of source ranges that related to the diagnostic.</p>
<p>In this section, we'll be giving examples produced by the Clang command line
driver, but diagnostics can be <a href="#DiagnosticClient">rendered in many
different ways</a> depending on how the DiagnosticClient interface is
implemented. A representative example of a diagnostic is:</p>
<pre>
t.c:38:15: error: invalid operands to binary expression ('int *' and '_Complex float')
<span style="color:darkgreen">P = (P-42) + Gamma*4;</span>
<span style="color:blue">~~~~~~ ^ ~~~~~~~</span>
</pre>
<p>In this example, you can see the English translation, the severity (error),
you can see the source location (the caret ("^") and file/line/column info),
the source ranges "~~~~", arguments to the diagnostic ("int*" and "_Complex
float"). You'll have to believe me that there is a unique ID backing the
diagnostic :).</p>
<p>Getting all of this to happen has several steps and involves many moving
pieces, this section describes them and talks about best practices when adding
a new diagnostic.</p>
<!-- ============================= -->
<h4>The Diagnostic*Kinds.td files</h4>
<!-- ============================= -->
<p>Diagnostics are created by adding an entry to one of the <tt>
clang/Basic/Diagnostic*Kinds.td</tt> files, depending on what library will
be using it. From this file, tblgen generates the unique ID of the diagnostic,
the severity of the diagnostic and the English translation + format string.</p>
<p>There is little sanity with the naming of the unique ID's right now. Some
start with err_, warn_, ext_ to encode the severity into the name. Since the
enum is referenced in the C++ code that produces the diagnostic, it is somewhat
useful for it to be reasonably short.</p>
<p>The severity of the diagnostic comes from the set {<tt>NOTE</tt>,
<tt>WARNING</tt>, <tt>EXTENSION</tt>, <tt>EXTWARN</tt>, <tt>ERROR</tt>}. The
<tt>ERROR</tt> severity is used for diagnostics indicating the program is never
acceptable under any circumstances. When an error is emitted, the AST for the
input code may not be fully built. The <tt>EXTENSION</tt> and <tt>EXTWARN</tt>
severities are used for extensions to the language that Clang accepts. This
means that Clang fully understands and can represent them in the AST, but we
produce diagnostics to tell the user their code is non-portable. The difference
is that the former are ignored by default, and the later warn by default. The
<tt>WARNING</tt> severity is used for constructs that are valid in the currently
selected source language but that are dubious in some way. The <tt>NOTE</tt>
level is used to staple more information onto previous diagnostics.</p>
<p>These <em>severities</em> are mapped into a smaller set (the
Diagnostic::Level enum, {<tt>Ignored</tt>, <tt>Note</tt>, <tt>Warning</tt>,
<tt>Error</tt>, <tt>Fatal</tt> }) of output <em>levels</em> by the diagnostics
subsystem based on various configuration options. Clang internally supports a
fully fine grained mapping mechanism that allows you to map almost any
diagnostic to the output level that you want. The only diagnostics that cannot
be mapped are <tt>NOTE</tt>s, which always follow the severity of the previously
emitted diagnostic and <tt>ERROR</tt>s, which can only be mapped to
<tt>Fatal</tt> (it is not possible to turn an error into a warning,
for example).</p>
<p>Diagnostic mappings are used in many ways. For example, if the user
specifies <tt>-pedantic</tt>, <tt>EXTENSION</tt> maps to <tt>Warning</tt>, if
they specify <tt>-pedantic-errors</tt>, it turns into <tt>Error</tt>. This is
used to implement options like <tt>-Wunused_macros</tt>, <tt>-Wundef</tt> etc.
</p>
<p>
Mapping to <tt>Fatal</tt> should only be used for diagnostics that are
considered so severe that error recovery won't be able to recover sensibly from
them (thus spewing a ton of bogus errors). One example of this class of error
are failure to #include a file.
</p>
<!-- ================= -->
<h4>The Format String</h4>
<!-- ================= -->
<p>The format string for the diagnostic is very simple, but it has some power.
It takes the form of a string in English with markers that indicate where and
how arguments to the diagnostic are inserted and formatted. For example, here
are some simple format strings:</p>
<pre>
"binary integer literals are an extension"
"format string contains '\\0' within the string body"
"more '<b>%%</b>' conversions than data arguments"
"invalid operands to binary expression (<b>%0</b> and <b>%1</b>)"
"overloaded '<b>%0</b>' must be a <b>%select{unary|binary|unary or binary}2</b> operator"
" (has <b>%1</b> parameter<b>%s1</b>)"
</pre>
<p>These examples show some important points of format strings. You can use any
plain ASCII character in the diagnostic string except "%" without a problem,
but these are C strings, so you have to use and be aware of all the C escape
sequences (as in the second example). If you want to produce a "%" in the
output, use the "%%" escape sequence, like the third diagnostic. Finally,
Clang uses the "%...[digit]" sequences to specify where and how arguments to
the diagnostic are formatted.</p>
<p>Arguments to the diagnostic are numbered according to how they are specified
by the C++ code that <a href="#producingdiag">produces them</a>, and are
referenced by <tt>%0</tt> .. <tt>%9</tt>. If you have more than 10 arguments
to your diagnostic, you are doing something wrong :). Unlike printf, there
is no requirement that arguments to the diagnostic end up in the output in
the same order as they are specified, you could have a format string with
<tt>"%1 %0"</tt> that swaps them, for example. The text in between the
percent and digit are formatting instructions. If there are no instructions,
the argument is just turned into a string and substituted in.</p>
<p>Here are some "best practices" for writing the English format string:</p>
<ul>
<li>Keep the string short. It should ideally fit in the 80 column limit of the
<tt>DiagnosticKinds.td</tt> file. This avoids the diagnostic wrapping when
printed, and forces you to think about the important point you are conveying
with the diagnostic.</li>
<li>Take advantage of location information. The user will be able to see the
line and location of the caret, so you don't need to tell them that the
problem is with the 4th argument to the function: just point to it.</li>
<li>Do not capitalize the diagnostic string, and do not end it with a
period.</li>
<li>If you need to quote something in the diagnostic string, use single
quotes.</li>
</ul>
<p>Diagnostics should never take random English strings as arguments: you
shouldn't use <tt>"you have a problem with %0"</tt> and pass in things like
<tt>"your argument"</tt> or <tt>"your return value"</tt> as arguments. Doing
this prevents <a href="#translation">translating</a> the Clang diagnostics to
other languages (because they'll get random English words in their otherwise
localized diagnostic). The exceptions to this are C/C++ language keywords
(e.g. auto, const, mutable, etc) and C/C++ operators (<tt>/=</tt>). Note
that things like "pointer" and "reference" are not keywords. On the other
hand, you <em>can</em> include anything that comes from the user's source code,
including variable names, types, labels, etc. The 'select' format can be
used to achieve this sort of thing in a localizable way, see below.</p>
<!-- ==================================== -->
<h4>Formatting a Diagnostic Argument</h4>
<!-- ==================================== -->
<p>Arguments to diagnostics are fully typed internally, and come from a couple
different classes: integers, types, names, and random strings. Depending on
the class of the argument, it can be optionally formatted in different ways.
This gives the DiagnosticClient information about what the argument means
without requiring it to use a specific presentation (consider this MVC for
Clang :).</p>
<p>Here are the different diagnostic argument formats currently supported by
Clang:</p>
<table>
<tr><td colspan="2"><b>"s" format</b></td></tr>
<tr><td>Example:</td><td><tt>"requires %1 parameter%s1"</tt></td></tr>
<tr><td>Class:</td><td>Integers</td></tr>
<tr><td>Description:</td><td>This is a simple formatter for integers that is
useful when producing English diagnostics. When the integer is 1, it prints
as nothing. When the integer is not 1, it prints as "s". This allows some
simple grammatical forms to be to be handled correctly, and eliminates the
need to use gross things like <tt>"requires %1 parameter(s)"</tt>.</td></tr>
<tr><td colspan="2"><b>"select" format</b></td></tr>
<tr><td>Example:</td><td><tt>"must be a %select{unary|binary|unary or binary}2
operator"</tt></td></tr>
<tr><td>Class:</td><td>Integers</td></tr>
<tr><td>Description:</td><td><p>This format specifier is used to merge multiple
related diagnostics together into one common one, without requiring the
difference to be specified as an English string argument. Instead of
specifying the string, the diagnostic gets an integer argument and the
format string selects the numbered option. In this case, the "%2" value
must be an integer in the range [0..2]. If it is 0, it prints 'unary', if
it is 1 it prints 'binary' if it is 2, it prints 'unary or binary'. This
allows other language translations to substitute reasonable words (or entire
phrases) based on the semantics of the diagnostic instead of having to do
things textually.</p>
<p>The selected string does undergo formatting.</p></td></tr>
<tr><td colspan="2"><b>"plural" format</b></td></tr>
<tr><td>Example:</td><td><tt>"you have %1 %plural{1:mouse|:mice}1 connected to
your computer"</tt></td></tr>
<tr><td>Class:</td><td>Integers</td></tr>
<tr><td>Description:</td><td><p>This is a formatter for complex plural forms.
It is designed to handle even the requirements of languages with very
complex plural forms, as many Baltic languages have. The argument consists
of a series of expression/form pairs, separated by ':', where the first form
whose expression evaluates to true is the result of the modifier.</p>
<p>An expression can be empty, in which case it is always true. See the
example at the top. Otherwise, it is a series of one or more numeric
conditions, separated by ','. If any condition matches, the expression
matches. Each numeric condition can take one of three forms.</p>
<ul>
<li>number: A simple decimal number matches if the argument is the same
as the number. Example: <tt>"%plural{1:mouse|:mice}4"</tt></li>
<li>range: A range in square brackets matches if the argument is within
the range. Then range is inclusive on both ends. Example:
<tt>"%plural{0:none|1:one|[2,5]:some|:many}2"</tt></li>
<li>modulo: A modulo operator is followed by a number, and
equals sign and either a number or a range. The tests are the
same as for plain
numbers and ranges, but the argument is taken modulo the number first.
Example: <tt>"%plural{%100=0:even hundred|%100=[1,50]:lower half|:everything
else}1"</tt></li>
</ul>
<p>The parser is very unforgiving. A syntax error, even whitespace, will
abort, as will a failure to match the argument against any
expression.</p></td></tr>
<tr><td colspan="2"><b>"ordinal" format</b></td></tr>
<tr><td>Example:</td><td><tt>"ambiguity in %ordinal0 argument"</tt></td></tr>
<tr><td>Class:</td><td>Integers</td></tr>
<tr><td>Description:</td><td><p>This is a formatter which represents the
argument number as an ordinal: the value <tt>1</tt> becomes <tt>1st</tt>,
<tt>3</tt> becomes <tt>3rd</tt>, and so on. Values less than <tt>1</tt>
are not supported.</p>
<p>This formatter is currently hard-coded to use English ordinals.</p></td></tr>
<tr><td colspan="2"><b>"objcclass" format</b></td></tr>
<tr><td>Example:</td><td><tt>"method %objcclass0 not found"</tt></td></tr>
<tr><td>Class:</td><td>DeclarationName</td></tr>
<tr><td>Description:</td><td><p>This is a simple formatter that indicates the
DeclarationName corresponds to an Objective-C class method selector. As
such, it prints the selector with a leading '+'.</p></td></tr>
<tr><td colspan="2"><b>"objcinstance" format</b></td></tr>
<tr><td>Example:</td><td><tt>"method %objcinstance0 not found"</tt></td></tr>
<tr><td>Class:</td><td>DeclarationName</td></tr>
<tr><td>Description:</td><td><p>This is a simple formatter that indicates the
DeclarationName corresponds to an Objective-C instance method selector. As
such, it prints the selector with a leading '-'.</p></td></tr>
<tr><td colspan="2"><b>"q" format</b></td></tr>
<tr><td>Example:</td><td><tt>"candidate found by name lookup is %q0"</tt></td></tr>
<tr><td>Class:</td><td>NamedDecl*</td></tr>
<tr><td>Description</td><td><p>This formatter indicates that the fully-qualified name of the declaration should be printed, e.g., "std::vector" rather than "vector".</p></td></tr>
<tr><td colspan="2"><b>"diff" format</b></td></tr>
<tr><td>Example:</td><td><tt>"no known conversion %diff{from | to | }1,2"</tt></td></tr>
<tr><td>Class:</td><td>QualType</td></tr>
<tr><td>Description</td><td><p>This formatter takes two QualTypes and attempts to print a template difference between the two. If tree printing is off, the text inside the the braces before the pipe is printed, with the formatted text replacing the $. If tree printing is on, the text after the pipe is printed and a type tree is printed after the diagnostic message.
</p></td></tr>
</table>
<p>It is really easy to add format specifiers to the Clang diagnostics system,
but they should be discussed before they are added. If you are creating a lot
of repetitive diagnostics and/or have an idea for a useful formatter, please
bring it up on the cfe-dev mailing list.</p>
<!-- ===================================================== -->
<h4 id="producingdiag">Producing the Diagnostic</h4>
<!-- ===================================================== -->
<p>Now that you've created the diagnostic in the DiagnosticKinds.td file, you
need to write the code that detects the condition in question and emits the
new diagnostic. Various components of Clang (e.g. the preprocessor, Sema,
etc) provide a helper function named "Diag". It creates a diagnostic and
accepts the arguments, ranges, and other information that goes along with
it.</p>
<p>For example, the binary expression error comes from code like this:</p>
<pre>
if (various things that are bad)
Diag(Loc, diag::err_typecheck_invalid_operands)
<< lex->getType() << rex->getType()
<< lex->getSourceRange() << rex->getSourceRange();
</pre>
<p>This shows that use of the Diag method: they take a location (a <a
href="#SourceLocation">SourceLocation</a> object) and a diagnostic enum value
(which matches the name from DiagnosticKinds.td). If the diagnostic takes
arguments, they are specified with the << operator: the first argument
becomes %0, the second becomes %1, etc. The diagnostic interface allows you to
specify arguments of many different types, including <tt>int</tt> and
<tt>unsigned</tt> for integer arguments, <tt>const char*</tt> and
<tt>std::string</tt> for string arguments, <tt>DeclarationName</tt> and
<tt>const IdentifierInfo*</tt> for names, <tt>QualType</tt> for types, etc.
SourceRanges are also specified with the << operator, but do not have a
specific ordering requirement.</p>
<p>As you can see, adding and producing a diagnostic is pretty straightforward.
The hard part is deciding exactly what you need to say to help the user, picking
a suitable wording, and providing the information needed to format it correctly.
The good news is that the call site that issues a diagnostic should be
completely independent of how the diagnostic is formatted and in what language
it is rendered.
</p>
<!-- ==================================================== -->
<h4 id="fix-it-hints">Fix-It Hints</h4>
<!-- ==================================================== -->
<p>In some cases, the front end emits diagnostics when it is clear
that some small change to the source code would fix the problem. For
example, a missing semicolon at the end of a statement or a use of
deprecated syntax that is easily rewritten into a more modern form.
Clang tries very hard to emit the diagnostic and recover gracefully
in these and other cases.</p>
<p>However, for these cases where the fix is obvious, the diagnostic
can be annotated with a hint (referred to as a "fix-it hint") that
describes how to change the code referenced by the diagnostic to fix
the problem. For example, it might add the missing semicolon at the
end of the statement or rewrite the use of a deprecated construct
into something more palatable. Here is one such example from the C++
front end, where we warn about the right-shift operator changing
meaning from C++98 to C++11:</p>
<pre>
test.cpp:3:7: warning: use of right-shift operator ('>>') in template argument will require parentheses in C++11
A<100 >> 2> *a;
^
( )
</pre>
<p>Here, the fix-it hint is suggesting that parentheses be added,
and showing exactly where those parentheses would be inserted into the
source code. The fix-it hints themselves describe what changes to make
to the source code in an abstract manner, which the text diagnostic
printer renders as a line of "insertions" below the caret line. <a
href="#DiagnosticClient">Other diagnostic clients</a> might choose
to render the code differently (e.g., as markup inline) or even give
the user the ability to automatically fix the problem.</p>
<p>Fix-it hints on errors and warnings need to obey these rules:</p>
<ul>
<li>Since they are automatically applied if <code>-Xclang -fixit</code>
is passed to the driver, they should only be used when it's very likely they
match the user's intent.</li>
<li>Clang must recover from errors as if the fix-it had been applied.</li>
</ul>
<p>If a fix-it can't obey these rules, put the fix-it on a note. Fix-its on
notes are not applied automatically.</p>
<p>All fix-it hints are described by the <code>FixItHint</code> class,
instances of which should be attached to the diagnostic using the
<< operator in the same way that highlighted source ranges and
arguments are passed to the diagnostic. Fix-it hints can be created
with one of three constructors:</p>
<dl>
<dt><code>FixItHint::CreateInsertion(Loc, Code)</code></dt>
<dd>Specifies that the given <code>Code</code> (a string) should be inserted
before the source location <code>Loc</code>.</dd>
<dt><code>FixItHint::CreateRemoval(Range)</code></dt>
<dd>Specifies that the code in the given source <code>Range</code>
should be removed.</dd>
<dt><code>FixItHint::CreateReplacement(Range, Code)</code></dt>
<dd>Specifies that the code in the given source <code>Range</code>
should be removed, and replaced with the given <code>Code</code> string.</dd>
</dl>
<!-- ============================================================= -->
<h4><a name="DiagnosticClient">The DiagnosticClient Interface</a></h4>
<!-- ============================================================= -->
<p>Once code generates a diagnostic with all of the arguments and the rest of
the relevant information, Clang needs to know what to do with it. As previously
mentioned, the diagnostic machinery goes through some filtering to map a
severity onto a diagnostic level, then (assuming the diagnostic is not mapped to
"<tt>Ignore</tt>") it invokes an object that implements the DiagnosticClient
interface with the information.</p>
<p>It is possible to implement this interface in many different ways. For
example, the normal Clang DiagnosticClient (named 'TextDiagnosticPrinter') turns
the arguments into strings (according to the various formatting rules), prints
out the file/line/column information and the string, then prints out the line of
code, the source ranges, and the caret. However, this behavior isn't required.
</p>
<p>Another implementation of the DiagnosticClient interface is the
'TextDiagnosticBuffer' class, which is used when Clang is in -verify mode.
Instead of formatting and printing out the diagnostics, this implementation just
captures and remembers the diagnostics as they fly by. Then -verify compares
the list of produced diagnostics to the list of expected ones. If they disagree,
it prints out its own output.
</p>
<p>There are many other possible implementations of this interface, and this is
why we prefer diagnostics to pass down rich structured information in arguments.
For example, an HTML output might want declaration names be linkified to where
they come from in the source. Another example is that a GUI might let you click
on typedefs to expand them. This application would want to pass significantly
more information about types through to the GUI than a simple flat string. The
interface allows this to happen.</p>
<!-- ====================================================== -->
<h4><a name="translation">Adding Translations to Clang</a></h4>
<!-- ====================================================== -->
<p>Not possible yet! Diagnostic strings should be written in UTF-8, the client
can translate to the relevant code page if needed. Each translation completely
replaces the format string for the diagnostic.</p>
<!-- ======================================================================= -->
<h3 id="SourceLocation">The SourceLocation and SourceManager classes</h3>
<!-- ======================================================================= -->
<p>Strangely enough, the SourceLocation class represents a location within the
source code of the program. Important design points include:</p>
<ol>
<li>sizeof(SourceLocation) must be extremely small, as these are embedded into
many AST nodes and are passed around often. Currently it is 32 bits.</li>
<li>SourceLocation must be a simple value object that can be efficiently
copied.</li>
<li>We should be able to represent a source location for any byte of any input
file. This includes in the middle of tokens, in whitespace, in trigraphs,
etc.</li>
<li>A SourceLocation must encode the current #include stack that was active when
the location was processed. For example, if the location corresponds to a
token, it should contain the set of #includes active when the token was
lexed. This allows us to print the #include stack for a diagnostic.</li>
<li>SourceLocation must be able to describe macro expansions, capturing both
the ultimate instantiation point and the source of the original character
data.</li>
</ol>
<p>In practice, the SourceLocation works together with the SourceManager class
to encode two pieces of information about a location: its spelling location
and its instantiation location. For most tokens, these will be the same.
However, for a macro expansion (or tokens that came from a _Pragma directive)
these will describe the location of the characters corresponding to the token
and the location where the token was used (i.e. the macro instantiation point
or the location of the _Pragma itself).</p>
<p>The Clang front-end inherently depends on the location of a token being
tracked correctly. If it is ever incorrect, the front-end may get confused and
die. The reason for this is that the notion of the 'spelling' of a Token in
Clang depends on being able to find the original input characters for the token.
This concept maps directly to the "spelling location" for the token.</p>
<!-- ======================================================================= -->
<h3 id="SourceRange">SourceRange and CharSourceRange</h3>
<!-- ======================================================================= -->
<!-- mostly taken from
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-August/010595.html -->
<p>Clang represents most source ranges by [first, last], where first and last
each point to the beginning of their respective tokens. For example
consider the SourceRange of the following statement:</p>
<pre>
x = foo + bar;
^first ^last
</pre>
<p>To map from this representation to a character-based
representation, the 'last' location needs to be adjusted to point to
(or past) the end of that token with either
<code>Lexer::MeasureTokenLength()</code> or
<code>Lexer::getLocForEndOfToken()</code>. For the rare cases
where character-level source ranges information is needed we use
the <code>CharSourceRange</code> class.</p>
<!-- ======================================================================= -->
<h2 id="libdriver">The Driver Library</h2>
<!-- ======================================================================= -->
<p>The clang Driver and library are documented <a
href="DriverInternals.html">here</a>.<p>
<!-- ======================================================================= -->
<h2 id="pch">Precompiled Headers</h2>
<!-- ======================================================================= -->
<p>Clang supports two implementations of precompiled headers. The
default implementation, precompiled headers (<a
href="PCHInternals.html">PCH</a>) uses a serialized representation
of Clang's internal data structures, encoded with the <a
href="http://llvm.org/docs/BitCodeFormat.html">LLVM bitstream
format</a>. Pretokenized headers (<a
href="PTHInternals.html">PTH</a>), on the other hand, contain a
serialized representation of the tokens encountered when
preprocessing a header (and anything that header includes).</p>
<!-- ======================================================================= -->
<h2 id="libfrontend">The Frontend Library</h2>
<!-- ======================================================================= -->
<p>The Frontend library contains functionality useful for building
tools on top of the clang libraries, for example several methods for
outputting diagnostics.</p>
<!-- ======================================================================= -->
<h2 id="liblex">The Lexer and Preprocessor Library</h2>
<!-- ======================================================================= -->
<p>The Lexer library contains several tightly-connected classes that are involved
with the nasty process of lexing and preprocessing C source code. The main
interface to this library for outside clients is the large <a
href="#Preprocessor">Preprocessor</a> class.
It contains the various pieces of state that are required to coherently read
tokens out of a translation unit.</p>
<p>The core interface to the Preprocessor object (once it is set up) is the
Preprocessor::Lex method, which returns the next <a href="#Token">Token</a> from
the preprocessor stream. There are two types of token providers that the
preprocessor is capable of reading from: a buffer lexer (provided by the <a
href="#Lexer">Lexer</a> class) and a buffered token stream (provided by the <a
href="#TokenLexer">TokenLexer</a> class).
<!-- ======================================================================= -->
<h3 id="Token">The Token class</h3>
<!-- ======================================================================= -->
<p>The Token class is used to represent a single lexed token. Tokens are
intended to be used by the lexer/preprocess and parser libraries, but are not
intended to live beyond them (for example, they should not live in the ASTs).<p>
<p>Tokens most often live on the stack (or some other location that is efficient
to access) as the parser is running, but occasionally do get buffered up. For
example, macro definitions are stored as a series of tokens, and the C++
front-end periodically needs to buffer tokens up for tentative parsing and
various pieces of look-ahead. As such, the size of a Token matter. On a 32-bit
system, sizeof(Token) is currently 16 bytes.</p>
<p>Tokens occur in two forms: "<a href="#AnnotationToken">Annotation
Tokens</a>" and normal tokens. Normal tokens are those returned by the lexer,
annotation tokens represent semantic information and are produced by the parser,
replacing normal tokens in the token stream. Normal tokens contain the
following information:</p>
<ul>
<li><b>A SourceLocation</b> - This indicates the location of the start of the
token.</li>
<li><b>A length</b> - This stores the length of the token as stored in the
SourceBuffer. For tokens that include them, this length includes trigraphs and
escaped newlines which are ignored by later phases of the compiler. By pointing
into the original source buffer, it is always possible to get the original
spelling of a token completely accurately.</li>
<li><b>IdentifierInfo</b> - If a token takes the form of an identifier, and if
identifier lookup was enabled when the token was lexed (e.g. the lexer was not
reading in 'raw' mode) this contains a pointer to the unique hash value for the
identifier. Because the lookup happens before keyword identification, this
field is set even for language keywords like 'for'.</li>
<li><b>TokenKind</b> - This indicates the kind of token as classified by the
lexer. This includes things like <tt>tok::starequal</tt> (for the "*="
operator), <tt>tok::ampamp</tt> for the "&&" token, and keyword values
(e.g. <tt>tok::kw_for</tt>) for identifiers that correspond to keywords. Note
that some tokens can be spelled multiple ways. For example, C++ supports
"operator keywords", where things like "and" are treated exactly like the
"&&" operator. In these cases, the kind value is set to
<tt>tok::ampamp</tt>, which is good for the parser, which doesn't have to
consider both forms. For something that cares about which form is used (e.g.
the preprocessor 'stringize' operator) the spelling indicates the original
form.</li>
<li><b>Flags</b> - There are currently four flags tracked by the
lexer/preprocessor system on a per-token basis:
<ol>
<li><b>StartOfLine</b> - This was the first token that occurred on its input
source line.</li>
<li><b>LeadingSpace</b> - There was a space character either immediately
before the token or transitively before the token as it was expanded
through a macro. The definition of this flag is very closely defined by
the stringizing requirements of the preprocessor.</li>
<li><b>DisableExpand</b> - This flag is used internally to the preprocessor to
represent identifier tokens which have macro expansion disabled. This
prevents them from being considered as candidates for macro expansion ever
in the future.</li>
<li><b>NeedsCleaning</b> - This flag is set if the original spelling for the
token includes a trigraph or escaped newline. Since this is uncommon,
many pieces of code can fast-path on tokens that did not need cleaning.
</ol>
</li>
</ul>
<p>One interesting (and somewhat unusual) aspect of normal tokens is that they
don't contain any semantic information about the lexed value. For example, if
the token was a pp-number token, we do not represent the value of the number
that was lexed (this is left for later pieces of code to decide). Additionally,
the lexer library has no notion of typedef names vs variable names: both are
returned as identifiers, and the parser is left to decide whether a specific
identifier is a typedef or a variable (tracking this requires scope information
among other things). The parser can do this translation by replacing tokens
returned by the preprocessor with "Annotation Tokens".</p>
<!-- ======================================================================= -->
<h3 id="AnnotationToken">Annotation Tokens</h3>
<!-- ======================================================================= -->
<p>Annotation Tokens are tokens that are synthesized by the parser and injected
into the preprocessor's token stream (replacing existing tokens) to record
semantic information found by the parser. For example, if "foo" is found to be
a typedef, the "foo" <tt>tok::identifier</tt> token is replaced with an
<tt>tok::annot_typename</tt>. This is useful for a couple of reasons: 1) this
makes it easy to handle qualified type names (e.g. "foo::bar::baz<42>::t")
in C++ as a single "token" in the parser. 2) if the parser backtracks, the
reparse does not need to redo semantic analysis to determine whether a token
sequence is a variable, type, template, etc.</p>
<p>Annotation Tokens are created by the parser and reinjected into the parser's
token stream (when backtracking is enabled). Because they can only exist in
tokens that the preprocessor-proper is done with, it doesn't need to keep around
flags like "start of line" that the preprocessor uses to do its job.
Additionally, an annotation token may "cover" a sequence of preprocessor tokens
(e.g. <tt>a::b::c</tt> is five preprocessor tokens). As such, the valid fields
of an annotation token are different than the fields for a normal token (but
they are multiplexed into the normal Token fields):</p>
<ul>
<li><b>SourceLocation "Location"</b> - The SourceLocation for the annotation
token indicates the first token replaced by the annotation token. In the example
above, it would be the location of the "a" identifier.</li>
<li><b>SourceLocation "AnnotationEndLoc"</b> - This holds the location of the
last token replaced with the annotation token. In the example above, it would
be the location of the "c" identifier.</li>
<li><b>void* "AnnotationValue"</b> - This contains an opaque object
that the parser gets from Sema. The parser merely preserves the
information for Sema to later interpret based on the annotation token
kind.</li>
<li><b>TokenKind "Kind"</b> - This indicates the kind of Annotation token this
is. See below for the different valid kinds.</li>
</ul>
<p>Annotation tokens currently come in three kinds:</p>
<ol>
<li><b>tok::annot_typename</b>: This annotation token represents a
resolved typename token that is potentially qualified. The
AnnotationValue field contains the <tt>QualType</tt> returned by
Sema::getTypeName(), possibly with source location information
attached.</li>
<li><b>tok::annot_cxxscope</b>: This annotation token represents a C++
scope specifier, such as "A::B::". This corresponds to the grammar
productions "::" and ":: [opt] nested-name-specifier". The
AnnotationValue pointer is a <tt>NestedNameSpecifier*</tt> returned by
the Sema::ActOnCXXGlobalScopeSpecifier and
Sema::ActOnCXXNestedNameSpecifier callbacks.</li>
<li><b>tok::annot_template_id</b>: This annotation token represents a
C++ template-id such as "foo<int, 4>", where "foo" is the name
of a template. The AnnotationValue pointer is a pointer to a malloc'd
TemplateIdAnnotation object. Depending on the context, a parsed
template-id that names a type might become a typename annotation token
(if all we care about is the named type, e.g., because it occurs in a
type specifier) or might remain a template-id token (if we want to
retain more source location information or produce a new type, e.g.,
in a declaration of a class template specialization). template-id
annotation tokens that refer to a type can be "upgraded" to typename
annotation tokens by the parser.</li>
</ol>
<p>As mentioned above, annotation tokens are not returned by the preprocessor,
they are formed on demand by the parser. This means that the parser has to be
aware of cases where an annotation could occur and form it where appropriate.
This is somewhat similar to how the parser handles Translation Phase 6 of C99:
String Concatenation (see C99 5.1.1.2). In the case of string concatenation,
the preprocessor just returns distinct tok::string_literal and
tok::wide_string_literal tokens and the parser eats a sequence of them wherever
the grammar indicates that a string literal can occur.</p>
<p>In order to do this, whenever the parser expects a tok::identifier or
tok::coloncolon, it should call the TryAnnotateTypeOrScopeToken or
TryAnnotateCXXScopeToken methods to form the annotation token. These methods
will maximally form the specified annotation tokens and replace the current
token with them, if applicable. If the current tokens is not valid for an
annotation token, it will remain an identifier or :: token.</p>
<!-- ======================================================================= -->
<h3 id="Lexer">The Lexer class</h3>
<!-- ======================================================================= -->
<p>The Lexer class provides the mechanics of lexing tokens out of a source
buffer and deciding what they mean. The Lexer is complicated by the fact that
it operates on raw buffers that have not had spelling eliminated (this is a
necessity to get decent performance), but this is countered with careful coding
as well as standard performance techniques (for example, the comment handling
code is vectorized on X86 and PowerPC hosts).</p>
<p>The lexer has a couple of interesting modal features:</p>
<ul>
<li>The lexer can operate in 'raw' mode. This mode has several features that
make it possible to quickly lex the file (e.g. it stops identifier lookup,
doesn't specially handle preprocessor tokens, handles EOF differently, etc).
This mode is used for lexing within an "<tt>#if 0</tt>" block, for
example.</li>
<li>The lexer can capture and return comments as tokens. This is required to
support the -C preprocessor mode, which passes comments through, and is
used by the diagnostic checker to identifier expect-error annotations.</li>
<li>The lexer can be in ParsingFilename mode, which happens when preprocessing
after reading a #include directive. This mode changes the parsing of '<'
to return an "angled string" instead of a bunch of tokens for each thing
within the filename.</li>
<li>When parsing a preprocessor directive (after "<tt>#</tt>") the
ParsingPreprocessorDirective mode is entered. This changes the parser to
return EOD at a newline.</li>
<li>The Lexer uses a LangOptions object to know whether trigraphs are enabled,
whether C++ or ObjC keywords are recognized, etc.</li>
</ul>
<p>In addition to these modes, the lexer keeps track of a couple of other
features that are local to a lexed buffer, which change as the buffer is
lexed:</p>
<ul>
<li>The Lexer uses BufferPtr to keep track of the current character being
lexed.</li>
<li>The Lexer uses IsAtStartOfLine to keep track of whether the next lexed token
will start with its "start of line" bit set.</li>
<li>The Lexer keeps track of the current #if directives that are active (which
can be nested).</li>
<li>The Lexer keeps track of an <a href="#MultipleIncludeOpt">
MultipleIncludeOpt</a> object, which is used to
detect whether the buffer uses the standard "<tt>#ifndef XX</tt> /
<tt>#define XX</tt>" idiom to prevent multiple inclusion. If a buffer does,
subsequent includes can be ignored if the XX macro is defined.</li>
</ul>
<!-- ======================================================================= -->
<h3 id="TokenLexer">The TokenLexer class</h3>
<!-- ======================================================================= -->
<p>The TokenLexer class is a token provider that returns tokens from a list
of tokens that came from somewhere else. It typically used for two things: 1)
returning tokens from a macro definition as it is being expanded 2) returning
tokens from an arbitrary buffer of tokens. The later use is used by _Pragma and
will most likely be used to handle unbounded look-ahead for the C++ parser.</p>
<!-- ======================================================================= -->
<h3 id="MultipleIncludeOpt">The MultipleIncludeOpt class</h3>
<!-- ======================================================================= -->
<p>The MultipleIncludeOpt class implements a really simple little state machine
that is used to detect the standard "<tt>#ifndef XX</tt> / <tt>#define XX</tt>"
idiom that people typically use to prevent multiple inclusion of headers. If a
buffer uses this idiom and is subsequently #include'd, the preprocessor can
simply check to see whether the guarding condition is defined or not. If so,
the preprocessor can completely ignore the include of the header.</p>
<!-- ======================================================================= -->
<h2 id="libparse">The Parser Library</h2>
<!-- ======================================================================= -->
<!-- ======================================================================= -->
<h2 id="libast">The AST Library</h2>
<!-- ======================================================================= -->
<!-- ======================================================================= -->
<h3 id="Type">The Type class and its subclasses</h3>
<!-- ======================================================================= -->
<p>The Type class (and its subclasses) are an important part of the AST. Types
are accessed through the ASTContext class, which implicitly creates and uniques
them as they are needed. Types have a couple of non-obvious features: 1) they
do not capture type qualifiers like const or volatile (See
<a href="#QualType">QualType</a>), and 2) they implicitly capture typedef
information. Once created, types are immutable (unlike decls).</p>
<p>Typedefs in C make semantic analysis a bit more complex than it would
be without them. The issue is that we want to capture typedef information
and represent it in the AST perfectly, but the semantics of operations need to
"see through" typedefs. For example, consider this code:</p>
<code>
void func() {<br>
typedef int foo;<br>
foo X, *Y;<br>
typedef foo* bar;<br>
bar Z;<br>
*X; <i>// error</i><br>
**Y; <i>// error</i><br>
**Z; <i>// error</i><br>
}<br>
</code>
<p>The code above is illegal, and thus we expect there to be diagnostics emitted
on the annotated lines. In this example, we expect to get:</p>
<pre>
<b>test.c:6:1: error: indirection requires pointer operand ('foo' invalid)</b>
*X; // error
<span style="color:blue">^~</span>
<b>test.c:7:1: error: indirection requires pointer operand ('foo' invalid)</b>
**Y; // error
<span style="color:blue">^~~</span>
<b>test.c:8:1: error: indirection requires pointer operand ('foo' invalid)</b>
**Z; // error
<span style="color:blue">^~~</span>
</pre>
<p>While this example is somewhat silly, it illustrates the point: we want to
retain typedef information where possible, so that we can emit errors about
"<tt>std::string</tt>" instead of "<tt>std::basic_string<char, std:...</tt>".
Doing this requires properly keeping typedef information (for example, the type
of "X" is "foo", not "int"), and requires properly propagating it through the
various operators (for example, the type of *Y is "foo", not "int"). In order
to retain this information, the type of these expressions is an instance of the
TypedefType class, which indicates that the type of these expressions is a
typedef for foo.
</p>
<p>Representing types like this is great for diagnostics, because the
user-specified type is always immediately available. There are two problems
with this: first, various semantic checks need to make judgements about the
<em>actual structure</em> of a type, ignoring typedefs. Second, we need an
efficient way to query whether two types are structurally identical to each
other, ignoring typedefs. The solution to both of these problems is the idea of
canonical types.</p>
<!-- =============== -->
<h4>Canonical Types</h4>
<!-- =============== -->
<p>Every instance of the Type class contains a canonical type pointer. For
simple types with no typedefs involved (e.g. "<tt>int</tt>", "<tt>int*</tt>",
"<tt>int**</tt>"), the type just points to itself. For types that have a
typedef somewhere in their structure (e.g. "<tt>foo</tt>", "<tt>foo*</tt>",
"<tt>foo**</tt>", "<tt>bar</tt>"), the canonical type pointer points to their
structurally equivalent type without any typedefs (e.g. "<tt>int</tt>",
"<tt>int*</tt>", "<tt>int**</tt>", and "<tt>int*</tt>" respectively).</p>
<p>This design provides a constant time operation (dereferencing the canonical
type pointer) that gives us access to the structure of types. For example,
we can trivially tell that "bar" and "foo*" are the same type by dereferencing
their canonical type pointers and doing a pointer comparison (they both point
to the single "<tt>int*</tt>" type).</p>
<p>Canonical types and typedef types bring up some complexities that must be
carefully managed. Specifically, the "isa/cast/dyncast" operators generally
shouldn't be used in code that is inspecting the AST. For example, when type
checking the indirection operator (unary '*' on a pointer), the type checker
must verify that the operand has a pointer type. It would not be correct to
check that with "<tt>isa<PointerType>(SubExpr->getType())</tt>",
because this predicate would fail if the subexpression had a typedef type.</p>
<p>The solution to this problem are a set of helper methods on Type, used to
check their properties. In this case, it would be correct to use
"<tt>SubExpr->getType()->isPointerType()</tt>" to do the check. This
predicate will return true if the <em>canonical type is a pointer</em>, which is
true any time the type is structurally a pointer type. The only hard part here
is remembering not to use the <tt>isa/cast/dyncast</tt> operations.</p>
<p>The second problem we face is how to get access to the pointer type once we
know it exists. To continue the example, the result type of the indirection
operator is the pointee type of the subexpression. In order to determine the
type, we need to get the instance of PointerType that best captures the typedef
information in the program. If the type of the expression is literally a
PointerType, we can return that, otherwise we have to dig through the
typedefs to find the pointer type. For example, if the subexpression had type
"<tt>foo*</tt>", we could return that type as the result. If the subexpression
had type "<tt>bar</tt>", we want to return "<tt>foo*</tt>" (note that we do
<em>not</em> want "<tt>int*</tt>"). In order to provide all of this, Type has
a getAsPointerType() method that checks whether the type is structurally a
PointerType and, if so, returns the best one. If not, it returns a null
pointer.</p>
<p>This structure is somewhat mystical, but after meditating on it, it will
make sense to you :).</p>
<!-- ======================================================================= -->
<h3 id="QualType">The QualType class</h3>