forked from herbstluftwm/herbstluftwm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-check-using-std.sh
More file actions
executable file
·37 lines (31 loc) · 961 Bytes
/
ci-check-using-std.sh
File metadata and controls
executable file
·37 lines (31 loc) · 961 Bytes
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
#!/bin/bash
###
# Searches the code for the use of "std::" prefixes in symbol reference that
# should be pulled into the namespace with "using std::…;".
#
# The list of symbols to enforce this for is assembled on-the-fly by looking
# for occurrences of "using std::…;"
###
set -o pipefail
set -o nounset
reporoot=$(realpath "$(dirname "$0")")
# Assemble list of std symbols to pull in:
# (exclude some that are not enforced yet)
usethis=$(grep --no-filename 'using std::' "$reporoot/src/"*.cpp \
| sed -r 's/^\s*using std::(.*);/\1/' \
| sort -u \
)
found_something=0
# set -x
for symbol in $usethis; do
# Find offending occurrences of "std::" prefixes:
grep --perl-regexp --color=auto '(?<!using )std::'"$symbol"'\b' src/*.cpp
grepret=$?
if [[ $grepret == 0 ]]; then
found_something=1
fi
done
if [[ $found_something != 0 ]]; then
echo >&2 "Found redundant uses of std:: prefixes (see above)"
exit 1
fi