Index: test/cfi/CMakeLists.txt =================================================================== --- test/cfi/CMakeLists.txt +++ test/cfi/CMakeLists.txt @@ -1,6 +1,13 @@ +set(CFI_LIT_TEST_MODE Standalone) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ${CMAKE_CURRENT_BINARY_DIR}/standalone/lit.site.cfg + ) + +set(CFI_LIT_TEST_MODE Devirt) +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/devirt/lit.site.cfg ) set(CFI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) @@ -32,11 +39,13 @@ endif() add_lit_testsuite(check-cfi "Running the cfi regression tests" - ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/standalone + ${CMAKE_CURRENT_BINARY_DIR}/devirt DEPENDS ${CFI_TEST_DEPS}) add_lit_target(check-cfi-and-supported "Running the cfi regression tests" - ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/standalone + ${CMAKE_CURRENT_BINARY_DIR}/devirt PARAMS check_supported=1 DEPENDS ${CFI_TEST_DEPS}) Index: test/cfi/lit.cfg =================================================================== --- test/cfi/lit.cfg +++ test/cfi/lit.cfg @@ -11,6 +11,14 @@ config.substitutions.append((r"%clangxx ", clangxx + ' ')) if config.lto_supported: clang_cfi = ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-flto -fsanitize=cfi ']) + + if config.cfi_lit_test_mode == "Devirt": + config.available_features.add('devirt') + clang_cfi += '-fwhole-program-vtables ' + config.substitutions.append((r"%expect_crash_unless_devirt ", "")) + else: + config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash)) + cxx = ' '.join(config.cxx_mode_flags) + ' ' diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi ' non_dso = '-fvisibility=hidden ' Index: test/cfi/lit.site.cfg.in =================================================================== --- test/cfi/lit.site.cfg.in +++ test/cfi/lit.site.cfg.in @@ -1,4 +1,6 @@ @LIT_SITE_CFG_IN_HEADER@ +config.cfi_lit_test_mode = "@CFI_LIT_TEST_MODE@" + lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg") Index: test/cfi/overwrite.cpp =================================================================== --- test/cfi/overwrite.cpp +++ test/cfi/overwrite.cpp @@ -1,5 +1,5 @@ // RUN: %clangxx_cfi -o %t1 %s -// RUN: %expect_crash %t1 2>&1 | FileCheck --check-prefix=CFI %s +// RUN: %expect_crash_unless_devirt %t1 2>&1 | FileCheck --check-prefix=CFI %s // RUN: %clangxx_cfi -DB32 -o %t2 %s // RUN: %expect_crash %t2 2>&1 | FileCheck --check-prefix=CFI %s @@ -55,7 +55,10 @@ // CFI-DIAG-NEXT: note: invalid vtable a->f(); - // CFI-NOT: {{^2$}} + // We don't check for the absence of a 2 here because under devirtualization + // our virtual call may be devirtualized and we will proceed with execution + // rather than crashing. + // NCFI: {{^2$}} fprintf(stderr, "2\n"); } Index: test/cfi/stats.cpp =================================================================== --- test/cfi/stats.cpp +++ test/cfi/stats.cpp @@ -2,6 +2,9 @@ // RUN: env SANITIZER_STATS_PATH=%t.stats %t // RUN: sanstats %t.stats | FileCheck %s +// FIXME: We currently emit the wrong debug info under devirtualization. +// UNSUPPORTED: devirt + struct ABase {}; struct A : ABase { Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -92,9 +92,11 @@ # does not crash but exits with a non-zero exit code. We ought to merge # KillTheDoctor and not --crash to make the latter more useful and remove the # need for this substitution. - config.substitutions.append( ("%expect_crash ", "not KillTheDoctor ") ) + config.expect_crash = "not KillTheDoctor " else: - config.substitutions.append( ("%expect_crash ", "not --crash ") ) + config.expect_crash = "not --crash " + +config.substitutions.append( ("%expect_crash ", config.expect_crash) ) target_arch = getattr(config, 'target_arch', None) if target_arch: