+7
-7
@@ -49,17 +49,17 @@ CheckOptions:
|
||||
|
||||
# Types
|
||||
- key: readability-identifier-naming.StructCase
|
||||
value: snake_case
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.ClassCase
|
||||
value: snake_case
|
||||
value: lower_case
|
||||
- key: readability-identifier-naming.EnumCase
|
||||
value: snake_case
|
||||
value: lower_case
|
||||
# - key: readability-identifier-naming.AbstractClassPrefix
|
||||
# value: I
|
||||
|
||||
# Functions
|
||||
- key: readability-identifier-naming.FunctionCase
|
||||
value: snake_case
|
||||
value: lower_case
|
||||
|
||||
# Variables
|
||||
- key: readability-identifier-naming.VariableCase
|
||||
@@ -81,13 +81,13 @@ CheckOptions:
|
||||
|
||||
# Static constexpr
|
||||
- key: readability-identifier-naming.StaticConstexprVariableCase
|
||||
value: aNy_CaSe
|
||||
value: aNy_CasE
|
||||
|
||||
# Constants
|
||||
- key: readability-identifier-naming.ConstantCase
|
||||
value: aNy_CaSe
|
||||
value: aNy_CasE
|
||||
- key: readability-identifier-naming.StaticConstantCase
|
||||
value: aNy_CaSe
|
||||
value: aNy_CasE
|
||||
- key: readability-identifier-naming.EnumConstantCase
|
||||
value: CamelCase
|
||||
- key: readability-identifier-naming.ScopedEnumConstantCase
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
CompileFlags:
|
||||
Add: [-std=c11, -Wall, -Werror, -Wpedantic]
|
||||
Add: [-std=c++17, -Wall, -Werror, -Wpedantic]
|
||||
|
||||
InlayHints:
|
||||
BlockEnd: true
|
||||
@@ -16,7 +16,7 @@ Hover:
|
||||
ShowAKA: true
|
||||
|
||||
If:
|
||||
PathMatch: (./.*\.c|./.*\.h)
|
||||
PathMatch: (./.*\.cpp|./.*\.hpp)
|
||||
Diagnostics:
|
||||
UnusedIncludes: Strict
|
||||
MissingIncludes: Strict
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_DIR="build"
|
||||
|
||||
echo "Running clang-format..."
|
||||
|
||||
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|hpp)$' || true)
|
||||
|
||||
if [ -z "$FILES" ]; then
|
||||
echo "No C/C++ files to check"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for file in $FILES; do
|
||||
clang-format -i "$file"
|
||||
git add "$file"
|
||||
done
|
||||
|
||||
echo "Running clang-tidy..."
|
||||
|
||||
for file in $FILES; do
|
||||
clang-tidy \
|
||||
"$file" \
|
||||
-p "$BUILD_DIR"
|
||||
done
|
||||
|
||||
echo "pre-commit checks passed"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
BUILD_DIR="build"
|
||||
|
||||
echo "Building..."
|
||||
|
||||
cmake --build "$BUILD_DIR"
|
||||
|
||||
echo "Running tests..."
|
||||
|
||||
ctest --test-dir "$BUILD_DIR" --output-on-failure
|
||||
|
||||
echo "pre-push checks passed"
|
||||
@@ -50,22 +50,6 @@ class function_definition_node : public function_declarartion_node {
|
||||
public:
|
||||
function_definition_node(front::token name, function_body_handle&& body)
|
||||
: function_declarartion_node(name), m_body(std::move(body)) {}
|
||||
|
||||
~function_definition_node() override = default;
|
||||
|
||||
function_definition_node(function_definition_node&& other) noexcept
|
||||
: function_declarartion_node(std::move(other)), m_body(std::move(other.m_body)) {}
|
||||
|
||||
function_definition_node(const function_definition_node&) = delete;
|
||||
|
||||
function_definition_node& operator=(function_definition_node&& other) noexcept {
|
||||
if (this == &other) return *this;
|
||||
function_declarartion_node::operator=(std::move(other));
|
||||
m_body = std::move(other.m_body);
|
||||
return *this;
|
||||
}
|
||||
|
||||
function_definition_node& operator=(const function_definition_node&) = delete;
|
||||
public:
|
||||
declaration_node_t declaration_type() const override { return declaration_node_t::FunctionDefinition; }
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
const handle<std::string_view>& value() const { return m_value; }
|
||||
public:
|
||||
std::ostream& print(std::ostream& os) const override {
|
||||
if (m_value.has_error()) return os << (std::string)m_value;
|
||||
if (m_value.has_error()) return os << m_value.error();
|
||||
return os << "string literal (" << *m_value << ")";
|
||||
}
|
||||
private:
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace furc {
|
||||
|
||||
struct location {
|
||||
std::string_view filename;
|
||||
std::size_t line;
|
||||
std::size_t column;
|
||||
std::size_t line = 0;
|
||||
std::size_t column = 0;
|
||||
};
|
||||
|
||||
static inline std::ostream& operator<<(std::ostream& os, const location& location) {
|
||||
|
||||
@@ -75,13 +75,10 @@ public:
|
||||
|
||||
Error error() const { return m_error; }
|
||||
|
||||
operator reference() { return *m_value; }
|
||||
operator const_reference() const { return *m_value; }
|
||||
|
||||
reference operator*() { return *m_value; }
|
||||
const_reference operator*() const { return *m_value; }
|
||||
pointer operator->() { return &*m_value; }
|
||||
const_pointer operator->() const { return &*m_value; }
|
||||
reference operator*() { return m_value.value(); } // NOLINT(bugprone-unchecked-optional-access)
|
||||
const_reference operator*() const { return m_value.value(); } // NOLINT(bugprone-unchecked-optional-access)
|
||||
pointer operator->() { return &m_value.value(); } // NOLINT(bugprone-unchecked-optional-access)
|
||||
const_pointer operator->() const { return &m_value.value(); } // NOLINT(bugprone-unchecked-optional-access)
|
||||
public:
|
||||
bool operator==(const T& rhs) const { return m_value.has_value() && *m_value == rhs; }
|
||||
public:
|
||||
@@ -119,7 +116,7 @@ public:
|
||||
|
||||
template <typename U, typename = std::enable_if_t<std::is_base_of_v<value_type, U>>>
|
||||
handle(location location, std::shared_ptr<U> value)
|
||||
: m_data(data(location, value)) {}
|
||||
: m_data(data(location, std::move(value))) {}
|
||||
|
||||
template <typename U,
|
||||
typename = std::enable_if_t<std::is_base_of_v<value_type, U> || std::is_base_of_v<U, value_type>>>
|
||||
@@ -196,16 +193,18 @@ private:
|
||||
|
||||
template <typename U, typename = std::enable_if_t<std::is_base_of_v<value_type, U>>>
|
||||
data(struct location location, std::shared_ptr<U> value)
|
||||
: location(location), value(value) {}
|
||||
: location(location), value(std::move(value)) {}
|
||||
|
||||
template <typename U,
|
||||
typename = std::enable_if_t<std::is_base_of_v<value_type, U> || std::is_base_of_v<U, value_type>>>
|
||||
data(handle<U*, Error>&& other) // NOLINT
|
||||
: location(other.m_data->location) {
|
||||
data(handle<U*, Error>&& other) // NOLINT
|
||||
: location(other.m_data->location) { // NOLINT(bugprone-unchecked-optional-access)
|
||||
if constexpr (std::is_base_of_v<value_type, U>) {
|
||||
value = std::static_pointer_cast<value_type>(std::move(other.m_data->value));
|
||||
value = std::static_pointer_cast<value_type>(
|
||||
std::move(other.m_data->value)); // NOLINT(bugprone-unchecked-optional-access)
|
||||
} else {
|
||||
value = std::dynamic_pointer_cast<value_type>(std::move(other.m_data->value));
|
||||
value = std::dynamic_pointer_cast<value_type>(
|
||||
std::move(other.m_data->value)); // NOLINT(bugprone-unchecked-optional-access)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,12 +58,12 @@ ast::node_handle<ast::declaration_node> parser::parse_declaration() {
|
||||
if (body.has_error()) return body;
|
||||
return ast::node_handle<ast::function_definition_node>{ first.location(),
|
||||
m_arena,
|
||||
name,
|
||||
*name,
|
||||
std::move(body) };
|
||||
}
|
||||
case token_t::Semicolon: {
|
||||
m_peekBuffer.clear();
|
||||
return ast::node_handle<ast::function_declarartion_node>{ first.location(), m_arena, name };
|
||||
return ast::node_handle<ast::function_declarartion_node>{ first.location(), m_arena, *name };
|
||||
}
|
||||
default: return { tok.location(), "unexpected token "s + tok->type };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user