Skip to content

Commit 9eb6ae9

Browse files
committed
add lint script to check for stdint types without std:: prefix
1 parent 8d47c60 commit 9eb6ae9

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
from pathlib import Path
3+
import re
4+
import sys
5+
6+
ROOT = Path(__file__).resolve().parents[2]
7+
HEADER = ROOT / "include" / "ankerl" / "unordered_dense.h"
8+
9+
10+
def build_query():
11+
# Literal names drawn from C++ wrapper headers (<cstddef>, <ctime>, <cstdio>, <cwchar>)
12+
names = [
13+
r"u?int(?:_fast|_least)?\d{1,2}_t",
14+
r"s?size_t",
15+
r"ptrdiff_t",
16+
r"u?intmax_t",
17+
r"u?intptr_t",
18+
r"nullptr_t",
19+
r"max_align_t",
20+
r"time_t",
21+
r"clock_t",
22+
r"tm",
23+
r"FILE",
24+
r"fpos_t",
25+
r"mbstate_t",
26+
r"wint_t",
27+
]
28+
literal_alts = "|".join(n for n in names)
29+
return re.compile(r"(?<!std::)\b(?:" + literal_alts + r")\b")
30+
31+
32+
def main():
33+
errors = []
34+
query = build_query()
35+
for lineno, line in enumerate(HEADER.read_text().splitlines(), 1):
36+
if query.search(line):
37+
errors.append(f"{HEADER}:{lineno}: {line}")
38+
39+
if errors:
40+
print("Found stdint types without std:: prefix:")
41+
print("\n".join(errors))
42+
sys.exit(1)
43+
44+
45+
if __name__ == "__main__":
46+
main()

0 commit comments

Comments
 (0)