Welcome to mirror list, hosted at ThFree Co, Russian Federation.

check_format.sh « utils « polly - github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4d7b033d1a79ef1b7355db46e238ff8cbcce5fc3 (plain)
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
#!/bin/bash

CLANG_FORMAT=${CLANG_FORMAT}

if [ "${CLANG_FORMAT}x" = "x" ]; then
  CLANG_FORMAT=`which clang-format`
  if [ "${CLANG_FORMAT}x" = "x" ]; then
     echo "Error: cannot find clang-format in your path"
     exit 1
  fi
fi

OK=0

for ARG in "$@"
  do
    ${CLANG_FORMAT} -style=llvm $ARG | diff -u $ARG - >&2

    if [[ $? -eq 1 ]]; then
      OK=1
    fi
  done

if [[ $OK -eq "1" ]]; then
  echo "Error: clang-format reported formatting differences"
  exit 1
else
  echo "OK: clang-format reported no formatting differences"
  exit 0
fi