Skip to content

Commit 7e02c2f

Browse files
jensmaurertkoeppe
authored andcommitted
[check] Add check for library element order
Also mark for exclusion four places where the canonical order cannot be established due to dependencies.
1 parent a5621c6 commit 7e02c2f

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

source/iostreams.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -3983,7 +3983,7 @@
39833983
int_type overflow(int_type c = traits::eof());
39843984
\end{itemdecl}
39853985

3986-
\begin{itemdescr}
3986+
\begin{itemdescr} % NOCHECK: order
39873987
\pnum
39883988
\effects
39893989
Consumes some initial subsequence of the characters of the

source/utilities.tex

+3-3
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@
19611961
constexpr tuple<CTypes...> tuple_cat(Tuples&&... tpls);
19621962
\end{itemdecl}
19631963

1964-
\begin{itemdescr}
1964+
\begin{itemdescr} % NOCHECK: order
19651965
\pnum
19661966
In the following paragraphs, let $\tcode{T}_i$ be the $i^\text{th}$ type in \tcode{Tuples},
19671967
$\tcode{U}_i$ be \tcode{remove_reference_t<T$_i$>}, and $\tcode{tp}_i$ be the $i^\text{th}$
@@ -4658,7 +4658,7 @@
46584658
variant_alternative_t<I, variant<Types...>>& emplace(Args&&... args);
46594659
\end{itemdecl}
46604660

4661-
\begin{itemdescr}
4661+
\begin{itemdescr} % NOCHECK: order
46624662
\pnum
46634663
\mandates
46644664
$\tcode{I} < \tcode{sizeof...(Types)}$.
@@ -4699,7 +4699,7 @@
46994699
variant_alternative_t<I, variant<Types...>>& emplace(initializer_list<U> il, Args&&... args);
47004700
\end{itemdecl}
47014701

4702-
\begin{itemdescr}
4702+
\begin{itemdescr} % NOCHECK: order
47034703
\pnum
47044704
\mandates
47054705
$\tcode{I} < \tcode{sizeof...(Types)}$.

tools/check-source.sh

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ grep -ne '^\\\(constraints\|mandates\|expects\|effects\|sync\|ensures\|returns\|
7373
# Fixup: sed 's/^\\\(constraints\|mandates\|expects\|effects\|sync\|ensures\|returns\|throws\|complexity\|remarks\|errors\)\s*\(.\)/\\\1\n\2/'
7474
# Fixup: sed 's/^\\ //'
7575

76+
# Order of library elements.
77+
../tools/element-order.awk *.tex |
78+
fail 'incorrect ordering of library elements' || failed=1
79+
7680
# Change marker in [diff] followed by stuff.
7781
grep -Hne '^\\\(change\|rationale\|effect\|difficulty\|howwide\)\s.\+$' compatibility.tex |
7882
fail "change marker in [diff] followed by stuff" || failed=1

tools/element-order.awk

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/awk -f
2+
3+
BEGIN {
4+
items = "constraints mandates expects effects sync ensures returns throws complexity remarks errors"
5+
linematch = "^[\\\\](" items ")"
6+
gsub(/ /, "|", linematch)
7+
items = " " items
8+
# print linematch
9+
}
10+
11+
/^.begin{itemdescr}/ {
12+
elements = ""
13+
startline = FNR
14+
check = 1
15+
if (/% NOCHECK:.* order/) {
16+
check = 0
17+
}
18+
}
19+
20+
/^.end{itemdescr}/ {
21+
if (check && length(elements) > 0) {
22+
regex = substr(elements, 2)
23+
gsub(/ /, " .* ", regex)
24+
if (items !~ regex) {
25+
printf "%s:%d-%d: bad element ordering: %s\n", FILENAME, startline, FNR, elements
26+
}
27+
}
28+
}
29+
30+
match ($0, linematch) > 0 {
31+
elements = elements " " substr($0, 2)
32+
}

0 commit comments

Comments
 (0)