1import lit.formats 2import os 3 4config.name = 'cfi' 5config.suffixes = ['.c', '.cpp', '.test'] 6config.test_source_root = os.path.dirname(__file__) 7 8clangxx = ' '.join([config.clang] + config.cxx_mode_flags) 9 10config.substitutions.append((r"%clang ", ' '.join([config.clang]) + ' ')) 11config.substitutions.append((r"%clangxx ", clangxx + ' ')) 12if config.lto_supported: 13 clang_cfi = ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-flto -fsanitize=cfi ']) 14 15 if config.cfi_lit_test_mode == "Devirt": 16 config.available_features.add('devirt') 17 clang_cfi += '-fwhole-program-vtables ' 18 config.substitutions.append((r"%expect_crash_unless_devirt ", "")) 19 else: 20 config.substitutions.append((r"%expect_crash_unless_devirt ", config.expect_crash)) 21 22 cxx = ' '.join(config.cxx_mode_flags) + ' ' 23 diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi ' 24 non_dso = '-fvisibility=hidden ' 25 dso = '-fsanitize-cfi-cross-dso -fvisibility=default ' 26 config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso)) 27 config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso)) 28 config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag)) 29 config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag)) 30 config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso)) 31 config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag)) 32else: 33 config.unsupported = True 34 35if lit_config.params.get('check_supported', None) and config.unsupported: 36 raise BaseException("Tests unsupported") 37