From 9acf263f5c46d722e3b5a2b2c26609df4e51e1e6 Mon Sep 17 00:00:00 2001 From: Dvir Yitzchaki Date: Thu, 21 Nov 2019 08:58:26 +0200 Subject: [PATCH 1/7] use conan and github actions --- .DS_Store | Bin 0 -> 6148 bytes .github/workflows/main.yml | 35 ++ .gitignore | 1 + .travis.yml | 97 ----- CMakeLists.txt | 52 ++- Chapter01/CMakeLists.txt | 2 +- Chapter01/Test.cpp | 2 +- Chapter02/CMakeLists.txt | 2 +- Chapter02/Test.cpp | 2 +- Chapter03/CMakeLists.txt | 2 +- Chapter03/Test.cpp | 2 +- Chapter04/CMakeLists.txt | 2 +- Chapter04/Test.cpp | 2 +- Chapter05/CMakeLists.txt | 2 +- Chapter05/Test.cpp | 2 +- Chapter06/CMakeLists.txt | 2 +- Chapter06/Test.cpp | 2 +- Chapter07/CMakeLists.txt | 2 +- Chapter07/Test.cpp | 2 +- Chapter08/CMakeLists.txt | 2 +- Chapter08/Test.cpp | 2 +- Chapter09/CMakeLists.txt | 4 +- Chapter09/CodeGenerator.cpp | 1 + Chapter09/TempMap.cpp | 1 + Chapter09/m68k/CMakeLists.txt | 1 + Chapter09/test/CMakeLists.txt | 3 +- Chapter09/test/Test.h | 2 +- Chapter09/test/TestMain.cpp | 2 +- Chapter09/test/checkedCompile.cpp | 2 +- Chapter09/test/compileFiles.cpp | 2 +- Chapter09/x64/CMakeLists.txt | 1 + Chapter10/CMakeLists.txt | 10 +- Chapter10/CodeGenerator.cpp | 1 + Chapter10/m68k/CMakeLists.txt | 8 +- Chapter10/m68k/m68kCodeGenerator.cpp | 6 +- Chapter10/test/CMakeLists.txt | 3 +- Chapter10/test/Test.cpp | 8 +- Chapter10/test/Test.h | 8 +- Chapter10/test/TestMain.cpp | 2 +- Chapter10/test/compileFiles.cpp | 2 +- Chapter10/x64/CMakeLists.txt | 8 +- Chapter10/x64/x64CodeGenerator.cpp | 6 +- appveyor.yml | 60 --- ci/build.cmake | 22 ++ cmake/HunterGate.cmake | 543 --------------------------- include/overload_set.h | 27 +- include/printRange.h | 1 + 47 files changed, 169 insertions(+), 782 deletions(-) create mode 100644 .DS_Store create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 ci/build.cmake delete mode 100644 cmake/HunterGate.cmake diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..dc91fee2ea3ef46f4419f1ee21a0066cfe4e7d40 GIT binary patch literal 6148 zcmeHK!EVz)5Zz4;^#Ve!#GyzWR_cLE4vAXG)e1>ZNUd!yH(s~%wvqXpok3t%`XJU zQJ17)J%}7@MAOMZl&J{%KbE4&@h>ufYv-_tDfoT8y?)U_mQKo6>zX%KoCgnAUGYdf z5l@Bq5RBC{D8sUvbi-ogy$I4ciNa!-#^rdBzwwuB!5QqT_9GZSRKV80v@(|4Xg86s{O~>$BO`X1gh0 zb=vc$oOL>_rrg?mJ)aBVK7YCW?qhXyd~*8j?ECq}rC9+EFRPX{iwn2{&3gNOn) z-X##FMc-m=5Jo__Nd+{i++H!bNe92QalXacph;(3&kS|!%-r5kxSk#SQin6{8>E&P zAO`L-uwuF%p8x&d-~aC>QI8lP2L3AsxYG-IU3esWwk|y!p0yJ66DSJC)dp`;z|coA g#NtuB4ypzG5)DA#Vr>vSAoL-iX`qG}_^S;31nH(= - TOOLCHAIN=ninja-clang-cxx17 - - - os: linux - env: > - TOOLCHAIN=ninja-gcc-7-cxx17 - - # - os: linux - # env: > - # TOOLCHAIN=analyze-cxx17 - - # - os: linux - # env: > - # TOOLCHAIN=sanitize-address-cxx17 - - # - os: linux - # env: > - # TOOLCHAIN=sanitize-leak-cxx17 - - # - os: linux - # env: > - # TOOLCHAIN=sanitize-thread-cxx17 - - # } - - # OSX { - - # - os: osx - # osx_image: xcode9.4 - # env: > - # TOOLCHAIN=osx-10-13-make-cxx14 - - - os: osx - osx_image: xcode9.4 - env: > - TOOLCHAIN=osx-10-13-cxx14 - - # } - -install: - # Info about OS - - uname -a - - # Info about available disk space - - df -h $HOME - - # Disable autoupdate - # * https://github.com/Homebrew/brew/blob/7d31a70373edae4d8e78d91a4cbc05324bebc3ba/Library/Homebrew/manpages/brew.1.md.erb#L202 - - export HOMEBREW_NO_AUTO_UPDATE=1 - - # Install Python 3 - - if [[ "`uname`" == "Darwin" ]]; then travis_retry brew upgrade python || echo "Ignoring failure..."; fi - - if [[ "`uname`" == "Darwin" ]]; then travis_retry brew install python3; fi - - # Install Python package 'requests' - # 'easy_install3' is not installed by 'brew install python3' on OS X 10.9 Maverick - - if [[ "`uname`" == "Darwin" ]]; then pip3 install requests; fi - - if [[ "`uname`" == "Darwin" ]]; then pip3 install gitpython; fi - - if [[ "`uname`" == "Linux" ]]; then travis_retry pip3 install --user requests; fi - - if [[ "`uname`" == "Linux" ]]; then travis_retry pip3 install --user gitpython; fi - - # Install latest Polly toolchains and scripts - - wget https://github.com/dvirtz/polly/archive/ninja-toolchains.zip - - unzip ninja-toolchains.zip - - POLLY_ROOT="`pwd`/polly-ninja-toolchains" - - export PATH="${POLLY_ROOT}/bin:${PATH}" - - # Install dependencies (CMake, Android NDK) - - install-ci-dependencies.py --prune-archives - - # Tune locations - - export PATH="`pwd`/_ci/cmake/bin:`pwd`/_ci/ninja_dir:${PATH}" - -script: - - build.py --toolchain ${TOOLCHAIN} --config Release --fwd POST_BUILD_TESTS=FALSE --jobs 1 --test \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index d0f5fc8..e12be9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,30 +2,52 @@ cmake_minimum_required(VERSION 3.3) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -include(HunterGate) +project(GreenTiger) + + +# Download automatically, you can also just copy the conan.cmake file +if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") + message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") + file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" + "${CMAKE_BINARY_DIR}/conan.cmake") +endif() + +include(${CMAKE_BINARY_DIR}/conan.cmake) + +if(WIN32) + find_program(CONAN conan.bat) +endif() -HunterGate( - URL "https://github.com/ruslo/hunter/archive/v0.23.66.tar.gz" - SHA1 "c599029cf00b124c624702739741fead5d4e605d" +conan_check() + +conan_add_remote( + NAME manu343726 + URL https://api.bintray.com/conan/manu343726/conan-packages) + + +set(DEPENDENCIES + boost/1.69.0@conan/stable + range-v3/0.9.0@ericniebler/stable + Catch2/2.9.2@catchorg/stable + gsl_microsoft/2.0.0@bincrafters/stable + type_safe/0.3@Manu343726/testing ) -project(GreenTiger) +conan_cmake_run(REQUIRES ${DEPENDENCIES} + CONAN_COMMAND ${CONAN} + GENERATORS cmake_paths + BUILD missing) -set(BOOST_COMPONENTS system filesystem) -hunter_add_package(Boost COMPONENTS ${BOOST_COMPONENTS}) -find_package(Boost CONFIG REQUIRED ${BOOST_COMPONENTS}) +include(${CMAKE_BINARY_DIR}/conan_paths.cmake) + + +find_package(Boost REQUIRED COMPONENTS system filesystem) -hunter_add_package(Catch) find_package(Catch2 CONFIG REQUIRED) -hunter_add_package(range-v3) find_package(range-v3 CONFIG REQUIRED) -hunter_add_package(Microsoft.GSL) -find_package(Microsoft.GSL CONFIG REQUIRED) - -hunter_add_package(type_safe) -find_package(type_safe CONFIG REQUIRED) +target_compile_options(range-v3 INTERFACE $<$:-Wno-deprecated-declarations>) include(CompilerWarnings) diff --git a/Chapter01/CMakeLists.txt b/Chapter01/CMakeLists.txt index bc21878..57ba83f 100644 --- a/Chapter01/CMakeLists.txt +++ b/Chapter01/CMakeLists.txt @@ -5,6 +5,6 @@ add_executable(Chapter01 ${HEADERS} ${SOURCES}) target_compile_definitions(Chapter01 PRIVATE CATCH_CPP14_OR_GREATER) -target_link_libraries(Chapter01 PRIVATE Boost::boost Catch2::Catch includeHeaders) +target_link_libraries(Chapter01 PRIVATE Boost::boost Catch2::Catch2 includeHeaders) parse_unit_tests(Chapter01) \ No newline at end of file diff --git a/Chapter01/Test.cpp b/Chapter01/Test.cpp index e657399..bf48f30 100644 --- a/Chapter01/Test.cpp +++ b/Chapter01/Test.cpp @@ -1,7 +1,7 @@ #include "Exercises.h" #include "Program.h" #define CATCH_CONFIG_MAIN -#include +#include using namespace GreenTiger; diff --git a/Chapter02/CMakeLists.txt b/Chapter02/CMakeLists.txt index a245024..08caeb6 100644 --- a/Chapter02/CMakeLists.txt +++ b/Chapter02/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries(Chapter02 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders) parse_unit_tests(Chapter02) \ No newline at end of file diff --git a/Chapter02/Test.cpp b/Chapter02/Test.cpp index 4aecf2c..597ba33 100644 --- a/Chapter02/Test.cpp +++ b/Chapter02/Test.cpp @@ -1,7 +1,7 @@ #include "Program.h" #include "testsHelper.h" #define CATCH_CONFIG_MAIN -#include +#include TEST_CASE("lex test files") { namespace fs = boost::filesystem; diff --git a/Chapter03/CMakeLists.txt b/Chapter03/CMakeLists.txt index acf296b..639262a 100644 --- a/Chapter03/CMakeLists.txt +++ b/Chapter03/CMakeLists.txt @@ -10,7 +10,7 @@ target_link_libraries(Chapter03 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders) parse_unit_tests(Chapter03) \ No newline at end of file diff --git a/Chapter03/Test.cpp b/Chapter03/Test.cpp index 023f18c..cf4f9a7 100644 --- a/Chapter03/Test.cpp +++ b/Chapter03/Test.cpp @@ -1,7 +1,7 @@ #include "Program.h" #include "testsHelper.h" #define CATCH_CONFIG_MAIN -#include +#include using namespace tiger; diff --git a/Chapter04/CMakeLists.txt b/Chapter04/CMakeLists.txt index d17b07e..2890932 100644 --- a/Chapter04/CMakeLists.txt +++ b/Chapter04/CMakeLists.txt @@ -15,7 +15,7 @@ target_link_libraries(Chapter04 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders) parse_unit_tests(Chapter04) \ No newline at end of file diff --git a/Chapter04/Test.cpp b/Chapter04/Test.cpp index a31c279..d45bba7 100644 --- a/Chapter04/Test.cpp +++ b/Chapter04/Test.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include using namespace tiger; using boost::get; diff --git a/Chapter05/CMakeLists.txt b/Chapter05/CMakeLists.txt index b5ee917..9686bc7 100644 --- a/Chapter05/CMakeLists.txt +++ b/Chapter05/CMakeLists.txt @@ -15,7 +15,7 @@ target_link_libraries(Chapter05 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders) parse_unit_tests(Chapter05) \ No newline at end of file diff --git a/Chapter05/Test.cpp b/Chapter05/Test.cpp index 765edfb..2708598 100644 --- a/Chapter05/Test.cpp +++ b/Chapter05/Test.cpp @@ -3,7 +3,7 @@ #define CATCH_CONFIG_MAIN #include #include -#include +#include using namespace tiger; using boost::get; diff --git a/Chapter06/CMakeLists.txt b/Chapter06/CMakeLists.txt index 947ffe1..615d6d7 100644 --- a/Chapter06/CMakeLists.txt +++ b/Chapter06/CMakeLists.txt @@ -17,7 +17,7 @@ target_link_libraries(Chapter06 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders) parse_unit_tests(Chapter06) \ No newline at end of file diff --git a/Chapter06/Test.cpp b/Chapter06/Test.cpp index 765edfb..2708598 100644 --- a/Chapter06/Test.cpp +++ b/Chapter06/Test.cpp @@ -3,7 +3,7 @@ #define CATCH_CONFIG_MAIN #include #include -#include +#include using namespace tiger; using boost::get; diff --git a/Chapter07/CMakeLists.txt b/Chapter07/CMakeLists.txt index 584d2d7..4fc6ce6 100644 --- a/Chapter07/CMakeLists.txt +++ b/Chapter07/CMakeLists.txt @@ -18,7 +18,7 @@ target_link_libraries(Chapter07 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders ) diff --git a/Chapter07/Test.cpp b/Chapter07/Test.cpp index 946eb0b..35efa06 100644 --- a/Chapter07/Test.cpp +++ b/Chapter07/Test.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include using namespace tiger; using namespace tiger::frame::x64FastCall; diff --git a/Chapter08/CMakeLists.txt b/Chapter08/CMakeLists.txt index 61b7348..bb6466e 100644 --- a/Chapter08/CMakeLists.txt +++ b/Chapter08/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(Chapter08 Boost::boost Boost::filesystem Boost::system - Catch2::Catch + Catch2::Catch2 includeHeaders ) diff --git a/Chapter08/Test.cpp b/Chapter08/Test.cpp index fd4c16f..fb947e0 100644 --- a/Chapter08/Test.cpp +++ b/Chapter08/Test.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include using namespace tiger; using namespace tiger::frame::x64FastCall; diff --git a/Chapter09/CMakeLists.txt b/Chapter09/CMakeLists.txt index cc33dd1..8114457 100644 --- a/Chapter09/CMakeLists.txt +++ b/Chapter09/CMakeLists.txt @@ -34,13 +34,15 @@ if(MSVC) set_source_files_properties(Program.cpp PROPERTIES COMPILE_FLAGS /bigobj) endif() +target_include_directories(Chapter09 PUBLIC ${CONAN_GSL_MICROSOFT_ROOT}/include) + target_link_libraries(Chapter09 PRIVATE ${MACHINE_LIBRARIES} PUBLIC Boost::boost includeHeaders - range-v3::range-v3 + range-v3 ) add_subdirectory(test) diff --git a/Chapter09/CodeGenerator.cpp b/Chapter09/CodeGenerator.cpp index 405aea4..eb37349 100644 --- a/Chapter09/CodeGenerator.cpp +++ b/Chapter09/CodeGenerator.cpp @@ -16,6 +16,7 @@ MSC_DIAG_OFF(4913) MSC_DIAG_ON() #include #include +#include #include #include diff --git a/Chapter09/TempMap.cpp b/Chapter09/TempMap.cpp index 9f46983..e9fc784 100644 --- a/Chapter09/TempMap.cpp +++ b/Chapter09/TempMap.cpp @@ -12,6 +12,7 @@ MSC_DIAG_OFF(4913) #include MSC_DIAG_ON() +#include namespace tiger { diff --git a/Chapter09/m68k/CMakeLists.txt b/Chapter09/m68k/CMakeLists.txt index be5694c..5572ecf 100644 --- a/Chapter09/m68k/CMakeLists.txt +++ b/Chapter09/m68k/CMakeLists.txt @@ -11,4 +11,5 @@ target_link_libraries(${CHAPTER}_m68k PRIVATE includeHeaders Boost::boost + range-v3 ) \ No newline at end of file diff --git a/Chapter09/test/CMakeLists.txt b/Chapter09/test/CMakeLists.txt index 1013f55..90048df 100644 --- a/Chapter09/test/CMakeLists.txt +++ b/Chapter09/test/CMakeLists.txt @@ -3,8 +3,7 @@ add_library(${CHAPTER}_testMain STATIC Test.h TestMain.cpp checkedCompile.cpp) set_target_properties(${CHAPTER}_testMain PROPERTIES OUTPUT_NAME testMain) target_link_libraries(${CHAPTER}_testMain PUBLIC - Catch2::Catch - Microsoft.GSL::GSL + Catch2::Catch2 Boost::filesystem Boost::system includeHeaders diff --git a/Chapter09/test/Test.h b/Chapter09/test/Test.h index 5378a7a..b3c1083 100644 --- a/Chapter09/test/Test.h +++ b/Chapter09/test/Test.h @@ -8,7 +8,7 @@ MSC_DIAG_OFF(4496 4459 4127) #include MSC_DIAG_ON() #include -#include +#include #include extern std::string arch; diff --git a/Chapter09/test/TestMain.cpp b/Chapter09/test/TestMain.cpp index 24b923e..5368a51 100644 --- a/Chapter09/test/TestMain.cpp +++ b/Chapter09/test/TestMain.cpp @@ -1,5 +1,5 @@ #define CATCH_CONFIG_RUNNER -#include +#include std::string arch; diff --git a/Chapter09/test/checkedCompile.cpp b/Chapter09/test/checkedCompile.cpp index f258e12..b7376ca 100644 --- a/Chapter09/test/checkedCompile.cpp +++ b/Chapter09/test/checkedCompile.cpp @@ -1,6 +1,6 @@ #include "Test.h" #include "Program.h" -#include +#include std::string checkedCompile(const std::string &string) { auto res = tiger::compile(arch, string); diff --git a/Chapter09/test/compileFiles.cpp b/Chapter09/test/compileFiles.cpp index a8f8bdd..70fcb09 100644 --- a/Chapter09/test/compileFiles.cpp +++ b/Chapter09/test/compileFiles.cpp @@ -1,7 +1,7 @@ #include "Program.h" #include "testsHelper.h" #include -#include +#include extern std::string arch; diff --git a/Chapter09/x64/CMakeLists.txt b/Chapter09/x64/CMakeLists.txt index e1a5c3d..64928f0 100644 --- a/Chapter09/x64/CMakeLists.txt +++ b/Chapter09/x64/CMakeLists.txt @@ -11,4 +11,5 @@ target_link_libraries(${CHAPTER}_x64 PRIVATE includeHeaders Boost::boost + range-v3 ) \ No newline at end of file diff --git a/Chapter10/CMakeLists.txt b/Chapter10/CMakeLists.txt index db42007..b0e174f 100644 --- a/Chapter10/CMakeLists.txt +++ b/Chapter10/CMakeLists.txt @@ -25,8 +25,12 @@ set(HEADERS Program.h ErrorHandler.h ExpressionParser.h Skipper.h IdentifierPars add_library(Chapter10 ${HEADERS} ${SOURCES}) target_include_directories(Chapter10 - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CONAN_GSL_MICROSOFT_ROOT}/include + ${CONAN_TYPE_SAFE_ROOT}/include + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} ) if(MSVC) @@ -39,7 +43,7 @@ target_link_libraries(Chapter10 PUBLIC Boost::boost includeHeaders - range-v3::range-v3 + range-v3 ) add_subdirectory(test) diff --git a/Chapter10/CodeGenerator.cpp b/Chapter10/CodeGenerator.cpp index 007cbfd..dda7faf 100644 --- a/Chapter10/CodeGenerator.cpp +++ b/Chapter10/CodeGenerator.cpp @@ -21,6 +21,7 @@ MSC_DIAG_ON() #include #include #include +#include #include #include diff --git a/Chapter10/m68k/CMakeLists.txt b/Chapter10/m68k/CMakeLists.txt index be5694c..0167946 100644 --- a/Chapter10/m68k/CMakeLists.txt +++ b/Chapter10/m68k/CMakeLists.txt @@ -5,10 +5,16 @@ add_library(${CHAPTER}_m68k ${HEADERS} ${SOURCES}) set_target_properties(${CHAPTER}_m68k PROPERTIES OUTPUT_NAME m68k) -target_include_directories(${CHAPTER}_m68k PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) +target_include_directories(${CHAPTER}_m68k + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CONAN_TYPE_SAFE_ROOT}/include + ${CONAN_GSL_MICROSOFT_ROOT}/include +) target_link_libraries(${CHAPTER}_m68k PRIVATE includeHeaders Boost::boost + range-v3 ) \ No newline at end of file diff --git a/Chapter10/m68k/m68kCodeGenerator.cpp b/Chapter10/m68k/m68kCodeGenerator.cpp index cbdccc5..a69d73a 100644 --- a/Chapter10/m68k/m68kCodeGenerator.cpp +++ b/Chapter10/m68k/m68kCodeGenerator.cpp @@ -15,7 +15,7 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : { // clang-format off Pattern{ir::Move{ir::Call{label()}, callingConvention.returnValue()}, {{InstructionType::OPERATION, "JSR `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to_()}}}, + callingConvention.callDefinedRegisters() | ranges::to}}}, Pattern{ir::Move{imm(), reg()}, {{InstructionType::OPERATION, "MOVE #`i0, `d0", {0, 1}}}}, Pattern{ir::Move{label(), reg()}, {{InstructionType::OPERATION, "MOVE #`l0, `d0", {0, 1}}}}, Pattern{ir::Move{imm(), ir::MemoryAccess{ir::BinaryOperation{ir::BinOp::PLUS, reg(), imm()}}}, @@ -54,9 +54,9 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : Pattern{ir::MemoryAccess{exp()}, {{InstructionType::OPERATION, "MOVE (`s0), `d0", {0, 1}}}}, Pattern{ir::Expression{imm()}, {{InstructionType::OPERATION, "MOVE #`i0, `d0", {0, 1}}}}, Pattern{ir::Call{label()}, {{InstructionType::OPERATION, "JSR `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to_()}}}, + callingConvention.callDefinedRegisters() | ranges::to}}}, Pattern{ir::Call{exp()}, {{InstructionType::OPERATION, "JSR `s0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to_()}}}, + callingConvention.callDefinedRegisters() | ranges::to}}}, Pattern{ir::Statement{label()}, {{InstructionType::LABEL, "`l0:", {0}}}} // clang-format on }} {} diff --git a/Chapter10/test/CMakeLists.txt b/Chapter10/test/CMakeLists.txt index 0d5fea2..0b3e070 100644 --- a/Chapter10/test/CMakeLists.txt +++ b/Chapter10/test/CMakeLists.txt @@ -3,8 +3,7 @@ add_library(${CHAPTER}_testMain STATIC Test.h TestMain.cpp Test.cpp) set_target_properties(${CHAPTER}_testMain PROPERTIES OUTPUT_NAME testMain) target_link_libraries(${CHAPTER}_testMain PUBLIC - Catch2::Catch - Microsoft.GSL::GSL + Catch2::Catch2 Boost::filesystem Boost::system includeHeaders diff --git a/Chapter10/test/Test.cpp b/Chapter10/test/Test.cpp index 1535a2f..6c4e567 100644 --- a/Chapter10/test/Test.cpp +++ b/Chapter10/test/Test.cpp @@ -145,10 +145,10 @@ class RangeMatcher : public Catch::MatcherBase { return false; } - auto m = mismatch(other, m_r); - if (m.first != end(other)) { - m_message = "at index "s + stringify(distance(begin(other), m.first)) - + ": " + stringify(*m.first) + " != " + stringify(*m.second); + auto &&[first, last] = mismatch(other, m_r); + if (first != end(other)) { + m_message = "at index "s + stringify(distance(begin(other), first)) + + ": " + stringify(*first) + " != " + stringify(*last); return false; } diff --git a/Chapter10/test/Test.h b/Chapter10/test/Test.h index ad987fa..a297a2b 100644 --- a/Chapter10/test/Test.h +++ b/Chapter10/test/Test.h @@ -17,7 +17,7 @@ MSC_DIAG_ON() #include #include #define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER -#include +#include #include #include #include @@ -145,8 +145,8 @@ class TestFixture { template ())), - decltype(ranges::end(std::declval()))>::value>> + base, decltype(ranges::begin(std::declval())), + decltype(ranges::end(std::declval()))>::value>> RegList(const Cont ®isters) : base{ranges::begin(registers), ranges::end(registers)} {} }; @@ -614,7 +614,7 @@ inline TestFixture::parser TestFixture::checkArg(size_t index, Arg &&arg, helpers::overload([](OptReg ®) { return RegList{reg}; }, [](auto && /*default*/) { return RegList{}; })(arg); - auto const r = x3::rule("argument") = [&]() -> parser { + auto const r = x3::rule("argument") = [&]() -> parser { if (arch == "m68k") { return checkMove( x3::lit('+') > checkMemoryAccess(checkReg(stackPointer())), argChecker, diff --git a/Chapter10/test/TestMain.cpp b/Chapter10/test/TestMain.cpp index f396be5..68f8243 100644 --- a/Chapter10/test/TestMain.cpp +++ b/Chapter10/test/TestMain.cpp @@ -1,5 +1,5 @@ #define CATCH_CONFIG_RUNNER -#include +#include std::string arch; diff --git a/Chapter10/test/compileFiles.cpp b/Chapter10/test/compileFiles.cpp index a8f8bdd..70fcb09 100644 --- a/Chapter10/test/compileFiles.cpp +++ b/Chapter10/test/compileFiles.cpp @@ -1,7 +1,7 @@ #include "Program.h" #include "testsHelper.h" #include -#include +#include extern std::string arch; diff --git a/Chapter10/x64/CMakeLists.txt b/Chapter10/x64/CMakeLists.txt index e1a5c3d..c41e115 100644 --- a/Chapter10/x64/CMakeLists.txt +++ b/Chapter10/x64/CMakeLists.txt @@ -5,10 +5,16 @@ add_library(${CHAPTER}_x64 ${HEADERS} ${SOURCES}) set_target_properties(${CHAPTER}_x64 PROPERTIES OUTPUT_NAME x64) -target_include_directories(${CHAPTER}_x64 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) +target_include_directories(${CHAPTER}_x64 + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CONAN_TYPE_SAFE_ROOT}/include + ${CONAN_GSL_MICROSOFT_ROOT}/include +) target_link_libraries(${CHAPTER}_x64 PRIVATE includeHeaders Boost::boost + range-v3 ) \ No newline at end of file diff --git a/Chapter10/x64/x64CodeGenerator.cpp b/Chapter10/x64/x64CodeGenerator.cpp index dc20cbd..b8d27d8 100644 --- a/Chapter10/x64/x64CodeGenerator.cpp +++ b/Chapter10/x64/x64CodeGenerator.cpp @@ -20,7 +20,7 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : { // clang-format off Pattern{ir::Move{ir::Call{label()}, callingConvention.returnValue()}, {{InstructionType::OPERATION, "call `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to_()}}}, + callingConvention.callDefinedRegisters() | ranges::to}}}, Pattern{ir::Move{imm(), reg()}, {{InstructionType::OPERATION, "mov `d0, `i0", {1, 0}}}}, Pattern{ir::Move{label(), reg()}, {{InstructionType::OPERATION, "mov `d0, `l0", {1, 0}}}}, Pattern{ir::Move{imm(), ir::MemoryAccess{ir::BinaryOperation{ir::BinOp::PLUS, reg(), imm()}}}, @@ -61,9 +61,9 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : Pattern{ir::MemoryAccess{exp()}, {{InstructionType::OPERATION, "mov `d0, [`s0]", {1, 0}}}}, Pattern{ir::Expression{imm()}, {{InstructionType::OPERATION, "mov `d0, `i0", {1, 0}}}}, Pattern{ir::Call{label()}, {{InstructionType::OPERATION, "call `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to_()}}}, + callingConvention.callDefinedRegisters() | ranges::to}}}, Pattern{ir::Call{exp()}, {{InstructionType::OPERATION, "call `s0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to_()}}}, + callingConvention.callDefinedRegisters() | ranges::to}}}, Pattern{ir::Statement{label()}, {{InstructionType::LABEL, "`l0:", {0}}}} // clang-format on } // namespace assembly diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index ed14d95..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,60 +0,0 @@ - -cache: - C:/.hunter - -environment: - matrix: - - # - TOOLCHAIN: "ninja-vs-15-2017-win64-cxx17" - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - # - TOOLCHAIN: "nmake-vs-15-2017-win64-cxx17" - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - - TOOLCHAIN: "vs-15-2017-win64-cxx17" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - - # - TOOLCHAIN: "vs-14-2015-sdk-8-1" - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - - TOOLCHAIN: "mingw-cxx17" - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - - # - TOOLCHAIN: "msys-cxx17" - # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - -install: - # Python 3 - - cmd: set PATH=C:\Python34-x64;C:\Python34-x64\Scripts;%PATH% - - # Install Python package 'requests', 'gitpython' - - cmd: pip install requests - - cmd: pip install gitpython - - # Install latest Polly toolchains and scripts - - cmd: appveyor DownloadFile https://github.com/dvirtz/polly/archive/ninja-toolchains.zip - - cmd: 7z x ninja-toolchains.zip - - cmd: set POLLY_ROOT=%cd%\polly-ninja-toolchains - - # Install dependencies (CMake, Ninja) - - cmd: python %POLLY_ROOT%\bin\install-ci-dependencies.py - - # Tune locations - - cmd: set PATH=%cd%\_ci\cmake\bin;%PATH% - - cmd: set PATH=%cd%\_ci\ninja_dir;%PATH% - - # Remove entry with sh.exe from PATH to fix error with MinGW toolchain - # (For MinGW make to work correctly sh.exe must NOT be in your path) - # * http://stackoverflow.com/a/3870338/2288008 - - cmd: set PATH=%PATH:C:\Program Files\Git\usr\bin;=% - - - cmd: set MINGW_PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin - - # MSYS2 location - - cmd: set MSYS_PATH=C:\msys64\usr\bin - - # Visual Studio 15 2017: Mimic behavior of older versions - - cmd: set VS150COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools - -build_script: - - cmd: python %POLLY_ROOT%\bin\build.py --config Release --toolchain "%TOOLCHAIN%" --fwd POST_BUILD_TESTS=FALSE --jobs 1 --test diff --git a/ci/build.cmake b/ci/build.cmake new file mode 100644 index 0000000..ce3b27d --- /dev/null +++ b/ci/build.cmake @@ -0,0 +1,22 @@ +if(NOT DEFINED BUILD_TYPE) + message(FATAL_ERROR "Please provide a build type with -DBUILD_TYPE=") +endif() + +set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT) + +function(execute EXECUTABLE) + execute_process(COMMAND ${EXECUTABLE} ${ARGN} RESULT_VARIABLE retcode) + if(NOT "${retcode}" STREQUAL "0") + message(FATAL_ERROR "Fatal error when running ${EXECUTABLE}") + endif() +endfunction() + +get_filename_component(SOURCE_FOLDER ${CMAKE_SCRIPT_MODE_FILE} DIRECTORY) +get_filename_component(SOURCE_FOLDER ${SOURCE_FOLDER} DIRECTORY) + +if(NOT DEFINED BUILD_FOLDER) + set(BUILD_FOLDER build) +endif() + +execute(${CMAKE_COMMAND} -S ${SOURCE_FOLDER} -B ${BUILD_FOLDER} -G Ninja -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DRUN_TESTS_POSTBUILD=ON -DCMAKE_CXX_STANDARD=17) +execute(${CMAKE_COMMAND} --build ${BUILD_FOLDER}) \ No newline at end of file diff --git a/cmake/HunterGate.cmake b/cmake/HunterGate.cmake deleted file mode 100644 index c24c0e5..0000000 --- a/cmake/HunterGate.cmake +++ /dev/null @@ -1,543 +0,0 @@ -# Copyright (c) 2013-2017, Ruslan Baratov -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# This is a gate file to Hunter package manager. -# Include this file using `include` command and add package you need, example: -# -# cmake_minimum_required(VERSION 3.0) -# -# include("cmake/HunterGate.cmake") -# HunterGate( -# URL "https://github.com/path/to/hunter/archive.tar.gz" -# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d" -# ) -# -# project(MyProject) -# -# hunter_add_package(Foo) -# hunter_add_package(Boo COMPONENTS Bar Baz) -# -# Projects: -# * https://github.com/hunter-packages/gate/ -# * https://github.com/ruslo/hunter - -option(HUNTER_ENABLED "Enable Hunter package manager support" ON) -if(HUNTER_ENABLED) - if(CMAKE_VERSION VERSION_LESS "3.0") - message(FATAL_ERROR "At least CMake version 3.0 required for hunter dependency management." - " Update CMake or set HUNTER_ENABLED to OFF.") - endif() -endif() - -include(CMakeParseArguments) # cmake_parse_arguments - -option(HUNTER_STATUS_PRINT "Print working status" ON) -option(HUNTER_STATUS_DEBUG "Print a lot info" OFF) -option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON) - -set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki") - -function(hunter_gate_status_print) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG) - message(STATUS "[hunter] ${print_message}") - endif() - endforeach() -endfunction() - -function(hunter_gate_status_debug) - foreach(print_message ${ARGV}) - if(HUNTER_STATUS_DEBUG) - string(TIMESTAMP timestamp) - message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}") - endif() - endforeach() -endfunction() - -function(hunter_gate_wiki wiki_page) - message("------------------------------ WIKI -------------------------------") - message(" ${HUNTER_WIKI}/${wiki_page}") - message("-------------------------------------------------------------------") - message("") - message(FATAL_ERROR "") -endfunction() - -function(hunter_gate_internal_error) - message("") - foreach(print_message ${ARGV}) - message("[hunter ** INTERNAL **] ${print_message}") - endforeach() - message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") - message("") - hunter_gate_wiki("error.internal") -endfunction() - -function(hunter_gate_fatal_error) - cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}") - string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki) - if(have_no_wiki) - hunter_gate_internal_error("Expected wiki") - endif() - message("") - foreach(x ${hunter_UNPARSED_ARGUMENTS}) - message("[hunter ** FATAL ERROR **] ${x}") - endforeach() - message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]") - message("") - hunter_gate_wiki("${hunter_WIKI}") -endfunction() - -function(hunter_gate_user_error) - hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data") -endfunction() - -function(hunter_gate_self root version sha1 result) - string(COMPARE EQUAL "${root}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("root is empty") - endif() - - string(COMPARE EQUAL "${version}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("version is empty") - endif() - - string(COMPARE EQUAL "${sha1}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("sha1 is empty") - endif() - - string(SUBSTRING "${sha1}" 0 7 archive_id) - - if(EXISTS "${root}/cmake/Hunter") - set(hunter_self "${root}") - else() - set( - hunter_self - "${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked" - ) - endif() - - set("${result}" "${hunter_self}" PARENT_SCOPE) -endfunction() - -# Set HUNTER_GATE_ROOT cmake variable to suitable value. -function(hunter_gate_detect_root) - # Check CMake variable - string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty) - if(not_empty) - set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable") - return() - endif() - - # Check environment variable - string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty) - if(not_empty) - set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT detected by environment variable") - return() - endif() - - # Check HOME environment variable - string(COMPARE NOTEQUAL "$ENV{HOME}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable") - return() - endif() - - # Check SYSTEMDRIVE and USERPROFILE environment variable (windows only) - if(WIN32) - string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug( - "HUNTER_ROOT set using SYSTEMDRIVE environment variable" - ) - return() - endif() - - string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result) - if(result) - set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE) - hunter_gate_status_debug( - "HUNTER_ROOT set using USERPROFILE environment variable" - ) - return() - endif() - endif() - - hunter_gate_fatal_error( - "Can't detect HUNTER_ROOT" - WIKI "error.detect.hunter.root" - ) -endfunction() - -macro(hunter_gate_lock dir) - if(NOT HUNTER_SKIP_LOCK) - if("${CMAKE_VERSION}" VERSION_LESS "3.2") - hunter_gate_fatal_error( - "Can't lock, upgrade to CMake 3.2 or use HUNTER_SKIP_LOCK" - WIKI "error.can.not.lock" - ) - endif() - hunter_gate_status_debug("Locking directory: ${dir}") - file(LOCK "${dir}" DIRECTORY GUARD FUNCTION) - hunter_gate_status_debug("Lock done") - endif() -endmacro() - -function(hunter_gate_download dir) - string( - COMPARE - NOTEQUAL - "$ENV{HUNTER_DISABLE_AUTOINSTALL}" - "" - disable_autoinstall - ) - if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL) - hunter_gate_fatal_error( - "Hunter not found in '${dir}'" - "Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'" - "Settings:" - " HUNTER_ROOT: ${HUNTER_GATE_ROOT}" - " HUNTER_SHA1: ${HUNTER_GATE_SHA1}" - WIKI "error.run.install" - ) - endif() - string(COMPARE EQUAL "${dir}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("Empty 'dir' argument") - endif() - - string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("HUNTER_GATE_SHA1 empty") - endif() - - string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad) - if(is_bad) - hunter_gate_internal_error("HUNTER_GATE_URL empty") - endif() - - set(done_location "${dir}/DONE") - set(sha1_location "${dir}/SHA1") - - set(build_dir "${dir}/Build") - set(cmakelists "${dir}/CMakeLists.txt") - - hunter_gate_lock("${dir}") - if(EXISTS "${done_location}") - # while waiting for lock other instance can do all the job - hunter_gate_status_debug("File '${done_location}' found, skip install") - return() - endif() - - file(REMOVE_RECURSE "${build_dir}") - file(REMOVE_RECURSE "${cmakelists}") - - file(MAKE_DIRECTORY "${build_dir}") # check directory permissions - - # Disabling languages speeds up a little bit, reduces noise in the output - # and avoids path too long windows error - file( - WRITE - "${cmakelists}" - "cmake_minimum_required(VERSION 3.0)\n" - "project(HunterDownload LANGUAGES NONE)\n" - "include(ExternalProject)\n" - "ExternalProject_Add(\n" - " Hunter\n" - " URL\n" - " \"${HUNTER_GATE_URL}\"\n" - " URL_HASH\n" - " SHA1=${HUNTER_GATE_SHA1}\n" - " DOWNLOAD_DIR\n" - " \"${dir}\"\n" - " TLS_VERIFY\n" - " ${HUNTER_TLS_VERIFY}\n" - " SOURCE_DIR\n" - " \"${dir}/Unpacked\"\n" - " CONFIGURE_COMMAND\n" - " \"\"\n" - " BUILD_COMMAND\n" - " \"\"\n" - " INSTALL_COMMAND\n" - " \"\"\n" - ")\n" - ) - - if(HUNTER_STATUS_DEBUG) - set(logging_params "") - else() - set(logging_params OUTPUT_QUIET) - endif() - - hunter_gate_status_debug("Run generate") - - # Need to add toolchain file too. - # Otherwise on Visual Studio + MDD this will fail with error: - # "Could not find an appropriate version of the Windows 10 SDK installed on this machine" - if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") - get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE) - set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}") - else() - # 'toolchain_arg' can't be empty - set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=") - endif() - - string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make) - if(no_make) - set(make_arg "") - else() - # Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM - set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}") - endif() - - execute_process( - COMMAND - "${CMAKE_COMMAND}" - "-H${dir}" - "-B${build_dir}" - "-G${CMAKE_GENERATOR}" - "${toolchain_arg}" - ${make_arg} - WORKING_DIRECTORY "${dir}" - RESULT_VARIABLE download_result - ${logging_params} - ) - - if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Configure project failed") - endif() - - hunter_gate_status_print( - "Initializing Hunter workspace (${HUNTER_GATE_SHA1})" - " ${HUNTER_GATE_URL}" - " -> ${dir}" - ) - execute_process( - COMMAND "${CMAKE_COMMAND}" --build "${build_dir}" - WORKING_DIRECTORY "${dir}" - RESULT_VARIABLE download_result - ${logging_params} - ) - - if(NOT download_result EQUAL 0) - hunter_gate_internal_error("Build project failed") - endif() - - file(REMOVE_RECURSE "${build_dir}") - file(REMOVE_RECURSE "${cmakelists}") - - file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}") - file(WRITE "${done_location}" "DONE") - - hunter_gate_status_debug("Finished") -endfunction() - -# Must be a macro so master file 'cmake/Hunter' can -# apply all variables easily just by 'include' command -# (otherwise PARENT_SCOPE magic needed) -macro(HunterGate) - if(HUNTER_GATE_DONE) - # variable HUNTER_GATE_DONE set explicitly for external project - # (see `hunter_download`) - set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) - endif() - - # First HunterGate command will init Hunter, others will be ignored - get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET) - - if(NOT HUNTER_ENABLED) - # Empty function to avoid error "unknown function" - function(hunter_add_package) - endfunction() - - set( - _hunter_gate_disabled_mode_dir - "${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode" - ) - if(EXISTS "${_hunter_gate_disabled_mode_dir}") - hunter_gate_status_debug( - "Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}" - ) - list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}") - endif() - elseif(_hunter_gate_done) - hunter_gate_status_debug("Secondary HunterGate (use old settings)") - hunter_gate_self( - "${HUNTER_CACHED_ROOT}" - "${HUNTER_VERSION}" - "${HUNTER_SHA1}" - _hunter_self - ) - include("${_hunter_self}/cmake/Hunter") - else() - set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_LIST_DIR}") - - string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name) - if(_have_project_name) - hunter_gate_fatal_error( - "Please set HunterGate *before* 'project' command. " - "Detected project: ${PROJECT_NAME}" - WIKI "error.huntergate.before.project" - ) - endif() - - cmake_parse_arguments( - HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV} - ) - - string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1) - string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url) - string( - COMPARE - NOTEQUAL - "${HUNTER_GATE_UNPARSED_ARGUMENTS}" - "" - _have_unparsed - ) - string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global) - string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath) - - if(_have_unparsed) - hunter_gate_user_error( - "HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}" - ) - endif() - if(_empty_sha1) - hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory") - endif() - if(_empty_url) - hunter_gate_user_error("URL suboption of HunterGate is mandatory") - endif() - if(_have_global) - if(HUNTER_GATE_LOCAL) - hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)") - endif() - if(_have_filepath) - hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)") - endif() - endif() - if(HUNTER_GATE_LOCAL) - if(_have_global) - hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)") - endif() - if(_have_filepath) - hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)") - endif() - endif() - if(_have_filepath) - if(_have_global) - hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)") - endif() - if(HUNTER_GATE_LOCAL) - hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)") - endif() - endif() - - hunter_gate_detect_root() # set HUNTER_GATE_ROOT - - # Beautify path, fix probable problems with windows path slashes - get_filename_component( - HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE - ) - hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}") - if(NOT HUNTER_ALLOW_SPACES_IN_PATH) - string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces) - if(NOT _contain_spaces EQUAL -1) - hunter_gate_fatal_error( - "HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces." - "Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error" - "(Use at your own risk!)" - WIKI "error.spaces.in.hunter.root" - ) - endif() - endif() - - string( - REGEX - MATCH - "[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*" - HUNTER_GATE_VERSION - "${HUNTER_GATE_URL}" - ) - string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty) - if(_is_empty) - set(HUNTER_GATE_VERSION "unknown") - endif() - - hunter_gate_self( - "${HUNTER_GATE_ROOT}" - "${HUNTER_GATE_VERSION}" - "${HUNTER_GATE_SHA1}" - _hunter_self - ) - - set(_master_location "${_hunter_self}/cmake/Hunter") - if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter") - # Hunter downloaded manually (e.g. by 'git clone') - set(_unused "xxxxxxxxxx") - set(HUNTER_GATE_SHA1 "${_unused}") - set(HUNTER_GATE_VERSION "${_unused}") - else() - get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE) - set(_done_location "${_archive_id_location}/DONE") - set(_sha1_location "${_archive_id_location}/SHA1") - - # Check Hunter already downloaded by HunterGate - if(NOT EXISTS "${_done_location}") - hunter_gate_download("${_archive_id_location}") - endif() - - if(NOT EXISTS "${_done_location}") - hunter_gate_internal_error("hunter_gate_download failed") - endif() - - if(NOT EXISTS "${_sha1_location}") - hunter_gate_internal_error("${_sha1_location} not found") - endif() - file(READ "${_sha1_location}" _sha1_value) - string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal) - if(NOT _is_equal) - hunter_gate_internal_error( - "Short SHA1 collision:" - " ${_sha1_value} (from ${_sha1_location})" - " ${HUNTER_GATE_SHA1} (HunterGate)" - ) - endif() - if(NOT EXISTS "${_master_location}") - hunter_gate_user_error( - "Master file not found:" - " ${_master_location}" - "try to update Hunter/HunterGate" - ) - endif() - endif() - include("${_master_location}") - set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES) - endif() -endmacro() diff --git a/include/overload_set.h b/include/overload_set.h index 06d388d..d8b222c 100644 --- a/include/overload_set.h +++ b/include/overload_set.h @@ -1,36 +1,21 @@ #pragma once #include #include +#include namespace helpers { -namespace detail { + namespace detail { -// https://www.youtube.com/watch?v=mqei4JJRQ7s -// make an overload of multiple function objects -template struct overload_set { - void operator()() {} -}; +template struct overload_set : Ts... { using Ts::operator()...; }; +template overload_set(Ts...) -> overload_set; -template -struct overload_set : Func, overload_set { - using Func::operator(); - using overload_set::operator(); - - overload_set(const overload_set &) = default; - overload_set &operator=(const overload_set &) = default; - - overload_set(const Func &f, const Funcs &... fs) - : Func(f), overload_set(fs...) {} -}; - -} // namespace detail + } template auto overload(Funcs &&... fs) { - using os = detail::overload_set::type...>; - return os(std::forward(fs)...); + return detail::overload_set{std::forward(fs)...}; } } // namespace helpers diff --git a/include/printRange.h b/include/printRange.h index 23cb0c9..1c1d42c 100644 --- a/include/printRange.h +++ b/include/printRange.h @@ -8,6 +8,7 @@ MSC_DIAG_OFF(4100) #include MSC_DIAG_ON() #include +#include namespace helpers { template From dce89c6de8b6a879a06334e7a7282dc234409319 Mon Sep 17 00:00:00 2001 From: Dvir Yitzchaki Date: Thu, 21 Nov 2019 16:03:59 +0200 Subject: [PATCH 2/7] fix clang errors --- .gitignore | 3 ++ CMakeLists.txt | 4 +- Chapter09/Assembly.cpp | 4 +- Chapter09/CallingConvention.cpp | 4 +- Chapter09/CodeGenerator.cpp | 2 +- Chapter09/Program.cpp | 2 +- Chapter09/m68k/m68kCodeGenerator.cpp | 2 +- Chapter09/x64/x64CodeGenerator.cpp | 4 +- Chapter10/Assembly.cpp | 10 ++--- Chapter10/CallingConvention.cpp | 6 +-- Chapter10/CodeGenerator.cpp | 4 +- Chapter10/FlowGraph.cpp | 4 +- Chapter10/Frame.cpp | 2 +- Chapter10/LivenessAnalyser.cpp | 4 +- Chapter10/Program.cpp | 4 +- Chapter10/m68k/m68kCodeGenerator.cpp | 2 +- Chapter10/test/Test.cpp | 2 +- Chapter10/test/Test.h | 23 +++++------- Chapter10/x64/x64CodeGenerator.cpp | 2 +- include/printRange.h | 4 +- include/satisfy_boost_range_backport.hpp | 48 ------------------------ 21 files changed, 46 insertions(+), 94 deletions(-) delete mode 100644 include/satisfy_boost_range_backport.hpp diff --git a/.gitignore b/.gitignore index cc40cf7..fe88ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ # build folders _*/ build + +# pyenv +.python-version diff --git a/CMakeLists.txt b/CMakeLists.txt index e12be9d..6b46e0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ conan_add_remote( set(DEPENDENCIES - boost/1.69.0@conan/stable + boost/1.71.0@_/_ range-v3/0.9.0@ericniebler/stable Catch2/2.9.2@catchorg/stable gsl_microsoft/2.0.0@bincrafters/stable @@ -47,7 +47,7 @@ find_package(Catch2 CONFIG REQUIRED) find_package(range-v3 CONFIG REQUIRED) -target_compile_options(range-v3 INTERFACE $<$:-Wno-deprecated-declarations>) +target_compile_options(range-v3 INTERFACE $<$,$>:-Wno-deprecated-declarations>) include(CompilerWarnings) diff --git a/Chapter09/Assembly.cpp b/Chapter09/Assembly.cpp index 2d0be14..2115479 100644 --- a/Chapter09/Assembly.cpp +++ b/Chapter09/Assembly.cpp @@ -25,7 +25,7 @@ Operation::Operation(std::initializer_list syntaxes, const Registers &sources /* = {} */, const Labels &labels /* = {} */, const Immediates &immediates /* = {} */) : - m_syntax{syntaxes | ranges::view::intersperse("\n") | ranges::action::join}, + m_syntax{syntaxes | ranges::views::intersperse("\n") | ranges::actions::join}, m_destinations{destinations}, m_sources{sources}, m_jumps{labels}, m_immediates{immediates} {} @@ -109,7 +109,7 @@ assembly::Instructions } return res; #else - return action::join(instructions); + return actions::join(instructions); #endif } diff --git a/Chapter09/CallingConvention.cpp b/Chapter09/CallingConvention.cpp index 50adaf9..554fd60 100644 --- a/Chapter09/CallingConvention.cpp +++ b/Chapter09/CallingConvention.cpp @@ -27,7 +27,7 @@ assembly::Instructions CallingConvention::procEntryExit2(const assembly::Instructions &body) const { // appends a “sink” instruction to the function body to tell the // register allocator that certain registers are live at procedure exit - namespace rv = ranges::view; + namespace rv = ranges::views; auto calleeSaved = calleeSavedRegisters(); auto liveAtExit = rv::concat(calleeSaved, rv::single(returnValue()), rv::single(stackPointer())); @@ -36,7 +36,7 @@ assembly::Instructions res.push_back(assembly::Operation{{}, {}, liveAtExit}); return res; #else - return ranges::view::concat( + return ranges::views::concat( body, rv::single(assembly::Operation{{}, {}, liveAtExit})); #endif } diff --git a/Chapter09/CodeGenerator.cpp b/Chapter09/CodeGenerator.cpp index eb37349..ca7aa55 100644 --- a/Chapter09/CodeGenerator.cpp +++ b/Chapter09/CodeGenerator.cpp @@ -302,7 +302,7 @@ bool DagMatcher::match(const ir::Call &code, const ir::Call &pattern, bool matchFailed = false; auto args = - code.args | ranges::view::transform([&](const ir::Expression &arg) { + code.args | ranges::views::transform([&](const ir::Expression &arg) { return helpers::match(arg)( [](int i) -> ir::Expression { return i; }, [](const temp::Register ®) -> ir::Expression { return reg; }, diff --git a/Chapter09/Program.cpp b/Chapter09/Program.cpp index eef472e..84a5159 100644 --- a/Chapter09/Program.cpp +++ b/Chapter09/Program.cpp @@ -59,7 +59,7 @@ CompileResult compile(const std::string &arch, Iterator &first, using namespace ranges; auto instructions = - compiled | view::transform([&](Fragment &fragment) { + compiled | views::transform([&](Fragment &fragment) { return helpers::match(fragment)( [&](FunctionFragment &function) { auto canonicalized = diff --git a/Chapter09/m68k/m68kCodeGenerator.cpp b/Chapter09/m68k/m68kCodeGenerator.cpp index f806a3d..cd1cc5c 100644 --- a/Chapter09/m68k/m68kCodeGenerator.cpp +++ b/Chapter09/m68k/m68kCodeGenerator.cpp @@ -65,7 +65,7 @@ Instructions CodeGenerator::translateString(const temp::Label &label, Instructions CodeGenerator::translateArgs(const std::vector &args, const temp::Map & /* tempMap */) const { - return args | ranges::view::transform([](const ir::Expression &arg) { + return args | ranges::views::transform([](const ir::Expression &arg) { return helpers::match(arg)( [](int i) { return Move{"MOVE #`i0, -(sp)", {}, {}, {}, {i}}; diff --git a/Chapter09/x64/x64CodeGenerator.cpp b/Chapter09/x64/x64CodeGenerator.cpp index f067829..a5b79b6 100644 --- a/Chapter09/x64/x64CodeGenerator.cpp +++ b/Chapter09/x64/x64CodeGenerator.cpp @@ -70,7 +70,7 @@ Instructions ? "mov " + *tempMap.lookup(argumentRegisters[index]) + ", " + arg : "push " + arg; }; - return ranges::view::zip_with( + return ranges::views::zip_with( [&](int index, const ir::Expression &arg) { return helpers::match(arg)( [&](int i) { @@ -87,7 +87,7 @@ Instructions return Move{}; }); }, - ranges::view::ints, args); + ranges::views::ints, args); } } // namespace x64 diff --git a/Chapter10/Assembly.cpp b/Chapter10/Assembly.cpp index a9f86fd..65ef7b3 100644 --- a/Chapter10/Assembly.cpp +++ b/Chapter10/Assembly.cpp @@ -72,7 +72,7 @@ void Instruction::print(std::ostream &out, const temp::Map &tempMap) const { auto const noop = [](size_t) { assert(false && "should not get here"); }; - namespace rv = ranges::view; + namespace rv = ranges::views; helpers::match (*this)( [&](const Label &label) { @@ -109,7 +109,7 @@ Instruction Instruction::create(const InstructionType type, parse(inst.m_syntax, setOperand(inst.m_labels), setOperand(inst.m_destinations), setOperand(inst.m_sources), setOperand(inst.m_immediates), noop); - auto const toRegisters = ranges::view::transform( + auto const toRegisters = ranges::views::transform( [](const Operand &op) { return boost::get(op); }); inst.m_implicitDestinations = implicitDestinations | toRegisters; inst.m_implicitSources = implicitSources | toRegisters; @@ -155,7 +155,7 @@ temp::Registers Instruction::destinations() const { return helpers::match(*this)( [](const Label &) -> temp::Registers { return {}; }, [](const auto &inst) -> temp::Registers { - return ranges::view::concat(inst.m_destinations, + return ranges::views::concat(inst.m_destinations, inst.m_implicitDestinations); }); } @@ -164,7 +164,7 @@ temp::Registers Instruction::sources() const { return helpers::match(*this)( [](const Label &) -> temp::Registers { return {}; }, [](const auto &inst) -> temp::Registers { - return ranges::view::concat(inst.m_sources, inst.m_implicitSources); + return ranges::views::concat(inst.m_sources, inst.m_implicitSources); }); } @@ -195,7 +195,7 @@ assembly::Instructions } return res; #else - return instructions | view::join; + return instructions | views::join; #endif } diff --git a/Chapter10/CallingConvention.cpp b/Chapter10/CallingConvention.cpp index 60bc9c4..1b5e88c 100644 --- a/Chapter10/CallingConvention.cpp +++ b/Chapter10/CallingConvention.cpp @@ -24,7 +24,7 @@ ir::Expression } temp::Registers CallingConvention::liveAtExitRegisters() const { - namespace rv = ranges::view; + namespace rv = ranges::views; auto calleeSaved = calleeSavedRegisters(); return rv::concat(calleeSaved, rv::single(stackPointer())); } @@ -33,13 +33,13 @@ assembly::Instructions CallingConvention::procEntryExit2(const assembly::Instructions &body) const { // appends a “sink” instruction to the function body to tell the // register allocator that certain registers are live at procedure exit - namespace rv = ranges::view; + namespace rv = ranges::views; #ifdef _MSC_VER auto res = body; res.push_back(assembly::Operation{{}, {}, liveAtExitRegisters()}); return res; #else - return ranges::view::concat( + return ranges::views::concat( body, rv::single(assembly::Operation{{}, {}, liveAtExitRegisters()})); #endif } diff --git a/Chapter10/CodeGenerator.cpp b/Chapter10/CodeGenerator.cpp index dda7faf..b2f1604 100644 --- a/Chapter10/CodeGenerator.cpp +++ b/Chapter10/CodeGenerator.cpp @@ -169,7 +169,7 @@ boost::optional DagMatcher::match(const Dag &dag) const { continue; } - namespace rv = ranges::view; + namespace rv = ranges::views; auto maxOperandIndex = ranges::max( pattern.m_initializers @@ -312,7 +312,7 @@ bool DagMatcher::match(const ir::Call &code, const ir::Call &pattern, bool matchFailed = false; auto args = - code.args | ranges::view::transform([&](const ir::Expression &arg) { + code.args | ranges::views::transform([&](const ir::Expression &arg) { return helpers::match(arg)( [](int i) -> ir::Expression { return i; }, [](const temp::Register ®) -> ir::Expression { return reg; }, diff --git a/Chapter10/FlowGraph.cpp b/Chapter10/FlowGraph.cpp index c975022..8cefa01 100644 --- a/Chapter10/FlowGraph.cpp +++ b/Chapter10/FlowGraph.cpp @@ -17,8 +17,8 @@ FlowGraph::FlowGraph(const assembly::Instructions &instructions) : base{instructions.size()}, m_uses{instructions.size()}, m_defs{instructions.size()}, m_isMove{instructions.size()} { using namespace assembly; - namespace rv = ranges::view; - namespace ra = ranges::action; + namespace rv = ranges::views; + namespace ra = ranges::actions; const std::unordered_map label_map = rv::zip(instructions, rv::ints) diff --git a/Chapter10/Frame.cpp b/Chapter10/Frame.cpp index bcd4f47..b598d75 100644 --- a/Chapter10/Frame.cpp +++ b/Chapter10/Frame.cpp @@ -11,7 +11,7 @@ Frame::Frame(temp::Map &tempMap, const CallingConvention &callingConvention) : ir::Statement Frame::procEntryExit1(const ir::Statement &body) const { return ir::Sequence{ - ranges::view::concat(m_parameterMoves, ranges::view::single(body))}; + ranges::views::concat(m_parameterMoves, ranges::views::single(body))}; } assembly::Instructions diff --git a/Chapter10/LivenessAnalyser.cpp b/Chapter10/LivenessAnalyser.cpp index 94e4ce1..e27406b 100644 --- a/Chapter10/LivenessAnalyser.cpp +++ b/Chapter10/LivenessAnalyser.cpp @@ -20,8 +20,8 @@ MSC_DIAG_OFF(4239 4459 4913) #include MSC_DIAG_ON() -namespace rv = ranges::view; -namespace ra = ranges::action; +namespace rv = ranges::views; +namespace ra = ranges::actions; namespace tiger { namespace regalloc { diff --git a/Chapter10/Program.cpp b/Chapter10/Program.cpp index 12c5feb..6f0f9cb 100644 --- a/Chapter10/Program.cpp +++ b/Chapter10/Program.cpp @@ -70,8 +70,8 @@ CompileResult compile(const std::string &arch, Iterator &first, Canonicalizer canonicalizer{tempMap}; auto &codeGenerator = machine->codeGenerator(); - namespace rv = ranges::view; - namespace ra = ranges::action; + namespace rv = ranges::views; + namespace ra = ranges::actions; auto const fragments = compiled | rv::transform([&](Fragment &fragment) { return helpers::match(fragment)( diff --git a/Chapter10/m68k/m68kCodeGenerator.cpp b/Chapter10/m68k/m68kCodeGenerator.cpp index a69d73a..26e08ed 100644 --- a/Chapter10/m68k/m68kCodeGenerator.cpp +++ b/Chapter10/m68k/m68kCodeGenerator.cpp @@ -70,7 +70,7 @@ Instructions CodeGenerator::translateString(const temp::Label &label, Instructions CodeGenerator::translateArgs(const std::vector &args, const temp::Map & /* tempMap */) const { - return args | ranges::view::transform([this](const ir::Expression &arg) { + return args | ranges::views::transform([this](const ir::Expression &arg) { return helpers::match(arg)( [this](int i) { return Operation{"MOVE #`i0, +(`s0)", diff --git a/Chapter10/test/Test.cpp b/Chapter10/test/Test.cpp index 6c4e567..116c250 100644 --- a/Chapter10/test/Test.cpp +++ b/Chapter10/test/Test.cpp @@ -173,7 +173,7 @@ void TestFixture::checkInterference( const InterferenceGraphs &interefernceGraphs) const { REQUIRE(ranges::distance(interefernceGraphs) == ranges::distance(m_interferences)); - ranges::for_each(ranges::view::zip(interefernceGraphs, m_interferences), + ranges::for_each(ranges::views::zip(interefernceGraphs, m_interferences), [](const auto &p) { REQUIRE_THAT(p.first, Equals(p.second)); }); diff --git a/Chapter10/test/Test.h b/Chapter10/test/Test.h index a297a2b..f5a63f1 100644 --- a/Chapter10/test/Test.h +++ b/Chapter10/test/Test.h @@ -2,9 +2,6 @@ #include "Tree.h" #include "irange.h" #include "warning_suppress.h" -#ifdef _MSC_VER -#include "satisfy_boost_range_backport.hpp" -#endif #include #include #include @@ -400,8 +397,8 @@ inline TestFixture::parser TestFixture::checkReg(const temp::Register ®) { inline TestFixture::parser TestFixture::checkReg(OptReg ®) { static auto const predefinedRegisters = this->predefinedRegisters(); static const x3::symbols regsParser{ - predefinedRegisters | ranges::view::values, - predefinedRegisters | ranges::view::keys, "regsParser"}; + predefinedRegisters | ranges::views::values, + predefinedRegisters | ranges::views::keys, "regsParser"}; auto const r = x3::rule{"register"} = ((x3::lit("t") >> x3::int_[setOrCheck(reg)]) | regsParser[setOrCheck(reg)]); return r; @@ -541,7 +538,7 @@ inline TestFixture::parser TestFixture::checkMove(Dst &&dest, Src &&src, inline auto TestFixture::liveRegistersAnd(const RegList &liveRegisters) const { return [&liveRegisters](auto&&... regs) { - return ranges::view::concat(liveRegisters, ranges::view::single(Reg{regs})...); + return ranges::views::concat(liveRegisters, ranges::views::single(Reg{regs})...); }; } @@ -618,7 +615,7 @@ inline TestFixture::parser TestFixture::checkArg(size_t index, Arg &&arg, if (arch == "m68k") { return checkMove( x3::lit('+') > checkMemoryAccess(checkReg(stackPointer())), argChecker, - ranges::view::concat(ranges::view::single(stackPointer()), uses)); + ranges::views::concat(ranges::views::single(stackPointer()), uses)); } static const auto &argumentRegisters = this->argumentRegisters(); @@ -648,15 +645,15 @@ inline TestFixture::parser TestFixture::checkArgs(const RegList &liveRegisters, }, [](const temp::Register &r) { return boost::optional{r}; }, [](const auto &) { return boost::optional{}; }); - auto const arguments = view::concat(view::single(toOptReg(args))...); + auto const arguments = views::concat(views::single(toOptReg(args))...); auto withLiveArguments = [&liveRegisters, arguments](size_t i) -> RegList { std::vector> a{ - arguments | view::drop(i + 1) - | view::filter( + arguments | views::drop(i + 1) + | views::filter( [](const boost::optional &r) { return r.is_initialized(); })}; - return view::concat( + return views::concat( liveRegisters, - view::transform(a, [](const boost::optional &r) { return *r; })); + views::transform(a, [](const boost::optional &r) { return *r; })); }; return combineParsers(checkArg(I, args, withLiveArguments(I))...); } @@ -905,7 +902,7 @@ inline TestFixture::parser TestFixture::checkParameterMove(size_t index, x3::rule{"parameter move"} = [&]() -> parser { if (index < argumentRegisters.size()) { auto const liveRegisters = - argumentRegisters | ranges::view::slice(index + 1, argumentCount) | ranges::to_vector; + argumentRegisters | ranges::views::slice(index + 1, argumentCount) | ranges::to_vector; return checkInlineParameterWrite( index, std::forward(arg), checkReg(argumentRegisters[index]), {argumentRegisters[index]}, {}, liveRegisters, does_escape::value); diff --git a/Chapter10/x64/x64CodeGenerator.cpp b/Chapter10/x64/x64CodeGenerator.cpp index b8d27d8..57ad05e 100644 --- a/Chapter10/x64/x64CodeGenerator.cpp +++ b/Chapter10/x64/x64CodeGenerator.cpp @@ -79,7 +79,7 @@ Instructions CodeGenerator::translateString(const temp::Label &label, Instructions CodeGenerator::translateArgs(const std::vector &args, const temp::Map & /*tempMap*/) const { - namespace rv = ranges::view; + namespace rv = ranges::views; auto const registerArguments = rv::zip_with( [](temp::Register argumentRegister, const ir::Expression &arg) { return helpers::match(arg)( diff --git a/include/printRange.h b/include/printRange.h index 1c1d42c..7dda3ac 100644 --- a/include/printRange.h +++ b/include/printRange.h @@ -16,8 +16,8 @@ void printRange(std::ostream &ost, const R &rng, ElementToString &&elementToString) { using namespace ranges; ost << "{"; - copy(rng | view::transform(std::forward(elementToString)) - | view::intersperse(", "), + copy(rng | views::transform(std::forward(elementToString)) + | views::intersperse(", "), ostream_iterator(ost)); ost << "}"; } diff --git a/include/satisfy_boost_range_backport.hpp b/include/satisfy_boost_range_backport.hpp deleted file mode 100644 index 6cbb79e..0000000 --- a/include/satisfy_boost_range_backport.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/// \file -// Range v3 library -// -// Copyright Eric Niebler 2014 -// -// Use, modification and distribution is subject to the -// Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) -// -// Project home: https://github.com/ericniebler/range-v3 -// - -#ifndef RANGES_V3_DETAIL_SATISFY_BOOST_RANGE_HPP -#define RANGES_V3_DETAIL_SATISFY_BOOST_RANGE_HPP - -#include - -namespace boost { - - /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3 views - template struct range_mutable_iterator; - - /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3 views - template struct range_const_iterator; - - /// \brief Boost Range specialisation point, for making Boost ranges out of range-v3 views - template struct range_value; -} - -/// \brief Macro specialising Boost Range metafunctions for the specified view -#define RANGES_SATISFY_BOOST_RANGE(view_name) \ -namespace boost { \ - template \ - struct range_mutable_iterator< view_name< Ts... >, void> { \ - using type = ranges::range_iterator_t< view_name< Ts... > >; \ - }; \ - template \ - struct range_const_iterator < view_name< Ts... >, void> { \ - using type = ranges::range_iterator_t< const view_name< Ts... > >; \ - }; \ - template \ - struct range_value < view_name< Ts... > > { \ - using type = ranges::range_value_t < view_name< Ts... > >; \ - }; \ -} - -#endif From 0d22150aab3cf427fed4c6348661a2179518fba1 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Sun, 1 Dec 2019 18:37:11 +0200 Subject: [PATCH 3/7] fix VS build --- CMakeLists.txt | 8 +++++++- Chapter01/CMakeLists.txt | 1 - Chapter02/CMakeLists.txt | 1 - Chapter02/Program.cpp | 2 +- Chapter03/CMakeLists.txt | 1 - Chapter03/DeclerationParser.h | 2 +- Chapter03/ExpressionParser.h | 2 +- Chapter03/IdentifierParser.h | 2 +- Chapter03/Skipper.h | 2 +- Chapter04/CMakeLists.txt | 1 - Chapter04/DeclerationParser.h | 2 +- Chapter04/ExpressionParser.h | 2 +- Chapter04/IdentifierParser.h | 2 +- Chapter04/Skipper.h | 2 +- Chapter04/StringParser.h | 2 +- Chapter05/CMakeLists.txt | 1 - Chapter05/DeclerationParser.h | 2 +- Chapter05/ExpressionParser.h | 2 +- Chapter05/IdentifierParser.h | 2 +- Chapter05/Program.cpp | 3 +++ Chapter05/Skipper.h | 2 +- Chapter05/StringParser.h | 2 +- Chapter06/CMakeLists.txt | 1 - Chapter06/DeclerationParser.h | 2 +- Chapter06/ExpressionParser.h | 2 +- Chapter06/IdentifierParser.h | 2 +- Chapter06/Skipper.h | 2 +- Chapter06/StringParser.h | 2 +- Chapter07/CMakeLists.txt | 1 - Chapter07/DeclerationParser.h | 2 +- Chapter07/ExpressionParser.h | 2 +- Chapter07/IdentifierParser.h | 2 +- Chapter07/Skipper.h | 2 +- Chapter07/StringParser.h | 2 +- Chapter08/CMakeLists.txt | 1 - Chapter08/DeclerationParser.h | 2 +- Chapter08/ExpressionParser.h | 2 +- Chapter08/IdentifierParser.h | 2 +- Chapter08/Skipper.h | 2 +- Chapter08/StringParser.h | 2 +- Chapter09/Assembly.cpp | 13 ++----------- Chapter09/CallingConvention.cpp | 6 +++++- Chapter09/CodeGenerator.cpp | 2 +- Chapter09/DeclerationParser.h | 4 ++-- Chapter09/ExpressionParser.h | 5 ++--- Chapter09/IdentifierParser.h | 5 ++--- Chapter09/Skipper.h | 2 +- Chapter09/StringParser.h | 5 ++--- Chapter09/test/Test.h | 2 +- Chapter10/Assembly.cpp | 10 +--------- Chapter10/CallingConvention.cpp | 6 +++++- Chapter10/CodeGenerator.cpp | 4 +++- Chapter10/DeclerationParser.h | 4 ++-- Chapter10/ExpressionParser.h | 5 ++--- Chapter10/FlowGraph.cpp | 2 +- Chapter10/Frame.cpp | 3 +++ Chapter10/IdentifierParser.h | 5 ++--- Chapter10/LivenessAnalyser.cpp | 1 + Chapter10/Skipper.h | 2 +- Chapter10/StringParser.h | 5 ++--- Chapter10/m68k/m68kCodeGenerator.cpp | 8 ++++---- Chapter10/test/Test.h | 18 ++++++------------ Chapter10/x64/x64CodeGenerator.cpp | 8 ++++---- 63 files changed, 95 insertions(+), 109 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b46e0c..675f0b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,14 +40,20 @@ conan_cmake_run(REQUIRES ${DEPENDENCIES} include(${CMAKE_BINARY_DIR}/conan_paths.cmake) +set(Boost_USE_STATIC_LIBS ON) find_package(Boost REQUIRED COMPONENTS system filesystem) +set_target_properties(Boost::filesystem PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") + find_package(Catch2 CONFIG REQUIRED) find_package(range-v3 CONFIG REQUIRED) -target_compile_options(range-v3 INTERFACE $<$,$>:-Wno-deprecated-declarations>) +target_compile_options(range-v3 + INTERFACE + $<$,$>:-Wno-deprecated-declarations> + $<$:/wd4996;/Wv:18>) include(CompilerWarnings) diff --git a/Chapter01/CMakeLists.txt b/Chapter01/CMakeLists.txt index 57ba83f..aafa9e5 100644 --- a/Chapter01/CMakeLists.txt +++ b/Chapter01/CMakeLists.txt @@ -3,7 +3,6 @@ set(HEADERS Program.h Exercises.h) add_executable(Chapter01 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter01 PRIVATE CATCH_CPP14_OR_GREATER) target_link_libraries(Chapter01 PRIVATE Boost::boost Catch2::Catch2 includeHeaders) diff --git a/Chapter02/CMakeLists.txt b/Chapter02/CMakeLists.txt index 08caeb6..9133ad2 100644 --- a/Chapter02/CMakeLists.txt +++ b/Chapter02/CMakeLists.txt @@ -3,7 +3,6 @@ set(HEADERS Program.h) add_executable(Chapter02 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter02 PRIVATE CATCH_CPP14_OR_GREATER) target_link_libraries(Chapter02 PRIVATE diff --git a/Chapter02/Program.cpp b/Chapter02/Program.cpp index 85bf4cf..8d5915a 100644 --- a/Chapter02/Program.cpp +++ b/Chapter02/Program.cpp @@ -1,5 +1,5 @@ #include "warning_suppress.h" -MSC_DIAG_OFF(4458 4457) +MSC_DIAG_OFF(4458 4457 4819) #include #include MSC_DIAG_ON() diff --git a/Chapter03/CMakeLists.txt b/Chapter03/CMakeLists.txt index 639262a..0e2cf6d 100644 --- a/Chapter03/CMakeLists.txt +++ b/Chapter03/CMakeLists.txt @@ -3,7 +3,6 @@ set(HEADERS Program.h ErrorHandler.h ExpressionParser.h Skipper.h IdentifierPars add_executable(Chapter03 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter03 PRIVATE CATCH_CPP14_OR_GREATER $<$:BOOST_SPIRIT_DEBUG>) target_link_libraries(Chapter03 PRIVATE diff --git a/Chapter03/DeclerationParser.h b/Chapter03/DeclerationParser.h index 5042161..2762da3 100644 --- a/Chapter03/DeclerationParser.h +++ b/Chapter03/DeclerationParser.h @@ -2,7 +2,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter03/ExpressionParser.h b/Chapter03/ExpressionParser.h index 9dda76a..22280bf 100644 --- a/Chapter03/ExpressionParser.h +++ b/Chapter03/ExpressionParser.h @@ -8,7 +8,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter03/IdentifierParser.h b/Chapter03/IdentifierParser.h index 3de219b..72877d5 100644 --- a/Chapter03/IdentifierParser.h +++ b/Chapter03/IdentifierParser.h @@ -2,7 +2,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter03/Skipper.h b/Chapter03/Skipper.h index a9fb95a..1479090 100644 --- a/Chapter03/Skipper.h +++ b/Chapter03/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter04/CMakeLists.txt b/Chapter04/CMakeLists.txt index 2890932..22d1af3 100644 --- a/Chapter04/CMakeLists.txt +++ b/Chapter04/CMakeLists.txt @@ -4,7 +4,6 @@ set(HEADERS Program.h ErrorHandler.h ExpressionParser.h Skipper.h IdentifierPars add_executable(Chapter04 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter04 PRIVATE CATCH_CPP14_OR_GREATER $<$:BOOST_SPIRIT_DEBUG>) if(MSVC) set_source_files_properties(Program.cpp PROPERTIES COMPILE_FLAGS /bigobj) diff --git a/Chapter04/DeclerationParser.h b/Chapter04/DeclerationParser.h index 413e278..c0f9752 100644 --- a/Chapter04/DeclerationParser.h +++ b/Chapter04/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter04/ExpressionParser.h b/Chapter04/ExpressionParser.h index 320bab5..09e213e 100644 --- a/Chapter04/ExpressionParser.h +++ b/Chapter04/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter04/IdentifierParser.h b/Chapter04/IdentifierParser.h index a777933..4a01851 100644 --- a/Chapter04/IdentifierParser.h +++ b/Chapter04/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter04/Skipper.h b/Chapter04/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter04/Skipper.h +++ b/Chapter04/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter04/StringParser.h b/Chapter04/StringParser.h index b4acab8..99b486b 100644 --- a/Chapter04/StringParser.h +++ b/Chapter04/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter05/CMakeLists.txt b/Chapter05/CMakeLists.txt index 9686bc7..d6eb533 100644 --- a/Chapter05/CMakeLists.txt +++ b/Chapter05/CMakeLists.txt @@ -4,7 +4,6 @@ set(HEADERS Program.h ErrorHandler.h ExpressionParser.h Skipper.h IdentifierPars add_executable(Chapter05 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter05 PRIVATE CATCH_CPP14_OR_GREATER) if(MSVC) set_source_files_properties(Program.cpp PROPERTIES COMPILE_FLAGS /bigobj) diff --git a/Chapter05/DeclerationParser.h b/Chapter05/DeclerationParser.h index 268ccd1..7afadd6 100644 --- a/Chapter05/DeclerationParser.h +++ b/Chapter05/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter05/ExpressionParser.h b/Chapter05/ExpressionParser.h index 65a2984..c9239e0 100644 --- a/Chapter05/ExpressionParser.h +++ b/Chapter05/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter05/IdentifierParser.h b/Chapter05/IdentifierParser.h index f51204f..6180ac2 100644 --- a/Chapter05/IdentifierParser.h +++ b/Chapter05/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter05/Program.cpp b/Chapter05/Program.cpp index 52a4efc..f541809 100644 --- a/Chapter05/Program.cpp +++ b/Chapter05/Program.cpp @@ -1,8 +1,11 @@ #include "Program.h" #include "Compiler.h" #include "ExpressionParser.h" +#include "warning_suppress.h" +MSC_DIAG_OFF(4819) #include #include +MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter05/Skipper.h b/Chapter05/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter05/Skipper.h +++ b/Chapter05/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter05/StringParser.h b/Chapter05/StringParser.h index cc21011..f434ad2 100644 --- a/Chapter05/StringParser.h +++ b/Chapter05/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter06/CMakeLists.txt b/Chapter06/CMakeLists.txt index 615d6d7..2e6355f 100644 --- a/Chapter06/CMakeLists.txt +++ b/Chapter06/CMakeLists.txt @@ -6,7 +6,6 @@ list(APPEND HEADERS x64FastCall/Frame.h x64FastCall/Frame.cpp) add_executable(Chapter06 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter06 PRIVATE CATCH_CPP14_OR_GREATER) if(MSVC) set_source_files_properties(Program.cpp PROPERTIES COMPILE_FLAGS /bigobj) diff --git a/Chapter06/DeclerationParser.h b/Chapter06/DeclerationParser.h index 268ccd1..7afadd6 100644 --- a/Chapter06/DeclerationParser.h +++ b/Chapter06/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter06/ExpressionParser.h b/Chapter06/ExpressionParser.h index 65a2984..c9239e0 100644 --- a/Chapter06/ExpressionParser.h +++ b/Chapter06/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter06/IdentifierParser.h b/Chapter06/IdentifierParser.h index f51204f..6180ac2 100644 --- a/Chapter06/IdentifierParser.h +++ b/Chapter06/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter06/Skipper.h b/Chapter06/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter06/Skipper.h +++ b/Chapter06/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter06/StringParser.h b/Chapter06/StringParser.h index cc21011..f434ad2 100644 --- a/Chapter06/StringParser.h +++ b/Chapter06/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter07/CMakeLists.txt b/Chapter07/CMakeLists.txt index 4fc6ce6..d2e1f96 100644 --- a/Chapter07/CMakeLists.txt +++ b/Chapter07/CMakeLists.txt @@ -7,7 +7,6 @@ list(APPEND HEADERS x64FastCall/Frame.h x64FastCall/Frame.cpp) add_executable(Chapter07 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter07 PRIVATE CATCH_CPP14_OR_GREATER) if(MSVC) set_source_files_properties(Program.cpp PROPERTIES COMPILE_FLAGS /bigobj) diff --git a/Chapter07/DeclerationParser.h b/Chapter07/DeclerationParser.h index 268ccd1..7afadd6 100644 --- a/Chapter07/DeclerationParser.h +++ b/Chapter07/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter07/ExpressionParser.h b/Chapter07/ExpressionParser.h index 65a2984..c9239e0 100644 --- a/Chapter07/ExpressionParser.h +++ b/Chapter07/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter07/IdentifierParser.h b/Chapter07/IdentifierParser.h index f51204f..6180ac2 100644 --- a/Chapter07/IdentifierParser.h +++ b/Chapter07/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter07/Skipper.h b/Chapter07/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter07/Skipper.h +++ b/Chapter07/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter07/StringParser.h b/Chapter07/StringParser.h index cc21011..f434ad2 100644 --- a/Chapter07/StringParser.h +++ b/Chapter07/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter08/CMakeLists.txt b/Chapter08/CMakeLists.txt index bb6466e..18e443c 100644 --- a/Chapter08/CMakeLists.txt +++ b/Chapter08/CMakeLists.txt @@ -7,7 +7,6 @@ list(APPEND HEADERS x64FastCall/Frame.h x64FastCall/Frame.cpp) add_executable(Chapter08 ${HEADERS} ${SOURCES}) -target_compile_definitions(Chapter08 PRIVATE CATCH_CPP14_OR_GREATER) if(MSVC) set_source_files_properties(Program.cpp PROPERTIES COMPILE_FLAGS /bigobj) diff --git a/Chapter08/DeclerationParser.h b/Chapter08/DeclerationParser.h index 268ccd1..7afadd6 100644 --- a/Chapter08/DeclerationParser.h +++ b/Chapter08/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter08/ExpressionParser.h b/Chapter08/ExpressionParser.h index 65a2984..c9239e0 100644 --- a/Chapter08/ExpressionParser.h +++ b/Chapter08/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter08/IdentifierParser.h b/Chapter08/IdentifierParser.h index f51204f..6180ac2 100644 --- a/Chapter08/IdentifierParser.h +++ b/Chapter08/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter08/Skipper.h b/Chapter08/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter08/Skipper.h +++ b/Chapter08/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter08/StringParser.h b/Chapter08/StringParser.h index cc21011..f434ad2 100644 --- a/Chapter08/StringParser.h +++ b/Chapter08/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter09/Assembly.cpp b/Chapter09/Assembly.cpp index 2115479..5cf201e 100644 --- a/Chapter09/Assembly.cpp +++ b/Chapter09/Assembly.cpp @@ -1,7 +1,7 @@ #include "Assembly.h" #include "variantMatch.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4459 4127) +MSC_DIAG_OFF(4459 4127 4819) #include MSC_DIAG_ON() #include @@ -101,16 +101,7 @@ std::ostream &operator<<( assembly::Instructions joinInstructions(ranges::any_view instructions) { - using namespace ranges; -#ifdef _MSC_VER - assembly::Instructions res; - for (auto &&insts : instructions) { - move(insts, back_inserter(res)); - } - return res; -#else - return actions::join(instructions); -#endif + return ranges::actions::join(instructions); } } // namespace assembly diff --git a/Chapter09/CallingConvention.cpp b/Chapter09/CallingConvention.cpp index 554fd60..90ec43c 100644 --- a/Chapter09/CallingConvention.cpp +++ b/Chapter09/CallingConvention.cpp @@ -1,6 +1,10 @@ #include "CallingConvention.h" #include "Assembly.h" -#include +#include "warning_suppress.h" +MSC_DIAG_OFF(4702) +#include +MSC_DIAG_ON() +#include namespace tiger { namespace frame { diff --git a/Chapter09/CodeGenerator.cpp b/Chapter09/CodeGenerator.cpp index ca7aa55..97136a4 100644 --- a/Chapter09/CodeGenerator.cpp +++ b/Chapter09/CodeGenerator.cpp @@ -7,7 +7,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459 4456) +MSC_DIAG_OFF(4996 4459 4456 4819) #include MSC_DIAG_ON() #include diff --git a/Chapter09/DeclerationParser.h b/Chapter09/DeclerationParser.h index 268ccd1..d448c1a 100644 --- a/Chapter09/DeclerationParser.h +++ b/Chapter09/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include @@ -29,7 +29,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter09/ExpressionParser.h b/Chapter09/ExpressionParser.h index 65a2984..0f4e270 100644 --- a/Chapter09/ExpressionParser.h +++ b/Chapter09/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() @@ -34,6 +34,7 @@ class ExpressionParser namespace phoenix = boost::phoenix; using namespace std::string_literals; + using namespace boost::spirit::qi::labels; using ascii::alnum; using phoenix::at_c; @@ -52,8 +53,6 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; - relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( "<", ast::Operation::LESS_THEN)(">", ast::Operation::GREATER_THEN)( diff --git a/Chapter09/IdentifierParser.h b/Chapter09/IdentifierParser.h index f51204f..bb359b6 100644 --- a/Chapter09/IdentifierParser.h +++ b/Chapter09/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include @@ -23,6 +23,7 @@ class IdentifierParser namespace phoenix = boost::phoenix; using namespace std::string_literals; + using namespace boost::spirit::labels; using ascii::alnum; using ascii::alpha; @@ -34,8 +35,6 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; - keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter09/Skipper.h b/Chapter09/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter09/Skipper.h +++ b/Chapter09/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter09/StringParser.h b/Chapter09/StringParser.h index cc21011..748f5a5 100644 --- a/Chapter09/StringParser.h +++ b/Chapter09/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include @@ -23,6 +23,7 @@ class StringParser namespace phoenix = boost::phoenix; using namespace std::string_literals; + using namespace boost::spirit::labels; using qi::fail; using qi::lit; @@ -35,8 +36,6 @@ class StringParser using phoenix::bind; - using namespace qi::labels; - string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter | asciiCode | (char_ - '"'))] diff --git a/Chapter09/test/Test.h b/Chapter09/test/Test.h index b3c1083..f0013dd 100644 --- a/Chapter09/test/Test.h +++ b/Chapter09/test/Test.h @@ -3,7 +3,7 @@ #include "warning_suppress.h" #include #include -MSC_DIAG_OFF(4496 4459 4127) +MSC_DIAG_OFF(4496 4459 4127 4819) #include #include MSC_DIAG_ON() diff --git a/Chapter10/Assembly.cpp b/Chapter10/Assembly.cpp index 65ef7b3..17019c1 100644 --- a/Chapter10/Assembly.cpp +++ b/Chapter10/Assembly.cpp @@ -1,7 +1,7 @@ #include "Assembly.h" #include "variantMatch.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4459 4127) +MSC_DIAG_OFF(4459 4127 4819) #include MSC_DIAG_ON() #include @@ -188,15 +188,7 @@ std::ostream &operator<<( assembly::Instructions joinInstructions(gsl::span instructions) { using namespace ranges; -#ifdef _MSC_VER - assembly::Instructions res; - for (auto &&insts : instructions) { - move(insts, back_inserter(res)); - } - return res; -#else return instructions | views::join; -#endif } } // namespace assembly diff --git a/Chapter10/CallingConvention.cpp b/Chapter10/CallingConvention.cpp index 1b5e88c..502fbb1 100644 --- a/Chapter10/CallingConvention.cpp +++ b/Chapter10/CallingConvention.cpp @@ -1,6 +1,10 @@ #include "CallingConvention.h" #include "Assembly.h" -#include +#include "warning_suppress.h" +MSC_DIAG_OFF(4702) +#include +MSC_DIAG_ON() +#include namespace tiger { namespace frame { diff --git a/Chapter10/CodeGenerator.cpp b/Chapter10/CodeGenerator.cpp index b2f1604..00e0eef 100644 --- a/Chapter10/CodeGenerator.cpp +++ b/Chapter10/CodeGenerator.cpp @@ -7,7 +7,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459 4456) +MSC_DIAG_OFF(4996 4459 4456 4819) #include MSC_DIAG_ON() #include @@ -18,7 +18,9 @@ MSC_DIAG_ON() MSC_DIAG_OFF(4459) #include MSC_DIAG_ON() +MSC_DIAG_OFF(4702) #include +MSC_DIAG_ON() #include #include #include diff --git a/Chapter10/DeclerationParser.h b/Chapter10/DeclerationParser.h index 268ccd1..d448c1a 100644 --- a/Chapter10/DeclerationParser.h +++ b/Chapter10/DeclerationParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include @@ -29,7 +29,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter10/ExpressionParser.h b/Chapter10/ExpressionParser.h index 65a2984..0f4e270 100644 --- a/Chapter10/ExpressionParser.h +++ b/Chapter10/ExpressionParser.h @@ -11,7 +11,7 @@ #include #include #include -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() @@ -34,6 +34,7 @@ class ExpressionParser namespace phoenix = boost::phoenix; using namespace std::string_literals; + using namespace boost::spirit::qi::labels; using ascii::alnum; using phoenix::at_c; @@ -52,8 +53,6 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; - relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( "<", ast::Operation::LESS_THEN)(">", ast::Operation::GREATER_THEN)( diff --git a/Chapter10/FlowGraph.cpp b/Chapter10/FlowGraph.cpp index 8cefa01..5456316 100644 --- a/Chapter10/FlowGraph.cpp +++ b/Chapter10/FlowGraph.cpp @@ -6,7 +6,7 @@ MSC_DIAG_OFF(4459) #include #include #include -#include +#include #include MSC_DIAG_ON() #include diff --git a/Chapter10/Frame.cpp b/Chapter10/Frame.cpp index b598d75..beb01ad 100644 --- a/Chapter10/Frame.cpp +++ b/Chapter10/Frame.cpp @@ -1,6 +1,9 @@ #include "Frame.h" #include "Assembly.h" +#include "warning_suppress.h" +MSC_DIAG_OFF(4702) #include +MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter10/IdentifierParser.h b/Chapter10/IdentifierParser.h index f51204f..bb359b6 100644 --- a/Chapter10/IdentifierParser.h +++ b/Chapter10/IdentifierParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include @@ -23,6 +23,7 @@ class IdentifierParser namespace phoenix = boost::phoenix; using namespace std::string_literals; + using namespace boost::spirit::labels; using ascii::alnum; using ascii::alpha; @@ -34,8 +35,6 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; - keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter10/LivenessAnalyser.cpp b/Chapter10/LivenessAnalyser.cpp index e27406b..1543fec 100644 --- a/Chapter10/LivenessAnalyser.cpp +++ b/Chapter10/LivenessAnalyser.cpp @@ -18,6 +18,7 @@ MSC_DIAG_OFF(4239 4459 4913) #include #include #include +#include MSC_DIAG_ON() namespace rv = ranges::views; diff --git a/Chapter10/Skipper.h b/Chapter10/Skipper.h index 000fe68..efa739b 100644 --- a/Chapter10/Skipper.h +++ b/Chapter10/Skipper.h @@ -1,6 +1,6 @@ #pragma once #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() diff --git a/Chapter10/StringParser.h b/Chapter10/StringParser.h index cc21011..748f5a5 100644 --- a/Chapter10/StringParser.h +++ b/Chapter10/StringParser.h @@ -3,7 +3,7 @@ #include "ErrorHandler.h" #include "Skipper.h" #include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459) +MSC_DIAG_OFF(4996 4459 4819) #include MSC_DIAG_ON() #include @@ -23,6 +23,7 @@ class StringParser namespace phoenix = boost::phoenix; using namespace std::string_literals; + using namespace boost::spirit::labels; using qi::fail; using qi::lit; @@ -35,8 +36,6 @@ class StringParser using phoenix::bind; - using namespace qi::labels; - string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter | asciiCode | (char_ - '"'))] diff --git a/Chapter10/m68k/m68kCodeGenerator.cpp b/Chapter10/m68k/m68kCodeGenerator.cpp index 26e08ed..f47260c 100644 --- a/Chapter10/m68k/m68kCodeGenerator.cpp +++ b/Chapter10/m68k/m68kCodeGenerator.cpp @@ -2,7 +2,7 @@ #include "Tree.h" #include "m68kCallingConvention.h" #include "variantMatch.h" -#include +#include #include namespace tiger { @@ -15,7 +15,7 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : { // clang-format off Pattern{ir::Move{ir::Call{label()}, callingConvention.returnValue()}, {{InstructionType::OPERATION, "JSR `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to}}}, + callingConvention.callDefinedRegisters() | ranges::to()}}}, Pattern{ir::Move{imm(), reg()}, {{InstructionType::OPERATION, "MOVE #`i0, `d0", {0, 1}}}}, Pattern{ir::Move{label(), reg()}, {{InstructionType::OPERATION, "MOVE #`l0, `d0", {0, 1}}}}, Pattern{ir::Move{imm(), ir::MemoryAccess{ir::BinaryOperation{ir::BinOp::PLUS, reg(), imm()}}}, @@ -54,9 +54,9 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : Pattern{ir::MemoryAccess{exp()}, {{InstructionType::OPERATION, "MOVE (`s0), `d0", {0, 1}}}}, Pattern{ir::Expression{imm()}, {{InstructionType::OPERATION, "MOVE #`i0, `d0", {0, 1}}}}, Pattern{ir::Call{label()}, {{InstructionType::OPERATION, "JSR `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to}}}, + callingConvention.callDefinedRegisters() | ranges::to()}}}, Pattern{ir::Call{exp()}, {{InstructionType::OPERATION, "JSR `s0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to}}}, + callingConvention.callDefinedRegisters() | ranges::to()}}}, Pattern{ir::Statement{label()}, {{InstructionType::LABEL, "`l0:", {0}}}} // clang-format on }} {} diff --git a/Chapter10/test/Test.h b/Chapter10/test/Test.h index f5a63f1..d946804 100644 --- a/Chapter10/test/Test.h +++ b/Chapter10/test/Test.h @@ -5,7 +5,7 @@ #include #include #include -MSC_DIAG_OFF(4496 4459 4127) +MSC_DIAG_OFF(4496 4459 4127 4819) #include #include MSC_DIAG_ON() @@ -37,12 +37,6 @@ MSC_DIAG_ON() #include #include -#ifdef _MSC_VER -// make these work with boost -RANGES_SATISFY_BOOST_RANGE(ranges::v3::iter_transform_view) -RANGES_SATISFY_BOOST_RANGE(ranges::v3::transform_view) -#endif - namespace x3 = boost::spirit::x3; namespace ir = tiger::ir; namespace temp = tiger::temp; @@ -142,10 +136,10 @@ class TestFixture { template ())), - decltype(ranges::end(std::declval()))>::value>> - RegList(const Cont ®isters) : - base{ranges::begin(registers), ranges::end(registers)} {} + base, decltype(ranges::begin(std::declval())), + decltype(ranges::end(std::declval()))>::value>> + RegList(Cont &®isters) : + base{ranges::begin(std::forward(registers)), ranges::end(std::forward(registers))} {} }; template @@ -792,7 +786,7 @@ inline TestFixture::parser const RegList &liveRegisters /*= {}*/) { auto const liveRegistersAnd = this->liveRegistersAnd(liveRegisters); auto const r = x3::rule{"member address"} = - checkMove(temps[0], memberIndex, liveRegistersAnd(base)) + checkMove(temps[0], memberIndex, liveRegistersAnd(base) | ranges::to()) > checkMove(temps[1], wordSize(), liveRegistersAnd(base, temps[0])) > checkBinaryOperation(ir::BinOp::MUL, temps[0], temps[1], temps[2], liveRegistersAnd(base)) diff --git a/Chapter10/x64/x64CodeGenerator.cpp b/Chapter10/x64/x64CodeGenerator.cpp index 57ad05e..afeaf7c 100644 --- a/Chapter10/x64/x64CodeGenerator.cpp +++ b/Chapter10/x64/x64CodeGenerator.cpp @@ -2,7 +2,7 @@ #include "CallingConvention.h" #include "Tree.h" #include "x64Registers.h" -#include +#include #include #include #include @@ -20,7 +20,7 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : { // clang-format off Pattern{ir::Move{ir::Call{label()}, callingConvention.returnValue()}, {{InstructionType::OPERATION, "call `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to}}}, + callingConvention.callDefinedRegisters() | ranges::to()}}}, Pattern{ir::Move{imm(), reg()}, {{InstructionType::OPERATION, "mov `d0, `i0", {1, 0}}}}, Pattern{ir::Move{label(), reg()}, {{InstructionType::OPERATION, "mov `d0, `l0", {1, 0}}}}, Pattern{ir::Move{imm(), ir::MemoryAccess{ir::BinaryOperation{ir::BinOp::PLUS, reg(), imm()}}}, @@ -61,9 +61,9 @@ CodeGenerator::CodeGenerator(frame::CallingConvention &callingConvention) : Pattern{ir::MemoryAccess{exp()}, {{InstructionType::OPERATION, "mov `d0, [`s0]", {1, 0}}}}, Pattern{ir::Expression{imm()}, {{InstructionType::OPERATION, "mov `d0, `i0", {1, 0}}}}, Pattern{ir::Call{label()}, {{InstructionType::OPERATION, "call `l0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to}}}, + callingConvention.callDefinedRegisters() | ranges::to()}}}, Pattern{ir::Call{exp()}, {{InstructionType::OPERATION, "call `s0", {0}, {}, - callingConvention.callDefinedRegisters() | ranges::to}}}, + callingConvention.callDefinedRegisters() | ranges::to()}}}, Pattern{ir::Statement{label()}, {{InstructionType::LABEL, "`l0:", {0}}}} // clang-format on } // namespace assembly From 998da2c07bd0319ddb96f95319eb8f79d80d8171 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Sun, 1 Dec 2019 21:30:47 +0200 Subject: [PATCH 4/7] disable Windows debug --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dece4a1..18dc074 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: windows-native: strategy: matrix: - build_type: [Debug, Release] + build_type: [Release] runs-on: windows-2019 env: CC: cl.exe From 4629858d201d03f3ff072cf6e84aa37566bb8955 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Mon, 2 Dec 2019 00:25:59 +0200 Subject: [PATCH 5/7] fix VS release --- Chapter09/Assembly.h | 3 +++ Chapter10/Assembly.cpp | 2 +- Chapter10/FlowGraph.cpp | 2 +- Chapter10/Program.cpp | 4 ++-- Chapter10/test/Test.h | 4 ++-- Chapter10/x64/x64CodeGenerator.cpp | 3 +++ include/printRange.h | 6 ++---- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Chapter09/Assembly.h b/Chapter09/Assembly.h index 161ffe9..c18f3ad 100644 --- a/Chapter09/Assembly.h +++ b/Chapter09/Assembly.h @@ -1,8 +1,11 @@ #pragma once #include "TempMap.h" +#include "warning_suppress.h" #include #include +MSC_DIAG_OFF(4702) #include +MSC_DIAG_ON() #include #include diff --git a/Chapter10/Assembly.cpp b/Chapter10/Assembly.cpp index 17019c1..aa0ebbf 100644 --- a/Chapter10/Assembly.cpp +++ b/Chapter10/Assembly.cpp @@ -9,7 +9,7 @@ MSC_DIAG_OFF(4913) #include #include MSC_DIAG_ON() -MSC_DIAG_OFF(4459) +MSC_DIAG_OFF(4459 4702) #include MSC_DIAG_ON() #include diff --git a/Chapter10/FlowGraph.cpp b/Chapter10/FlowGraph.cpp index 5456316..7a8c87d 100644 --- a/Chapter10/FlowGraph.cpp +++ b/Chapter10/FlowGraph.cpp @@ -2,7 +2,7 @@ #include "variantMatch.h" #include "warning_suppress.h" #include -MSC_DIAG_OFF(4459) +MSC_DIAG_OFF(4459 4702) #include #include #include diff --git a/Chapter10/Program.cpp b/Chapter10/Program.cpp index 6f0f9cb..d7a15d9 100644 --- a/Chapter10/Program.cpp +++ b/Chapter10/Program.cpp @@ -16,15 +16,15 @@ #include #include #include -MSC_DIAG_OFF(4459) +MSC_DIAG_OFF(4459 4702) #include #include -MSC_DIAG_ON() #include #include #include #include #include +MSC_DIAG_ON() namespace tiger { diff --git a/Chapter10/test/Test.h b/Chapter10/test/Test.h index d946804..e307e0a 100644 --- a/Chapter10/test/Test.h +++ b/Chapter10/test/Test.h @@ -16,6 +16,7 @@ MSC_DIAG_ON() #define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER #include #include +MSC_DIAG_OFF(4702 4172) #include #include #include @@ -24,9 +25,7 @@ MSC_DIAG_ON() #include #include #include -MSC_DIAG_OFF(4702 4172) #include -MSC_DIAG_ON() #include #include #include @@ -36,6 +35,7 @@ MSC_DIAG_ON() #include #include #include +MSC_DIAG_ON() namespace x3 = boost::spirit::x3; namespace ir = tiger::ir; diff --git a/Chapter10/x64/x64CodeGenerator.cpp b/Chapter10/x64/x64CodeGenerator.cpp index afeaf7c..0022d77 100644 --- a/Chapter10/x64/x64CodeGenerator.cpp +++ b/Chapter10/x64/x64CodeGenerator.cpp @@ -2,11 +2,14 @@ #include "CallingConvention.h" #include "Tree.h" #include "x64Registers.h" +#include "warning_suppress.h" +MSC_DIAG_OFF(4702 4172) #include #include #include #include #include +MSC_DIAG_ON() namespace tiger { namespace assembly { diff --git a/include/printRange.h b/include/printRange.h index 7dda3ac..b6b0306 100644 --- a/include/printRange.h +++ b/include/printRange.h @@ -1,14 +1,12 @@ #pragma once #include "warning_suppress.h" #include -MSC_DIAG_OFF(4913) +MSC_DIAG_OFF(4913 4100 4702) #include -MSC_DIAG_ON() -MSC_DIAG_OFF(4100) #include -MSC_DIAG_ON() #include #include +MSC_DIAG_ON() namespace helpers { template From 5806dbfcd1aadd0e9699b1666f8a7aa9eaa3e0e2 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Sat, 7 Dec 2019 18:36:39 +0200 Subject: [PATCH 6/7] Use VS /experimenal:external to disable warnings --- CMakeLists.txt | 3 +-- Chapter02/Program.cpp | 3 --- Chapter03/DeclerationParser.h | 5 +---- Chapter03/ExpressionParser.h | 5 +---- Chapter03/IdentifierParser.h | 3 --- Chapter03/Skipper.h | 3 --- Chapter04/DeclerationParser.h | 5 +---- Chapter04/ExpressionParser.h | 5 +---- Chapter04/IdentifierParser.h | 5 +---- Chapter04/Skipper.h | 3 --- Chapter04/StringParser.h | 5 +---- Chapter05/DeclerationParser.h | 5 +---- Chapter05/ExpressionParser.h | 5 +---- Chapter05/IdentifierParser.h | 5 +---- Chapter05/Program.cpp | 3 --- Chapter05/Skipper.h | 3 --- Chapter05/StringParser.h | 5 +---- Chapter06/DeclerationParser.h | 5 +---- Chapter06/ExpressionParser.h | 5 +---- Chapter06/IdentifierParser.h | 5 +---- Chapter06/Skipper.h | 3 --- Chapter06/StringParser.h | 5 +---- Chapter07/DeclerationParser.h | 5 +---- Chapter07/ExpressionParser.h | 5 +---- Chapter07/IdentifierParser.h | 5 +---- Chapter07/Skipper.h | 3 --- Chapter07/StringParser.h | 5 +---- Chapter08/DeclerationParser.h | 5 +---- Chapter08/ExpressionParser.h | 5 +---- Chapter08/IdentifierParser.h | 5 +---- Chapter08/Skipper.h | 3 --- Chapter08/StringParser.h | 5 +---- Chapter09/Assembly.cpp | 7 ------- Chapter09/Assembly.h | 3 --- Chapter09/CallingConvention.cpp | 3 --- Chapter09/CodeGenerator.cpp | 5 ----- Chapter09/DeclerationParser.h | 3 --- Chapter09/ExpressionParser.h | 3 --- Chapter09/IdentifierParser.h | 3 --- Chapter09/Skipper.h | 3 --- Chapter09/StringParser.h | 3 --- Chapter09/TempMap.cpp | 3 --- Chapter09/test/Test.h | 3 --- Chapter10/Assembly.cpp | 9 --------- Chapter10/CallingConvention.cpp | 3 --- Chapter10/CodeGenerator.cpp | 9 --------- Chapter10/DeclerationParser.h | 3 --- Chapter10/ExpressionParser.h | 3 --- Chapter10/FlowGraph.cpp | 3 --- Chapter10/Frame.cpp | 3 --- Chapter10/IdentifierParser.h | 3 --- Chapter10/LivenessAnalyser.cpp | 3 --- Chapter10/Program.cpp | 2 -- Chapter10/Skipper.h | 3 --- Chapter10/StringParser.h | 3 --- Chapter10/TempMap.cpp | 1 - Chapter10/test/Test.cpp | 3 --- Chapter10/test/Test.h | 5 ----- Chapter10/test/arithmetic.cpp | 2 -- Chapter10/x64/x64CodeGenerator.cpp | 3 --- cmake/CompilerWarnings.cmake | 6 ++++-- include/printRange.h | 3 --- include/warning_suppress.h | 2 +- 63 files changed, 28 insertions(+), 223 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 675f0b0..119ca87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) project(GreenTiger) +include(CompilerWarnings) # Download automatically, you can also just copy the conan.cmake file if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") @@ -55,8 +56,6 @@ target_compile_options(range-v3 $<$,$>:-Wno-deprecated-declarations> $<$:/wd4996;/Wv:18>) -include(CompilerWarnings) - option(BUILD_TESTS "Build tests" ON) if(BUILD_TESTS) enable_testing() diff --git a/Chapter02/Program.cpp b/Chapter02/Program.cpp index 8d5915a..bfaa496 100644 --- a/Chapter02/Program.cpp +++ b/Chapter02/Program.cpp @@ -1,8 +1,5 @@ -#include "warning_suppress.h" -MSC_DIAG_OFF(4458 4457 4819) #include #include -MSC_DIAG_ON() #include #include #include diff --git a/Chapter03/DeclerationParser.h b/Chapter03/DeclerationParser.h index 2762da3..e801ce0 100644 --- a/Chapter03/DeclerationParser.h +++ b/Chapter03/DeclerationParser.h @@ -1,10 +1,7 @@ #pragma once #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -26,7 +23,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using qi::fail; using qi::lit; diff --git a/Chapter03/ExpressionParser.h b/Chapter03/ExpressionParser.h index 22280bf..60f5d9e 100644 --- a/Chapter03/ExpressionParser.h +++ b/Chapter03/ExpressionParser.h @@ -3,14 +3,11 @@ #include "ErrorHandler.h" #include "IdentifierParser.h" #include "Skipper.h" -#include "warning_suppress.h" #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { @@ -41,7 +38,7 @@ class ExpressionParser using qi::repeat; using qi::uint_; - using namespace qi::labels; + using namespace boost::spirit::labels; lvalue = identifier >> *((lit('.') > identifier) | (lit('[') > expression > ']')); diff --git a/Chapter03/IdentifierParser.h b/Chapter03/IdentifierParser.h index 72877d5..60b7c23 100644 --- a/Chapter03/IdentifierParser.h +++ b/Chapter03/IdentifierParser.h @@ -1,10 +1,7 @@ #pragma once #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter03/Skipper.h b/Chapter03/Skipper.h index 1479090..8c1cd2d 100644 --- a/Chapter03/Skipper.h +++ b/Chapter03/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter04/DeclerationParser.h b/Chapter04/DeclerationParser.h index c0f9752..d3a8746 100644 --- a/Chapter04/DeclerationParser.h +++ b/Chapter04/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include @@ -29,7 +26,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter04/ExpressionParser.h b/Chapter04/ExpressionParser.h index 09e213e..5c0d640 100644 --- a/Chapter04/ExpressionParser.h +++ b/Chapter04/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { @@ -52,7 +49,7 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; + using namespace boost::spirit::labels; relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( diff --git a/Chapter04/IdentifierParser.h b/Chapter04/IdentifierParser.h index 4a01851..9878568 100644 --- a/Chapter04/IdentifierParser.h +++ b/Chapter04/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -34,7 +31,7 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; + using namespace boost::spirit::labels; keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter04/Skipper.h b/Chapter04/Skipper.h index efa739b..4daa662 100644 --- a/Chapter04/Skipper.h +++ b/Chapter04/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter04/StringParser.h b/Chapter04/StringParser.h index 99b486b..73f5f65 100644 --- a/Chapter04/StringParser.h +++ b/Chapter04/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -36,7 +33,7 @@ class StringParser using phoenix::bind; - using namespace qi::labels; + using namespace boost::spirit::labels; string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter diff --git a/Chapter05/DeclerationParser.h b/Chapter05/DeclerationParser.h index 7afadd6..0876a43 100644 --- a/Chapter05/DeclerationParser.h +++ b/Chapter05/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include @@ -29,7 +26,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter05/ExpressionParser.h b/Chapter05/ExpressionParser.h index c9239e0..6f76ab2 100644 --- a/Chapter05/ExpressionParser.h +++ b/Chapter05/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { @@ -52,7 +49,7 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; + using namespace boost::spirit::labels; relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( diff --git a/Chapter05/IdentifierParser.h b/Chapter05/IdentifierParser.h index 6180ac2..f3f5dba 100644 --- a/Chapter05/IdentifierParser.h +++ b/Chapter05/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -34,7 +31,7 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; + using namespace boost::spirit::labels; keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter05/Program.cpp b/Chapter05/Program.cpp index f541809..52a4efc 100644 --- a/Chapter05/Program.cpp +++ b/Chapter05/Program.cpp @@ -1,11 +1,8 @@ #include "Program.h" #include "Compiler.h" #include "ExpressionParser.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4819) #include #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter05/Skipper.h b/Chapter05/Skipper.h index efa739b..4daa662 100644 --- a/Chapter05/Skipper.h +++ b/Chapter05/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter05/StringParser.h b/Chapter05/StringParser.h index f434ad2..ccf57f3 100644 --- a/Chapter05/StringParser.h +++ b/Chapter05/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -35,7 +32,7 @@ class StringParser using phoenix::bind; - using namespace qi::labels; + using namespace boost::spirit::labels; string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter diff --git a/Chapter06/DeclerationParser.h b/Chapter06/DeclerationParser.h index 7afadd6..0876a43 100644 --- a/Chapter06/DeclerationParser.h +++ b/Chapter06/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include @@ -29,7 +26,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter06/ExpressionParser.h b/Chapter06/ExpressionParser.h index c9239e0..6f76ab2 100644 --- a/Chapter06/ExpressionParser.h +++ b/Chapter06/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { @@ -52,7 +49,7 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; + using namespace boost::spirit::labels; relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( diff --git a/Chapter06/IdentifierParser.h b/Chapter06/IdentifierParser.h index 6180ac2..f3f5dba 100644 --- a/Chapter06/IdentifierParser.h +++ b/Chapter06/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -34,7 +31,7 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; + using namespace boost::spirit::labels; keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter06/Skipper.h b/Chapter06/Skipper.h index efa739b..4daa662 100644 --- a/Chapter06/Skipper.h +++ b/Chapter06/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter06/StringParser.h b/Chapter06/StringParser.h index f434ad2..ccf57f3 100644 --- a/Chapter06/StringParser.h +++ b/Chapter06/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -35,7 +32,7 @@ class StringParser using phoenix::bind; - using namespace qi::labels; + using namespace boost::spirit::labels; string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter diff --git a/Chapter07/DeclerationParser.h b/Chapter07/DeclerationParser.h index 7afadd6..0876a43 100644 --- a/Chapter07/DeclerationParser.h +++ b/Chapter07/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include @@ -29,7 +26,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter07/ExpressionParser.h b/Chapter07/ExpressionParser.h index c9239e0..6f76ab2 100644 --- a/Chapter07/ExpressionParser.h +++ b/Chapter07/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { @@ -52,7 +49,7 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; + using namespace boost::spirit::labels; relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( diff --git a/Chapter07/IdentifierParser.h b/Chapter07/IdentifierParser.h index 6180ac2..f3f5dba 100644 --- a/Chapter07/IdentifierParser.h +++ b/Chapter07/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -34,7 +31,7 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; + using namespace boost::spirit::labels; keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter07/Skipper.h b/Chapter07/Skipper.h index efa739b..4daa662 100644 --- a/Chapter07/Skipper.h +++ b/Chapter07/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter07/StringParser.h b/Chapter07/StringParser.h index f434ad2..ccf57f3 100644 --- a/Chapter07/StringParser.h +++ b/Chapter07/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -35,7 +32,7 @@ class StringParser using phoenix::bind; - using namespace qi::labels; + using namespace boost::spirit::labels; string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter diff --git a/Chapter08/DeclerationParser.h b/Chapter08/DeclerationParser.h index 7afadd6..0876a43 100644 --- a/Chapter08/DeclerationParser.h +++ b/Chapter08/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include @@ -29,7 +26,7 @@ class DeclerationParser namespace phoenix = boost::phoenix; using namespace std::string_literals; - using namespace qi::labels; + using namespace boost::spirit::labels; using phoenix::at_c; using phoenix::push_back; diff --git a/Chapter08/ExpressionParser.h b/Chapter08/ExpressionParser.h index c9239e0..6f76ab2 100644 --- a/Chapter08/ExpressionParser.h +++ b/Chapter08/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { @@ -52,7 +49,7 @@ class ExpressionParser using qi::uint_; using qi::uint_parser; - using namespace qi::labels; + using namespace boost::spirit::labels; relationalOp.add("=", ast::Operation::EQUAL)("<>", ast::Operation::NOT_EQUAL)( diff --git a/Chapter08/IdentifierParser.h b/Chapter08/IdentifierParser.h index 6180ac2..f3f5dba 100644 --- a/Chapter08/IdentifierParser.h +++ b/Chapter08/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -34,7 +31,7 @@ class IdentifierParser using qi::on_success; using qi::raw; - using namespace qi::labels; + using namespace boost::spirit::labels; keywords.add("array")("if")("then")("else")("while")("for")("to")("do")( "let")("in")("end")("of")("break")("nil")("function")("var")("type"); diff --git a/Chapter08/Skipper.h b/Chapter08/Skipper.h index efa739b..4daa662 100644 --- a/Chapter08/Skipper.h +++ b/Chapter08/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter08/StringParser.h b/Chapter08/StringParser.h index f434ad2..ccf57f3 100644 --- a/Chapter08/StringParser.h +++ b/Chapter08/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { @@ -35,7 +32,7 @@ class StringParser using phoenix::bind; - using namespace qi::labels; + using namespace boost::spirit::labels; string = lit('"') > skip(skipper.alias())[*(escapeCharacter | controlCharacter diff --git a/Chapter09/Assembly.cpp b/Chapter09/Assembly.cpp index 5cf201e..2577eb9 100644 --- a/Chapter09/Assembly.cpp +++ b/Chapter09/Assembly.cpp @@ -1,18 +1,11 @@ #include "Assembly.h" #include "variantMatch.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4459 4127 4819) #include -MSC_DIAG_ON() #include #ifdef _MSC_VER -MSC_DIAG_OFF(4913) #include -MSC_DIAG_ON() #endif -MSC_DIAG_OFF(4459) #include -MSC_DIAG_ON() #include #include diff --git a/Chapter09/Assembly.h b/Chapter09/Assembly.h index c18f3ad..161ffe9 100644 --- a/Chapter09/Assembly.h +++ b/Chapter09/Assembly.h @@ -1,11 +1,8 @@ #pragma once #include "TempMap.h" -#include "warning_suppress.h" #include #include -MSC_DIAG_OFF(4702) #include -MSC_DIAG_ON() #include #include diff --git a/Chapter09/CallingConvention.cpp b/Chapter09/CallingConvention.cpp index 90ec43c..2498b33 100644 --- a/Chapter09/CallingConvention.cpp +++ b/Chapter09/CallingConvention.cpp @@ -1,9 +1,6 @@ #include "CallingConvention.h" #include "Assembly.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4702) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter09/CodeGenerator.cpp b/Chapter09/CodeGenerator.cpp index 97136a4..607cbf8 100644 --- a/Chapter09/CodeGenerator.cpp +++ b/Chapter09/CodeGenerator.cpp @@ -2,18 +2,13 @@ #include "CallingConvention.h" #include "TreeAdapted.h" #include "variantMatch.h" -#include "warning_suppress.h" #include #include #include #include -MSC_DIAG_OFF(4996 4459 4456 4819) #include -MSC_DIAG_ON() #include -MSC_DIAG_OFF(4913) #include -MSC_DIAG_ON() #include #include #include diff --git a/Chapter09/DeclerationParser.h b/Chapter09/DeclerationParser.h index d448c1a..0876a43 100644 --- a/Chapter09/DeclerationParser.h +++ b/Chapter09/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include diff --git a/Chapter09/ExpressionParser.h b/Chapter09/ExpressionParser.h index 0f4e270..232d8a3 100644 --- a/Chapter09/ExpressionParser.h +++ b/Chapter09/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { diff --git a/Chapter09/IdentifierParser.h b/Chapter09/IdentifierParser.h index bb359b6..97e3094 100644 --- a/Chapter09/IdentifierParser.h +++ b/Chapter09/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter09/Skipper.h b/Chapter09/Skipper.h index efa739b..4daa662 100644 --- a/Chapter09/Skipper.h +++ b/Chapter09/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter09/StringParser.h b/Chapter09/StringParser.h index 748f5a5..3239b10 100644 --- a/Chapter09/StringParser.h +++ b/Chapter09/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter09/TempMap.cpp b/Chapter09/TempMap.cpp index e9fc784..dc84424 100644 --- a/Chapter09/TempMap.cpp +++ b/Chapter09/TempMap.cpp @@ -6,12 +6,9 @@ */ #include "TempMap.h" -#include "warning_suppress.h" #include #include -MSC_DIAG_OFF(4913) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter09/test/Test.h b/Chapter09/test/Test.h index f0013dd..1dbf46a 100644 --- a/Chapter09/test/Test.h +++ b/Chapter09/test/Test.h @@ -1,12 +1,9 @@ #include "TempMap.h" #include "Tree.h" -#include "warning_suppress.h" #include #include -MSC_DIAG_OFF(4496 4459 4127 4819) #include #include -MSC_DIAG_ON() #include #include #include diff --git a/Chapter10/Assembly.cpp b/Chapter10/Assembly.cpp index aa0ebbf..c431d2c 100644 --- a/Chapter10/Assembly.cpp +++ b/Chapter10/Assembly.cpp @@ -1,22 +1,13 @@ #include "Assembly.h" #include "variantMatch.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4459 4127 4819) #include -MSC_DIAG_ON() #include -MSC_DIAG_OFF(4913) #include #include -MSC_DIAG_ON() -MSC_DIAG_OFF(4459 4702) #include -MSC_DIAG_ON() #include #include -MSC_DIAG_OFF(4702) #include -MSC_DIAG_ON() #include #include diff --git a/Chapter10/CallingConvention.cpp b/Chapter10/CallingConvention.cpp index 502fbb1..2d3d8f6 100644 --- a/Chapter10/CallingConvention.cpp +++ b/Chapter10/CallingConvention.cpp @@ -1,9 +1,6 @@ #include "CallingConvention.h" #include "Assembly.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4702) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter10/CodeGenerator.cpp b/Chapter10/CodeGenerator.cpp index 00e0eef..633c877 100644 --- a/Chapter10/CodeGenerator.cpp +++ b/Chapter10/CodeGenerator.cpp @@ -2,25 +2,16 @@ #include "CallingConvention.h" #include "TreeAdapted.h" #include "variantMatch.h" -#include "warning_suppress.h" #include #include #include #include -MSC_DIAG_OFF(4996 4459 4456 4819) #include -MSC_DIAG_ON() #include -MSC_DIAG_OFF(4913) #include #include -MSC_DIAG_ON() -MSC_DIAG_OFF(4459) #include -MSC_DIAG_ON() -MSC_DIAG_OFF(4702) #include -MSC_DIAG_ON() #include #include #include diff --git a/Chapter10/DeclerationParser.h b/Chapter10/DeclerationParser.h index d448c1a..0876a43 100644 --- a/Chapter10/DeclerationParser.h +++ b/Chapter10/DeclerationParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include #include #include diff --git a/Chapter10/ExpressionParser.h b/Chapter10/ExpressionParser.h index 0f4e270..232d8a3 100644 --- a/Chapter10/ExpressionParser.h +++ b/Chapter10/ExpressionParser.h @@ -4,16 +4,13 @@ #include "IdentifierParser.h" #include "Skipper.h" #include "StringParser.h" -#include "warning_suppress.h" #include #include #include #include #include #include -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { diff --git a/Chapter10/FlowGraph.cpp b/Chapter10/FlowGraph.cpp index 7a8c87d..89b741c 100644 --- a/Chapter10/FlowGraph.cpp +++ b/Chapter10/FlowGraph.cpp @@ -1,14 +1,11 @@ #include "FlowGraph.h" #include "variantMatch.h" -#include "warning_suppress.h" #include -MSC_DIAG_OFF(4459 4702) #include #include #include #include #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter10/Frame.cpp b/Chapter10/Frame.cpp index beb01ad..b598d75 100644 --- a/Chapter10/Frame.cpp +++ b/Chapter10/Frame.cpp @@ -1,9 +1,6 @@ #include "Frame.h" #include "Assembly.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4702) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter10/IdentifierParser.h b/Chapter10/IdentifierParser.h index bb359b6..97e3094 100644 --- a/Chapter10/IdentifierParser.h +++ b/Chapter10/IdentifierParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter10/LivenessAnalyser.cpp b/Chapter10/LivenessAnalyser.cpp index 1543fec..d24fe47 100644 --- a/Chapter10/LivenessAnalyser.cpp +++ b/Chapter10/LivenessAnalyser.cpp @@ -3,9 +3,7 @@ #include "FlowGraph.h" #include "irange.h" #include "variantMatch.h" -#include "warning_suppress.h" #include -MSC_DIAG_OFF(4239 4459 4913) #include #include #include @@ -19,7 +17,6 @@ MSC_DIAG_OFF(4239 4459 4913) #include #include #include -MSC_DIAG_ON() namespace rv = ranges::views; namespace ra = ranges::actions; diff --git a/Chapter10/Program.cpp b/Chapter10/Program.cpp index d7a15d9..218fc08 100644 --- a/Chapter10/Program.cpp +++ b/Chapter10/Program.cpp @@ -16,7 +16,6 @@ #include #include #include -MSC_DIAG_OFF(4459 4702) #include #include #include @@ -24,7 +23,6 @@ MSC_DIAG_OFF(4459 4702) #include #include #include -MSC_DIAG_ON() namespace tiger { diff --git a/Chapter10/Skipper.h b/Chapter10/Skipper.h index efa739b..4daa662 100644 --- a/Chapter10/Skipper.h +++ b/Chapter10/Skipper.h @@ -1,8 +1,5 @@ #pragma once -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() namespace tiger { template diff --git a/Chapter10/StringParser.h b/Chapter10/StringParser.h index 748f5a5..3239b10 100644 --- a/Chapter10/StringParser.h +++ b/Chapter10/StringParser.h @@ -2,10 +2,7 @@ #include "Annotation.h" #include "ErrorHandler.h" #include "Skipper.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4996 4459 4819) #include -MSC_DIAG_ON() #include namespace tiger { diff --git a/Chapter10/TempMap.cpp b/Chapter10/TempMap.cpp index 9383817..341d5a0 100644 --- a/Chapter10/TempMap.cpp +++ b/Chapter10/TempMap.cpp @@ -6,7 +6,6 @@ */ #include "TempMap.h" -#include "warning_suppress.h" #include #include diff --git a/Chapter10/test/Test.cpp b/Chapter10/test/Test.cpp index 116c250..718866b 100644 --- a/Chapter10/test/Test.cpp +++ b/Chapter10/test/Test.cpp @@ -1,10 +1,7 @@ #include "Test.h" #include "CallingConvention.h" #include "FlowGraph.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4459) #include "MachineRegistrar.h" -MSC_DIAG_ON() #include #include #include diff --git a/Chapter10/test/Test.h b/Chapter10/test/Test.h index e307e0a..4c403d5 100644 --- a/Chapter10/test/Test.h +++ b/Chapter10/test/Test.h @@ -1,14 +1,11 @@ #include "Program.h" #include "Tree.h" #include "irange.h" -#include "warning_suppress.h" #include #include #include -MSC_DIAG_OFF(4496 4459 4127 4819) #include #include -MSC_DIAG_ON() #include #include #include @@ -16,7 +13,6 @@ MSC_DIAG_ON() #define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER #include #include -MSC_DIAG_OFF(4702 4172) #include #include #include @@ -35,7 +31,6 @@ MSC_DIAG_OFF(4702 4172) #include #include #include -MSC_DIAG_ON() namespace x3 = boost::spirit::x3; namespace ir = tiger::ir; diff --git a/Chapter10/test/arithmetic.cpp b/Chapter10/test/arithmetic.cpp index 1ff3923..04c3ab6 100644 --- a/Chapter10/test/arithmetic.cpp +++ b/Chapter10/test/arithmetic.cpp @@ -1,8 +1,6 @@ #include "Test.h" -MSC_DIAG_OFF(4459) #include #include -MSC_DIAG_ON() #include TEST_CASE_METHOD(TestFixture, "arithmetic") { diff --git a/Chapter10/x64/x64CodeGenerator.cpp b/Chapter10/x64/x64CodeGenerator.cpp index 0022d77..afeaf7c 100644 --- a/Chapter10/x64/x64CodeGenerator.cpp +++ b/Chapter10/x64/x64CodeGenerator.cpp @@ -2,14 +2,11 @@ #include "CallingConvention.h" #include "Tree.h" #include "x64Registers.h" -#include "warning_suppress.h" -MSC_DIAG_OFF(4702 4172) #include #include #include #include #include -MSC_DIAG_ON() namespace tiger { namespace assembly { diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index de59bcc..946a388 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -1,16 +1,18 @@ option(TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" TRUE) if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /experimental:external /external:W0 ") + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/external:I ") if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") else() string(APPEND CMAKE_CXX_FLAGS " /W4") endif() - string(APPEND CMAKE_CXX_FLAGS " /DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS") + string(APPEND CMAKE_CXX_FLAGS " /DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /wd4702") if(TREAT_WARNINGS_AS_ERRORS) string(APPEND CMAKE_CXX_FLAGS " /WX") endif() - # string(APPEND CMAKE_CXX_FLAGS " /permissive-") + string(APPEND CMAKE_CXX_FLAGS " /permissive-") elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -pedantic -Wno-unused-function -Wno-missing-field-initializers -Wno-missing-braces") string(APPEND CMAKE_C_FLAGS " -Wall -Wextra -pedantic -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wno-unused-function") diff --git a/include/printRange.h b/include/printRange.h index b6b0306..cc96a0e 100644 --- a/include/printRange.h +++ b/include/printRange.h @@ -1,12 +1,9 @@ #pragma once -#include "warning_suppress.h" #include -MSC_DIAG_OFF(4913 4100 4702) #include #include #include #include -MSC_DIAG_ON() namespace helpers { template diff --git a/include/warning_suppress.h b/include/warning_suppress.h index eedc8ae..8c07cb4 100644 --- a/include/warning_suppress.h +++ b/include/warning_suppress.h @@ -3,7 +3,7 @@ // macros to suppress compiler warnings // see https://svn.boost.org/trac10/wiki/Guidelines/WarningsGuidelines -#ifdef _MSC_VER +#ifdef DUMMY_MSC_VER #define MSC_DIAG_OFF(numbers) \ __pragma(warning(push)) \ __pragma(warning(disable:numbers)) From ea650c19525b2a454fb7240e0221f58d39cbcc66 Mon Sep 17 00:00:00 2001 From: dvirtz Date: Sat, 7 Dec 2019 23:50:07 +0200 Subject: [PATCH 7/7] build with docker on windows --- .github/workflows/main.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18dc074..a5be7d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,24 +12,17 @@ jobs: build_type: [Debug, Release] runs-on: ubuntu-18.04 steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2-beta - name: run docker run: docker run --rm -v $GITHUB_WORKSPACE:/home/conan/repo conanio/${{ matrix.image }} cmake -DBUILD_TYPE=${{ matrix.build_type }} -P /home/conan/repo/ci/build.cmake - windows-native: + windows-docker: strategy: matrix: - build_type: [Release] + image: ['dvirtz/msvc_16:lstc2019'] + build_type: [Debug, Release] runs-on: windows-2019 - env: - CC: cl.exe - CXX: cl.exe steps: - - uses: actions/checkout@master - - name: install conan - run: pip install conan - - name: build - shell: cmd - run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - call cmake -DBUILD_TYPE=${{ matrix.build_type }} -P ci/build.cmake + - uses: actions/checkout@v2-beta + - name: run docker + run: docker run --rm --mount type=bind,source=$env:GITHUB_WORKSPACE,destination=C:\Users\ContainerAdministrator\repo ${{ matrix.image }} cmake -DBUILD_TYPE=${{ matrix.build_type }} -P C:\Users\ContainerAdministrator\repo\ci\build.cmake