2015-02-21 04:31:18 +08:00
|
|
|
import lit.formats
|
|
|
|
import os
|
|
|
|
|
2017-04-22 02:11:23 +08:00
|
|
|
config.name = 'cfi' + config.name_suffix
|
2015-09-10 10:18:02 +08:00
|
|
|
config.suffixes = ['.c', '.cpp', '.test']
|
2015-02-21 04:31:18 +08:00
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
clangxx = ' '.join([config.clang] + config.cxx_mode_flags)
|
|
|
|
|
2016-02-24 08:16:57 +08:00
|
|
|
config.substitutions.append((r"%clang ", ' '.join([config.clang]) + ' '))
|
2015-02-21 04:31:18 +08:00
|
|
|
config.substitutions.append((r"%clangxx ", clangxx + ' '))
|
2015-11-21 05:16:00 +08:00
|
|
|
if config.lto_supported:
|
2017-04-22 02:11:23 +08:00
|
|
|
clang_cfi = ' '.join(config.lto_launch + [config.clang] + config.lto_flags + ['-fsanitize=cfi '])
|
2016-06-25 08:24:22 +08:00
|
|
|
|
|
|
|
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))
|
|
|
|
|
2016-04-29 01:09:09 +08:00
|
|
|
cxx = ' '.join(config.cxx_mode_flags) + ' '
|
|
|
|
diag = '-fno-sanitize-trap=cfi -fsanitize-recover=cfi '
|
|
|
|
non_dso = '-fvisibility=hidden '
|
|
|
|
dso = '-fsanitize-cfi-cross-dso -fvisibility=default '
|
|
|
|
config.substitutions.append((r"%clang_cfi ", clang_cfi + non_dso))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi ", clang_cfi + cxx + non_dso))
|
|
|
|
config.substitutions.append((r"%clang_cfi_diag ", clang_cfi + non_dso + diag))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi_diag ", clang_cfi + cxx + non_dso + diag))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi_dso ", clang_cfi + cxx + dso))
|
|
|
|
config.substitutions.append((r"%clangxx_cfi_dso_diag ", clang_cfi + cxx + dso + diag))
|
2015-02-21 04:31:18 +08:00
|
|
|
else:
|
|
|
|
config.unsupported = True
|
2015-02-26 04:14:05 +08:00
|
|
|
|
|
|
|
if lit_config.params.get('check_supported', None) and config.unsupported:
|
|
|
|
raise BaseException("Tests unsupported")
|