diff --git a/.clang-tidy b/.clang-tidy index 3ed75780..4ec447af 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -5,6 +5,7 @@ Checks: '*include*, misc-const-correctness, misc-static-assert, misc-unused-parameters, + readability-redundant-member-init, readability-named-parameter, readability-else-after-return, readability-inconsistent-declaration-parameter-name, @@ -63,6 +64,12 @@ Checks: '*include*, -hicpp-special-member-functions, -cppcoreguidelines-macro-to-enum, -modernize-macro-to-enum, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-avoid-const-or-ref-data-members, + -bugprone-reserved-identifier, + -cert-dcl37-c, + -cert-dcl51-cpp, + -cppcoreguidelines-non-private-member-variables-in-classes, ' WarningsAsErrors: '*' HeaderFilterRegex: '^.*/src/.*$' diff --git a/src/compiler/ClassGenerationContext.cpp b/src/compiler/ClassGenerationContext.cpp index 5a34e7f9..8dfde529 100644 --- a/src/compiler/ClassGenerationContext.cpp +++ b/src/compiler/ClassGenerationContext.cpp @@ -43,8 +43,7 @@ #include "../vmobjects/VMSymbol.h" ClassGenerationContext::ClassGenerationContext() - : name(nullptr), superName(nullptr), classSide(false), instanceFields(), - instanceMethods(), classFields(), classMethods() {} + : name(nullptr), superName(nullptr), classSide(false) {} void ClassGenerationContext::AddClassField(VMSymbol* field) { classFields.push_back(field); diff --git a/src/compiler/Variable.h b/src/compiler/Variable.h index d42aa64d..3e43878c 100644 --- a/src/compiler/Variable.h +++ b/src/compiler/Variable.h @@ -14,7 +14,7 @@ class Variable { assert(index != 0xff); } - Variable() : name({}), index(0xff), isArgument(false), coord({}) {} + Variable() : name({}), index(0xff), isArgument(false) {} Variable(const Variable* old, size_t newIndex, bool isArgument) : name(old->name), index(newIndex), isArgument(isArgument), diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h index ea3916ba..77533ffe 100644 --- a/src/interpreter/bytecodes.h +++ b/src/interpreter/bytecodes.h @@ -131,7 +131,7 @@ class Bytecode { }; inline uint16_t ComputeOffset(uint8_t byte1, uint8_t byte2) { - return ((uint16_t)byte1) | (((uint16_t)byte2) << 8); + return ((uint16_t)byte1) | (((uint16_t)byte2) << 8U); } bool IsJumpBytecode(uint8_t bc); diff --git a/src/memory/DebugCopyingHeap.h b/src/memory/DebugCopyingHeap.h index 63aaa966..cbde164a 100644 --- a/src/memory/DebugCopyingHeap.h +++ b/src/memory/DebugCopyingHeap.h @@ -23,12 +23,12 @@ class DebugCopyingHeap : public Heap { void switchBuffers(bool increaseMemory); void invalidateOldBuffer(); - vector currentHeap{}; + vector currentHeap; size_t currentHeapSize; size_t currentHeapUsage{0}; size_t collectionLimit; - vector oldHeap{}; + vector oldHeap; size_t oldHeapSize{0}; bool oldHeapIsValid{false}; diff --git a/src/primitives/Array.cpp b/src/primitives/Array.cpp index cb501b29..348cf3df 100644 --- a/src/primitives/Array.cpp +++ b/src/primitives/Array.cpp @@ -61,7 +61,7 @@ static vm_oop_t arrCopy(vm_oop_t rcvr) { return self->Copy(); } -_Array::_Array() : PrimitiveContainer() { +_Array::_Array() { Add("new:", &arrNew, true); Add("at:", &arrAt, false); Add("at:put:", &arrAtPut, false); diff --git a/src/primitives/Block.cpp b/src/primitives/Block.cpp index abed3d3a..d7eead05 100644 --- a/src/primitives/Block.cpp +++ b/src/primitives/Block.cpp @@ -28,4 +28,4 @@ #include "../primitivesCore/PrimitiveContainer.h" -_Block::_Block() : PrimitiveContainer() {} +_Block::_Block() {} diff --git a/src/primitives/Class.cpp b/src/primitives/Class.cpp index 66350521..296781c1 100644 --- a/src/primitives/Class.cpp +++ b/src/primitives/Class.cpp @@ -58,7 +58,7 @@ static vm_oop_t clsFields(vm_oop_t rcvr) { return self->GetInstanceFields(); } -_Class::_Class() : PrimitiveContainer() { +_Class::_Class() { Add("new", &clsNew, false); Add("name", &clsName, false); Add("superclass", &clsSuperclass, false); diff --git a/src/primitives/Double.cpp b/src/primitives/Double.cpp index 137b81c9..54b56e58 100644 --- a/src/primitives/Double.cpp +++ b/src/primitives/Double.cpp @@ -220,7 +220,7 @@ static vm_oop_t dblMax(vm_oop_t leftPtr, vm_oop_t rightObj) { return rightObj; } -_Double::_Double() : PrimitiveContainer() { +_Double::_Double() { Add("+", &dblPlus, false); Add("-", &dblMinus, false); Add("*", &dblStar, false); diff --git a/src/primitives/Integer.cpp b/src/primitives/Integer.cpp index 38b2a065..3484954a 100644 --- a/src/primitives/Integer.cpp +++ b/src/primitives/Integer.cpp @@ -339,7 +339,7 @@ static vm_oop_t intRange(vm_oop_t leftObj, vm_oop_t rightObj) { return arr; } -_Integer::_Integer() : PrimitiveContainer() { +_Integer::_Integer() { srand((unsigned)time(nullptr)); Add("+", &intPlus, false); diff --git a/src/primitives/Method.cpp b/src/primitives/Method.cpp index 33b82e0f..024a19ce 100644 --- a/src/primitives/Method.cpp +++ b/src/primitives/Method.cpp @@ -36,7 +36,7 @@ void mInvokeOnWith(VMFrame* frame) { mthd->Invoke(frame); } -_Method::_Method() : PrimitiveContainer() { +_Method::_Method() { Add("signature", &mSignature, false); Add("holder", &mHolder, false); Add("invokeOn:with:", &mInvokeOnWith, false); diff --git a/src/primitives/Object.cpp b/src/primitives/Object.cpp index 475be155..a4f7ecda 100644 --- a/src/primitives/Object.cpp +++ b/src/primitives/Object.cpp @@ -137,7 +137,7 @@ vm_oop_t objClass(vm_oop_t self) { return CLASS_OF(self); } -_Object::_Object() : PrimitiveContainer() { +_Object::_Object() { Add("==", &objEqualequal, false); Add("objectSize", &objObjectSize, false); Add("hashcode", &objHashcode, false); diff --git a/src/primitives/Primitive.cpp b/src/primitives/Primitive.cpp index da0ac530..1c0c609e 100644 --- a/src/primitives/Primitive.cpp +++ b/src/primitives/Primitive.cpp @@ -34,7 +34,7 @@ void pInvokeOnWith(VMFrame* frame) { mthd->Invoke(frame); } -_Primitive::_Primitive() : PrimitiveContainer() { +_Primitive::_Primitive() { Add("signature", &pSignature, false); Add("holder", &pHolder, false); Add("invokeOn:with:", &pInvokeOnWith, false); diff --git a/src/primitives/String.cpp b/src/primitives/String.cpp index a4466b94..786a9b53 100644 --- a/src/primitives/String.cpp +++ b/src/primitives/String.cpp @@ -183,7 +183,7 @@ static vm_oop_t strIsDigits(vm_oop_t rcvr) { return load_ptr(falseObject); } -_String::_String() : PrimitiveContainer() { +_String::_String() { Add("concatenate:", &strConcatenate_, false); Add("asSymbol", &strAsSymbol, false); Add("hashcode", &strHashcode, false); diff --git a/src/primitives/Symbol.cpp b/src/primitives/Symbol.cpp index 2c2d0696..efbd6e96 100644 --- a/src/primitives/Symbol.cpp +++ b/src/primitives/Symbol.cpp @@ -41,6 +41,6 @@ static vm_oop_t symAsString(vm_oop_t rcvr) { return Universe::NewString(str); } -_Symbol::_Symbol() : PrimitiveContainer() { +_Symbol::_Symbol() { Add("asString", &symAsString, false); } diff --git a/src/primitives/System.cpp b/src/primitives/System.cpp index d84dcdfd..ad9a2403 100644 --- a/src/primitives/System.cpp +++ b/src/primitives/System.cpp @@ -169,7 +169,7 @@ void printStackTrace(VMFrame* frame) { frame->PrintStackTrace(); } -_System::_System() : PrimitiveContainer() { +_System::_System() { gettimeofday(&start_time, nullptr); Add("global:", &sysGlobal_, false); diff --git a/src/primitivesCore/PrimitiveContainer.h b/src/primitivesCore/PrimitiveContainer.h index 12d750d1..e696c77e 100644 --- a/src/primitivesCore/PrimitiveContainer.h +++ b/src/primitivesCore/PrimitiveContainer.h @@ -53,8 +53,8 @@ class PrimitiveContainer { bool classSide); private: - std::map framePrims{}; - std::map unaryPrims{}; - std::map binaryPrims{}; - std::map ternaryPrims{}; + std::map framePrims; + std::map unaryPrims; + std::map binaryPrims; + std::map ternaryPrims; }; diff --git a/src/primitivesCore/PrimitiveLoader.h b/src/primitivesCore/PrimitiveLoader.h index c75d8cea..f4b5f961 100644 --- a/src/primitivesCore/PrimitiveLoader.h +++ b/src/primitivesCore/PrimitiveLoader.h @@ -63,7 +63,7 @@ class PrimitiveLoader { bool supportsClass(const std::string& name); - std::map primitiveObjects{}; + std::map primitiveObjects; static PrimitiveLoader loader; }; diff --git a/src/vmobjects/VMDouble.h b/src/vmobjects/VMDouble.h index 0ad05ae0..9faa37c6 100644 --- a/src/vmobjects/VMDouble.h +++ b/src/vmobjects/VMDouble.h @@ -32,7 +32,7 @@ class VMDouble : public AbstractVMObject { public: typedef GCDouble Stored; - VMDouble(double val) : AbstractVMObject(), embeddedDouble(val) {} + VMDouble(double val) : embeddedDouble(val) {} [[nodiscard]] VMDouble* CloneForMovingGC() const override; [[nodiscard]] inline double GetEmbeddedDouble() const; diff --git a/src/vmobjects/VMString.h b/src/vmobjects/VMString.h index 5e640f45..272422b3 100644 --- a/src/vmobjects/VMString.h +++ b/src/vmobjects/VMString.h @@ -33,7 +33,7 @@ class VMString : public AbstractVMObject { typedef GCString Stored; VMString(const size_t length, const char* str) - : AbstractVMObject(), length(length), + : length(length), // set the chars-pointer to point at the position of the first // character chars((char*)&chars + sizeof(char*)) {