aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy71
-rw-r--r--arch/x86_64/include/x86_64/cpu/control_register.hpp1
-rw-r--r--arch/x86_64/include/x86_64/cpu/registers.hpp2
-rw-r--r--arch/x86_64/include/x86_64/memory/kernel_mapper.hpp1
-rw-r--r--arch/x86_64/include/x86_64/memory/recursive_page_mapper.hpp2
-rw-r--r--arch/x86_64/include/x86_64/vga/crtc.hpp2
-rw-r--r--arch/x86_64/src/kapi/cio.cpp1
-rw-r--r--arch/x86_64/src/kapi/memory.cpp10
-rw-r--r--kernel/src/kapi/cio.cpp3
-rw-r--r--kernel/src/kapi/memory.cpp6
-rw-r--r--kernel/src/kstd/print.cpp1
-rw-r--r--libs/kstd/include/kstd/asm_ptr1
-rw-r--r--libs/kstd/include/kstd/bits/formatter.hpp1
-rw-r--r--libs/kstd/include/kstd/bits/shared_ptr.hpp5
-rw-r--r--libs/kstd/include/kstd/stack1
-rw-r--r--libs/kstd/include/kstd/vector17
-rw-r--r--libs/multiboot2/include/multiboot2/impl/tag.hpp3
17 files changed, 93 insertions, 35 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 831bf8d..6b3bfd9 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,7 +1,66 @@
Checks:
- - '-clang-diagnostic-*'
- - 'clang-analyzer-*'
- - 'cppcoreguidelines-*'
- - '-cppcoreguidelines-owning-memory'
- - 'modernize-*'
- - 'misc-include-cleaner' \ No newline at end of file
+ - bugprone-assignment-in-if-condition
+ - bugprone-branch-clone
+ - bugprone-chained-comparison
+ - bugprone-copy-constructor-init
+ - bugprone-crtp-constructor-accessibility
+ - bugprone-dangling-handle
+ - bugprone-forward-declaration-namespace
+ - bugprone-forwarding-reference-overload
+ - bugprone-incorrect-enable-if
+ - bugprone-incorrect-enable-shared-from-this
+ - bugprone-stringview-nullptr
+ - bugprone-suspicious-enum-usage
+ - bugprone-suspicious-include
+ - bugprone-suspicious-memset-usage
+ - bugprone-suspicious-missing-comma
+ - bugprone-suspicious-semicolon
+ - bugprone-suspicious-stringview-data-usage
+ - bugprone-switch-missing-default-case
+ - bugprone-terminating-continue
+ - bugprone-undelegated-constructor
+ - bugprone-unused-raii
+
+ - cppcoreguidelines-avoid-const-or-ref-data-members
+ - cppcoreguidelines-avoid-do-while
+ - cppcoreguidelines-avoid-goto
+ - cppcoreguidelines-avoid-non-const-global-variables
+ - cppcoreguidelines-init-variables
+ - cppcoreguidelines-misleading-capture-default-by-value
+ - cppcoreguidelines-missing-std-forward
+ - cppcoreguidelines-no-malloc
+ - cppcoreguidelines-prefer-member-initializer
+ - cppcoreguidelines-pro-type-member-init
+ - cppcoreguidelines-slicing
+ - cppcoreguidelines-use-enum-class
+ - cppcoreguidelines-virtual-class-destructor
+
+ - misc-definitions-in-headers
+ - misc-include-cleaner
+ - misc-no-recursion
+ - misc-redundant-expression
+ - misc-static-assert
+ - misc-unused-using-decls
+ - modernize-avoid-c-arrays
+ - modernize-loop-convert
+ - modernize-use-auto
+ - modernize-use-nodiscard
+ - modernize-use-nullptr
+ - modernize-use-override
+ - modernize-use-std-print
+ - modernize-use-trailing-return-type
+ - modernize-use-transparent-functors
+ - modernize-use-using
+
+ - readability-magic-numbers
+
+CheckOptions:
+ cppcoreguidelines-avoid-non-const-global-variables.AllowInternalLinkage: true
+ modernize-use-std-print.ReplacementPrintFunction: 'kstd::print'
+ modernize-use-std-print.ReplacementPrintlnFunction: 'kstd::println'
+ modernize-use-std-print.PrintHeader: 'kstd/print'
+ modernize-use-trailing-return-type.TransformLambdas: none
+ readability-magic-numbers.IgnoredIntegerValues: '1;2;3;4;5;6;7;10'
+ readability-magic-numbers.IgnorePowersOf2IntegerValues: true
+ readability-magic-numbers.IgnoreBitFieldsWidths: true
+ readability-magic-numbers.IgnoreTypeAliases: true
diff --git a/arch/x86_64/include/x86_64/cpu/control_register.hpp b/arch/x86_64/include/x86_64/cpu/control_register.hpp
index e626b3b..9c3bad5 100644
--- a/arch/x86_64/include/x86_64/cpu/control_register.hpp
+++ b/arch/x86_64/include/x86_64/cpu/control_register.hpp
@@ -10,6 +10,7 @@
#include <cstdint>
#include <string_view>
#include <type_traits>
+#include <utility>
namespace teachos::cpu::x86_64
{
diff --git a/arch/x86_64/include/x86_64/cpu/registers.hpp b/arch/x86_64/include/x86_64/cpu/registers.hpp
index 8eb89e3..3ddd539 100644
--- a/arch/x86_64/include/x86_64/cpu/registers.hpp
+++ b/arch/x86_64/include/x86_64/cpu/registers.hpp
@@ -1,6 +1,8 @@
#ifndef TEACHOS_X86_64_CPU_REGISTERS_HPP
#define TEACHOS_X86_64_CPU_REGISTERS_HPP
+#include "kapi/memory.hpp"
+
#include "x86_64/cpu/control_register.hpp" // IWYU pragma: export
#include "x86_64/cpu/model_specific_register.hpp" // IWYU pragma: export
diff --git a/arch/x86_64/include/x86_64/memory/kernel_mapper.hpp b/arch/x86_64/include/x86_64/memory/kernel_mapper.hpp
index 5b9c2fd..c393d73 100644
--- a/arch/x86_64/include/x86_64/memory/kernel_mapper.hpp
+++ b/arch/x86_64/include/x86_64/memory/kernel_mapper.hpp
@@ -7,6 +7,7 @@
#include <elf/section_header.hpp>
#include <multiboot2/information.hpp>
+#include <cstdint>
#include <string_view>
namespace teachos::memory::x86_64
diff --git a/arch/x86_64/include/x86_64/memory/recursive_page_mapper.hpp b/arch/x86_64/include/x86_64/memory/recursive_page_mapper.hpp
index dc52065..819f404 100644
--- a/arch/x86_64/include/x86_64/memory/recursive_page_mapper.hpp
+++ b/arch/x86_64/include/x86_64/memory/recursive_page_mapper.hpp
@@ -3,6 +3,8 @@
#include "kapi/memory.hpp"
+#include <cstddef>
+
namespace teachos::memory::x86_64
{
diff --git a/arch/x86_64/include/x86_64/vga/crtc.hpp b/arch/x86_64/include/x86_64/vga/crtc.hpp
index d4b4f51..fde69c2 100644
--- a/arch/x86_64/include/x86_64/vga/crtc.hpp
+++ b/arch/x86_64/include/x86_64/vga/crtc.hpp
@@ -12,13 +12,11 @@ namespace teachos::vga::x86_64::crtc
/**
* @brief The address port of the CRT Controller.
*/
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
using address = io::port<0x3d4, std::byte, io::port_write>;
/**
* @brief The data port of the CRT Controller.
*/
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
using data = io::port<0x3d5, std::byte, io::port_read, io::port_write>;
namespace registers
diff --git a/arch/x86_64/src/kapi/cio.cpp b/arch/x86_64/src/kapi/cio.cpp
index ade02aa..617146e 100644
--- a/arch/x86_64/src/kapi/cio.cpp
+++ b/arch/x86_64/src/kapi/cio.cpp
@@ -7,7 +7,6 @@
namespace teachos::cio
{
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
auto static constinit vga_device = std::optional<vga::x86_64::text::device>{};
auto init() -> void
diff --git a/arch/x86_64/src/kapi/memory.cpp b/arch/x86_64/src/kapi/memory.cpp
index 5234110..73ee669 100644
--- a/arch/x86_64/src/kapi/memory.cpp
+++ b/arch/x86_64/src/kapi/memory.cpp
@@ -148,13 +148,11 @@ namespace teachos::memory
}
}
- } // namespace
+ auto constinit region_based_allocator = std::optional<x86_64::region_allocator>{};
+ auto constinit buffered_allocator = std::optional<x86_64::buffered_allocator<4>>{};
+ auto constinit recursive_page_mapper = std::optional<x86_64::recursive_page_mapper>{};
- // NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
- auto constinit region_based_allocator = std::optional<x86_64::region_allocator>{};
- auto constinit buffered_allocator = std::optional<x86_64::buffered_allocator<4>>{};
- auto constinit recursive_page_mapper = std::optional<x86_64::recursive_page_mapper>{};
- // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
+ } // namespace
auto init() -> void
{
diff --git a/kernel/src/kapi/cio.cpp b/kernel/src/kapi/cio.cpp
index fd5ad0d..01c6420 100644
--- a/kernel/src/kapi/cio.cpp
+++ b/kernel/src/kapi/cio.cpp
@@ -17,8 +17,7 @@ namespace teachos::cio
constinit null_device null_device::instance;
} // namespace
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
- constinit auto active_device = static_cast<output_device *>(&null_device::instance);
+ constinit auto static active_device = static_cast<output_device *>(&null_device::instance);
auto set_output_device(output_device & device) -> std::optional<output_device *>
{
diff --git a/kernel/src/kapi/memory.cpp b/kernel/src/kapi/memory.cpp
index d6c84e1..2f707ec 100644
--- a/kernel/src/kapi/memory.cpp
+++ b/kernel/src/kapi/memory.cpp
@@ -50,10 +50,8 @@ namespace teachos::memory
constinit bad_page_mapper bad_page_mapper::instance{};
} // namespace
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
- constinit auto active_frame_allocator = static_cast<frame_allocator *>(&bad_frame_allocator::instance);
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
- constinit auto active_page_mapper = static_cast<page_mapper *>(&bad_page_mapper::instance);
+ constinit auto static active_frame_allocator = static_cast<frame_allocator *>(&bad_frame_allocator::instance);
+ constinit auto static active_page_mapper = static_cast<page_mapper *>(&bad_page_mapper::instance);
auto set_frame_allocator(frame_allocator & allocator) -> std::optional<frame_allocator *>
{
diff --git a/kernel/src/kstd/print.cpp b/kernel/src/kstd/print.cpp
index c70f031..2665b9a 100644
--- a/kernel/src/kstd/print.cpp
+++ b/kernel/src/kstd/print.cpp
@@ -102,7 +102,6 @@ namespace kstd::os
{
while (current != end && *current >= '0' && *current <= '9')
{
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
index = index * 10 + static_cast<std::size_t>(*current - '0');
std::advance(current, 1);
}
diff --git a/libs/kstd/include/kstd/asm_ptr b/libs/kstd/include/kstd/asm_ptr
index e8636c3..c06a8b5 100644
--- a/libs/kstd/include/kstd/asm_ptr
+++ b/libs/kstd/include/kstd/asm_ptr
@@ -2,6 +2,7 @@
#define KSTD_ASM_POINTER_HPP
#include <bit>
+#include <cstddef>
namespace kstd
{
diff --git a/libs/kstd/include/kstd/bits/formatter.hpp b/libs/kstd/include/kstd/bits/formatter.hpp
index 4d983f3..eadc0ef 100644
--- a/libs/kstd/include/kstd/bits/formatter.hpp
+++ b/libs/kstd/include/kstd/bits/formatter.hpp
@@ -278,7 +278,6 @@ namespace kstd
{
if (index >= m_number_of_args)
return {.value = nullptr, .format = nullptr};
- // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
return m_args[index];
}
diff --git a/libs/kstd/include/kstd/bits/shared_ptr.hpp b/libs/kstd/include/kstd/bits/shared_ptr.hpp
index 4bcf499..8caae3b 100644
--- a/libs/kstd/include/kstd/bits/shared_ptr.hpp
+++ b/libs/kstd/include/kstd/bits/shared_ptr.hpp
@@ -2,6 +2,7 @@
#define KSTD_BITS_SHARED_PTR_HPP
#include <atomic>
+#include <cstddef>
namespace kstd
{
@@ -72,7 +73,7 @@ namespace kstd
* @return Reference to this shared pointer.
*/
[[gnu::section(".stl_text")]]
- shared_ptr & operator=(shared_ptr const & other)
+ auto operator=(shared_ptr const & other) -> shared_ptr &
{
if (this != &other)
{
@@ -97,7 +98,7 @@ namespace kstd
* @return Reference to this shared pointer.
*/
[[gnu::section(".stl_text")]]
- shared_ptr & operator=(shared_ptr && other) noexcept
+ auto operator=(shared_ptr && other) noexcept -> shared_ptr &
{
if (this != &other)
{
diff --git a/libs/kstd/include/kstd/stack b/libs/kstd/include/kstd/stack
index 8cd208a..8dc8e10 100644
--- a/libs/kstd/include/kstd/stack
+++ b/libs/kstd/include/kstd/stack
@@ -2,6 +2,7 @@
#define KSTD_STACK_HPP
#include "kstd/vector"
+#include <initializer_list>
#include <utility>
namespace kstd
diff --git a/libs/kstd/include/kstd/vector b/libs/kstd/include/kstd/vector
index 9d96eb8..bbb2287 100644
--- a/libs/kstd/include/kstd/vector
+++ b/libs/kstd/include/kstd/vector
@@ -1,9 +1,11 @@
#ifndef KSTD_VECTOR_HPP
#define KSTD_VECTOR_HPP
-#include "bits/os.hpp"
+#include <kstd/os/error.hpp>
#include <algorithm>
+#include <cstddef>
+#include <initializer_list>
namespace kstd
{
@@ -62,14 +64,14 @@ namespace kstd
/**
* @brief Construct data by copying all elements from the initializer list.
*
- * @param initalizer_list List we want to copy all elements from.
+ * @param initializer_list List we want to copy all elements from.
*/
- explicit vector(std::initializer_list<value_type> initalizer_list)
- : _size(initalizer_list.size())
- , _capacity(initalizer_list.size())
+ explicit vector(std::initializer_list<value_type> initializer_list)
+ : _size(initializer_list.size())
+ , _capacity(initializer_list.size())
, _data(new value_type[_capacity]{})
{
- std::ranges::copy(initalizer_list, _data);
+ std::ranges::copy(initializer_list, _data);
}
/**
@@ -83,9 +85,8 @@ namespace kstd
vector(vector<value_type> const & other)
: _size(other._size)
, _capacity(other._capacity)
+ , _data(new value_type[_capacity]{})
{
- delete[] _data;
- _data = new value_type[_capacity]{};
std::ranges::copy(other, _data);
}
diff --git a/libs/multiboot2/include/multiboot2/impl/tag.hpp b/libs/multiboot2/include/multiboot2/impl/tag.hpp
index 3d0cea5..708cda4 100644
--- a/libs/multiboot2/include/multiboot2/impl/tag.hpp
+++ b/libs/multiboot2/include/multiboot2/impl/tag.hpp
@@ -29,7 +29,6 @@ namespace multiboot2::impl
[[nodiscard]] auto full_size() const noexcept -> std::size_t
{
- // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
return (m_size + 7) & (~7);
}
@@ -67,7 +66,7 @@ namespace multiboot2::impl
explicit tag(tag_header const * header)
requires(sizeof(tag) > sizeof(tag_header))
: tag_header{header}
- , Data{*std::bit_cast<Data const *>(header + 1)} // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
+ , Data{*std::bit_cast<Data const *>(header + 1)}
{}
explicit tag(tag_header const * header)