[clang-tools-extra] Fix a link in ReleaseNotes.rst
[llvm-project.git] / clang-tools-extra / clangd / quality / CompletionModel.cmake
blobdc0c0cde4dabbbd682982055303962b3522aeb0e
1 # Run the Completion Model Codegenerator on the model present in the 
2 # ${model} directory.
3 # Produces a pair of files called ${filename}.h and  ${filename}.cpp in the 
4 # ${CMAKE_CURRENT_BINARY_DIR}. The generated header
5 # will define a C++ class called ${cpp_class} - which may be a
6 # namespace-qualified class name.
7 set(CLANGD_COMPLETION_MODEL_COMPILER ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py)
8 function(gen_decision_forest model filename cpp_class)
9   set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER})
11   set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
12   set(header_file ${output_dir}/${filename}.h)
13   set(cpp_file ${output_dir}/${filename}.cpp)
15   add_custom_command(OUTPUT ${header_file} ${cpp_file}
16     COMMAND "${Python3_EXECUTABLE}" ${model_compiler}
17       --model ${model}
18       --output_dir ${output_dir}
19       --filename ${filename}
20       --cpp_class ${cpp_class}
21     COMMENT "Generating code completion model runtime..."
22     DEPENDS ${model_compiler} ${model}/forest.json ${model}/features.json
23     VERBATIM )
25   set_source_files_properties(${header_file} PROPERTIES
26     GENERATED 1)
27   set_source_files_properties(${cpp_file} PROPERTIES
28     GENERATED 1)
30   # Disable unused label warning for generated files.
31   if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
32     set_source_files_properties(${cpp_file} PROPERTIES
33       COMPILE_FLAGS /wd4102)
34   else()
35     set_source_files_properties(${cpp_file} PROPERTIES
36       COMPILE_FLAGS -Wno-unused)
37   endif()
38 endfunction()