Skip to content

Commit

Permalink
Upgrade clang format version to 18 in CI
Browse files Browse the repository at this point in the history
Lai-YT authored and leewei05 committed Jul 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9c7ee3a commit 8a64879
Showing 3 changed files with 56 additions and 49 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -13,9 +13,15 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install clang-tidy
run: |
sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main'
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -q -y clang-format-18
- name: coding convention
run: |
sudo apt-get install -q -y clang-format
export CLANG_FORMAT=clang-format-18
scripts/check-format.sh
tidy:
92 changes: 46 additions & 46 deletions include/visitor.hpp
Original file line number Diff line number Diff line change
@@ -69,52 +69,52 @@ class Visitor {
// This is to provide the fallback operation for all concrete classes derived
// from such abstract class.

virtual void Visit(CondMut<AstNode>&){};
virtual void Visit(CondMut<StmtNode>&){};
virtual void Visit(CondMut<ExprNode>&){};
virtual void Visit(CondMut<DeclStmtNode>&){};
virtual void Visit(CondMut<DeclNode>&){};
virtual void Visit(CondMut<DesNode>&){};
virtual void Visit(CondMut<VarDeclNode>&){};
virtual void Visit(CondMut<ArrDeclNode>&){};
virtual void Visit(CondMut<RecordDeclNode>&){};
virtual void Visit(CondMut<FieldNode>&){};
virtual void Visit(CondMut<RecordVarDeclNode>&){};
virtual void Visit(CondMut<ParamNode>&){};
virtual void Visit(CondMut<FuncDefNode>&){};
virtual void Visit(CondMut<LoopInitNode>&){};
virtual void Visit(CondMut<CompoundStmtNode>&){};
virtual void Visit(CondMut<ExternDeclNode>&){};
virtual void Visit(CondMut<TransUnitNode>&){};
virtual void Visit(CondMut<IfStmtNode>&){};
virtual void Visit(CondMut<WhileStmtNode>&){};
virtual void Visit(CondMut<ForStmtNode>&){};
virtual void Visit(CondMut<ReturnStmtNode>&){};
virtual void Visit(CondMut<GotoStmtNode>&){};
virtual void Visit(CondMut<BreakStmtNode>&){};
virtual void Visit(CondMut<ContinueStmtNode>&){};
virtual void Visit(CondMut<SwitchStmtNode>&){};
virtual void Visit(CondMut<LabeledStmtNode>&){};
virtual void Visit(CondMut<IdLabeledStmtNode>&){};
virtual void Visit(CondMut<CaseStmtNode>&){};
virtual void Visit(CondMut<DefaultStmtNode>&){};
virtual void Visit(CondMut<ExprStmtNode>&){};
virtual void Visit(CondMut<InitExprNode>&){};
virtual void Visit(CondMut<ArrDesNode>&){};
virtual void Visit(CondMut<IdDesNode>&){};
virtual void Visit(CondMut<NullExprNode>&){};
virtual void Visit(CondMut<IdExprNode>&){};
virtual void Visit(CondMut<IntConstExprNode>&){};
virtual void Visit(CondMut<ArgExprNode>&){};
virtual void Visit(CondMut<ArrSubExprNode>&){};
virtual void Visit(CondMut<CondExprNode>&){};
virtual void Visit(CondMut<FuncCallExprNode>&){};
virtual void Visit(CondMut<PostfixArithExprNode>&){};
virtual void Visit(CondMut<RecordMemExprNode>&){};
virtual void Visit(CondMut<UnaryExprNode>&){};
virtual void Visit(CondMut<BinaryExprNode>&){};
virtual void Visit(CondMut<AssignmentExprNode>&){};
virtual void Visit(CondMut<SimpleAssignmentExprNode>&){};
virtual void Visit(CondMut<AstNode>&) {};
virtual void Visit(CondMut<StmtNode>&) {};
virtual void Visit(CondMut<ExprNode>&) {};
virtual void Visit(CondMut<DeclStmtNode>&) {};
virtual void Visit(CondMut<DeclNode>&) {};
virtual void Visit(CondMut<DesNode>&) {};
virtual void Visit(CondMut<VarDeclNode>&) {};
virtual void Visit(CondMut<ArrDeclNode>&) {};
virtual void Visit(CondMut<RecordDeclNode>&) {};
virtual void Visit(CondMut<FieldNode>&) {};
virtual void Visit(CondMut<RecordVarDeclNode>&) {};
virtual void Visit(CondMut<ParamNode>&) {};
virtual void Visit(CondMut<FuncDefNode>&) {};
virtual void Visit(CondMut<LoopInitNode>&) {};
virtual void Visit(CondMut<CompoundStmtNode>&) {};
virtual void Visit(CondMut<ExternDeclNode>&) {};
virtual void Visit(CondMut<TransUnitNode>&) {};
virtual void Visit(CondMut<IfStmtNode>&) {};
virtual void Visit(CondMut<WhileStmtNode>&) {};
virtual void Visit(CondMut<ForStmtNode>&) {};
virtual void Visit(CondMut<ReturnStmtNode>&) {};
virtual void Visit(CondMut<GotoStmtNode>&) {};
virtual void Visit(CondMut<BreakStmtNode>&) {};
virtual void Visit(CondMut<ContinueStmtNode>&) {};
virtual void Visit(CondMut<SwitchStmtNode>&) {};
virtual void Visit(CondMut<LabeledStmtNode>&) {};
virtual void Visit(CondMut<IdLabeledStmtNode>&) {};
virtual void Visit(CondMut<CaseStmtNode>&) {};
virtual void Visit(CondMut<DefaultStmtNode>&) {};
virtual void Visit(CondMut<ExprStmtNode>&) {};
virtual void Visit(CondMut<InitExprNode>&) {};
virtual void Visit(CondMut<ArrDesNode>&) {};
virtual void Visit(CondMut<IdDesNode>&) {};
virtual void Visit(CondMut<NullExprNode>&) {};
virtual void Visit(CondMut<IdExprNode>&) {};
virtual void Visit(CondMut<IntConstExprNode>&) {};
virtual void Visit(CondMut<ArgExprNode>&) {};
virtual void Visit(CondMut<ArrSubExprNode>&) {};
virtual void Visit(CondMut<CondExprNode>&) {};
virtual void Visit(CondMut<FuncCallExprNode>&) {};
virtual void Visit(CondMut<PostfixArithExprNode>&) {};
virtual void Visit(CondMut<RecordMemExprNode>&) {};
virtual void Visit(CondMut<UnaryExprNode>&) {};
virtual void Visit(CondMut<BinaryExprNode>&) {};
virtual void Visit(CondMut<AssignmentExprNode>&) {};
virtual void Visit(CondMut<SimpleAssignmentExprNode>&) {};

/// @note To make the class abstract. But still we have to provide an
/// out-of-class definition for the destructor.
5 changes: 3 additions & 2 deletions scripts/check-format.sh
Original file line number Diff line number Diff line change
@@ -5,14 +5,15 @@
# otherwise, exits with the count of violations.
#

CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
SOURCES=$(find "$(git rev-parse --show-toplevel)" | grep -E "\.(c|h)pp\$")

total_violation_count=0
for file in $SOURCES; do
# reports violations
clang-format --dry-run "$file"
$CLANG_FORMAT --dry-run "$file"
# count violations
violation_count=$(clang-format --output-replacements-xml "$file" | grep -E -c "</replacement>")
violation_count=$($CLANG_FORMAT --output-replacements-xml "$file" | grep -E -c "</replacement>")
total_violation_count=$((total_violation_count + violation_count))
done
exit "$total_violation_count"

0 comments on commit 8a64879

Please sign in to comment.