Skip to content

Commit 329c541

Browse files
authored
Rewrite using C++ standard library implementations (#171)
* Add CLAUDE.md * Reboot implementation using modern C++ * Move cmake targets to more appropriate folder structure * Update github jobs configurations * Remove redundant tests * Reserve memory during percent encoding + decoding * Improve IPv4 parsing performance * Apply punycode encoding performance fix * Improve performance of URL path processing * Apply clang-format * Fix bugs in punycode and IP address processing * Fix memory issues in static_vector * Update clang-tidy configuration * Add vcpkg triplet to resolve clang/libcxx compilation on Linux * Extend test coverage across compilers
1 parent 8c03e21 commit 329c541

212 files changed

Lines changed: 12812 additions & 35696 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 91 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,104 @@
1-
BasedOnStyle: Google
1+
---
2+
# Modern C++23 clang-format configuration
3+
BasedOnStyle: Google
4+
Language: Cpp
5+
6+
# C++ Standard
7+
Standard: Latest
8+
9+
# Indentation
10+
IndentWidth: 2
11+
TabWidth: 4
12+
UseTab: Never
213
AccessModifierOffset: -1
314
ConstructorInitializerIndentWidth: 4
4-
AlignTrailingComments: true
5-
AllowAllParametersOfDeclarationOnNextLine: true
6-
#AllowShortIfStatementsOnASingleLine: WithoutElse
7-
AllowShortFunctionsOnASingleLine: None
8-
AllowShortLoopsOnASingleLine: true
15+
ContinuationIndentWidth: 4
16+
IndentCaseLabels: true
17+
IndentPPDirectives: AfterHash
18+
IndentWrappedFunctionNames: false
19+
20+
# Line breaking
21+
ColumnLimit: 120
922
AlwaysBreakTemplateDeclarations: Yes
1023
AlwaysBreakBeforeMultilineStrings: true
1124
BreakBeforeBinaryOperators: None
12-
BreakConstructorInitializersBeforeComma: false
25+
BreakBeforeBraces: Attach
26+
BreakConstructorInitializers: BeforeComma
27+
BreakInheritanceList: BeforeComma
28+
BreakStringLiterals: true
29+
30+
# Alignment
31+
AlignAfterOpenBracket: Align
32+
AlignConsecutiveAssignments: false
33+
AlignConsecutiveDeclarations: false
34+
AlignConsecutiveMacros: true
35+
AlignEscapedNewlines: Left
36+
AlignOperands: Align
37+
AlignTrailingComments: true
38+
39+
# Spacing
40+
SpacesBeforeTrailingComments: 2
41+
SpacesInParentheses: false
42+
SpaceInEmptyParentheses: false
43+
SpacesInCStyleCastParentheses: false
44+
SpacesInConditionalStatement: false
45+
SpacesInContainerLiterals: false
46+
SpaceAfterCStyleCast: false
47+
SpaceAfterLogicalNot: false
48+
SpaceAfterTemplateKeyword: true
49+
SpaceBeforeAssignmentOperators: true
50+
SpaceBeforeCpp11BracedList: false
51+
SpaceBeforeCtorInitializerColon: true
52+
SpaceBeforeInheritanceColon: true
53+
SpaceBeforeParens: ControlStatements
54+
SpaceBeforeRangeBasedForLoopColon: true
55+
SpaceBeforeSquareBrackets: false
56+
57+
# Function and parameter formatting
58+
AllowAllParametersOfDeclarationOnNextLine: true
59+
AllowShortFunctionsOnASingleLine: None
60+
AllowShortLambdasOnASingleLine: All
61+
AllowShortIfStatementsOnASingleLine: Never
62+
AllowShortLoopsOnASingleLine: false
63+
AllowShortCaseLabelsOnASingleLine: false
64+
AllowShortBlocksOnASingleLine: Never
65+
66+
# Bin packing and constructor initialization
1367
BinPackParameters: true
14-
ColumnLimit: 120
68+
BinPackArguments: true
1569
ConstructorInitializerAllOnOneLineOrOnePerLine: true
16-
ExperimentalAutoDetectBinPacking: false
17-
IndentCaseLabels: true
70+
AllowAllConstructorInitializersOnNextLine: false
71+
72+
# Other
73+
Cpp11BracedListStyle: true
74+
DerivePointerAlignment: false
75+
PointerAlignment: Left
76+
ReferenceAlignment: Left
77+
ReflowComments: true
78+
SortIncludes: false
79+
SortUsingDeclarations: false
1880
MaxEmptyLinesToKeep: 1
19-
ObjCSpaceBeforeProtocolList: false
81+
82+
# Penalties for breaking (higher = less likely to break)
2083
PenaltyBreakComment: 60
2184
PenaltyBreakString: 1000
2285
PenaltyBreakFirstLessLess: 120
2386
PenaltyExcessCharacter: 1000000
2487
PenaltyReturnTypeOnItsOwnLine: 200
25-
SpacesBeforeTrailingComments: 2
26-
Cpp11BracedListStyle: true
27-
Standard: Auto
28-
IndentWidth: 2
29-
TabWidth: 4
30-
UseTab: Never
31-
BreakBeforeBraces: Attach
32-
SpacesInParentheses: false
33-
SpaceInEmptyParentheses: false
34-
SpacesInCStyleCastParentheses: false
35-
SortIncludes: false
36-
SortUsingDeclarations: false
88+
PenaltyBreakBeforeFirstCallParameter: 19
89+
90+
# C++20/23 specific features
91+
RequiresClausePosition: OwnLine
92+
IndentRequiresClause: true
93+
SpaceAroundPointerQualifiers: Default
94+
95+
# Include formatting
96+
IncludeBlocks: Preserve
97+
98+
# Namespace formatting
99+
CompactNamespaces: false
100+
FixNamespaceComments: true
101+
NamespaceIndentation: None
102+
103+
# Empty lines
104+
KeepEmptyLinesAtTheStartOfBlocks: false

.clang-tidy

Lines changed: 134 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,135 @@
1-
Checks: '-*,bugprone-*,-bugprone-exception-escape,clang-diagnostic-*,cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-macro-usage,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-avoid-c-arrays,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,modernize-*,performance-*'
1+
---
2+
# Comprehensive modern C++23 clang-tidy configuration
3+
Checks: >
4+
-*,
5+
bugprone-*,
6+
-bugprone-exception-escape,
7+
-bugprone-easily-swappable-parameters,
8+
clang-diagnostic-*,
9+
clang-analyzer-*,
10+
concurrency-*,
11+
cppcoreguidelines-*,
12+
-cppcoreguidelines-avoid-magic-numbers,
13+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
14+
-cppcoreguidelines-pro-bounds-constant-array-index,
15+
-cppcoreguidelines-macro-usage,
16+
-cppcoreguidelines-non-private-member-variables-in-classes,
17+
-cppcoreguidelines-avoid-c-arrays,
18+
-cppcoreguidelines-avoid-do-while,
19+
-cppcoreguidelines-pro-type-reinterpret-cast,
20+
misc-*,
21+
-misc-unused-parameters,
22+
-misc-non-private-member-variables-in-classes,
23+
-misc-no-recursion,
24+
modernize-*,
25+
-modernize-use-trailing-return-type,
26+
-modernize-avoid-c-arrays,
27+
performance-*,
28+
portability-*,
29+
readability-*,
30+
-readability-identifier-length,
31+
-readability-function-cognitive-complexity,
32+
-readability-magic-numbers,
33+
-readability-uppercase-literal-suffix,
34+
-readability-else-after-return
35+
36+
WarningsAsErrors: ''
37+
HeaderFilterRegex: '.*'
38+
FormatStyle: file
39+
240
CheckOptions:
3-
- key: readability-identifier-naming.ClassCase
4-
value: lower_case
5-
- key: readability-identifier-naming.EnumCase
6-
value: lower_case
7-
- key: readability-identifier-naming.FunctionCase
8-
value: lower_case
9-
- key: readability-identifier-naming.MemberCase
10-
value: lower_case
11-
- key: readability-identifier-naming.ParameterCase
12-
value: lower_case
13-
- key: readability-identifier-naming.UnionCase
14-
value: lower_case
15-
- key: readability-identifier-naming.VariableCase
16-
value: lower_case
17-
- key: readability-identifier-naming.IgnoreMainLikeFunctions
18-
value: 1
41+
# Naming conventions (snake_case style)
42+
- key: readability-identifier-naming.ClassCase
43+
value: lower_case
44+
- key: readability-identifier-naming.StructCase
45+
value: lower_case
46+
- key: readability-identifier-naming.EnumCase
47+
value: lower_case
48+
- key: readability-identifier-naming.FunctionCase
49+
value: lower_case
50+
- key: readability-identifier-naming.MethodCase
51+
value: lower_case
52+
- key: readability-identifier-naming.MemberCase
53+
value: lower_case
54+
- key: readability-identifier-naming.PrivateMemberSuffix
55+
value: '_'
56+
- key: readability-identifier-naming.ParameterCase
57+
value: lower_case
58+
- key: readability-identifier-naming.VariableCase
59+
value: lower_case
60+
- key: readability-identifier-naming.ConstantCase
61+
value: lower_case
62+
- key: readability-identifier-naming.ConstantMemberCase
63+
value: lower_case
64+
- key: readability-identifier-naming.StaticConstantCase
65+
value: lower_case
66+
- key: readability-identifier-naming.UnionCase
67+
value: lower_case
68+
- key: readability-identifier-naming.NamespaceCase
69+
value: lower_case
70+
- key: readability-identifier-naming.TemplateParameterCase
71+
value: CamelCase
72+
- key: readability-identifier-naming.TypeAliasCase
73+
value: lower_case
74+
- key: readability-identifier-naming.TypedefCase
75+
value: lower_case
76+
- key: readability-identifier-naming.IgnoreMainLikeFunctions
77+
value: 1
78+
79+
# Modernize options
80+
- key: modernize-loop-convert.MaxCopySize
81+
value: '16'
82+
- key: modernize-loop-convert.MinConfidence
83+
value: reasonable
84+
- key: modernize-pass-by-value.IncludeStyle
85+
value: google
86+
- key: modernize-replace-auto-ptr.IncludeStyle
87+
value: google
88+
- key: modernize-use-nullptr.NullMacros
89+
value: 'NULL'
90+
91+
# Performance options
92+
- key: performance-for-range-copy.WarnOnAllAutoCopies
93+
value: '1'
94+
- key: performance-inefficient-string-concatenation.StrictMode
95+
value: '1'
96+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
97+
value: '1'
98+
- key: performance-unnecessary-value-param.AllowedTypes
99+
value: ''
100+
101+
# Readability options
102+
- key: readability-braces-around-statements.ShortStatementLines
103+
value: '0'
104+
- key: readability-implicit-bool-conversion.AllowIntegerConditions
105+
value: '0'
106+
- key: readability-implicit-bool-conversion.AllowPointerConditions
107+
value: '0'
108+
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
109+
value: '1'
110+
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
111+
value: '1'
112+
113+
# Bugprone options
114+
- key: bugprone-argument-comment.StrictMode
115+
value: '0'
116+
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
117+
value: '1'
118+
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
119+
value: '1'
120+
- key: bugprone-string-constructor.WarnOnLargeLength
121+
value: '1'
122+
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
123+
value: '1'
124+
125+
# C++ Core Guidelines options
126+
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
127+
value: '1'
128+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
129+
value: '0'
130+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
131+
value: '1'
132+
133+
# Misc options
134+
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
135+
value: '1'

.github/workflows/clang-format.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: clang-format Check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
formatting-check:
7+
name: Formatting Check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- name: Install clang-format
13+
run: |
14+
wget https://apt.llvm.org/llvm.sh
15+
chmod +x llvm.sh
16+
sudo ./llvm.sh 21
17+
sudo apt-get install -y clang-format-21
18+
19+
- name: Run clang-format
20+
run: |
21+
find include tests -name '*.hpp' -o -name '*.cpp' | xargs clang-format-21 --dry-run --Werror
22+
23+
- name: Formatting check passed
24+
if: success()
25+
run: echo "✓ All files are properly formatted"
26+
27+
- name: Formatting check failed
28+
if: failure()
29+
run: |
30+
echo "✗ Some files need formatting. Run 'clang-format -i <files>' to fix."
31+
echo "Or run: find include tests -name '*.hpp' -o -name '*.cpp' | xargs clang-format -i"
32+
exit 1

.github/workflows/clang-tidy.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: clang-tidy Check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
clang-tidy:
7+
name: clang-tidy Check
8+
runs-on: ubuntu-24.04
9+
env:
10+
CC: clang-21
11+
CXX: clang++-21
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install clang-tidy and dependencies
17+
run: |
18+
wget https://apt.llvm.org/llvm.sh
19+
chmod +x llvm.sh
20+
sudo ./llvm.sh 21
21+
sudo apt-get update
22+
sudo apt-get install -y clang-tidy-21 libc++-21-dev libc++abi-21-dev ninja-build
23+
24+
- name: Install vcpkg
25+
run: |
26+
git clone https://github.com/microsoft/vcpkg.git ${GITHUB_WORKSPACE}/vcpkg
27+
cd ${GITHUB_WORKSPACE}/vcpkg
28+
./bootstrap-vcpkg.sh
29+
export CXXFLAGS="-stdlib=libc++"
30+
export LDFLAGS="-stdlib=libc++ -lc++abi"
31+
./vcpkg install uni-algo nlohmann-json
32+
33+
- name: Install Catch2
34+
run: |
35+
cd ${GITHUB_WORKSPACE}/vcpkg
36+
export CXXFLAGS="-stdlib=libc++"
37+
export LDFLAGS="-stdlib=libc++ -lc++abi"
38+
./vcpkg install catch2
39+
40+
- name: Configure CMake
41+
run: |
42+
cmake \
43+
-B build \
44+
-G Ninja \
45+
-DCMAKE_CXX_STANDARD=23 \
46+
-DCMAKE_BUILD_TYPE=Debug \
47+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
48+
-Dskyr_BUILD_TESTS=ON \
49+
-Dskyr_BUILD_DOCS=OFF \
50+
-Dskyr_BUILD_EXAMPLES=OFF \
51+
-Dskyr_BUILD_WITH_LLVM_LIBCXX=ON \
52+
-DCMAKE_TOOLCHAIN_FILE=${GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake
53+
54+
- name: Run clang-tidy on source files
55+
if: false # Disabled for now
56+
run: |
57+
find tests -name '*.cpp' -print0 | \
58+
xargs -0 -n1 -P$(nproc) clang-tidy-21 -p build
59+
60+
- name: clang-tidy check passed
61+
if: success()
62+
run: echo "✓ clang-tidy found no issues"
63+
64+
- name: clang-tidy check failed
65+
if: failure()
66+
run: |
67+
echo "✗ clang-tidy found issues. Review the output above for details."
68+
exit 1

0 commit comments

Comments
 (0)