xref: /minix3/external/bsd/llvm/dist/clang/utils/FindSpecRefs (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc#!/usr/bin/env python
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambucimport os
4*f4a2713aSLionel Sambucimport re
5*f4a2713aSLionel Sambucimport time
6*f4a2713aSLionel Sambucfrom pprint import pprint
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc###
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambucc99URL = 'http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf'
11*f4a2713aSLionel Sambucc99TOC = [('Foreword', 'xi'),
12*f4a2713aSLionel Sambuc('Introduction', 'xiv'),
13*f4a2713aSLionel Sambuc('1. Scope', '1'),
14*f4a2713aSLionel Sambuc('2. Normative references', '2'),
15*f4a2713aSLionel Sambuc('3. Terms, definitions, and symbols', '3'),
16*f4a2713aSLionel Sambuc('4. Conformance', '7'),
17*f4a2713aSLionel Sambuc('5. Environment', '9'),
18*f4a2713aSLionel Sambuc('5.1 Conceptual models', '9'),
19*f4a2713aSLionel Sambuc('5.1.1 Translation environment', '9'),
20*f4a2713aSLionel Sambuc('5.1.2 Execution environments', '11'),
21*f4a2713aSLionel Sambuc('5.2 Environmental considerations', '17'),
22*f4a2713aSLionel Sambuc('5.2.1 Character sets', '17'),
23*f4a2713aSLionel Sambuc('5.2.2 Character display semantics', '19'),
24*f4a2713aSLionel Sambuc('5.2.3 Signals and interrupts', '20'),
25*f4a2713aSLionel Sambuc('5.2.4 Environmental limits', '20'),
26*f4a2713aSLionel Sambuc('6. Language', '29'),
27*f4a2713aSLionel Sambuc('6.1 Notation', '29'),
28*f4a2713aSLionel Sambuc('6.2 Concepts', '29'),
29*f4a2713aSLionel Sambuc('6.2.1 Scopes of identifiers', '29'),
30*f4a2713aSLionel Sambuc('6.2.2 Linkages of identifiers', '30'),
31*f4a2713aSLionel Sambuc('6.2.3 Name spaces of identifiers', '31'),
32*f4a2713aSLionel Sambuc('6.2.4 Storage durations of objects', '32'),
33*f4a2713aSLionel Sambuc('6.2.5 Types', '33'),
34*f4a2713aSLionel Sambuc('6.2.6 Representations of types', '37'),
35*f4a2713aSLionel Sambuc('6.2.7 Compatible type and composite type', '40'),
36*f4a2713aSLionel Sambuc('6.3 Conversions', '42'),
37*f4a2713aSLionel Sambuc('6.3.1 Arithmetic operands', '42'),
38*f4a2713aSLionel Sambuc('6.3.2 Other operands', '46'),
39*f4a2713aSLionel Sambuc('6.4 Lexical elements', '49'),
40*f4a2713aSLionel Sambuc('6.4.1 Keywords', '50'),
41*f4a2713aSLionel Sambuc('6.4.2 Identifiers', '51'),
42*f4a2713aSLionel Sambuc('6.4.3 Universal character names', '53'),
43*f4a2713aSLionel Sambuc('6.4.4 Constants', '54'),
44*f4a2713aSLionel Sambuc('6.4.5 String literals', '62'),
45*f4a2713aSLionel Sambuc('6.4.6 Punctuators', '63'),
46*f4a2713aSLionel Sambuc('6.4.7 Header names', '64'),
47*f4a2713aSLionel Sambuc('6.4.8 Preprocessing numbers', '65'),
48*f4a2713aSLionel Sambuc('6.4.9 Comments', '66'),
49*f4a2713aSLionel Sambuc('6.5 Expressions', '67'),
50*f4a2713aSLionel Sambuc('6.5.1 Primary expressions', '69'),
51*f4a2713aSLionel Sambuc('6.5.2 Postfix operators', '69'),
52*f4a2713aSLionel Sambuc('6.5.3 Unary operators', '78'),
53*f4a2713aSLionel Sambuc('6.5.4 Cast operators', '81'),
54*f4a2713aSLionel Sambuc('6.5.5 Multiplicative operators', '82'),
55*f4a2713aSLionel Sambuc('6.5.6 Additive operators', '82'),
56*f4a2713aSLionel Sambuc('6.5.7 Bitwise shift operators', '84'),
57*f4a2713aSLionel Sambuc('6.5.8 Relational operators', '85'),
58*f4a2713aSLionel Sambuc('6.5.9 Equality operators', '86'),
59*f4a2713aSLionel Sambuc('6.5.10 Bitwise AND operator', '87'),
60*f4a2713aSLionel Sambuc('6.5.11 Bitwise exclusive OR operator', '88'),
61*f4a2713aSLionel Sambuc('6.5.12 Bitwise inclusive OR operator', '88'),
62*f4a2713aSLionel Sambuc('6.5.13 Logical AND operator', '89'),
63*f4a2713aSLionel Sambuc('6.5.14 Logical OR operator', '89'),
64*f4a2713aSLionel Sambuc('6.5.15 Conditional operator', '90'),
65*f4a2713aSLionel Sambuc('6.5.16 Assignment operators', '91'),
66*f4a2713aSLionel Sambuc('6.5.17 Comma operator', '94'),
67*f4a2713aSLionel Sambuc('6.6 Constant expressions', '95'),
68*f4a2713aSLionel Sambuc('6.7 Declarations', '97'),
69*f4a2713aSLionel Sambuc('6.7.1 Storage-class specifiers', '98'),
70*f4a2713aSLionel Sambuc('6.7.2 Type specifiers', '99'),
71*f4a2713aSLionel Sambuc('6.7.3 Type qualifiers', '108'),
72*f4a2713aSLionel Sambuc('6.7.4 Function specifiers', '112'),
73*f4a2713aSLionel Sambuc('6.7.5 Declarators', '114'),
74*f4a2713aSLionel Sambuc('6.7.6 Type names', '122'),
75*f4a2713aSLionel Sambuc('6.7.7 Type definitions', '123'),
76*f4a2713aSLionel Sambuc('6.7.8 Initialization', '125'),
77*f4a2713aSLionel Sambuc('6.8 Statements and blocks', '131'),
78*f4a2713aSLionel Sambuc('6.8.1 Labeled statements', '131'),
79*f4a2713aSLionel Sambuc('6.8.2 Compound statement', '132'),
80*f4a2713aSLionel Sambuc('6.8.3 Expression and null statements', '132'),
81*f4a2713aSLionel Sambuc('6.8.4 Selection statements', '133'),
82*f4a2713aSLionel Sambuc('6.8.5 Iteration statements', '135'),
83*f4a2713aSLionel Sambuc('6.8.6 Jump statements', '136'),
84*f4a2713aSLionel Sambuc('6.9 External definitions', '140'),
85*f4a2713aSLionel Sambuc('6.9.1 Function definitions', '141'),
86*f4a2713aSLionel Sambuc('6.9.2 External object definitions', '143'),
87*f4a2713aSLionel Sambuc('6.10 Preprocessing directives', '145'),
88*f4a2713aSLionel Sambuc('6.10.1 Conditional inclusion', '147'),
89*f4a2713aSLionel Sambuc('6.10.2 Source file inclusion', '149'),
90*f4a2713aSLionel Sambuc('6.10.3 Macro replacement', '151'),
91*f4a2713aSLionel Sambuc('6.10.4 Line control', '158'),
92*f4a2713aSLionel Sambuc('6.10.5 Error directive', '159'),
93*f4a2713aSLionel Sambuc('6.10.6 Pragma directive', '159'),
94*f4a2713aSLionel Sambuc('6.10.7 Null directive', '160'),
95*f4a2713aSLionel Sambuc('6.10.8 Predefined macro names', '160'),
96*f4a2713aSLionel Sambuc('6.10.9 Pragma operator', '161'),
97*f4a2713aSLionel Sambuc('6.11 Future language directions', '163'),
98*f4a2713aSLionel Sambuc('6.11.1 Floating types', '163'),
99*f4a2713aSLionel Sambuc('6.11.2 Linkages of identifiers', '163'),
100*f4a2713aSLionel Sambuc('6.11.3 External names', '163'),
101*f4a2713aSLionel Sambuc('6.11.4 Character escape sequences', '163'),
102*f4a2713aSLionel Sambuc('6.11.5 Storage-class specifiers', '163'),
103*f4a2713aSLionel Sambuc('6.11.6 Function declarators', '163'),
104*f4a2713aSLionel Sambuc('6.11.7 Function definitions', '163'),
105*f4a2713aSLionel Sambuc('6.11.8 Pragma directives', '163'),
106*f4a2713aSLionel Sambuc('6.11.9 Predefined macro names', '163'),
107*f4a2713aSLionel Sambuc('7. Library', '164'),
108*f4a2713aSLionel Sambuc('7.1 Introduction', '164'),
109*f4a2713aSLionel Sambuc('7.1.1 Definitions of terms', '164'),
110*f4a2713aSLionel Sambuc('7.1.2 Standard headers', '165'),
111*f4a2713aSLionel Sambuc('7.1.3 Reserved identifiers', '166'),
112*f4a2713aSLionel Sambuc('7.1.4 Use of library functions', '166'),
113*f4a2713aSLionel Sambuc('7.2 Diagnostics <assert.h>', '169'),
114*f4a2713aSLionel Sambuc('7.2.1 Program diagnostics', '169'),
115*f4a2713aSLionel Sambuc('7.3 Complex arithmetic <complex.h>', '170'),
116*f4a2713aSLionel Sambuc('7.3.1 Introduction', '170'),
117*f4a2713aSLionel Sambuc('7.3.2 Conventions', '170'),
118*f4a2713aSLionel Sambuc('7.3.3 Branch cuts', '171'),
119*f4a2713aSLionel Sambuc('7.3.4 The CX_LIMITED_RANGE pragma', '171'),
120*f4a2713aSLionel Sambuc('7.3.5 Trigonometric functions', '172'),
121*f4a2713aSLionel Sambuc('7.3.6 Hyperbolic functions', '174'),
122*f4a2713aSLionel Sambuc('7.3.7 Exponential and logarithmic functions', '176'),
123*f4a2713aSLionel Sambuc('7.3.8 Power and absolute-value functions', '177'),
124*f4a2713aSLionel Sambuc('7.3.9 Manipulation functions', '178'),
125*f4a2713aSLionel Sambuc('7.4 Character handling <ctype.h>', '181'),
126*f4a2713aSLionel Sambuc('7.4.1 Character classification functions', '181'),
127*f4a2713aSLionel Sambuc('7.4.2 Character case mapping functions', '184'),
128*f4a2713aSLionel Sambuc('7.5 Errors <errno.h>', '186'),
129*f4a2713aSLionel Sambuc('7.6 Floating-point environment <fenv.h>', '187'),
130*f4a2713aSLionel Sambuc('7.6.1 The FENV_ACCESS pragma', '189'),
131*f4a2713aSLionel Sambuc('7.6.2 Floating-point exceptions', '190'),
132*f4a2713aSLionel Sambuc('7.6.3 Rounding', '193'),
133*f4a2713aSLionel Sambuc('7.6.4 Environment', '194'),
134*f4a2713aSLionel Sambuc('7.7 Characteristics of floating types <float.h>', '197'),
135*f4a2713aSLionel Sambuc('7.8 Format conversion of integer types <inttypes.h>', '198'),
136*f4a2713aSLionel Sambuc('7.8.1 Macros for format specifiers', '198'),
137*f4a2713aSLionel Sambuc('7.8.2 Functions for greatest-width integer types', '199'),
138*f4a2713aSLionel Sambuc('7.9 Alternative spellings <iso646.h>', '202'),
139*f4a2713aSLionel Sambuc('7.10 Sizes of integer types <limits.h>', '203'),
140*f4a2713aSLionel Sambuc('7.11 Localization <locale.h>', '204'),
141*f4a2713aSLionel Sambuc('7.11.1 Locale control', '205'),
142*f4a2713aSLionel Sambuc('7.11.2 Numeric formatting convention inquiry', '206'),
143*f4a2713aSLionel Sambuc('7.12 Mathematics <math.h>', '212'),
144*f4a2713aSLionel Sambuc('7.12.1 Treatment of error conditions', '214'),
145*f4a2713aSLionel Sambuc('7.12.2 The FP_CONTRACT pragma', '215'),
146*f4a2713aSLionel Sambuc('7.12.3 Classification macros', '216'),
147*f4a2713aSLionel Sambuc('7.12.4 Trigonometric functions', '218'),
148*f4a2713aSLionel Sambuc('7.12.5 Hyperbolic functions', '221'),
149*f4a2713aSLionel Sambuc('7.12.6 Exponential and logarithmic functions', '223'),
150*f4a2713aSLionel Sambuc('7.12.7 Power and absolute-value functions', '228'),
151*f4a2713aSLionel Sambuc('7.12.8 Error and gamma functions', '230'),
152*f4a2713aSLionel Sambuc('7.12.9 Nearest integer functions', '231'),
153*f4a2713aSLionel Sambuc('7.12.10 Remainder functions', '235'),
154*f4a2713aSLionel Sambuc('7.12.11 Manipulation functions', '236'),
155*f4a2713aSLionel Sambuc('7.12.12 Maximum, minimum, and positive difference functions', '238'),
156*f4a2713aSLionel Sambuc('7.12.13 Floating multiply-add', '239'),
157*f4a2713aSLionel Sambuc('7.12.14 Comparison macros', '240'),
158*f4a2713aSLionel Sambuc('7.13 Nonlocal jumps <setjmp.h>', '243'),
159*f4a2713aSLionel Sambuc('7.13.1 Save calling environment', '243'),
160*f4a2713aSLionel Sambuc('7.13.2 Restore calling environment', '244'),
161*f4a2713aSLionel Sambuc('7.14 Signal handling <signal.h>', '246'),
162*f4a2713aSLionel Sambuc('7.14.1 Specify signal handling', '247'),
163*f4a2713aSLionel Sambuc('7.14.2 Send signal', '248'),
164*f4a2713aSLionel Sambuc('7.15 Variable arguments <stdarg.h>', '249'),
165*f4a2713aSLionel Sambuc('7.15.1 Variable argument list access macros', '249'),
166*f4a2713aSLionel Sambuc('7.16 Boolean type and values <stdbool.h>', '253'),
167*f4a2713aSLionel Sambuc('7.17 Common definitions <stddef.h>', '254'),
168*f4a2713aSLionel Sambuc('7.18 Integer types <stdint.h>', '255'),
169*f4a2713aSLionel Sambuc('7.18.1 Integer types', '255'),
170*f4a2713aSLionel Sambuc('7.18.2 Limits of specified-width integer types', '257'),
171*f4a2713aSLionel Sambuc('7.18.3 Limits of other integer types', '259'),
172*f4a2713aSLionel Sambuc('7.18.4 Macros for integer constants', '260'),
173*f4a2713aSLionel Sambuc('7.19 Input/output <stdio.h>', '262'),
174*f4a2713aSLionel Sambuc('7.19.1 Introduction', '262'),
175*f4a2713aSLionel Sambuc('7.19.2 Streams', '264'),
176*f4a2713aSLionel Sambuc('7.19.3 Files', '266'),
177*f4a2713aSLionel Sambuc('7.19.4 Operations on files', '268'),
178*f4a2713aSLionel Sambuc('7.19.5 File access functions', '270'),
179*f4a2713aSLionel Sambuc('7.19.6 Formatted input/output functions', '274'),
180*f4a2713aSLionel Sambuc('7.19.7 Character input/output functions', '296'),
181*f4a2713aSLionel Sambuc('7.19.8 Direct input/output functions', '301'),
182*f4a2713aSLionel Sambuc('7.19.9 File positioning functions', '302'),
183*f4a2713aSLionel Sambuc('7.19.10 Error-handling functions', '304'),
184*f4a2713aSLionel Sambuc('7.20 General utilities <stdlib.h>', '306'),
185*f4a2713aSLionel Sambuc('7.20.1 Numeric conversion functions', '307'),
186*f4a2713aSLionel Sambuc('7.20.2 Pseudo-random sequence generation functions', '312'),
187*f4a2713aSLionel Sambuc('7.20.3 Memory management functions', '313'),
188*f4a2713aSLionel Sambuc('7.20.4 Communication with the environment', '315'),
189*f4a2713aSLionel Sambuc('7.20.5 Searching and sorting utilities', '318'),
190*f4a2713aSLionel Sambuc('7.20.6 Integer arithmetic functions', '320'),
191*f4a2713aSLionel Sambuc('7.20.7 Multibyte/wide character conversion functions', '321'),
192*f4a2713aSLionel Sambuc('7.20.8 Multibyte/wide string conversion functions', '323'),
193*f4a2713aSLionel Sambuc('7.21 String handling <string.h>', '325'),
194*f4a2713aSLionel Sambuc('7.21.1 String function conventions', '325'),
195*f4a2713aSLionel Sambuc('7.21.2 Copying functions', '325'),
196*f4a2713aSLionel Sambuc('7.21.3 Concatenation functions', '327'),
197*f4a2713aSLionel Sambuc('7.21.4 Comparison functions', '328'),
198*f4a2713aSLionel Sambuc('7.21.5 Search functions', '330'),
199*f4a2713aSLionel Sambuc('7.21.6 Miscellaneous functions', '333'),
200*f4a2713aSLionel Sambuc('7.22 Type-generic math <tgmath.h>', '335'),
201*f4a2713aSLionel Sambuc('7.23 Date and time <time.h>', '338'),
202*f4a2713aSLionel Sambuc('7.23.1 Components of time', '338'),
203*f4a2713aSLionel Sambuc('7.23.2 Time manipulation functions', '339'),
204*f4a2713aSLionel Sambuc('7.23.3 Time conversion functions', '341'),
205*f4a2713aSLionel Sambuc('7.24 Extended multibyte and wide character utilities <wchar.h>', '348'),
206*f4a2713aSLionel Sambuc('7.24.1 Introduction', '348'),
207*f4a2713aSLionel Sambuc('7.24.2 Formatted wide character input/output functions', '349'),
208*f4a2713aSLionel Sambuc('7.24.3 Wide character input/output functions', '367'),
209*f4a2713aSLionel Sambuc('7.24.4 General wide string utilities', '371'),
210*f4a2713aSLionel Sambuc('7.24.5 Wide character time conversion functions', '385'),
211*f4a2713aSLionel Sambuc('7.24.6 Extended multibyte/wide character conversion utilities', '386'),
212*f4a2713aSLionel Sambuc('7.25 Wide character classification and mapping utilities <wctype.h>',
213*f4a2713aSLionel Sambuc  '393'),
214*f4a2713aSLionel Sambuc('7.25.1 Introduction', '393'),
215*f4a2713aSLionel Sambuc('7.25.2 Wide character classification utilities', '394'),
216*f4a2713aSLionel Sambuc('7.25.3 Wide character case mapping utilities', '399'),
217*f4a2713aSLionel Sambuc('7.26 Future library directions', '401'),
218*f4a2713aSLionel Sambuc('7.26.1 Complex arithmetic <complex.h>', '401'),
219*f4a2713aSLionel Sambuc('7.26.2 Character handling <ctype.h>', '401'),
220*f4a2713aSLionel Sambuc('7.26.3 Errors <errno.h>', '401'),
221*f4a2713aSLionel Sambuc('7.26.4 Format conversion of integer types <inttypes.h>', '401'),
222*f4a2713aSLionel Sambuc('7.26.5 Localization <locale.h>', '401'),
223*f4a2713aSLionel Sambuc('7.26.6 Signal handling <signal.h>', '401'),
224*f4a2713aSLionel Sambuc('7.26.7 Boolean type and values <stdbool.h>', '401'),
225*f4a2713aSLionel Sambuc('7.26.8 Integer types <stdint.h>', '401'),
226*f4a2713aSLionel Sambuc('7.26.9 Input/output <stdio.h>', '402'),
227*f4a2713aSLionel Sambuc('7.26.10 General utilities <stdlib.h>', '402'),
228*f4a2713aSLionel Sambuc('7.26.11 String handling <string.h>', '402'),
229*f4a2713aSLionel Sambuc('<wchar.h>', '402'),
230*f4a2713aSLionel Sambuc('<wctype.h>', '402'),
231*f4a2713aSLionel Sambuc('Annex A (informative) Language syntax summary', '403'),
232*f4a2713aSLionel Sambuc('A.1 Lexical grammar', '403'),
233*f4a2713aSLionel Sambuc('A.2 Phrase structure grammar', '409'),
234*f4a2713aSLionel Sambuc('A.3 Preprocessing directives', '416'),
235*f4a2713aSLionel Sambuc('Annex B (informative) Library summary', '418'),
236*f4a2713aSLionel Sambuc('B.1 Diagnostics <assert.h>', '418'),
237*f4a2713aSLionel Sambuc('B.2 Complex <complex.h>', '418'),
238*f4a2713aSLionel Sambuc('B.3 Character handling <ctype.h>', '420'),
239*f4a2713aSLionel Sambuc('B.4 Errors <errno.h>', '420'),
240*f4a2713aSLionel Sambuc('B.5 Floating-point environment <fenv.h>', '420'),
241*f4a2713aSLionel Sambuc('B.6 Characteristics of floating types <float.h>', '421'),
242*f4a2713aSLionel Sambuc('B.7 Format conversion of integer types <inttypes.h>', '421'),
243*f4a2713aSLionel Sambuc('B.8 Alternative spellings <iso646.h>', '422'),
244*f4a2713aSLionel Sambuc('B.9 Sizes of integer types <limits.h>', '422'),
245*f4a2713aSLionel Sambuc('B.10 Localization <locale.h>', '422'),
246*f4a2713aSLionel Sambuc('B.11 Mathematics <math.h>', '422'),
247*f4a2713aSLionel Sambuc('B.12 Nonlocal jumps <setjmp.h>', '427'),
248*f4a2713aSLionel Sambuc('B.13 Signal handling <signal.h>', '427'),
249*f4a2713aSLionel Sambuc('B.14 Variable arguments <stdarg.h>', '427'),
250*f4a2713aSLionel Sambuc('B.15 Boolean type and values <stdbool.h>', '427'),
251*f4a2713aSLionel Sambuc('B.16 Common definitions <stddef.h>', '428'),
252*f4a2713aSLionel Sambuc('B.17 Integer types <stdint.h>', '428'),
253*f4a2713aSLionel Sambuc('B.18 Input/output <stdio.h>', '428'),
254*f4a2713aSLionel Sambuc('B.19 General utilities <stdlib.h>', '430'),
255*f4a2713aSLionel Sambuc('B.20 String handling <string.h>', '432'),
256*f4a2713aSLionel Sambuc('B.21 Type-generic math <tgmath.h>', '433'),
257*f4a2713aSLionel Sambuc('B.22 Date and time <time.h>', '433'),
258*f4a2713aSLionel Sambuc('B.23 Extended multibyte/wide character utilities <wchar.h>', '434'),
259*f4a2713aSLionel Sambuc('B.24 Wide character classification and mapping utilities <wctype.h>',
260*f4a2713aSLionel Sambuc  '436'),
261*f4a2713aSLionel Sambuc('Annex C (informative) Sequence points', '438'),
262*f4a2713aSLionel Sambuc('Annex D (normative) Universal character names for identifiers', '439'),
263*f4a2713aSLionel Sambuc('Annex E (informative) Implementation limits', '441'),
264*f4a2713aSLionel Sambuc('Annex F (normative) IEC 60559 floating-point arithmetic', '443'),
265*f4a2713aSLionel Sambuc('F.1 Introduction', '443'),
266*f4a2713aSLionel Sambuc('F.2 Types', '443'),
267*f4a2713aSLionel Sambuc('F.3 Operators and functions', '444'),
268*f4a2713aSLionel Sambuc('F.4 Floating to integer conversion', '446'),
269*f4a2713aSLionel Sambuc('F.5 Binary-decimal conversion', '446'),
270*f4a2713aSLionel Sambuc('F.6 Contracted expressions', '447'),
271*f4a2713aSLionel Sambuc('F.7 Floating-point environment', '447'),
272*f4a2713aSLionel Sambuc('F.8 Optimization', '450'),
273*f4a2713aSLionel Sambuc('F.9 Mathematics <math.h>', '453'),
274*f4a2713aSLionel Sambuc('Annex G (informative) IEC 60559-compatible complex arithmetic', '466'),
275*f4a2713aSLionel Sambuc('G.1 Introduction', '466'),
276*f4a2713aSLionel Sambuc('G.2 Types', '466'),
277*f4a2713aSLionel Sambuc('G.3 Conventions', '466'),
278*f4a2713aSLionel Sambuc('G.4 Conversions', '467'),
279*f4a2713aSLionel Sambuc('G.5 Binary operators', '467'),
280*f4a2713aSLionel Sambuc('G.6 Complex arithmetic <complex.h>', '471'),
281*f4a2713aSLionel Sambuc('G.7 Type-generic math <tgmath.h>', '479'),
282*f4a2713aSLionel Sambuc('Annex H (informative) Language independent arithmetic', '480'),
283*f4a2713aSLionel Sambuc('H.1 Introduction', '480'),
284*f4a2713aSLionel Sambuc('H.2 Types', '480'),
285*f4a2713aSLionel Sambuc('H.3 Notification', '484'),
286*f4a2713aSLionel Sambuc('Annex I (informative) Common warnings', '486'),
287*f4a2713aSLionel Sambuc('Annex J (informative) Portability issues', '488'),
288*f4a2713aSLionel Sambuc('J.1 Unspecified behavior', '488'),
289*f4a2713aSLionel Sambuc('J.2 Undefined behavior', '491'),
290*f4a2713aSLionel Sambuc('J.3 Implementation-defined behavior', '504'),
291*f4a2713aSLionel Sambuc('J.4 Locale-specific behavior', '511'),
292*f4a2713aSLionel Sambuc('J.5 Common extensions', '512'),
293*f4a2713aSLionel Sambuc('Bibliography', '515'),
294*f4a2713aSLionel Sambuc('Index', '517')]
295*f4a2713aSLionel Sambuc
296*f4a2713aSLionel SambuccXXURL = 'http://open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2723.pdf'
297*f4a2713aSLionel SambuccXXTOC = [('Contents', 'ii'),
298*f4a2713aSLionel Sambuc('List of Tables', 'ix'),
299*f4a2713aSLionel Sambuc('1 General', '1'),
300*f4a2713aSLionel Sambuc('1.1 Scope', '1'),
301*f4a2713aSLionel Sambuc('1.2 Normative references', '1'),
302*f4a2713aSLionel Sambuc('1.3 Definitions', '2'),
303*f4a2713aSLionel Sambuc('1.4 Implementation compliance', '4'),
304*f4a2713aSLionel Sambuc('1.5 Structure of this International Standard', '5'),
305*f4a2713aSLionel Sambuc('1.6 Syntax notation', '5'),
306*f4a2713aSLionel Sambuc('1.7 The C++ memory model', '6'),
307*f4a2713aSLionel Sambuc('1.8 The C++ object model', '6'),
308*f4a2713aSLionel Sambuc('1.9 Program execution', '7'),
309*f4a2713aSLionel Sambuc('1.10 Multi-threaded executions and data races', '10'),
310*f4a2713aSLionel Sambuc('1.11 Acknowledgments', '13'),
311*f4a2713aSLionel Sambuc('2 Lexical conventions', '15'),
312*f4a2713aSLionel Sambuc('2.1 Phases of translation', '15'),
313*f4a2713aSLionel Sambuc('2.2 Character sets', '16'),
314*f4a2713aSLionel Sambuc('2.3 Trigraph sequences', '17'),
315*f4a2713aSLionel Sambuc('2.4 Preprocessing tokens', '17'),
316*f4a2713aSLionel Sambuc('2.5 Alternative tokens', '18'),
317*f4a2713aSLionel Sambuc('2.6 Tokens', '19'),
318*f4a2713aSLionel Sambuc('2.7 Comments', '19'),
319*f4a2713aSLionel Sambuc('2.8 Header names', '19'),
320*f4a2713aSLionel Sambuc('2.9 Preprocessing numbers', '20'),
321*f4a2713aSLionel Sambuc('2.10 Identifiers', '20'),
322*f4a2713aSLionel Sambuc('2.11 Keywords', '20'),
323*f4a2713aSLionel Sambuc('2.12 Operators and punctuators', '21'),
324*f4a2713aSLionel Sambuc('2.13 Literals', '21'),
325*f4a2713aSLionel Sambuc('3 Basic concepts', '29'),
326*f4a2713aSLionel Sambuc('3.1 Declarations and definitions', '29'),
327*f4a2713aSLionel Sambuc('3.2 One definition rule', '31'),
328*f4a2713aSLionel Sambuc('3.3 Declarative regions and scopes', '33'),
329*f4a2713aSLionel Sambuc('3.4 Name lookup', '38'),
330*f4a2713aSLionel Sambuc('3.5 Program and linkage', '51'),
331*f4a2713aSLionel Sambuc('3.6 Start and termination', '54'),
332*f4a2713aSLionel Sambuc('3.7 Storage duration', '58'),
333*f4a2713aSLionel Sambuc('3.8 Object Lifetime', '62'),
334*f4a2713aSLionel Sambuc('3.9 Types', '65'),
335*f4a2713aSLionel Sambuc('3.10 Lvalues and rvalues', '70'),
336*f4a2713aSLionel Sambuc('3.11 Alignment', '72'),
337*f4a2713aSLionel Sambuc('4 Standard conversions', '73'),
338*f4a2713aSLionel Sambuc('4.1 Lvalue-to-rvalue conversion', '74'),
339*f4a2713aSLionel Sambuc('4.2 Array-to-pointer conversion', '74'),
340*f4a2713aSLionel Sambuc('4.3 Function-to-pointer conversion', '74'),
341*f4a2713aSLionel Sambuc('4.4 Qualification conversions', '74'),
342*f4a2713aSLionel Sambuc('4.5 Integral promotions', '75'),
343*f4a2713aSLionel Sambuc('4.6 Floating point promotion', '76'),
344*f4a2713aSLionel Sambuc('4.7 Integral conversions', '76'),
345*f4a2713aSLionel Sambuc('4.8 Floating point conversions', '76'),
346*f4a2713aSLionel Sambuc('4.9 Floating-integral conversions', '77'),
347*f4a2713aSLionel Sambuc('4.10 Pointer conversions', '77'),
348*f4a2713aSLionel Sambuc('4.11 Pointer to member conversions', '77'),
349*f4a2713aSLionel Sambuc('4.12 Boolean conversions', '78'),
350*f4a2713aSLionel Sambuc('4.13 Integer conversion rank', '78'),
351*f4a2713aSLionel Sambuc('5 Expressions', '79'),
352*f4a2713aSLionel Sambuc('5.1 Primary expressions', '80'),
353*f4a2713aSLionel Sambuc('5.2 Postfix expressions', '85'),
354*f4a2713aSLionel Sambuc('5.3 Unary expressions', '96'),
355*f4a2713aSLionel Sambuc('5.4 Explicit type conversion (cast notation)', '104'),
356*f4a2713aSLionel Sambuc('5.5 Pointer-to-member operators', '105'),
357*f4a2713aSLionel Sambuc('5.6 Multiplicative operators', '106'),
358*f4a2713aSLionel Sambuc('5.7 Additive operators', '106'),
359*f4a2713aSLionel Sambuc('5.8 Shift operators', '107'),
360*f4a2713aSLionel Sambuc('5.9 Relational operators', '108'),
361*f4a2713aSLionel Sambuc('5.10 Equality operators', '109'),
362*f4a2713aSLionel Sambuc('5.11 Bitwise AND operator', '110'),
363*f4a2713aSLionel Sambuc('5.12 Bitwise exclusive OR operator', '110'),
364*f4a2713aSLionel Sambuc('5.13 Bitwise inclusive OR operator', '110'),
365*f4a2713aSLionel Sambuc('5.14 Logical AND operator', '110'),
366*f4a2713aSLionel Sambuc('5.15 Logical OR operator', '110'),
367*f4a2713aSLionel Sambuc('5.16 Conditional operator', '111'),
368*f4a2713aSLionel Sambuc('5.17 Assignment and compound assignment operators', '112'),
369*f4a2713aSLionel Sambuc('5.18 Comma operator', '113'),
370*f4a2713aSLionel Sambuc('5.19 Constant expressions', '113'),
371*f4a2713aSLionel Sambuc('6 Statements', '116'),
372*f4a2713aSLionel Sambuc('6.1 Labeled statement', '116'),
373*f4a2713aSLionel Sambuc('6.2 Expression statement', '116'),
374*f4a2713aSLionel Sambuc('6.3 Compound statement or block', '116'),
375*f4a2713aSLionel Sambuc('6.4 Selection statements', '117'),
376*f4a2713aSLionel Sambuc('6.5 Iteration statements', '118'),
377*f4a2713aSLionel Sambuc('6.6 Jump statements', '121'),
378*f4a2713aSLionel Sambuc('6.7 Declaration statement', '122'),
379*f4a2713aSLionel Sambuc('6.8 Ambiguity resolution', '123'),
380*f4a2713aSLionel Sambuc('7 Declarations', '125'),
381*f4a2713aSLionel Sambuc('7.1 Specifiers', '126'),
382*f4a2713aSLionel Sambuc('7.2 Enumeration declarations', '140'),
383*f4a2713aSLionel Sambuc('7.3 Namespaces', '143'),
384*f4a2713aSLionel Sambuc('7.4 The asm declaration', '156'),
385*f4a2713aSLionel Sambuc('7.5 Linkage specifications', '156'),
386*f4a2713aSLionel Sambuc('8 Declarators', '160'),
387*f4a2713aSLionel Sambuc('8.1 Type names', '161'),
388*f4a2713aSLionel Sambuc('8.2 Ambiguity resolution', '161'),
389*f4a2713aSLionel Sambuc('8.3 Meaning of declarators', '163'),
390*f4a2713aSLionel Sambuc('8.4 Function definitions', '175'),
391*f4a2713aSLionel Sambuc('8.5 Initializers', '177'),
392*f4a2713aSLionel Sambuc('9 Classes', '191'),
393*f4a2713aSLionel Sambuc('9.1 Class names', '193'),
394*f4a2713aSLionel Sambuc('9.2 Class members', '194'),
395*f4a2713aSLionel Sambuc('9.3 Member functions', '197'),
396*f4a2713aSLionel Sambuc('9.4 Static members', '200'),
397*f4a2713aSLionel Sambuc('9.5 Unions', '202'),
398*f4a2713aSLionel Sambuc('9.6 Bit-fields', '203'),
399*f4a2713aSLionel Sambuc('9.7 Nested class declarations', '204'),
400*f4a2713aSLionel Sambuc('9.8 Local class declarations', '205'),
401*f4a2713aSLionel Sambuc('9.9 Nested type names', '206'),
402*f4a2713aSLionel Sambuc('10 Derived classes', '207'),
403*f4a2713aSLionel Sambuc('10.1 Multiple base classes', '208'),
404*f4a2713aSLionel Sambuc('10.2 Member name lookup', '210'),
405*f4a2713aSLionel Sambuc('10.3 Virtual functions', '213'),
406*f4a2713aSLionel Sambuc('10.4 Abstract classes', '217'),
407*f4a2713aSLionel Sambuc('11 Member access control', '219'),
408*f4a2713aSLionel Sambuc('11.1 Access specifiers', '221'),
409*f4a2713aSLionel Sambuc('11.2 Accessibility of base classes and base class members', '222'),
410*f4a2713aSLionel Sambuc('11.3 Access declarations', '224'),
411*f4a2713aSLionel Sambuc('11.4 Friends', '225'),
412*f4a2713aSLionel Sambuc('11.5 Protected member access', '228'),
413*f4a2713aSLionel Sambuc('11.6 Access to virtual functions', '229'),
414*f4a2713aSLionel Sambuc('11.7 Multiple access', '230'),
415*f4a2713aSLionel Sambuc('11.8 Nested classes', '230'),
416*f4a2713aSLionel Sambuc('12 Special member functions', '231'),
417*f4a2713aSLionel Sambuc('12.1 Constructors', '231'),
418*f4a2713aSLionel Sambuc('12.2 Temporary objects', '233'),
419*f4a2713aSLionel Sambuc('12.3 Conversions', '235'),
420*f4a2713aSLionel Sambuc('12.4 Destructors', '238'),
421*f4a2713aSLionel Sambuc('12.5 Free store', '240'),
422*f4a2713aSLionel Sambuc('12.6 Initialization', '242'),
423*f4a2713aSLionel Sambuc('12.7 Construction and destruction', '247'),
424*f4a2713aSLionel Sambuc('12.8 Copying class objects', '250'),
425*f4a2713aSLionel Sambuc('12.9 Inheriting Constructors', '255'),
426*f4a2713aSLionel Sambuc('13 Overloading', '259'),
427*f4a2713aSLionel Sambuc('13.1 Overloadable declarations', '259'),
428*f4a2713aSLionel Sambuc('13.2 Declaration matching', '261'),
429*f4a2713aSLionel Sambuc('13.3 Overload resolution', '262'),
430*f4a2713aSLionel Sambuc('13.4 Address of overloaded function', '281'),
431*f4a2713aSLionel Sambuc('13.5 Overloaded operators', '282'),
432*f4a2713aSLionel Sambuc('13.6 Built-in operators', '286'),
433*f4a2713aSLionel Sambuc('14 Templates', '290'),
434*f4a2713aSLionel Sambuc('14.1 Template parameters', '291'),
435*f4a2713aSLionel Sambuc('14.2 Names of template specializations', '294'),
436*f4a2713aSLionel Sambuc('14.3 Template arguments', '296'),
437*f4a2713aSLionel Sambuc('14.4 Type equivalence', '302'),
438*f4a2713aSLionel Sambuc('14.5 Template declarations', '303'),
439*f4a2713aSLionel Sambuc('14.6 Name resolution', '318'),
440*f4a2713aSLionel Sambuc('14.7 Template instantiation and specialization', '331'),
441*f4a2713aSLionel Sambuc('14.8 Function template specializations', '343'),
442*f4a2713aSLionel Sambuc('15 Exception handling', '363'),
443*f4a2713aSLionel Sambuc('15.1 Throwing an exception', '364'),
444*f4a2713aSLionel Sambuc('15.2 Constructors and destructors', '366'),
445*f4a2713aSLionel Sambuc('15.3 Handling an exception', '366'),
446*f4a2713aSLionel Sambuc('15.4 Exception specifications', '368'),
447*f4a2713aSLionel Sambuc('15.5 Special functions', '371'),
448*f4a2713aSLionel Sambuc('15.6 Exceptions and access', '372'),
449*f4a2713aSLionel Sambuc('16 Preprocessing directives', '373'),
450*f4a2713aSLionel Sambuc('16.1 Conditional inclusion', '375'),
451*f4a2713aSLionel Sambuc('16.2 Source file inclusion', '376'),
452*f4a2713aSLionel Sambuc('16.3 Macro replacement', '377'),
453*f4a2713aSLionel Sambuc('16.4 Line control', '382'),
454*f4a2713aSLionel Sambuc('16.5 Error directive', '383'),
455*f4a2713aSLionel Sambuc('16.6 Pragma directive', '383'),
456*f4a2713aSLionel Sambuc('16.7 Null directive', '383'),
457*f4a2713aSLionel Sambuc('16.8 Predefined macro names', '383'),
458*f4a2713aSLionel Sambuc('16.9 Pragma operator', '384'),
459*f4a2713aSLionel Sambuc('17 Library introduction', '386'),
460*f4a2713aSLionel Sambuc('17.1 General', '386'),
461*f4a2713aSLionel Sambuc('17.2 Overview', '386'),
462*f4a2713aSLionel Sambuc('17.3 Definitions', '386'),
463*f4a2713aSLionel Sambuc('17.4 Additional definitions', '390'),
464*f4a2713aSLionel Sambuc('17.5 Method of description (Informative)', '390'),
465*f4a2713aSLionel Sambuc('17.6 Library-wide requirements', '396'),
466*f4a2713aSLionel Sambuc('18 Language support library', '407'),
467*f4a2713aSLionel Sambuc('18.1 Types', '407'),
468*f4a2713aSLionel Sambuc('18.2 Implementation properties', '408'),
469*f4a2713aSLionel Sambuc('18.3 Integer types', '417'),
470*f4a2713aSLionel Sambuc('18.4 Start and termination', '418'),
471*f4a2713aSLionel Sambuc('18.5 Dynamic memory management', '420'),
472*f4a2713aSLionel Sambuc('18.6 Type identification', '424'),
473*f4a2713aSLionel Sambuc('18.7 Exception handling', '427'),
474*f4a2713aSLionel Sambuc('18.8 Initializer lists', '432'),
475*f4a2713aSLionel Sambuc('18.9 Other runtime support', '434'),
476*f4a2713aSLionel Sambuc('19 Diagnostics library', '435'),
477*f4a2713aSLionel Sambuc('19.1 Exception classes', '435'),
478*f4a2713aSLionel Sambuc('19.2 Assertions', '439'),
479*f4a2713aSLionel Sambuc('19.3 Error numbers', '440'),
480*f4a2713aSLionel Sambuc('19.4 System error support', '440'),
481*f4a2713aSLionel Sambuc('20 General utilities library', '452'),
482*f4a2713aSLionel Sambuc('20.1 Requirements', '452'),
483*f4a2713aSLionel Sambuc('20.2 Utility components', '457'),
484*f4a2713aSLionel Sambuc('20.3 Compile-time rational arithmetic', '463'),
485*f4a2713aSLionel Sambuc('20.4 Tuples', '465'),
486*f4a2713aSLionel Sambuc('20.5 Metaprogramming and type traits', '473'),
487*f4a2713aSLionel Sambuc('20.6 Function objects', '486'),
488*f4a2713aSLionel Sambuc('20.7 Memory', '509'),
489*f4a2713aSLionel Sambuc('20.8 Time utilities', '548'),
490*f4a2713aSLionel Sambuc('20.9 Date and time functions', '562'),
491*f4a2713aSLionel Sambuc('21 Strings library', '563'),
492*f4a2713aSLionel Sambuc('21.1 Character traits', '563'),
493*f4a2713aSLionel Sambuc('21.2 String classes', '569'),
494*f4a2713aSLionel Sambuc('21.3 Class template basic_string', '572'),
495*f4a2713aSLionel Sambuc('21.4 Numeric Conversions', '599'),
496*f4a2713aSLionel Sambuc('21.5 Null-terminated sequence utilities', '600'),
497*f4a2713aSLionel Sambuc('22 Localization library', '604'),
498*f4a2713aSLionel Sambuc('22.1 Locales', '604'),
499*f4a2713aSLionel Sambuc('22.2 Standard locale categories', '617'),
500*f4a2713aSLionel Sambuc('22.3 Standard code conversion facets', '657'),
501*f4a2713aSLionel Sambuc('22.4 C Library Locales', '659'),
502*f4a2713aSLionel Sambuc('23 Containers library', '660'),
503*f4a2713aSLionel Sambuc('23.1 Container requirements', '660'),
504*f4a2713aSLionel Sambuc('23.2 Sequence containers', '681'),
505*f4a2713aSLionel Sambuc('23.3 Associative containers', '719'),
506*f4a2713aSLionel Sambuc('23.4 Unordered associative containers', '744'),
507*f4a2713aSLionel Sambuc('24 Iterators library', '759'),
508*f4a2713aSLionel Sambuc('24.1 Iterator requirements', '759'),
509*f4a2713aSLionel Sambuc('24.2 Header <iterator> synopsis', '764'),
510*f4a2713aSLionel Sambuc('24.3 Iterator primitives', '767'),
511*f4a2713aSLionel Sambuc('24.4 Predefined iterators', '770'),
512*f4a2713aSLionel Sambuc('24.5 Stream iterators', '784'),
513*f4a2713aSLionel Sambuc('25 Algorithms library', '792'),
514*f4a2713aSLionel Sambuc('25.1 Non-modifying sequence operations', '802'),
515*f4a2713aSLionel Sambuc('25.2 Mutating sequence operations', '806'),
516*f4a2713aSLionel Sambuc('25.3 Sorting and related operations', '815'),
517*f4a2713aSLionel Sambuc('25.4 C library algorithms', '829'),
518*f4a2713aSLionel Sambuc('26 Numerics library', '831'),
519*f4a2713aSLionel Sambuc('26.1 Numeric type requirements', '831'),
520*f4a2713aSLionel Sambuc('26.2 The floating-point environment', '832'),
521*f4a2713aSLionel Sambuc('26.3 Complex numbers', '833'),
522*f4a2713aSLionel Sambuc('26.4 Random number generation', '842'),
523*f4a2713aSLionel Sambuc('26.5 Numeric arrays', '884'),
524*f4a2713aSLionel Sambuc('26.6 Generalized numeric operations', '904'),
525*f4a2713aSLionel Sambuc('26.7 C Library', '907'),
526*f4a2713aSLionel Sambuc('27 Input/output library', '912'),
527*f4a2713aSLionel Sambuc('27.1 Iostreams requirements', '912'),
528*f4a2713aSLionel Sambuc('27.2 Forward declarations', '912'),
529*f4a2713aSLionel Sambuc('27.3 Standard iostream objects', '915'),
530*f4a2713aSLionel Sambuc('27.4 Iostreams base classes', '916'),
531*f4a2713aSLionel Sambuc('27.5 Stream buffers', '934'),
532*f4a2713aSLionel Sambuc('27.6 Formatting and manipulators', '944'),
533*f4a2713aSLionel Sambuc('27.7 String-based streams', '972'),
534*f4a2713aSLionel Sambuc('27.8 File-based streams', '984'),
535*f4a2713aSLionel Sambuc('28 Regular expressions library', '1000'),
536*f4a2713aSLionel Sambuc('28.1 Definitions', '1000'),
537*f4a2713aSLionel Sambuc('28.2 Requirements', '1000'),
538*f4a2713aSLionel Sambuc('28.3 Regular expressions summary', '1002'),
539*f4a2713aSLionel Sambuc('28.4 Header <regex> synopsis', '1003'),
540*f4a2713aSLionel Sambuc('28.5 Namespace std::regex_constants', '1009'),
541*f4a2713aSLionel Sambuc('28.6 Class regex_error', '1012'),
542*f4a2713aSLionel Sambuc('28.7 Class template regex_traits', '1012'),
543*f4a2713aSLionel Sambuc('28.8 Class template basic_regex', '1015'),
544*f4a2713aSLionel Sambuc('28.9 Class template sub_match', '1020'),
545*f4a2713aSLionel Sambuc('28.10Class template match_results', '1025'),
546*f4a2713aSLionel Sambuc('28.11Regular expression algorithms', '1029'),
547*f4a2713aSLionel Sambuc('28.12Regular expression Iterators', '1033'),
548*f4a2713aSLionel Sambuc('28.13Modified ECMAScript regular expression grammar', '1039'),
549*f4a2713aSLionel Sambuc('29 Atomic operations library', '1042'),
550*f4a2713aSLionel Sambuc('29.1 Order and Consistency', '1044'),
551*f4a2713aSLionel Sambuc('29.2 Lock-free Property', '1046'),
552*f4a2713aSLionel Sambuc('29.3 Atomic Types', '1046'),
553*f4a2713aSLionel Sambuc('29.4 Operations on Atomic Types', '1051'),
554*f4a2713aSLionel Sambuc('29.5 Flag Type and Operations', '1054'),
555*f4a2713aSLionel Sambuc('30 Thread support library', '1057'),
556*f4a2713aSLionel Sambuc('30.1 Requirements', '1057'),
557*f4a2713aSLionel Sambuc('30.2 Threads', '1058'),
558*f4a2713aSLionel Sambuc('30.3 Mutual exclusion', '1063'),
559*f4a2713aSLionel Sambuc('30.4 Condition variables', '1077'),
560*f4a2713aSLionel Sambuc('A Grammar summary', '1085'),
561*f4a2713aSLionel Sambuc('A.1 Keywords', '1085'),
562*f4a2713aSLionel Sambuc('A.2 Lexical conventions', '1085'),
563*f4a2713aSLionel Sambuc('A.3 Basic concepts', '1089'),
564*f4a2713aSLionel Sambuc('A.4 Expressions', '1090'),
565*f4a2713aSLionel Sambuc('A.5 Statements', '1093'),
566*f4a2713aSLionel Sambuc('A.6 Declarations', '1094'),
567*f4a2713aSLionel Sambuc('A.7 Declarators', '1097'),
568*f4a2713aSLionel Sambuc('A.8 Classes', '1098'),
569*f4a2713aSLionel Sambuc('A.9 Derived classes', '1099'),
570*f4a2713aSLionel Sambuc('A.10 Special member functions', '1099'),
571*f4a2713aSLionel Sambuc('A.11 Overloading', '1100'),
572*f4a2713aSLionel Sambuc('A.12 Templates', '1100'),
573*f4a2713aSLionel Sambuc('A.13 Exception handling', '1101'),
574*f4a2713aSLionel Sambuc('A.14 Preprocessing directives', '1101'),
575*f4a2713aSLionel Sambuc('B Implementation quantities', '1103'),
576*f4a2713aSLionel Sambuc('C Compatibility', '1105'),
577*f4a2713aSLionel Sambuc('C.1 C++ and ISO C', '1105'),
578*f4a2713aSLionel Sambuc('C.2 Standard C library', '1114'),
579*f4a2713aSLionel Sambuc('D Compatibility features', '1119'),
580*f4a2713aSLionel Sambuc('D.1 Increment operator with bool operand', '1119'),
581*f4a2713aSLionel Sambuc('D.2 static keyword', '1119'),
582*f4a2713aSLionel Sambuc('D.3 Access declarations', '1119'),
583*f4a2713aSLionel Sambuc('D.4 Implicit conversion from const strings', '1119'),
584*f4a2713aSLionel Sambuc('D.5 C standard library headers', '1119'),
585*f4a2713aSLionel Sambuc('D.6 Old iostreams members', '1120'),
586*f4a2713aSLionel Sambuc('D.7 char* streams', '1121'),
587*f4a2713aSLionel Sambuc('D.8 Binders', '1130'),
588*f4a2713aSLionel Sambuc('D.9 auto_ptr', '1132'),
589*f4a2713aSLionel Sambuc('E Universal-character-names', '1135'),
590*f4a2713aSLionel Sambuc('F Cross references', '1137'),
591*f4a2713aSLionel Sambuc('Index', '1153')]
592*f4a2713aSLionel Sambuc
593*f4a2713aSLionel SambuckDocuments = {
594*f4a2713aSLionel Sambuc    'C99' : (c99URL, c99TOC, 12),
595*f4a2713aSLionel Sambuc    'C++' : (cXXURL, cXXTOC, 12),
596*f4a2713aSLionel Sambuc}
597*f4a2713aSLionel Sambuc
598*f4a2713aSLionel Sambucdef findClosestTOCEntry(data, target):
599*f4a2713aSLionel Sambuc    # FIXME: Fix for named spec references
600*f4a2713aSLionel Sambuc    if isinstance(target[0],str):
601*f4a2713aSLionel Sambuc        return ('.'.join(target),'<named>',1)
602*f4a2713aSLionel Sambuc
603*f4a2713aSLionel Sambuc    offset = data[2]
604*f4a2713aSLionel Sambuc    best = None
605*f4a2713aSLionel Sambuc    for (name,page) in data[1]:
606*f4a2713aSLionel Sambuc        if ' ' in name:
607*f4a2713aSLionel Sambuc            section,name = name.split(' ',1)
608*f4a2713aSLionel Sambuc            if section == 'Annex':
609*f4a2713aSLionel Sambuc                section,name = name.split(' ',1)
610*f4a2713aSLionel Sambuc                section = 'Annex '+section
611*f4a2713aSLionel Sambuc        else:
612*f4a2713aSLionel Sambuc            section = None
613*f4a2713aSLionel Sambuc        try:
614*f4a2713aSLionel Sambuc            page = int(page) + offset
615*f4a2713aSLionel Sambuc        except:
616*f4a2713aSLionel Sambuc            page = 1
617*f4a2713aSLionel Sambuc        try:
618*f4a2713aSLionel Sambuc            spec = SpecIndex.fromstring(section)
619*f4a2713aSLionel Sambuc        except:
620*f4a2713aSLionel Sambuc            spec = None
621*f4a2713aSLionel Sambuc
622*f4a2713aSLionel Sambuc        # Meh, could be better...
623*f4a2713aSLionel Sambuc        if spec is not None:
624*f4a2713aSLionel Sambuc            dist = spec - target
625*f4a2713aSLionel Sambuc            if best is None or dist < best[0]:
626*f4a2713aSLionel Sambuc                best = (dist, (section, name, page))
627*f4a2713aSLionel Sambuc    return best[1]
628*f4a2713aSLionel Sambuc
629*f4a2713aSLionel Sambuc# What a hack. Slow to boot.
630*f4a2713aSLionel SambucdoxyLineRefRE = re.compile(r"<a name=\"l([0-9]+)\"></a>")
631*f4a2713aSLionel Sambucdef findClosestLineReference(clangRoot, doxyName, target):
632*f4a2713aSLionel Sambuc    try:
633*f4a2713aSLionel Sambuc        f = open(os.path.join(clangRoot, 'docs', 'doxygen', 'html', doxyName))
634*f4a2713aSLionel Sambuc    except:
635*f4a2713aSLionel Sambuc        return None
636*f4a2713aSLionel Sambuc
637*f4a2713aSLionel Sambuc    best = None
638*f4a2713aSLionel Sambuc    for m in doxyLineRefRE.finditer(f.read()):
639*f4a2713aSLionel Sambuc        line = int(m.group(1), 10)
640*f4a2713aSLionel Sambuc        dist = abs(line - target)
641*f4a2713aSLionel Sambuc        if best is None or dist < best[0]:
642*f4a2713aSLionel Sambuc            best = (dist,'l'+m.group(1))
643*f4a2713aSLionel Sambuc    f.close()
644*f4a2713aSLionel Sambuc    if best is not None:
645*f4a2713aSLionel Sambuc        return best[1]
646*f4a2713aSLionel Sambuc    return None
647*f4a2713aSLionel Sambuc
648*f4a2713aSLionel Sambuc###
649*f4a2713aSLionel Sambuc
650*f4a2713aSLionel SambucnameAndSpecRefRE = re.compile(r"(C99|C90|C\+\+|H\&S) ((([0-9]+)(\.[0-9]+)*|\[[^]]+\])(p[0-9]+)?)")
651*f4a2713aSLionel SambucloneSpecRefRE = re.compile(r" (([0-9]+)(\.[0-9]+){2,100}(p[0-9]+)?)")
652*f4a2713aSLionel Sambucdef scanFile(path, filename):
653*f4a2713aSLionel Sambuc    try:
654*f4a2713aSLionel Sambuc        f = open(path)
655*f4a2713aSLionel Sambuc    except IOError:
656*f4a2713aSLionel Sambuc        print >>sys.stderr,'WARNING: Unable to open:',path
657*f4a2713aSLionel Sambuc        return
658*f4a2713aSLionel Sambuc
659*f4a2713aSLionel Sambuc    for i,ln in enumerate(f):
660*f4a2713aSLionel Sambuc        ignore = set()
661*f4a2713aSLionel Sambuc        for m in nameAndSpecRefRE.finditer(ln):
662*f4a2713aSLionel Sambuc            section = m.group(2)
663*f4a2713aSLionel Sambuc            name = m.group(1)
664*f4a2713aSLionel Sambuc            if section.endswith('.'):
665*f4a2713aSLionel Sambuc                section = section[:-1]
666*f4a2713aSLionel Sambuc            yield RefItem(name, section, filename, path, i+1)
667*f4a2713aSLionel Sambuc            ignore.add(section)
668*f4a2713aSLionel Sambuc        for m in loneSpecRefRE.finditer(ln):
669*f4a2713aSLionel Sambuc            section = m.group(1)
670*f4a2713aSLionel Sambuc            if section.endswith('.'):
671*f4a2713aSLionel Sambuc                section = section[:-1]
672*f4a2713aSLionel Sambuc            if section not in ignore:
673*f4a2713aSLionel Sambuc                yield RefItem(None, section, filename, path, i+1)
674*f4a2713aSLionel Sambuc
675*f4a2713aSLionel Sambuc###
676*f4a2713aSLionel Sambuc
677*f4a2713aSLionel Sambucclass SpecIndex:
678*f4a2713aSLionel Sambuc    @staticmethod
679*f4a2713aSLionel Sambuc    def fromstring(str):
680*f4a2713aSLionel Sambuc        # Check for named sections
681*f4a2713aSLionel Sambuc        if str[0] == '[':
682*f4a2713aSLionel Sambuc            assert ']' in str
683*f4a2713aSLionel Sambuc            secs = str[1:str.index(']')].split('.')
684*f4a2713aSLionel Sambuc            tail = str[str.index(']')+1:]
685*f4a2713aSLionel Sambuc            if tail:
686*f4a2713aSLionel Sambuc                assert tail[0] == 'p'
687*f4a2713aSLionel Sambuc                paragraph = int(tail[1:])
688*f4a2713aSLionel Sambuc            else:
689*f4a2713aSLionel Sambuc                paragraph = None
690*f4a2713aSLionel Sambuc            indices = secs
691*f4a2713aSLionel Sambuc        else:
692*f4a2713aSLionel Sambuc            secs = str.split('.')
693*f4a2713aSLionel Sambuc            paragraph = None
694*f4a2713aSLionel Sambuc            if 'p' in secs[-1]:
695*f4a2713aSLionel Sambuc                secs[-1],p = secs[-1].split('p',1)
696*f4a2713aSLionel Sambuc                paragraph = int(p)
697*f4a2713aSLionel Sambuc            indices = map(int, secs)
698*f4a2713aSLionel Sambuc        return SpecIndex(indices, paragraph)
699*f4a2713aSLionel Sambuc
700*f4a2713aSLionel Sambuc    def __init__(self, indices, paragraph=None):
701*f4a2713aSLionel Sambuc        assert len(indices)>0
702*f4a2713aSLionel Sambuc        self.indices = tuple(indices)
703*f4a2713aSLionel Sambuc        self.paragraph = paragraph
704*f4a2713aSLionel Sambuc
705*f4a2713aSLionel Sambuc    def __str__(self):
706*f4a2713aSLionel Sambuc        s =  '.'.join(map(str,self.indices))
707*f4a2713aSLionel Sambuc        if self.paragraph is not None:
708*f4a2713aSLionel Sambuc            s += '.p%d'%(self.paragraph,)
709*f4a2713aSLionel Sambuc        return s
710*f4a2713aSLionel Sambuc
711*f4a2713aSLionel Sambuc    def __repr__(self):
712*f4a2713aSLionel Sambuc        return 'SpecIndex(%s, %s)'%(self.indices, self.paragraph)
713*f4a2713aSLionel Sambuc
714*f4a2713aSLionel Sambuc    def __cmp__(self, b):
715*f4a2713aSLionel Sambuc        return cmp((self.indices,self.paragraph),
716*f4a2713aSLionel Sambuc                   (b.indices,b.paragraph))
717*f4a2713aSLionel Sambuc
718*f4a2713aSLionel Sambuc    def __hash__(self):
719*f4a2713aSLionel Sambuc        return hash((self.indices,self.paragraph))
720*f4a2713aSLionel Sambuc
721*f4a2713aSLionel Sambuc    def __sub__(self, indices):
722*f4a2713aSLionel Sambuc        def sub(a,b):
723*f4a2713aSLionel Sambuc            a = a or 0
724*f4a2713aSLionel Sambuc            b = b or 0
725*f4a2713aSLionel Sambuc            return abs(a-b)
726*f4a2713aSLionel Sambuc        return map(sub,self.indices,indices)
727*f4a2713aSLionel Sambuc
728*f4a2713aSLionel Sambucclass RefItem:
729*f4a2713aSLionel Sambuc    def __init__(self, name, section, filename, path, line):
730*f4a2713aSLionel Sambuc        self.name = name
731*f4a2713aSLionel Sambuc        self.section = SpecIndex.fromstring(section)
732*f4a2713aSLionel Sambuc        self.filename = filename
733*f4a2713aSLionel Sambuc        self.path = path
734*f4a2713aSLionel Sambuc        self.line = line
735*f4a2713aSLionel Sambuc
736*f4a2713aSLionel Sambuc    def __str__(self):
737*f4a2713aSLionel Sambuc        if self.name is not None:
738*f4a2713aSLionel Sambuc            return '%s %s'%(self.name, self.section)
739*f4a2713aSLionel Sambuc        else:
740*f4a2713aSLionel Sambuc            return '--- %s'%(self.section,)
741*f4a2713aSLionel Sambuc
742*f4a2713aSLionel Sambuc    def __repr__(self):
743*f4a2713aSLionel Sambuc        return 'RefItem(%s, %r, "%s", "%s", %d)'%(self.name,
744*f4a2713aSLionel Sambuc                                              self.section,
745*f4a2713aSLionel Sambuc                                              self.filename,
746*f4a2713aSLionel Sambuc                                              self.path,
747*f4a2713aSLionel Sambuc                                              self.line)
748*f4a2713aSLionel Sambuc
749*f4a2713aSLionel Sambuc    def __cmp__(self, b):
750*f4a2713aSLionel Sambuc        return cmp((self.name,self.section,self.filename,self.path,self.line),
751*f4a2713aSLionel Sambuc                   (b.name,b.section,self.filename,self.path,self.line))
752*f4a2713aSLionel Sambuc
753*f4a2713aSLionel Sambuc    def __hash__(self):
754*f4a2713aSLionel Sambuc        return hash((self.name,self.section,self.filename,self.path,self.line))
755*f4a2713aSLionel Sambuc
756*f4a2713aSLionel Sambuc###
757*f4a2713aSLionel Sambuc
758*f4a2713aSLionel Sambucdef sorted(l):
759*f4a2713aSLionel Sambuc    l = list(l)
760*f4a2713aSLionel Sambuc    l.sort()
761*f4a2713aSLionel Sambuc    return l
762*f4a2713aSLionel Sambuc
763*f4a2713aSLionel Sambucdef getRevision(path):
764*f4a2713aSLionel Sambuc    import subprocess
765*f4a2713aSLionel Sambuc    p = subprocess.Popen(['svn', 'info', path],
766*f4a2713aSLionel Sambuc                         stdin=open('/dev/null','r'),
767*f4a2713aSLionel Sambuc                         stdout=subprocess.PIPE)
768*f4a2713aSLionel Sambuc    for ln in p.stdout.read(1024).split('\n'):
769*f4a2713aSLionel Sambuc        if ln.startswith('Revision:'):
770*f4a2713aSLionel Sambuc            return ln.split(':',1)[1].strip()
771*f4a2713aSLionel Sambuc    return None
772*f4a2713aSLionel Sambuc
773*f4a2713aSLionel Sambucdef buildRefTree(references):
774*f4a2713aSLionel Sambuc    root = (None, {}, [])
775*f4a2713aSLionel Sambuc
776*f4a2713aSLionel Sambuc    def getNode(keys):
777*f4a2713aSLionel Sambuc        if not keys:
778*f4a2713aSLionel Sambuc            return root
779*f4a2713aSLionel Sambuc        key,parent = keys[-1],getNode(keys[:-1])
780*f4a2713aSLionel Sambuc        node = parent[1].get(key)
781*f4a2713aSLionel Sambuc        if node is None:
782*f4a2713aSLionel Sambuc            parent[1][key] = node = (key, {}, [])
783*f4a2713aSLionel Sambuc        return node
784*f4a2713aSLionel Sambuc
785*f4a2713aSLionel Sambuc    for ref in references:
786*f4a2713aSLionel Sambuc        n = getNode((ref.name,) + ref.section.indices)
787*f4a2713aSLionel Sambuc        n[2].append(ref)
788*f4a2713aSLionel Sambuc
789*f4a2713aSLionel Sambuc    def flatten((key, children, data)):
790*f4a2713aSLionel Sambuc        children = sorted(map(flatten,children.values()))
791*f4a2713aSLionel Sambuc        return (key, children, sorted(data))
792*f4a2713aSLionel Sambuc
793*f4a2713aSLionel Sambuc    return flatten(root)
794*f4a2713aSLionel Sambuc
795*f4a2713aSLionel Sambucdef preorder(node,parents=(),first=True):
796*f4a2713aSLionel Sambuc    (key,children,data) = node
797*f4a2713aSLionel Sambuc    if first:
798*f4a2713aSLionel Sambuc        yield parents+(node,)
799*f4a2713aSLionel Sambuc    for c in children:
800*f4a2713aSLionel Sambuc        for item in preorder(c, parents+(node,)):
801*f4a2713aSLionel Sambuc            yield item
802*f4a2713aSLionel Sambuc
803*f4a2713aSLionel Sambucdef main():
804*f4a2713aSLionel Sambuc    global options
805*f4a2713aSLionel Sambuc    from optparse import OptionParser
806*f4a2713aSLionel Sambuc    parser = OptionParser("usage: %prog [options] CLANG_ROOT <output-dir>")
807*f4a2713aSLionel Sambuc    parser.add_option("", "--debug", dest="debug",
808*f4a2713aSLionel Sambuc                      help="Print extra debugging output",
809*f4a2713aSLionel Sambuc                      action="store_true",
810*f4a2713aSLionel Sambuc                      default=False)
811*f4a2713aSLionel Sambuc    (opts, args) = parser.parse_args()
812*f4a2713aSLionel Sambuc
813*f4a2713aSLionel Sambuc    if len(args) != 2:
814*f4a2713aSLionel Sambuc        parser.error("incorrect number of arguments")
815*f4a2713aSLionel Sambuc
816*f4a2713aSLionel Sambuc    references = []
817*f4a2713aSLionel Sambuc    root,outputDir = args
818*f4a2713aSLionel Sambuc    if os.path.isdir(root):
819*f4a2713aSLionel Sambuc        for (dirpath, dirnames, filenames) in os.walk(root):
820*f4a2713aSLionel Sambuc            for filename in filenames:
821*f4a2713aSLionel Sambuc                name,ext = os.path.splitext(filename)
822*f4a2713aSLionel Sambuc                if ext in ('.c', '.cpp', '.h', '.def'):
823*f4a2713aSLionel Sambuc                    fullpath = os.path.join(dirpath, filename)
824*f4a2713aSLionel Sambuc                    references.extend(list(scanFile(fullpath, filename)))
825*f4a2713aSLionel Sambuc    else:
826*f4a2713aSLionel Sambuc        references.extend(list(scanFile(root, root)))
827*f4a2713aSLionel Sambuc
828*f4a2713aSLionel Sambuc    refTree = buildRefTree(references)
829*f4a2713aSLionel Sambuc
830*f4a2713aSLionel Sambuc    specs = {}
831*f4a2713aSLionel Sambuc    for ref in references:
832*f4a2713aSLionel Sambuc        spec = specs[ref.name] = specs.get(ref.name,{})
833*f4a2713aSLionel Sambuc        items = spec[ref.section] = spec.get(ref.section,[])
834*f4a2713aSLionel Sambuc        items.append(ref)
835*f4a2713aSLionel Sambuc
836*f4a2713aSLionel Sambuc    print 'Found %d references.'%(len(references),)
837*f4a2713aSLionel Sambuc
838*f4a2713aSLionel Sambuc    if opts.debug:
839*f4a2713aSLionel Sambuc        pprint(refTree)
840*f4a2713aSLionel Sambuc
841*f4a2713aSLionel Sambuc    referencesPath = os.path.join(outputDir,'references.html')
842*f4a2713aSLionel Sambuc    print 'Writing: %s'%(referencesPath,)
843*f4a2713aSLionel Sambuc    f = open(referencesPath,'w')
844*f4a2713aSLionel Sambuc    print >>f, '<html><head><title>clang: Specification References</title></head>'
845*f4a2713aSLionel Sambuc    print >>f, '<body>'
846*f4a2713aSLionel Sambuc    print >>f, '\t<h2>Specification References</h2>'
847*f4a2713aSLionel Sambuc    for i,node in enumerate(refTree[1]):
848*f4a2713aSLionel Sambuc        specName = node[0] or 'Unknown'
849*f4a2713aSLionel Sambuc        print >>f, '<a href="#spec%d">%s</a><br>'%(i,specName)
850*f4a2713aSLionel Sambuc    for i,node in enumerate(refTree[1]):
851*f4a2713aSLionel Sambuc        specName = node[0] or 'Unknown'
852*f4a2713aSLionel Sambuc        print >>f, '<hr>'
853*f4a2713aSLionel Sambuc        print >>f, '<a name="spec%d">'%(i,)
854*f4a2713aSLionel Sambuc        print >>f, '<h3>Document: %s</h3>'%(specName or 'Unknown',)
855*f4a2713aSLionel Sambuc        print >>f, '<table border="1" cellspacing="2" width="80%">'
856*f4a2713aSLionel Sambuc        print >>f, '<tr><th width="20%">Name</th><th>References</th></tr>'
857*f4a2713aSLionel Sambuc        docData = kDocuments.get(specName)
858*f4a2713aSLionel Sambuc        for path in preorder(node,first=False):
859*f4a2713aSLionel Sambuc            if not path[-1][2]:
860*f4a2713aSLionel Sambuc                continue
861*f4a2713aSLionel Sambuc            components = '.'.join([str(p[0]) for p in path[1:]])
862*f4a2713aSLionel Sambuc            print >>f, '\t<tr>'
863*f4a2713aSLionel Sambuc            tocEntry = None
864*f4a2713aSLionel Sambuc            if docData is not None:
865*f4a2713aSLionel Sambuc                tocEntry = findClosestTOCEntry(docData, [p[0] for p in path[1:]])
866*f4a2713aSLionel Sambuc            if tocEntry is not None:
867*f4a2713aSLionel Sambuc                section,name,page = tocEntry
868*f4a2713aSLionel Sambuc                # If section is exact print the TOC name
869*f4a2713aSLionel Sambuc                if page is not None:
870*f4a2713aSLionel Sambuc                    linkStr = '<a href="%s#page=%d">%s</a> (pg.%d)'%(docData[0],page,components,page)
871*f4a2713aSLionel Sambuc                else:
872*f4a2713aSLionel Sambuc                    linkStr = components
873*f4a2713aSLionel Sambuc                if section == components:
874*f4a2713aSLionel Sambuc                    print >>f, '\t\t<td valign=top>%s<br>%s</td>'%(linkStr,name)
875*f4a2713aSLionel Sambuc                else:
876*f4a2713aSLionel Sambuc                    print >>f, '\t\t<td valign=top>%s</td>'%(linkStr,)
877*f4a2713aSLionel Sambuc            else:
878*f4a2713aSLionel Sambuc                print >>f, '\t\t<td valign=top>%s</td>'%(components,)
879*f4a2713aSLionel Sambuc            print >>f, '\t\t<td valign=top>'
880*f4a2713aSLionel Sambuc            for item in path[-1][2]:
881*f4a2713aSLionel Sambuc                # XXX total hack
882*f4a2713aSLionel Sambuc                relativePath = item.path[len(root):]
883*f4a2713aSLionel Sambuc                if relativePath.startswith('/'):
884*f4a2713aSLionel Sambuc                    relativePath = relativePath[1:]
885*f4a2713aSLionel Sambuc                # XXX this is broken, how does doxygen mangle w/ multiple
886*f4a2713aSLionel Sambuc                # refs? Can we just read its map?
887*f4a2713aSLionel Sambuc                filename = os.path.basename(relativePath)
888*f4a2713aSLionel Sambuc                doxyName = '%s-source.html'%(filename.replace('.','_8'),)
889*f4a2713aSLionel Sambuc                # Grrr, why can't doxygen write line number references.
890*f4a2713aSLionel Sambuc                lineReference = findClosestLineReference(root,doxyName,item.line)
891*f4a2713aSLionel Sambuc                if lineReference is not None:
892*f4a2713aSLionel Sambuc                    linkStr = 'http://clang.llvm.org/doxygen/%s#%s'%(doxyName,lineReference)
893*f4a2713aSLionel Sambuc                else:
894*f4a2713aSLionel Sambuc                    linkStr = 'http://clang.llvm.org/doxygen/%s'%(doxyName,)
895*f4a2713aSLionel Sambuc                if item.section.paragraph is not None:
896*f4a2713aSLionel Sambuc                    paraText = '&nbsp;(p%d)'%(item.section.paragraph,)
897*f4a2713aSLionel Sambuc                else:
898*f4a2713aSLionel Sambuc                    paraText = ''
899*f4a2713aSLionel Sambuc                print >>f,'<a href="%s">%s:%d</a>%s<br>'%(linkStr,relativePath,item.line,paraText)
900*f4a2713aSLionel Sambuc            print >>f, '\t\t</td>'
901*f4a2713aSLionel Sambuc            print >>f, '\t</tr>'
902*f4a2713aSLionel Sambuc        print >>f, '</table>'
903*f4a2713aSLionel Sambuc    print >>f, '<hr>'
904*f4a2713aSLionel Sambuc    print >>f, 'Generated: %s<br>'%(time.strftime('%Y-%m-%d %H:%M'),)
905*f4a2713aSLionel Sambuc    print >>f, 'SVN Revision: %s'%(getRevision(root),)
906*f4a2713aSLionel Sambuc    print >>f, '</body>'
907*f4a2713aSLionel Sambuc    f.close()
908*f4a2713aSLionel Sambuc
909*f4a2713aSLionel Sambucif __name__=='__main__':
910*f4a2713aSLionel Sambuc   main()
911