Skip to content

Commit 1ede684

Browse files
committed
add .clang-tidy and .clang-format
1 parent 480e902 commit 1ede684

File tree

3 files changed

+115
-3
lines changed

3 files changed

+115
-3
lines changed

.clang-format

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
AccessModifierOffset: 0
2+
AlignEscapedNewlinesLeft: true
3+
AlignTrailingComments: false
4+
AllowAllParametersOfDeclarationOnNextLine: false
5+
AllowShortFunctionsOnASingleLine: false
6+
AllowShortIfStatementsOnASingleLine: false
7+
AllowShortLoopsOnASingleLine: false
8+
AlwaysBreakBeforeMultilineStrings: false
9+
AlwaysBreakTemplateDeclarations: false
10+
BinPackParameters: false
11+
BreakBeforeBinaryOperators: false
12+
BreakBeforeTernaryOperators: false
13+
BreakConstructorInitializersBeforeComma: false
14+
15+
BreakBeforeBraces: Custom
16+
BraceWrapping:
17+
AfterClass: true
18+
AfterControlStatement: true
19+
AfterEnum: true
20+
AfterFunction: true
21+
AfterNamespace: true
22+
AfterStruct: true
23+
AfterUnion: true
24+
BeforeCatch: true
25+
BeforeElse: true
26+
IndentBraces: false
27+
28+
ColumnLimit: 0
29+
CommentPragmas: ''
30+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
31+
ConstructorInitializerIndentWidth: 0
32+
ContinuationIndentWidth: 0
33+
Cpp11BracedListStyle: true
34+
DerivePointerAlignment: false
35+
IndentCaseLabels: true
36+
IndentWidth: 4
37+
Language: Cpp
38+
MaxEmptyLinesToKeep: 2
39+
NamespaceIndentation: All
40+
PenaltyBreakBeforeFirstCallParameter: 100
41+
PenaltyBreakComment: 100
42+
PenaltyBreakFirstLessLess: 0
43+
PenaltyBreakString: 100
44+
PenaltyExcessCharacter: 1
45+
PenaltyReturnTypeOnItsOwnLine: 20
46+
SpaceAfterCStyleCast: false
47+
SpaceAfterTemplateKeyword: false
48+
SpaceBeforeAssignmentOperators: true
49+
SpaceBeforeParens: ControlStatements
50+
SpaceInEmptyParentheses: false
51+
SpacesBeforeTrailingComments: 1
52+
SpacesInAngles: false
53+
SpacesInCStyleCastParentheses: false
54+
SpacesInContainerLiterals: false
55+
SpacesInParentheses: false
56+
SpacesInSquareBrackets: false
57+
Standard: Cpp11
58+
TabWidth: 4
59+
UseTab: Never

.clang-tidy

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,cert-*,clang-analyzer-*,performance-*,readability-avoid-const-params-in-decls,readability-braces-around-statements,readability-delete-null-pointer,readability-implicit-bool-conversion,readability-inconsistent-declaration-parameter-name,readability-misleading-indentation,readability-misplaced-array-index,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-function-ptr-dereference,readability-simplify-boolean-expr'
3+
WarningsAsErrors: ''
4+
HeaderFilterRegex: ''
5+
AnalyzeTemporaryDtors: false
6+
FormatStyle: file
7+
User: tom
8+
CheckOptions:
9+
- key: cert-dcl59-cpp.HeaderFileExtensions
10+
value: h,hh,hpp,hxx
11+
- key: cert-err09-cpp.CheckThrowTemporaries
12+
value: '1'
13+
- key: cert-err61-cpp.CheckThrowTemporaries
14+
value: '1'
15+
- key: cert-oop11-cpp.IncludeStyle
16+
value: llvm
17+
- key: google-readability-braces-around-statements.ShortStatementLines
18+
value: '1'
19+
- key: google-readability-function-size.StatementThreshold
20+
value: '800'
21+
- key: google-readability-namespace-comments.ShortNamespaceLines
22+
value: '10'
23+
- key: google-readability-namespace-comments.SpacesBeforeComments
24+
value: '2'
25+
- key: modernize-loop-convert.MaxCopySize
26+
value: '16'
27+
- key: modernize-loop-convert.MinConfidence
28+
value: reasonable
29+
- key: modernize-loop-convert.NamingStyle
30+
value: CamelCase
31+
- key: modernize-pass-by-value.IncludeStyle
32+
value: llvm
33+
- key: modernize-replace-auto-ptr.IncludeStyle
34+
value: llvm
35+
- key: modernize-use-nullptr.NullMacros
36+
value: 'NULL'
37+
- key: performance-faster-string-find.StringLikeClasses
38+
value: 'std::basic_string'
39+
- key: performance-for-range-copy.WarnOnAllAutoCopies
40+
value: '0'
41+
- key: performance-inefficient-string-concatenation.StrictMode
42+
value: '0'
43+
- key: performance-type-promotion-in-math-fn.IncludeStyle
44+
value: llvm
45+
- key: performance-unnecessary-value-param.IncludeStyle
46+
value: llvm
47+
- key: readability-braces-around-statements.ShortStatementLines
48+
value: '0'
49+
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
50+
value: '0'
51+
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
52+
value: '0'
53+
...
54+

CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ find_program(CLANG_TIDY
3737
if(CLANG_TIDY)
3838
# whenever clang-tidy is available, use it to automatically add braces after ever "make"
3939
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=-*,readability-braces-around-statements;-fix")
40-
# set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-style=file;-fix")
40+
# set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-fix")
4141
endif(CLANG_TIDY)
4242
endif(${CMAKE_VERSION} VERSION_GREATER "3.6.0")
4343

@@ -58,7 +58,6 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
5858
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g3 -O2 -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize -stdlib=${STDCXX}")
5959
endif()
6060

61-
6261
### setup project include dirs
6362
set(PROJECT_LOCAL_INCLUDE_DIRS
6463
${CMAKE_SOURCE_DIR}/include
@@ -399,7 +398,7 @@ add_subdirectory(test)
399398

400399
# Additional targets to perform clang-format/clang-tidy
401400
# Get all project files
402-
file(GLOB_RECURSE
401+
file(GLOB_RECURSE
403402
ALL_SOURCE_FILES
404403
LIST_DIRECTORIES false
405404
${CMAKE_SOURCE_DIR}/*.[chi]

0 commit comments

Comments
 (0)