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"%clangxx ", clangxx + ' '))
11if config.lto_supported:
12  clangxx_cfi = ' '.join(config.lto_launch + [clangxx] + config.lto_flags + ['-flto -fsanitize=cfi '])
13  clangxx_cfi_diag = clangxx_cfi + '-fno-sanitize-trap=cfi -fsanitize-recover=cfi '
14  config.substitutions.append((r"%clangxx_cfi ", clangxx_cfi))
15  config.substitutions.append((r"%clangxx_cfi_diag ", clangxx_cfi_diag))
16  config.substitutions.append((r"%clangxx_cfi_dso ", clangxx_cfi + '-fsanitize-cfi-cross-dso '))
17  config.substitutions.append((r"%clangxx_cfi_dso_diag ", clangxx_cfi_diag + '-fsanitize-cfi-cross-dso '))
18else:
19  config.unsupported = True
20
21if lit_config.params.get('check_supported', None) and config.unsupported:
22  raise BaseException("Tests unsupported")
23