diff --git a/CMakeLists.txt b/CMakeLists.txt index b764086c8e974dc53aadd345cdd287918d599afb..45ad49ba7208780ae33f5168f468ef37fca57925 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,12 +66,20 @@ endif() target_compile_features(${module_name} PRIVATE cxx_std_14) +if (DOSANITIZE STREQUAL "ON") +set(SANITIZE_FLAGS -fsanitize=address,leak,undefined,float-divide-by-zero -fno-omit-frame-pointer) +else() +set(SANITIZE_FLAGS) +endif() + target_compile_options(${module_name} PRIVATE - $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: - -Wall -Wextra -Wold-style-cast -Winline -pedantic -Werror=narrowing -Wshadow $<$<BOOL:${WERROR}>:-Werror>>) +$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: +-Wall -Wextra -fPIC -Wold-style-cast -Winline -pedantic -Werror=narrowing -Wshadow -fstrict-aliasing -Wstrict-aliasing=1 $<$<BOOL:${WERROR}>:-Werror> ${SANITIZE_FLAGS}>) target_compile_options(${module_name} PRIVATE - $<$<CXX_COMPILER_ID:MSVC>: - /W4>) +$<$<CXX_COMPILER_ID:MSVC>: +/W4>) + +target_link_options(${module_name} PUBLIC ${SANITIZE_FLAGS}) if(CMAKE_COMPILER_IS_GNUCXX AND COVERAGE) append_coverage_compiler_flags() diff --git a/include/aidge/hook/hook.hpp b/include/aidge/hook/hook.hpp index 0448659b937c3498f57cae9935196ef2f38ecf6d..f263ac0e451b52be36499b4d705af95105670d93 100644 --- a/include/aidge/hook/hook.hpp +++ b/include/aidge/hook/hook.hpp @@ -31,7 +31,7 @@ protected: public: Hook(std::shared_ptr<Operator> op) : mOperator(op) {} - virtual ~Hook(); + virtual ~Hook() = default; virtual void call() = 0; diff --git a/include/aidge/nodeTester/ConditionalData.hpp b/include/aidge/nodeTester/ConditionalData.hpp index 9d889d6a0737d4c6cdf026b5c96c73280d93f2ff..d8ed187f024a57ea38af5a10986ae909939c2f70 100644 --- a/include/aidge/nodeTester/ConditionalData.hpp +++ b/include/aidge/nodeTester/ConditionalData.hpp @@ -34,7 +34,7 @@ struct ConditionalData { */ //void* value; std::unique_ptr<BaseConditionalValue> value; - const std::type_info* type; + const std::type_info* type =nullptr; ///////////////////////////////// // diff --git a/include/aidge/operator/GenericOperator.hpp b/include/aidge/operator/GenericOperator.hpp index 184100174714df5fc059e374cb85549f6bfd4135..8b95a219d0cbdf35c1c9e06fde1978c07c278ca4 100644 --- a/include/aidge/operator/GenericOperator.hpp +++ b/include/aidge/operator/GenericOperator.hpp @@ -24,6 +24,7 @@ #include "aidge/utils/Registrar.hpp" #include "aidge/utils/Types.h" + namespace Aidge { class GenericOperator_Op : public Operator, diff --git a/src/graphRegex/GraphFsmInterpreter.cpp b/src/graphRegex/GraphFsmInterpreter.cpp index 6d04fc97cf6d66ad4ca170b18d078833bd98d7eb..2984ab4fb3864244c9e32dbfcda9ef2ae080acf0 100644 --- a/src/graphRegex/GraphFsmInterpreter.cpp +++ b/src/graphRegex/GraphFsmInterpreter.cpp @@ -63,7 +63,6 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::keyF(std::shared_ptr<AstNode<gReg return graph; } - std::shared_ptr<FsmGraph> GraphFsmInterpreter::sepF(std::shared_ptr<FsmGraph> leftFsm,std::shared_ptr<FsmGraph> rigthFsm){ size_t idxLeft = leftFsm->getNbSubFsm(); @@ -73,7 +72,6 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::sepF(std::shared_ptr<FsmGraph> le return leftFsm; } - std::shared_ptr<FsmGraph> GraphFsmInterpreter::nextF(std::shared_ptr<FsmGraph> leftFsm,std::shared_ptr<FsmGraph> rigthFsm){ /* combine the 2 Graph @@ -89,6 +87,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::nextF(std::shared_ptr<FsmGraph> l //the rigthFsm is no longer usfull return leftFsm; } + std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fsm){ /* + @@ -154,6 +153,7 @@ std::shared_ptr<FsmGraph> GraphFsmInterpreter::qomF(std::shared_ptr<FsmGraph> fs return fsm; } + std::shared_ptr<FsmGraph> GraphFsmInterpreter::qzmF(std::shared_ptr<FsmGraph> fsm){ /* qomf and a bypass empty start to valide diff --git a/src/nodeTester/ConditionalInterpreter.cpp b/src/nodeTester/ConditionalInterpreter.cpp index ccf9794a88bb1a2d90b4799915031f3138641f01..48947035eb0648effe39ff5c9ac394ead8cc7650 100644 --- a/src/nodeTester/ConditionalInterpreter.cpp +++ b/src/nodeTester/ConditionalInterpreter.cpp @@ -223,6 +223,11 @@ using namespace Aidge; throw std::runtime_error(errorMessage.str()); } dataVector.push_back(data); + + //clear + for (std::size_t i = 0; i < datas.size(); ++i) { + delete datas[i]; + } datas.clear(); return dataVector; } @@ -255,6 +260,10 @@ using namespace Aidge; throw std::runtime_error("EQ Unknown type encountered :" + a->getType() ); } dataVector.push_back(data); + //clear + for (std::size_t i = 0; i < datas.size(); ++i) { + delete datas[i]; + } datas.clear(); return dataVector; } @@ -286,6 +295,10 @@ using namespace Aidge; throw std::runtime_error("NEQ Unknown type encountered :" + a->getType() ); } dataVector.push_back(data); + //clear + for (std::size_t i = 0; i < datas.size(); ++i) { + delete datas[i]; + } datas.clear(); return dataVector; } @@ -309,6 +322,10 @@ using namespace Aidge; dataVector.push_back(data); + //clear + for (std::size_t i = 0; i < datas.size(); ++i) { + delete datas[i]; + } datas.clear(); return dataVector; } @@ -332,6 +349,10 @@ using namespace Aidge; dataVector.push_back(data); + //clear + for (std::size_t i = 0; i < datas.size(); ++i) { + delete datas[i]; + } datas.clear(); return dataVector; } @@ -354,6 +375,10 @@ using namespace Aidge; dataVector.push_back(data); + //clear + for (std::size_t i = 0; i < datas.size(); ++i) { + delete datas[i]; + } datas.clear(); return dataVector; } diff --git a/unit_tests/graphMatching/Test_GRegex.cpp b/unit_tests/graphMatching/Test_GRegex.cpp index 7184fad76a921239753d4752ae1a4a61bf3aec16..2c5907d82e7c5b1d32f1fb38493c7333b68f8731 100644 --- a/unit_tests/graphMatching/Test_GRegex.cpp +++ b/unit_tests/graphMatching/Test_GRegex.cpp @@ -53,6 +53,10 @@ TEST_CASE("Create good init GRegex", "[GRegex]") { // Perform tests REQUIRE(GReg.getStmInit().size() == 1); REQUIRE(GReg.getStmFab().getNumberOfStm() == 1); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } @@ -101,6 +105,10 @@ TEST_CASE("Function matchFromStartNodes | One Match of Nodes sequence", "[GRegex // Perform tests REQUIRE(result == true_result); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } TEST_CASE("Function matchFromStartNodes | One Match of parallel branches ", "[GRegex]") { @@ -166,6 +174,10 @@ TEST_CASE("Function matchFromStartNodes | One Match of parallel branches ", "[GR // Perform tests REQUIRE(result == true_result); REQUIRE(wrong_start_result == empty_result); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } /* diff --git a/unit_tests/graphMatching/Test_SeqStm.cpp b/unit_tests/graphMatching/Test_SeqStm.cpp index baabbbc3c10ec751c64a65ab01c2c4d502f58cb5..db8662e3329abe153d4a0fb2b3c46b950208d6bc 100644 --- a/unit_tests/graphMatching/Test_SeqStm.cpp +++ b/unit_tests/graphMatching/Test_SeqStm.cpp @@ -79,6 +79,10 @@ TEST_CASE("Create good init SeqStm", "[SeqStm]") { REQUIRE(stm.getAllCommonNode().size() == 0); REQUIRE(stm.getAllNodeTested().size() == 0); REQUIRE(stm.getAllNodeValidated().size() == 0); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } TEST_CASE("Test testNode function", "[SeqStm]") { @@ -156,4 +160,8 @@ TEST_CASE("Test testNode function", "[SeqStm]") { REQUIRE(stm.isStmBlocked() == true); REQUIRE(stm.getAllNodeTested() == testAllNodeTested); REQUIRE(stm.getAllNodeValidated() == testAllNodeValidated); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } \ No newline at end of file diff --git a/unit_tests/graphMatching/Test_StmFactory.cpp b/unit_tests/graphMatching/Test_StmFactory.cpp index b595372fd97a56f2ecf2575429c63db92484bbc0..3c66d0fa817cea674de5ab849091290c976e5735 100644 --- a/unit_tests/graphMatching/Test_StmFactory.cpp +++ b/unit_tests/graphMatching/Test_StmFactory.cpp @@ -36,6 +36,10 @@ TEST_CASE("Create good init StmFactory", "[StmFactory]") { } StmFactory stmF(nodesRegex); REQUIRE(stmF.getNumberOfStm() == 0); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } TEST_CASE("Test in makeNewStm the getStmIdx StmFactory", "[SeqStm]") { @@ -66,6 +70,10 @@ TEST_CASE("Test in makeNewStm the getStmIdx StmFactory", "[SeqStm]") { //test the number of stm REQUIRE(stmF.getNumberOfStm() == 2); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } TEST_CASE("Test in makeNewStm the stm StmFactory", "[SeqStm]") { @@ -123,6 +131,9 @@ TEST_CASE("Test in makeNewStm the stm StmFactory", "[SeqStm]") { REQUIRE(stm->getAllNodeTested() == testAllNodeTested); REQUIRE(stm->getAllNodeValidated() == testAllNodeValidated); + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } @@ -185,5 +196,9 @@ TEST_CASE("Test in duplicateStm StmFactory", "[SeqStm]") { REQUIRE(stmD->isStmBlocked() == false); REQUIRE(stmD->getAllNodeTested().size() == 0); REQUIRE(stmD->getAllNodeValidated().size() == 0); + + for (const std::string& key : nodeTypeKey) { + delete nodesRegex[key]; + } } diff --git a/unit_tests/graphRegex/Test_FsmMatch.cpp b/unit_tests/graphRegex/Test_FsmMatch.cpp index d89b274b3c287b0ee3af97b899c6fbd22e973148..cb66f4bfbf6935ad0ca022ffd2ac5ac4e7fb69d8 100644 --- a/unit_tests/graphRegex/Test_FsmMatch.cpp +++ b/unit_tests/graphRegex/Test_FsmMatch.cpp @@ -86,6 +86,4 @@ TEST_CASE("FsmMatch") { } - - } \ No newline at end of file