Skip to content

Commit 5ac129b

Browse files
committed
Add .clang-format and formatting / typos GitHub workflows
Use the LLVM style unmodified, so that exchanging code between upstream will be less tedious. We currently *don't* follow that style. I'm inclined to doing a mass-format soon, though. v2: - fix a typo
1 parent 8a86876 commit 5ac129b

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BasedOnStyle: LLVM
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: clang-format check
2+
on: [pull_request]
3+
4+
jobs:
5+
clang-format-check:
6+
name: clang-format
7+
runs-on: "ubuntu-20.04"
8+
steps:
9+
- name: Setup environment
10+
run: |
11+
sudo apt-get install -yqq clang-format-11
12+
- name: Checkout llvm-dialects
13+
uses: actions/checkout@v2
14+
- name: Run clang-format
15+
run: |
16+
git diff ${{ github.base_ref }} -U0 --no-color -- '**/*.cpp' '**/*.cc' '**/*.h' '**/*.hh' \
17+
| clang-format-diff-11 -p1 >not-formatted.diff 2>&1
18+
- name: Check formatting
19+
run: |
20+
if ! grep -q '[^[:space:]]' not-formatted.diff ; then
21+
echo "Code formatted. Success."
22+
else
23+
echo "Code not formatted."
24+
echo "Please run clang-format-diff on your changes and push again:"
25+
echo " git diff ${{ github.base_ref }} -U0 --no-color | clang-format-diff -p1 -i"
26+
echo ""
27+
echo "Tip: you can disable clang-format checks: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code"
28+
echo ""
29+
echo "Diff:"
30+
cat not-formatted.diff
31+
echo ""
32+
exit 3
33+
fi

.github/workflows/check-typos.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Spell Check
2+
on: [pull_request]
3+
4+
jobs:
5+
run:
6+
name: typos
7+
runs-on: "ubuntu-20.04"
8+
steps:
9+
- name: Checkout Repository
10+
uses: actions/checkout@v2
11+
12+
- name: Check spelling
13+
uses: crate-ci/[email protected]
14+
15+
- name: Help
16+
if: always()
17+
run: |
18+
echo 'To run the check locally, install typos from https://github.com/crate-ci/typos and run `typos` in the repository.'
19+
echo 'Run `typos -w` to automatically correct spelling mistakes.'
20+
echo
21+
echo 'Please add false positives to .typos.toml'

lib/TableGen/GenDialect.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ std::unique_ptr<PredicateExpr> DialectsContext::parsePredicateExpr(DagInit *dag)
915915

916916
if (!argName) {
917917
report_fatal_error(
918-
Twine("Predicate appliation has missing argument name: ")
918+
Twine("Predicate application has missing argument name: ")
919919
+ dag->getAsString());
920920
}
921921

0 commit comments

Comments
 (0)