Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial clang-tidy linting #29

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 38 additions & 23 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,48 @@ UseTab: Never
ColumnLimit: 80
ReflowComments: true
AccessModifierOffset: -4
SortIncludes: Never
UseCRLF: false

BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
AfterCaseLabel: true
AfterClass: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakInheritanceList: AfterComma
SeparateDefinitionBlocks: Always
AlwaysBreakTemplateDeclarations: Yes

SortIncludes: true
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"radiant/TotallyRad.h"'
Priority: 0
SortPriority: 0
- Regex: '^"radiant/.*\.h"'
Priority: 0
SortPriority: 1
- Regex: '^".*\.h"$'
Priority: 1
SortPriority: 2
- Regex: '^<.*>$'
Priority: 1
SortPriority: 3

BinPackArguments: false
BinPackParameters: false
AllowAllArgumentsOnNextLine: false
Expand All @@ -41,13 +56,13 @@ ReferenceAlignment: Left
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Right
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
Enabled: true
AcrossEmptyLines: false
AcrossComments: true
AlignEscapedNewlines: Right
AlignOperands: Align
IndentCaseBlocks: false
Expand Down
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
Checks: '-*'
WarningsAsErrors: '*'
2 changes: 2 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ jobs:
cache-dependency-path: ./tools/rad/setup.py
- name: Install Rad Tool
run: pip install -e ./tools/rad
- name: Initialize
run: rad init
- name: Run Linter
run: rad lint --all-files --skip no-commit-to-branch
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repos:
rev: 9a9bbc00895bbdb7670231c2565d4f1309c42905 # v1.3.5
hooks:
- id: clang-format
args: [-i]
- repo: https://github.com/psf/black
rev: ec91a2be3c44d88e1a3960a4937ad6ed3b63464e # 23.12.1
hooks:
Expand All @@ -29,3 +30,12 @@ repos:
language: system
types: [python]
require_serial: true
- repo: local
hooks:
- id: clang-tidy
name: clang-tidy
entry: rad
args: [lint, --clang-tidy]
language: python
files: \.(c|cc|cpp|cxx|h|hh|hpp|hxx|)$
require_serial: true
6 changes: 6 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")

package(default_visibility = ["//visibility:public"])

exports_files([
"AUTHORS",
"LICENSE",
])

refresh_compile_commands(
name = "refresh_compile_commands",
)

config_setting(
name = "msvc",
flag_values = {
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
commit = "a14ad3a64e7bf398ab48105aaa0348e032ac87f8",
commit = "4f28899228fb3ad0126897876f147ca15026151e",
)

# Windows - allows building with the EWDK, must set EWDKDIR environment variable
Expand Down
8 changes: 8 additions & 0 deletions radiant/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
InheritParentConfig: true
Checks:
- misc-include-cleaner
- llvm-include-order
- performance-*
- portability-*
- -performance-enum-size
3 changes: 0 additions & 3 deletions radiant/Algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@

#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"
#include "radiant/Utility.h"
#include "radiant/TotallyRad.h"

namespace rad
Expand Down
3 changes: 3 additions & 0 deletions radiant/Atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"
#include "radiant/detail/AtomicIntrinsics.h"

#include <stddef.h>

namespace rad
{

Expand Down
1 change: 0 additions & 1 deletion radiant/EmptyOptimizedPair.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/Utility.h"

namespace rad
Expand Down
4 changes: 3 additions & 1 deletion radiant/Integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// limitations under the License.

#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"
#include "radiant/Res.h"
#include "radiant/TypeTraits.h"

#include <stdint.h>

namespace rad
{
Expand Down
4 changes: 3 additions & 1 deletion radiant/Iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"
#include "radiant/Utility.h"

#include <stddef.h>

namespace rad
{

Expand Down
2 changes: 2 additions & 0 deletions radiant/Res.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "radiant/TotallyRad.h"
#include "radiant/Result.h"

#include <stdint.h>

namespace rad
{

Expand Down
4 changes: 4 additions & 0 deletions radiant/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"
#include "radiant/TypeWrapper.h"

#include <stdint.h>
#if RAD_ENABLE_STD
#include <initializer_list>
#endif

namespace rad
{
Expand Down
3 changes: 2 additions & 1 deletion radiant/ScopeExit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/Utility.h"
#include "radiant/TypeTraits.h"
#include "radiant/Utility.h" // NOLINT(misc-include-cleaner)

namespace rad
{
Expand Down
8 changes: 6 additions & 2 deletions radiant/SharedPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/Memory.h"
#include "radiant/Atomic.h"
#include "radiant/Locks.h"
#include "radiant/EmptyOptimizedPair.h"
#include "radiant/Locks.h" // NOLINT(misc-include-cleaner)
#include "radiant/Memory.h" // NOLINT(misc-include-cleaner)
#include "radiant/TypeTraits.h"
#include "radiant/detail/AtomicIntrinsics.h"

#include <stdint.h>

namespace rad
{
Expand Down
6 changes: 5 additions & 1 deletion radiant/Span.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/Iterator.h"
#include "radiant/Byte.h"
#include "radiant/Iterator.h"
#include "radiant/TypeTraits.h"

#include <stddef.h>
#include <stdint.h>

namespace rad
{
Expand Down
15 changes: 12 additions & 3 deletions radiant/TotallyRad.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,19 @@ static_assert(!(RAD_WINDOWS && RAD_MACOS), "env invalid os");

#define RAD_UNUSED(x) ((void)x)

#include <stdint.h>
#ifdef RAD_MSC_VERSION
// MSVC does not seem to have something like __has_builtin, but
// also seems to define a superset of what the other compilers do
// in terms of intrinsics
#define RAD_HAS_BUILTIN(v) 1
#else
#define RAD_HAS_BUILTIN(v) __has_builtin(v)
#endif

#if RAD_WINDOWS && RAD_KERNEL_MODE
#include <wdm.h>
#if RAD_WINDOWS
#define RAD_YIELD_PROCESSOR() YieldProcessor()
#else
#define RAD_YIELD_PROCESSOR() sched_yield()
#endif

#define RAD_CONCAT_INNER(x, y) x##y
Expand Down
2 changes: 2 additions & 0 deletions radiant/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "radiant/TotallyRad.h"
#include "radiant/detail/StdTypeTraits.h"

#include <stdint.h>

namespace rad
{

Expand Down
1 change: 1 addition & 0 deletions radiant/TypeWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"
#include "radiant/Utility.h"

#if RAD_ENABLE_STD
Expand Down
3 changes: 2 additions & 1 deletion radiant/UniqueResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/Utility.h"
#include "radiant/TypeTraits.h"
#include "radiant/Utility.h" // NOLINT(misc-include-cleaner)

namespace rad
{
Expand Down
2 changes: 2 additions & 0 deletions radiant/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "radiant/TotallyRad.h"
#include "radiant/TypeTraits.h"

#include <stdint.h>

namespace rad
{

Expand Down
9 changes: 8 additions & 1 deletion radiant/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
#pragma once

#include "radiant/TotallyRad.h"
#include "radiant/Memory.h"
#include "radiant/EmptyOptimizedPair.h"
#include "radiant/Memory.h"
#include "radiant/Res.h"
#include "radiant/Span.h"
#include "radiant/detail/VectorOperations.h"

#include <stdint.h>
#if RAD_ENABLE_STD
#include <initializer_list>
#endif

namespace rad
{

Expand Down
Loading
Loading