Index: cmake/Modules/AddCompilerRT.cmake =================================================================== --- cmake/Modules/AddCompilerRT.cmake +++ cmake/Modules/AddCompilerRT.cmake @@ -113,6 +113,8 @@ LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}) endmacro() +set(COMPILER_RT_TEST_CFLAGS "") + # Unittests support. set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest) set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc) @@ -124,6 +126,19 @@ ) if(MSVC) + # MSVC system headers and gtest use a lot of deprecated stuff. + list(APPEND COMPILER_RT_TEST_CFLAGS + -Wno-deprecated-declarations) + + # clang doesn't support exceptions on Windows yet. + list(APPEND COMPILER_RT_TEST_CFLAGS + -D_HAS_EXCEPTIONS=0) + + # We should teach clang to understand more pragmas. + list(APPEND COMPILER_RT_TEST_CFLAGS + -Wno-unknown-pragmas + -Wno-undefined-inline) + # Clang doesn't support SEH on Windows yet. list(APPEND COMPILER_RT_GTEST_CFLAGS -DGTEST_HAS_SEH=0) endif() Index: lib/asan/tests/CMakeLists.txt =================================================================== --- lib/asan/tests/CMakeLists.txt +++ lib/asan/tests/CMakeLists.txt @@ -21,6 +21,7 @@ asan_test_utils.h) set(ASAN_UNITTEST_COMMON_CFLAGS + ${COMPILER_RT_TEST_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS} -I${COMPILER_RT_SOURCE_DIR}/include -I${COMPILER_RT_SOURCE_DIR}/lib @@ -39,21 +40,6 @@ list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -g) endif() -if(MSVC) - # MSVC system headers and gtest use a lot of deprecated stuff. - list(APPEND ASAN_UNITTEST_COMMON_CFLAGS - -Wno-deprecated-declarations) - - # clang doesn't support exceptions on Windows yet. - list(APPEND ASAN_UNITTEST_COMMON_CFLAGS - -D_HAS_EXCEPTIONS=0) - - # We should teach clang to understand more pragmas. - list(APPEND ASAN_UNITTEST_COMMON_CFLAGS - -Wno-unknown-pragmas - -Wno-undefined-inline) -endif() - # Use -D instead of definitions to please custom compile command. list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -DASAN_HAS_BLACKLIST=1 Index: lib/sanitizer_common/tests/CMakeLists.txt =================================================================== --- lib/sanitizer_common/tests/CMakeLists.txt +++ lib/sanitizer_common/tests/CMakeLists.txt @@ -34,6 +34,7 @@ endforeach() set(SANITIZER_TEST_CFLAGS_COMMON + ${COMPILER_RT_TEST_CFLAGS} ${COMPILER_RT_GTEST_CFLAGS} -I${COMPILER_RT_SOURCE_DIR}/include -I${COMPILER_RT_SOURCE_DIR}/lib @@ -50,21 +51,6 @@ list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -g) endif() -if(MSVC) - # MSVC system headers and gtest use a lot of deprecated stuff. - list(APPEND SANITIZER_TEST_CFLAGS_COMMON - -Wno-deprecated-declarations) - - # clang doesn't support exceptions on Windows yet. - list(APPEND SANITIZER_TEST_CFLAGS_COMMON - -D_HAS_EXCEPTIONS=0) - - # We should teach clang to understand more pragmas. - list(APPEND SANITIZER_TEST_CFLAGS_COMMON - -Wno-unknown-pragmas - -Wno-undefined-inline) -endif() - if(NOT MSVC) list(APPEND SANITIZER_TEST_LINK_FLAGS_COMMON --driver-mode=g++) endif()