-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 (lint): Added a clang format GitHub Action workflow + configuration
- Loading branch information
Showing
27 changed files
with
901 additions
and
738 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: LLVM | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignArrayOfStructures: None | ||
AlignConsecutiveAssignments: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
AlignFunctionPointers: false | ||
PadOperators: true | ||
AlignConsecutiveBitFields: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
AlignFunctionPointers: false | ||
PadOperators: false | ||
AlignConsecutiveDeclarations: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
AlignFunctionPointers: false | ||
PadOperators: false | ||
AlignConsecutiveMacros: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
AlignFunctionPointers: false | ||
PadOperators: false | ||
AlignConsecutiveShortCaseStatements: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCaseColons: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: Align | ||
AlignTrailingComments: | ||
Kind: Always | ||
OverEmptyLines: 0 | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowBreakBeforeNoexceptSpecifier: Never | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortCompoundRequirementOnASingleLine: true | ||
AllowShortEnumsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
AttributeMacros: | ||
- __capability | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BitFieldColonSpacing: Both | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: false | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterExternBlock: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakAdjacentStringLiterals: true | ||
BreakAfterAttributes: Leave | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakArrays: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeConceptDeclarations: Always | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInlineASMColon: OnlyMultiline | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakInheritanceList: BeforeColon | ||
BreakStringLiterals: true | ||
ColumnLimit: 80 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
EmptyLineAfterAccessModifier: Never | ||
EmptyLineBeforeAccessModifier: LogicalBlock | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IfMacros: | ||
- KJ_IF_MAYBE | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '.*' | ||
Priority: 1 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
IncludeIsMainRegex: '(Test)?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentAccessModifiers: false | ||
IndentCaseBlocks: false | ||
IndentCaseLabels: false | ||
IndentExternBlock: AfterExternBlock | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentRequiresClause: true | ||
IndentWidth: 2 | ||
IndentWrappedFunctionNames: false | ||
InsertBraces: false | ||
InsertNewlineAtEOF: false | ||
InsertTrailingCommas: None | ||
IntegerLiteralSeparator: | ||
Binary: 0 | ||
BinaryMinDigits: 0 | ||
Decimal: 0 | ||
DecimalMinDigits: 0 | ||
Hex: 0 | ||
HexMinDigits: 0 | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
KeepEmptyLinesAtEOF: false | ||
LambdaBodyIndentation: Signature | ||
LineEnding: DeriveLF | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCBreakBeforeNestedBlockParam: true | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PackConstructorInitializers: BinPack | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakOpenParenthesis: 0 | ||
PenaltyBreakScopeResolution: 500 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyIndentedWhitespace: 0 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Right | ||
PPIndentWidth: -1 | ||
QualifierAlignment: Leave | ||
ReferenceAlignment: Pointer | ||
ReflowComments: true | ||
RemoveBracesLLVM: false | ||
RemoveParentheses: Leave | ||
RemoveSemicolon: false | ||
RequiresClausePosition: OwnLine | ||
RequiresExpressionIndentation: OuterScope | ||
SeparateDefinitionBlocks: Leave | ||
ShortNamespaceLines: 1 | ||
SkipMacroDefinitionBody: false | ||
SortIncludes: CaseSensitive | ||
SortJavaStaticImport: Before | ||
SortUsingDeclarations: LexicographicNumeric | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceAroundPointerQualifiers: Default | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCaseColon: false | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeJsonColon: false | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeParensOptions: | ||
AfterControlStatements: true | ||
AfterForeachMacros: true | ||
AfterFunctionDefinitionName: false | ||
AfterFunctionDeclarationName: false | ||
AfterIfMacros: true | ||
AfterOverloadedOperator: false | ||
AfterPlacementOperator: true | ||
AfterRequiresInClause: false | ||
AfterRequiresInExpression: false | ||
BeforeNonEmptyParentheses: false | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceBeforeSquareBrackets: false | ||
SpaceInEmptyBlock: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: Never | ||
SpacesInContainerLiterals: true | ||
SpacesInLineCommentPrefix: | ||
Minimum: 1 | ||
Maximum: -1 | ||
SpacesInParens: Never | ||
SpacesInParensOptions: | ||
InCStyleCasts: false | ||
InConditionalStatements: false | ||
InEmptyParentheses: false | ||
Other: false | ||
SpacesInSquareBrackets: false | ||
Standard: Latest | ||
StatementAttributeLikeMacros: | ||
- Q_EMIT | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 8 | ||
UseTab: Never | ||
VerilogBreakBetweenInstancePorts: true | ||
WhitespaceSensitiveMacros: | ||
- BOOST_PP_STRINGIZE | ||
- CF_SWIFT_NAME | ||
- NS_SWIFT_NAME | ||
- PP_STRINGIZE | ||
- STRINGIZE | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.git/* | ||
.github/* | ||
.direnv/* | ||
build/* | ||
result/* | ||
tests/munit/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "build" | ||
name: build | ||
|
||
on: | ||
pull_request: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: lint | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Formatting Check | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
path: | ||
- "src" | ||
- "tests" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run clang-format style check for C/C++/Protobuf programs. | ||
uses: jidicula/clang-format-action@v4.13.0 | ||
with: | ||
clang-format-version: "18" | ||
check-path: ${{ matrix.path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
project (tinyhash-lib) | ||
project(tinyhash-lib) | ||
|
||
set (TINYHASH_NAME "tinyhash" CACHE INTERNAL "") | ||
set(TINYHASH_NAME "tinyhash" CACHE INTERNAL "") | ||
|
||
if (BUILD_STATIC) | ||
set (TINYHASH_LIB_TYPE STATIC) | ||
else () | ||
set (TINYHASH_LIB_TYPE SHARED) | ||
endif () | ||
set(TINYHASH_LIB_TYPE STATIC) | ||
else() | ||
set(TINYHASH_LIB_TYPE SHARED) | ||
endif() | ||
|
||
add_subdirectory(common) | ||
add_subdirectory(separate_chaining) | ||
add_subdirectory(open_addressing) | ||
|
||
set (TINYHASH_SRC | ||
tinyhash.c | ||
) | ||
set(TINYHASH_SRC tinyhash.c) | ||
|
||
set (TINYHASH_HEADERS | ||
tinyhash.h | ||
) | ||
set(TINYHASH_HEADERS tinyhash.h) | ||
|
||
add_library( | ||
${TINYHASH_NAME} ${TINYHASH_LIB_TYPE} | ||
add_library(${TINYHASH_NAME} ${TINYHASH_LIB_TYPE} | ||
${TINYHASH_SRC} | ||
$<TARGET_OBJECTS:common_objects> | ||
$<TARGET_OBJECTS:separate_chaining_objects> | ||
$<TARGET_OBJECTS:open_addressing_objects> | ||
) | ||
|
||
install (TARGETS ${TINYHASH_NAME} DESTINATION lib) | ||
install (FILES ${TINYHASH_HEADERS} DESTINATION include/${TINYHASH_NAME}) | ||
install(TARGETS ${TINYHASH_NAME} DESTINATION lib) | ||
install(FILES ${TINYHASH_HEADERS} DESTINATION include/${TINYHASH_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#include "key.h" | ||
|
||
#include <string.h> | ||
|
||
#include "key.h" | ||
#include "hash.h" | ||
|
||
th_key_t th_key_create(th_any_t data, size_t size) | ||
{ | ||
return (th_key_t) { | ||
.hash = th_hash(data, size), | ||
.size = size, | ||
.data = data, | ||
}; | ||
th_key_t th_key_create(th_any_t data, size_t size) { | ||
return (th_key_t){ | ||
.hash = th_hash(data, size), | ||
.size = size, | ||
.data = data, | ||
}; | ||
} | ||
|
||
bool th_key_is_equal(th_key_t *first, th_key_t *second) | ||
{ | ||
if (first->size != second->size) return false; | ||
bool th_key_is_equal(th_key_t *first, th_key_t *second) { | ||
if (first->size != second->size) | ||
return false; | ||
|
||
return memcmp(first->data, second->data, first->size) == 0; | ||
return memcmp(first->data, second->data, first->size) == 0; | ||
} |
Oops, something went wrong.