1 #! /usr/bin/env python3
2 import sys, os, re, urllib.request
5 default_issue_list_path = 'cwg_index.html'
6 issue_list_url = "https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_index.html"
7 output = 'cxx_dr_status.html'
8 dr_test_dir = '../test/CXX/drs'
11 def __init__(self, section, issue, url, status, title):
12 self.section, self.issue, self.url, self.status, self.title = \
13 section, issue, url, status, title
15 return '%s (%s): %s' % (self.issue, self.status, self.title)
19 section, issue_link, status, liaison, title = [
20 col.split('>', 1)[1].split('</TD>')[0]
21 for col in dr.split('</TR>', 1)[0].split('<TD')[1:]
23 except Exception as ex:
24 print(f"Parse error: {ex}\n{dr}", file=sys.stderr)
26 _, url, issue = issue_link.split('"', 2)
28 issue = int(issue.split('>', 1)[1].split('<', 1)[0])
29 title = title.replace('<issue_title>', '').replace('</issue_title>', '').replace('\r\n', '\n').strip()
30 return DR(section, issue, url, status, title)
33 status_re = re.compile(r'\bdr([0-9]+): (.*)')
35 for test_cpp in os.listdir(dr_test_dir):
36 if not test_cpp.endswith('.cpp'):
38 test_cpp = os.path.join(dr_test_dir, test_cpp)
40 for match in re.finditer(status_re, open(test_cpp, 'r').read()):
41 status_map[int(match.group(1))] = match.group(2)
44 print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
49 if not path and os.path.exists(default_issue_list_path):
50 path = default_issue_list_path
53 print('Fetching issue list from {}'.format(issue_list_url))
54 with urllib.request.urlopen(issue_list_url) as f:
55 buffer = f.read().decode('utf-8')
57 print('Opening issue list from file {}'.format(path))
58 with open(path, 'r') as f:
60 except Exception as ex:
61 print('Unable to read the core issue list', file=sys.stderr)
62 print(ex, file=sys.stderr)
65 return sorted((parse(dr) for dr in buffer.split('<TR>')[2:]),
66 key = lambda dr: dr.issue)
69 issue_list_path = None
70 if len(sys.argv) == 1:
72 elif len(sys.argv) == 2:
73 issue_list_path = sys.argv[1]
75 print('Usage: {} [<path to cwg_index.html>]'.format(sys.argv[0]), file=sys.stderr)
78 status_map = collect_tests()
79 drs = get_issues(issue_list_path)
80 out_file = open(output, 'w')
83 <!-- This file is auto-generated by make_cxx_dr_status. Do not modify. -->
86 <META http-equiv="Content-Type" content="text/html; charset=utf-8">
87 <title>Clang - C++ Defect Report Status</title>
88 <link type="text/css" rel="stylesheet" href="menu.css">
89 <link type="text/css" rel="stylesheet" href="content.css">
90 <style type="text/css">
91 .none { background-color: #FFCCCC }
92 .partial { background-color: #FFE0B0 }
93 .unreleased { background-color: #FFFF99 }
94 .full { background-color: #CCFF99 }
95 .na { background-color: #DDDDDD }
96 .open * { color: #AAAAAA }
97 //.open { filter: opacity(0.2) }
98 tr:target { background-color: #FFFFBB }
99 th { background-color: #FFDDAA }
104 <!--#include virtual="menu.html.incl"-->
108 <!--*************************************************************************-->
109 <h1>C++ Defect Report Support in Clang</h1>
110 <!--*************************************************************************-->
112 <h2 id="cxxdr">C++ defect report implementation status</h2>
114 <p>This page tracks which C++ defect reports are implemented within Clang.</p>
116 <table width="689" border="1" cellspacing="0">
121 <th>Available in Clang?</th>
126 def availability(issue):
127 status = status_map.get(issue, 'unknown')
129 unresolved_status = ''
130 if status.endswith(' open'):
132 unresolved_status = 'open'
133 elif status.endswith(' drafting'):
135 unresolved_status = 'drafting'
136 elif status.endswith(' review'):
138 unresolved_status = 'review'
141 if status.endswith(' c++11'):
143 avail_suffix = ' (C++11 onwards)'
144 elif status.endswith(' c++14'):
146 avail_suffix = ' (C++14 onwards)'
147 elif status.endswith(' c++17'):
149 avail_suffix = ' (C++17 onwards)'
150 elif status.endswith(' c++20'):
152 avail_suffix = ' (C++20 onwards)'
153 if status == 'unknown':
155 avail_style = ' class="none"'
156 elif re.match('^[0-9]+\.?[0-9]*', status):
157 avail = 'Clang %s' % status
158 if float(status) > latest_release:
159 avail_style = ' class="unreleased"'
161 avail_style = ' class="full"'
162 elif status == 'yes':
164 avail_style = ' class="full"'
165 elif status == 'partial':
167 avail_style = ' class="partial"'
170 avail_style = ' class="none"'
173 avail_style = ' class="na"'
174 elif status == 'na lib':
175 avail = 'N/A (Library DR)'
176 avail_style = ' class="na"'
177 elif status == 'na abi':
178 avail = 'N/A (ABI constraint)'
179 avail_style = ' class="na"'
180 elif status.startswith('sup '):
181 dup = status.split(' ', 1)[1]
182 if dup.startswith('P'):
183 avail = 'Superseded by <a href="https://wg21.link/%s">%s</a>' % (dup, dup)
184 avail_style = ' class="na"'
186 avail = 'Superseded by <a href="#%s">%s</a>' % (dup, dup)
188 _, avail_style, _ = availability(int(dup))
190 print("issue %s marked as sup %s" % (issue, dup), file=sys.stderr)
191 avail_style = ' class="none"'
192 elif status.startswith('dup '):
193 dup = int(status.split(' ', 1)[1])
194 avail = 'Duplicate of <a href="#%s">%s</a>' % (dup, dup)
195 _, avail_style, _ = availability(dup)
197 assert False, 'unknown status %s for issue %s' % (status, dr.issue)
198 return (avail + avail_suffix, avail_style, unresolved_status)
202 if dr.status in ('concepts',):
203 # This refers to the old ("C++0x") concepts feature, which was not part
204 # of any C++ International Standard or Technical Specification.
207 elif dr.status == 'extension':
208 row_style = ' class="open"'
212 elif dr.status in ('open', 'drafting', 'review'):
213 row_style = ' class="open"'
214 avail, avail_style, unresolved_status = availability(dr.issue)
215 if avail == 'Unknown':
216 avail = 'Not resolved'
219 assert unresolved_status == dr.status, \
220 "Issue %s is marked '%s', which differs from CWG index status '%s'" \
221 % (dr.issue, unresolved_status, dr.status)
224 avail, avail_style, unresolved_status = availability(dr.issue)
225 assert not unresolved_status, \
226 "Issue %s is marked '%s', even though it is resolved in CWG index" \
227 % (dr.issue, unresolved_status)
229 if not avail.startswith('Sup') and not avail.startswith('Dup'):
230 count[avail] = count.get(avail, 0) + 1
234 <td><a href="https://wg21.link/cwg%s">%s</a></td>
237 <td%s align="center">%s</td>
238 </tr>''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
240 for status, num in sorted(count.items()):
241 print("%s: %s" % (status, num), file=sys.stderr)