From ad2fcfd74680d4a2fe6127c8ca52aea41b98f031 Mon Sep 17 00:00:00 2001 From: Username404-59 Date: Fri, 26 Feb 2021 18:05:01 +0100 Subject: [PATCH] Add stack protection flags in the CMakeLists.txt file (only for the GNU and Clang compilers). --- CMakeLists.txt | 4 ++++ src/transpiler/MainTranspile.cpp | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bb9a9b..385ad21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "-pthread") set(CMAKE_CXX_FLAGS_RELEASE "-Os") +if((${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) OR (${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector -fstack-clash-protection -Wall") +endif() + if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fira-loop-pressure -ftree-loop-distribution -floop-interchange -ftree-vectorize -fipa-pta -s") set(CMAKE_CXX_FLAGS "-flto -fno-use-linker-plugin -fwhole-program ${CMAKE_CXX_FLAGS}") diff --git a/src/transpiler/MainTranspile.cpp b/src/transpiler/MainTranspile.cpp index bcb7bc8..d6dced5 100644 --- a/src/transpiler/MainTranspile.cpp +++ b/src/transpiler/MainTranspile.cpp @@ -18,11 +18,7 @@ pair validLanguage(const string& it) { break; } } - pair result { - selected, - valid - }; - return result; + return pair(selected, valid); } string transpile(string toTranspile, string language)