[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CMakeLists.txt
blob5369dc92f69e8a099097781f244d4480172fc625
1 # Test runner infrastructure for Clang. This configures the Clang test trees
2 # for use by Lit, and delegates to LLVM's lit test handlers.
4 llvm_canonicalize_cmake_booleans(
5   CLANG_BUILD_EXAMPLES
6   CLANG_BUILT_STANDALONE
7   CLANG_DEFAULT_PIE_ON_LINUX
8   CLANG_ENABLE_ARCMT
9   CLANG_ENABLE_STATIC_ANALYZER
10   CLANG_PLUGIN_SUPPORT
11   CLANG_SPAWN_CC1
12   CLANG_ENABLE_CIR
13   ENABLE_BACKTRACES
14   LLVM_BUILD_EXAMPLES
15   LLVM_BYE_LINK_INTO_TOOLS
16   LLVM_ENABLE_PLUGINS
17   LLVM_ENABLE_ZLIB
18   LLVM_ENABLE_ZSTD
19   LLVM_ENABLE_PER_TARGET_RUNTIME_DIR
20   LLVM_ENABLE_THREADS
21   LLVM_ENABLE_REVERSE_ITERATION
22   LLVM_WITH_Z3
23   PPC_LINUX_DEFAULT_IEEELONGDOUBLE
24   LLVM_TOOL_LLVM_DRIVER_BUILD
25   )
27 configure_lit_site_cfg(
28   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
29   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
30   MAIN_CONFIG
31   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
32   PATHS
33   "LLVM_SOURCE_DIR"
34   "LLVM_BINARY_DIR"
35   "LLVM_TOOLS_DIR"
36   "LLVM_LIBS_DIR"
37   "SHLIBDIR"
38   "LLVM_LIT_TOOLS_DIR"
39   "LLVM_EXTERNAL_LIT"
40   "CLANG_BINARY_DIR"
41   "CLANG_SOURCE_DIR"
42   "CURRENT_TOOLS_DIR"
43   "CMAKE_LIBRARY_OUTPUT_DIRECTORY"
44   )
46 configure_lit_site_cfg(
47   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
48   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
49   MAIN_CONFIG
50   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
51   PATHS
52   "LLVM_SOURCE_DIR"
53   "LLVM_BINARY_DIR"
54   "LLVM_TOOLS_DIR"
55   "LLVM_LIBS_DIR"
56   "CLANG_BINARY_DIR"
57   "SHLIBDIR"
58   )
60 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)
61 if(CLANG_TEST_USE_VG)
62   set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg")
63 endif ()
65 list(APPEND CLANG_TEST_DEPS
66   apinotes-test
67   c-index-test
68   clang
69   clang-fuzzer-dictionary
70   clang-resource-headers
71   clang-format
72   clang-tblgen
73   clang-offload-bundler
74   clang-import-test
75   clang-refactor
76   clang-diff
77   clang-installapi
78   clang-scan-deps
79   clang-linker-wrapper
80   clang-nvlink-wrapper
81   clang-offload-bundler
82   clang-offload-packager
83   clang-sycl-linker
84   diagtool
85   hmaptool
86   )
87   
88 if(CLANG_ENABLE_STATIC_ANALYZER)
89   list(APPEND CLANG_TEST_DEPS
90     clang-check
91     clang-extdef-mapping
92     )
93 endif()
95 if (CLANG_ENABLE_ARCMT)
96   list(APPEND CLANG_TEST_DEPS
97     arcmt-test
98     c-arcmt-test
99   )
100 endif ()
102 if(CLANG_BUILD_EXAMPLES AND CLANG_PLUGIN_SUPPORT)
103   list(APPEND CLANG_TEST_DEPS
104     Attribute
105     AnnotateFunctions
106     CallSuperAttr
107     PluginsOrder
108     PrintFunctionNames
109     LLVMPrintFunctionNames
110     )
111 endif ()
113 set(CLANG_TEST_PARAMS
114   USE_Z3_SOLVER=0
115   )
117 if( NOT CLANG_BUILT_STANDALONE )
118   list(APPEND CLANG_TEST_DEPS
119     llvm-config
120     FileCheck count not
121     llc
122     llvm-ar
123     llvm-as
124     llvm-bcanalyzer
125     llvm-cat
126     llvm-cxxfilt
127     llvm-dis
128     llvm-dwarfdump
129     llvm-ifs
130     llvm-lto2
131     llvm-mc
132     llvm-modextract
133     llvm-nm
134     llvm-objcopy
135     llvm-objdump
136     llvm-pdbutil
137     llvm-profdata
138     llvm-rc
139     llvm-readelf
140     llvm-readobj
141     llvm-readtapi
142     llvm-strip
143     llvm-symbolizer
144     llvm-windres
145     obj2yaml
146     opt
147     split-file
148     yaml2obj
149     )
151   if(TARGET llvm-lto)
152     list(APPEND CLANG_TEST_DEPS llvm-lto)
153   endif()
154 endif()
156 if(CLANG_ENABLE_STATIC_ANALYZER)
157   if(CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS) # Determine if we built them
158     list(APPEND CLANG_TEST_DEPS
159       SampleAnalyzerPlugin
160       CheckerDependencyHandlingAnalyzerPlugin
161       CheckerOptionHandlingAnalyzerPlugin
162       )
163   endif()
164 endif()
166 if (HAVE_CLANG_REPL_SUPPORT)
167   list(APPEND CLANG_TEST_DEPS
168     clang-repl
169     )
170 endif()
172 # Copy gen_ast_dump_json_test.py to the clang build dir. This allows invoking
173 # it without having to pass the --clang= argument
174 configure_file(AST/gen_ast_dump_json_test.py
175   ${CLANG_BINARY_DIR}/bin/gen_ast_dump_json_test.py COPYONLY)
177 add_custom_target(clang-test-depends DEPENDS ${CLANG_TEST_DEPS})
178 set_target_properties(clang-test-depends PROPERTIES FOLDER "Clang/Tests")
180 add_lit_testsuite(check-clang "Running the Clang regression tests"
181   ${CMAKE_CURRENT_BINARY_DIR}
182   #LIT ${LLVM_LIT}
183   PARAMS ${CLANG_TEST_PARAMS}
184   DEPENDS ${CLANG_TEST_DEPS}
185   ARGS ${CLANG_TEST_EXTRA_ARGS}
186   )
188 add_lit_testsuites(CLANG ${CMAKE_CURRENT_SOURCE_DIR}
189   PARAMS ${CLANG_TEST_PARAMS}
190   DEPENDS ${CLANG_TEST_DEPS}
191   FOLDER "Clang tests/Suites"
194 # Add a legacy target spelling: clang-test
195 add_custom_target(clang-test)
196 add_dependencies(clang-test check-clang)
197 set_target_properties(clang-test PROPERTIES FOLDER "Clang/Tests")
199 # FIXME: This logic can be removed once all buildbots have moved
200 # debuginfo-test from clang/test to llvm/projects or monorepo.
201 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests)
202   message(WARNING "Including debuginfo-tests in clang/test is deprecated.  Move to llvm/projects or use monorepo.")
203   if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt)
204     add_subdirectory(debuginfo-tests)
205   endif()
206 endif()