Skip to content

Commit

Permalink
[1_7] clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii authored Mar 8, 2024
1 parent 46e817c commit 19746e1
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 3 deletions.
14 changes: 14 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Standard: Cpp11
SpaceBeforeAssignmentOperators: false
SpaceBeforeParens: Always
AlwaysBreakAfterReturnType: TopLevelDefinitions
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
SpaceAfterCStyleCast: true
AllowShortFunctionsOnASingleLine: All
BreakBeforeBraces: Custom
BraceWrapping:
BeforeElse: true
PointerAlignment: Left
CommentPragmas: '^\\.+'
26 changes: 26 additions & 0 deletions .github/workflows/clang-format-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
pull_request:
branches: [ main ]
paths:
- 'Data/**'
- 'Kernel/**'
- 'tests/**'
- '.github/workflows/clang-format-linter.yml'
- 'xmake.lua'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.16.2
with:
source: '.'
exclude: './build ./xmake ./workflow ./github'
extensions: 'hpp,cpp'
clangFormatVersion: 16
style: file
2 changes: 1 addition & 1 deletion Data/Drd/drd_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#ifndef DRD_INFO_H
#define DRD_INFO_H

#include "path.hpp"
#include "rel_hashmap.hpp"
#include "tag_info.hpp"
#include "tree.hpp"
#include "tree_label.hpp"
#include "path.hpp"

class drd_info;
class drd_info_rep : concrete_struct {
Expand Down
21 changes: 21 additions & 0 deletions bin/format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env elvish

use platform

if (eq $platform:os windows) {
set paths = [
~/scoop/shims/
~/scoop/apps/llvm/current/bin
]
} elif (eq $platform:os linux) {
set paths = [
/usr/lib/llvm-16/bin
$E:HOME/bin
]
} else {
}

# pin clang-format to 16.0.x
clang-format --version
clang-format -i **/*cpp
clang-format -i **/*hpp
1 change: 1 addition & 0 deletions bin/format.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
elvish bin\format
2 changes: 1 addition & 1 deletion tests/Data/Scheme/block_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* \date 2024
*/

#include "moe_doctests.hpp"
#include "block.hpp"
#include "file.hpp"
#include "moe_doctests.hpp"
#include "string.hpp"
#include "tm_ostream.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/Kernel/Types/modification_test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "moe_doctests.hpp"
#include "modification.hpp"
#include "moe_doctests.hpp"

TEST_CASE ("test construct func") {
modification m1 (MOD_ASSIGN, path (), tree ());
Expand Down

0 comments on commit 19746e1

Please sign in to comment.