diff --git a/CMakeLists.txt b/CMakeLists.txt index bc9524e9..0289f55e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,15 @@ project(nautilus VERSION 0.1) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Werror=extra -Werror=all -fpermissive -fPIC -fno-omit-frame-pointer") + +set(CMAKE_CXX_WARNINGS "-Wall -Wextra -pedantic-errors -Werror=extra-semi -Werror=extra -Werror=all -Werror=delete-non-virtual-dtor -Werror=deprecated -Werror=array-bounds -Werror=ignored-qualifiers -Werror=sign-compare") + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_WARNINGS "${CMAKE_CXX_WARNINGS} -Wpedantic-macros -Werror=integer-overflow -Werror=return-type -Werror=return-stack-address -Werror=writable-strings") +else () + set(CMAKE_CXX_WARNINGS "${CMAKE_CXX_WARNINGS} -Woverflow -Werror=return-type -Werror=return-local-addr -Werror=write-strings") +endif () +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_WARNINGS} -fpermissive -fPIC -fno-omit-frame-pointer") if (ENABLE_TEST_COVERAGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoverage-mapping -fprofile-instr-generate") diff --git a/nautilus/include/nautilus/Executable.hpp b/nautilus/include/nautilus/Executable.hpp index 28c7f6f7..d9b4de11 100644 --- a/nautilus/include/nautilus/Executable.hpp +++ b/nautilus/include/nautilus/Executable.hpp @@ -38,9 +38,9 @@ class Executable { public: using FunctionType = R(Args...); - explicit Invocable(void* fptr) : function(reinterpret_cast(fptr)) {}; + explicit Invocable(void* fptr) : function(reinterpret_cast(fptr)) {} - explicit Invocable(std::unique_ptr generic) : function(std::move(generic)) {}; + explicit Invocable(std::unique_ptr generic) : function(std::move(generic)) {} template requires(std::is_fundamental_v || std::is_fundamental_v>) @@ -132,7 +132,7 @@ class Executable { */ virtual std::unique_ptr getGenericInvocable(const std::string&) { return nullptr; - }; + } }; } // namespace nautilus::compiler diff --git a/nautilus/include/nautilus/function.hpp b/nautilus/include/nautilus/function.hpp index 1874cb82..f4c9556a 100644 --- a/nautilus/include/nautilus/function.hpp +++ b/nautilus/include/nautilus/function.hpp @@ -93,11 +93,9 @@ class MemberFuncWrapperImpl : public MemberFuncWrapper { MemberFuncWrapperImpl(T func) : func(func), callableRuntimeFunction(function(+[](MemberFuncWrapper* ptr, Tp* clazzPtr) -> auto { auto p = static_cast*>(ptr); - // return p->func(clazzPtr); Rp (Tp::*func)() = p->func; return (*clazzPtr.*func)(); - // return std::invoke(p->func, clazzPtr); - })) {}; + })) {} template auto operator()(FunctionArgumentsRaw... args) { diff --git a/nautilus/include/nautilus/static.hpp b/nautilus/include/nautilus/static.hpp index 8fa169d0..5323904c 100644 --- a/nautilus/include/nautilus/static.hpp +++ b/nautilus/include/nautilus/static.hpp @@ -16,11 +16,11 @@ class alignas(64) static_val { static_val() { tracing::pushStaticVal(&value); - }; + } static_val(T v) : value(v) { tracing::pushStaticVal((void*) &value); - }; + } static_val(const static_val& other) : static_val((T) other) { } @@ -91,6 +91,10 @@ class alignas(64) static_val { return value == other; } + bool operator!=(const T& other) const { + return value != other; + } + bool operator>(const T& other) const { return value > other; } @@ -139,15 +143,14 @@ class static_iterator { return tmp; } - bool operator==(const static_iterator& other) { - val = val + 1; - return m_iterator == other.m_iterator; + // Define comparison operators as friends to control their argument order + friend bool operator==(const static_iterator& lhs, const static_iterator& rhs) { + return lhs.m_iterator == rhs.m_iterator; } - bool operator!=(const static_iterator& other) const { - return !(*this == other); + friend bool operator!=(const static_iterator& lhs, const static_iterator& rhs) { + return lhs.m_iterator != rhs.m_iterator; } - private: static_val val; Iterator m_iterator; diff --git a/nautilus/include/nautilus/std/ostream.h b/nautilus/include/nautilus/std/ostream.h index 5eff0067..02f5b444 100644 --- a/nautilus/include/nautilus/std/ostream.h +++ b/nautilus/include/nautilus/std/ostream.h @@ -39,7 +39,8 @@ val>& flush(val class val> { public: - explicit val(val*> stream) : stream(stream) {}; + explicit val(val*> stream) : stream(stream) { + } template val(val>& other) : stream(other.stream) { } diff --git a/nautilus/include/nautilus/std/sstream.h b/nautilus/include/nautilus/std/sstream.h index e0a7f108..119ff699 100644 --- a/nautilus/include/nautilus/std/sstream.h +++ b/nautilus/include/nautilus/std/sstream.h @@ -48,7 +48,7 @@ class val> : public valstream); return val>(str_ptr); - }; + } ~val() { invoke( diff --git a/nautilus/include/nautilus/std/string.h b/nautilus/include/nautilus/std/string.h index 86818c22..f13300c5 100644 --- a/nautilus/include/nautilus/std/string.h +++ b/nautilus/include/nautilus/std/string.h @@ -31,6 +31,11 @@ class val> { val(const CharT* s) : val(val(s)) { } + val>& operator=(const val>& other) { + this->data_ptr = other.data_ptr; + return *this; + } + val at(val pos) { return invoke( +[](base_type* ptr, size_type p) -> CharT { return ptr->at(p); }, data_ptr, pos); @@ -259,7 +264,7 @@ class val> { auto ptr = std::move(data_ptr); data_ptr = nullptr; return ptr; - }; + } private: val data_ptr; diff --git a/nautilus/include/nautilus/val.hpp b/nautilus/include/nautilus/val.hpp index df877239..10b34aa6 100644 --- a/nautilus/include/nautilus/val.hpp +++ b/nautilus/include/nautilus/val.hpp @@ -92,20 +92,20 @@ class val { using basic_type = ValueType; #ifdef ENABLE_TRACING - val() : state(tracing::traceConstant(0)) {}; - val(ValueType value) : state(tracing::traceConstant(value)), value(value) {}; + val() : state(tracing::traceConstant(0)) {} + val(ValueType value) : state(tracing::traceConstant(value)), value(value) {} // copy constructor - val(const val& other) : state(tracing::traceCopy(other.state)), value(other.value) {}; + val(const val& other) : state(tracing::traceCopy(other.state)), value(other.value) {} // move constructor - val(const val&& other) noexcept : state(std::move(other.state)), value(other.value) {}; - val(tracing::value_ref& tc) : state(tc), value() {}; + val(const val&& other) noexcept : state(std::move(other.state)), value(other.value) {} + val(tracing::value_ref& tc) : state(tc), value() {} #else - val() {}; - val(ValueType value) : value(value) {}; + val() {} + val(ValueType value) : value(value) {} // copy constructor - val(const val& other) : value(other.value) {}; + val(const val& other) : value(other.value) {} // move constructor - val(const val&& other) : value(other.value) {}; + val(const val&& other) : value(other.value) {} #endif val& operator=(const val& other) { @@ -116,7 +116,7 @@ class val { #endif this->value = other.value; return *this; - }; + } template requires std::is_convertible_v @@ -234,21 +234,21 @@ class val { #ifdef ENABLE_TRACING - val() : state(tracing::traceConstant(0)), value(false) {}; - val(bool value) : state(tracing::traceConstant(value)), value(value) {}; + val() : state(tracing::traceConstant(0)), value(false) {} + val(bool value) : state(tracing::traceConstant(value)), value(value) {} // copy constructor - val(const val& other) : state(tracing::traceCopy(other.state)), value(other.value) {}; + val(const val& other) : state(tracing::traceCopy(other.state)), value(other.value) {} // move constructor - val(const val&& other) : state(other.state), value(other.value) {}; - val(tracing::value_ref& tc) : state(tc) {}; + val(const val&& other) : state(other.state), value(other.value) {} + val(tracing::value_ref& tc) : state(tc) {} #else - val() {}; - val(bool value) : value(value) {}; + val() {} + val(bool value) : value(value) {} // copy constructor - val(const val& other) : value(other.value) {}; + val(const val& other) : value(other.value) {} // move constructor - val(const val&& other) : value(other.value) {}; + val(const val&& other) : value(other.value) {} #endif val& operator=(const val& other) { @@ -261,7 +261,7 @@ class val { this->value = other.value; return *this; - }; + } operator bool() const { if SHOULD_TRACE () { @@ -279,7 +279,7 @@ class val { template auto inline&& make_value(Type&& value) { return std::forward(value); -}; +} template auto inline make_value(const Type& value) { diff --git a/nautilus/include/nautilus/val_enum.hpp b/nautilus/include/nautilus/val_enum.hpp index 5a79793f..bc04f360 100644 --- a/nautilus/include/nautilus/val_enum.hpp +++ b/nautilus/include/nautilus/val_enum.hpp @@ -20,17 +20,17 @@ class val { using raw_type = underlying_type_t; using basic_type = raw_type; - val() : value() {}; + val() : value() {} #ifdef ENABLE_TRACING - val(val t) : state(t.state), value((T) details::getRawValue(t)) {}; - val(val& t) : state(tracing::traceCopy(t.state)), value(t.value) {}; - val(val&& t) : state(t.state), value(t.value) {}; - val(T val) : state(tracing::traceConstant((underlying_type_t) val)), value(val) {}; + val(val t) : state(t.state), value((T) details::getRawValue(t)) {} + val(val& t) : state(tracing::traceCopy(t.state)), value(t.value) {} + val(val&& t) : state(t.state), value(t.value) {} + val(T val) : state(tracing::traceConstant((underlying_type_t) val)), value(val) {} #else - val(val t) : value((T) details::getRawValue(t)) {}; - val(val& t) : value(t.value) {}; - val(T val) : value(val) {}; + val(val t) : value((T) details::getRawValue(t)) {} + val(val& t) : value(t.value) {} + val(T val) : value(val) {} #endif operator val() const { @@ -45,7 +45,7 @@ class val { #endif this->value = other.value; return *this; - }; + } #ifdef ENABLE_TRACING tracing::TypedValueRefHolder state; diff --git a/nautilus/include/nautilus/val_ptr.hpp b/nautilus/include/nautilus/val_ptr.hpp index 971cb37f..4074cb08 100644 --- a/nautilus/include/nautilus/val_ptr.hpp +++ b/nautilus/include/nautilus/val_ptr.hpp @@ -17,12 +17,12 @@ class val { const tracing::TypedValueRefHolder state; #endif #ifdef ENABLE_TRACING - val(ValueType ref) : state(tracing::value_ref()), ptr(&ref) {}; - val(ValueType ref, tracing::value_ref value_ref) : state(value_ref), ptr(&ref) {}; - val(val ptr, tracing::value_ref ref) : state(ref), ptr(ptr) {}; + val(ValueType ref) : state(tracing::value_ref()), ptr(&ref) {} + val(ValueType ref, tracing::value_ref value_ref) : state(value_ref), ptr(&ref) {} + val(val ptr, tracing::value_ref ref) : state(ref), ptr(ptr) {} #else - val(ValueType ref) : ptr(&ref) {}; - val(val ptr) : ptr(ptr) {}; + val(ValueType ref) : ptr(&ref) {} + val(val ptr) : ptr(ptr) {} #endif template @@ -80,16 +80,16 @@ class base_ptr_val { using basic_type = std::remove_pointer_t; using pointer_type = ValuePtrType; - base_ptr_val() : value() {}; + base_ptr_val() : value() {} #ifdef ENABLE_TRACING - base_ptr_val(ValuePtrType ptr) : state(tracing::traceConstant((void*) ptr)), value(ptr) {}; - base_ptr_val(ValuePtrType ptr, tracing::value_ref tc) : state(tc), value(ptr) {}; - base_ptr_val(ValuePtrType ptr, tracing::TypedValueRefHolder tc) : state(std::move(tc)), value(ptr) {}; + base_ptr_val(ValuePtrType ptr) : state(tracing::traceConstant((void*) ptr)), value(ptr) {} + base_ptr_val(ValuePtrType ptr, tracing::value_ref tc) : state(tc), value(ptr) {} + base_ptr_val(ValuePtrType ptr, tracing::TypedValueRefHolder tc) : state(std::move(tc)), value(ptr) {} base_ptr_val(tracing::value_ref ref) : state(ref), value(nullptr) { } #else - base_ptr_val(ValuePtrType ptr) : value(ptr) {}; + base_ptr_val(ValuePtrType ptr) : value(ptr) {} #endif #ifdef ENABLE_TRACING @@ -120,7 +120,7 @@ class val : public base_ptr_val { #endif this->value = other.value; return *this; - }; + } val operator*() requires is_arithmetic @@ -130,7 +130,7 @@ class val : public base_ptr_val { #else return val(*this); #endif - }; + } template val operator[](T&& io) @@ -196,7 +196,7 @@ class val : public base_ptr_val { #endif this->value = other.value; return *this; - }; + } template requires std::is_pointer_v @@ -346,12 +346,12 @@ class val { #ifdef ENABLE_TRACING tracing::TypedValueRefHolder state; - val(bool ref) : state(tracing::value_ref()), ptr(&ref) {}; - val(bool& ref, tracing::value_ref value_ref) : state(value_ref), ptr(&ref) {}; - val(val ptr, tracing::value_ref ref) : state(ref), ptr(ptr) {}; + val(bool ref) : state(tracing::value_ref()), ptr(&ref) {} + val(bool& ref, tracing::value_ref value_ref) : state(value_ref), ptr(&ref) {} + val(val ptr, tracing::value_ref ref) : state(ref), ptr(ptr) {} #else - val(bool ref) : ptr(&ref) {}; - val(val ptr) : ptr(ptr) {}; + val(bool ref) : ptr(&ref) {} + val(val ptr) : ptr(ptr) {} #endif template diff --git a/nautilus/src/nautilus/compiler/backends/bc/ByteCode.hpp b/nautilus/src/nautilus/compiler/backends/bc/ByteCode.hpp index f6dc8cdd..c8b50875 100644 --- a/nautilus/src/nautilus/compiler/backends/bc/ByteCode.hpp +++ b/nautilus/src/nautilus/compiler/backends/bc/ByteCode.hpp @@ -352,7 +352,7 @@ class FunctionCallTarget { * @brief The general definition of opcode, that contains a bytecode, at max two input registers and a result register. */ struct OpCode { - OpCode(ByteCode op, short reg1, short reg2, short output) : op(op), reg1(reg1), reg2(reg2), output(output) {}; + OpCode(ByteCode op, short reg1, short reg2, short output) : op(op), reg1(reg1), reg2(reg2), output(output) {} ByteCode op; short reg1; short reg2; diff --git a/nautilus/src/nautilus/compiler/backends/mlir/ProxyFunctions.hpp b/nautilus/src/nautilus/compiler/backends/mlir/ProxyFunctions.hpp index c715810c..339b6a3b 100644 --- a/nautilus/src/nautilus/compiler/backends/mlir/ProxyFunctions.hpp +++ b/nautilus/src/nautilus/compiler/backends/mlir/ProxyFunctions.hpp @@ -12,7 +12,7 @@ class ProxyFunctions { public: ProxyFunctions() { functionNameToAddressMap.emplace(std::pair {"printValueFromMLIR", (void*) &printValueFromMLIR}); - }; + } ~ProxyFunctions() = default; void* getProxyFunctionAddress(std::string name) { return functionNameToAddressMap[name]; diff --git a/nautilus/src/nautilus/tracing/TraceOperation.hpp b/nautilus/src/nautilus/tracing/TraceOperation.hpp index 400fc458..814c1253 100644 --- a/nautilus/src/nautilus/tracing/TraceOperation.hpp +++ b/nautilus/src/nautilus/tracing/TraceOperation.hpp @@ -45,12 +45,8 @@ class TraceOperation { TraceOperation(Op op, std::vector&& input); - TraceOperation(const TraceOperation& other) = default; - friend std::ostream& operator<<(std::ostream& os, const TraceOperation& operation); - ~TraceOperation() = default; - Snapshot tag; Op op; Type resultType; diff --git a/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.hpp b/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.hpp index 2b8663d1..f36f7fdb 100644 --- a/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.hpp +++ b/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.hpp @@ -45,7 +45,7 @@ class TraceToIRConversionPhase { */ class IRConversionContext { public: - IRConversionContext(std::shared_ptr trace, const compiler::CompilationUnitID& id) : trace(trace), ir(std::make_shared(id)) {}; + IRConversionContext(std::shared_ptr trace, const compiler::CompilationUnitID& id) : trace(trace), ir(std::make_shared(id)) {} std::shared_ptr process(); diff --git a/nautilus/src/nautilus/tracing/tag/Trie.hpp b/nautilus/src/nautilus/tracing/tag/Trie.hpp index a75c0221..463ed4fa 100644 --- a/nautilus/src/nautilus/tracing/tag/Trie.hpp +++ b/nautilus/src/nautilus/tracing/tag/Trie.hpp @@ -34,7 +34,7 @@ class TrieNode { } else { return found->get(); } - }; + } private: T content; diff --git a/nautilus/test/execution-tests/PointerFunctions.hpp b/nautilus/test/execution-tests/PointerFunctions.hpp index c173e0d5..5f660d89 100644 --- a/nautilus/test/execution-tests/PointerFunctions.hpp +++ b/nautilus/test/execution-tests/PointerFunctions.hpp @@ -166,7 +166,7 @@ class WrapperType { public: val add() { return a.getX() + b.getX(); - }; + } val a; val b; };