diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -508,8 +508,7 @@ endif() endforeach() -list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) -if (NATIVE_ARCH_IDX EQUAL -1) +if (NOT ${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) message(STATUS "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code") else () diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -1228,8 +1228,7 @@ endif() get_target_property(transitive_libs ${lib} INTERFACE_LINK_LIBRARIES) foreach(transitive_lib ${transitive_libs}) - list(FIND link_libs ${transitive_lib} idx) - if(TARGET ${transitive_lib} AND idx EQUAL -1) + if(TARGET ${transitive_lib} AND NOT ${transitive_lib} IN_LIST link_libs) list(APPEND newer_libs ${transitive_lib}) list(APPEND link_libs ${transitive_lib}) endif() diff --git a/llvm/cmake/modules/AddSphinxTarget.cmake b/llvm/cmake/modules/AddSphinxTarget.cmake --- a/llvm/cmake/modules/AddSphinxTarget.cmake +++ b/llvm/cmake/modules/AddSphinxTarget.cmake @@ -68,8 +68,7 @@ # but we should only add this path once get_property(_CURRENT_MAKE_CLEAN_FILES DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES) - list(FIND _CURRENT_MAKE_CLEAN_FILES "${SPHINX_DOC_TREE_DIR}" _INDEX) - if (_INDEX EQUAL -1) + if (NOT "${SPHINX_DOC_TREE_DIR}" IN_LIST _CURRENT_MAKE_CLEAN_FILES) set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${SPHINX_DOC_TREE_DIR}") diff --git a/llvm/cmake/modules/ChooseMSVCCRT.cmake b/llvm/cmake/modules/ChooseMSVCCRT.cmake --- a/llvm/cmake/modules/ChooseMSVCCRT.cmake +++ b/llvm/cmake/modules/ChooseMSVCCRT.cmake @@ -81,11 +81,10 @@ set(flag_string " ") else() set(flag_string " /${LLVM_USE_CRT_${build}} ") - list(FIND ${MSVC_CRT} ${LLVM_USE_CRT_${build}} idx) - if (idx LESS 0) + if (NOT ${LLVM_USE_CRT_${build}} IN_LIST ${MSVC_CRT}) message(FATAL_ERROR "Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}") - endif (idx LESS 0) + endif() message(STATUS "Using ${build_type} VC++ CRT: ${LLVM_USE_CRT_${build}}") endif() foreach(lang C CXX) diff --git a/llvm/cmake/modules/LLVM-Config.cmake b/llvm/cmake/modules/LLVM-Config.cmake --- a/llvm/cmake/modules/LLVM-Config.cmake +++ b/llvm/cmake/modules/LLVM-Config.cmake @@ -131,29 +131,24 @@ endif() foreach(c ${link_components}) # add codegen, asmprinter, asmparser, disassembler - list(FIND LLVM_TARGETS_TO_BUILD ${c} idx) - if( NOT idx LESS 0 ) - list(FIND LLVM_AVAILABLE_LIBS LLVM${c}CodeGen lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(${c} IN_LIST LLVM_TARGETS_TO_BUILD) + if(LLVM${c}CodeGen IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${c}CodeGen") else() - list(FIND LLVM_AVAILABLE_LIBS LLVM${c} lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${c} IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${c}") else() message(FATAL_ERROR "Target ${c} is not in the set of libraries.") endif() endif() foreach(subcomponent IN ITEMS AsmPrinter AsmParser Desc Disassembler Info Utils) - list(FIND LLVM_AVAILABLE_LIBS LLVM${c}${subcomponent} lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${c}${subcomponent} IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${c}${subcomponent}") endif() endforeach() elseif( c STREQUAL "nativecodegen" ) foreach(subcomponent IN ITEMS CodeGen Desc Info) - list(FIND LLVM_AVAILABLE_LIBS LLVM${LLVM_NATIVE_ARCH}${subcomponent} lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${LLVM_NATIVE_ARCH}${subcomponent} IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${LLVM_NATIVE_ARCH}${subcomponent}") endif() endforeach() @@ -167,32 +162,28 @@ elseif( c STREQUAL "AllTargetsAsmParsers" ) # Link all the asm parsers from all the targets foreach(t ${LLVM_TARGETS_TO_BUILD}) - list(FIND LLVM_AVAILABLE_LIBS LLVM${t}AsmParser lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${t}AsmParser IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${t}AsmParser") endif() endforeach(t) elseif( c STREQUAL "AllTargetsDescs" ) # Link all the descs from all the targets foreach(t ${LLVM_TARGETS_TO_BUILD}) - list(FIND LLVM_AVAILABLE_LIBS LLVM${t}Desc lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${t}Desc IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${t}Desc") endif() endforeach(t) elseif( c STREQUAL "AllTargetsDisassemblers" ) # Link all the disassemblers from all the targets foreach(t ${LLVM_TARGETS_TO_BUILD}) - list(FIND LLVM_AVAILABLE_LIBS LLVM${t}Disassembler lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${t}Disassembler IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${t}Disassembler") endif() endforeach(t) elseif( c STREQUAL "AllTargetsInfos" ) # Link all the infos from all the targets foreach(t ${LLVM_TARGETS_TO_BUILD}) - list(FIND LLVM_AVAILABLE_LIBS LLVM${t}Info lib_idx) - if( lib_idx GREATER_EQUAL 0 ) + if(LLVM${t}Info IN_LIST LLVM_AVAILABLE_LIBS) list(APPEND expanded_components "${t}Info") endif() endforeach(t) @@ -236,22 +227,17 @@ endif() # Expand some keywords: - list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend) - list(FIND link_components "engine" engine_required) - if( NOT engine_required EQUAL -1 ) - list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit) - if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 ) + if(engine IN_LIST link_components) + if(${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD AND + ${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_WITH_JIT) list(APPEND link_components "jit") list(APPEND link_components "native") else() list(APPEND link_components "interpreter") endif() endif() - list(FIND link_components "native" native_required) - if( NOT native_required EQUAL -1 ) - if( NOT have_native_backend EQUAL -1 ) - list(APPEND link_components ${LLVM_NATIVE_ARCH}) - endif() + if(native IN_LIST link_components AND ${LLVM_NATIVE_ARCH} IN_LIST LLVM_TARGETS_TO_BUILD) + list(APPEND link_components ${LLVM_NATIVE_ARCH}) endif() # Translate symbolic component names to real libraries: @@ -301,8 +287,7 @@ # This duplicates the algorithm used by llvm-config, originally # in tools/llvm-config/llvm-config.cpp, function ComputeLibsForComponents. function(expand_topologically name required_libs visited_libs) - list(FIND visited_libs ${name} found) - if( found LESS 0 ) + if(NOT ${name} IN_LIST visited_libs) list(APPEND visited_libs ${name}) set(visited_libs ${visited_libs} PARENT_SCOPE) diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake --- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake +++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake @@ -130,8 +130,7 @@ set(always_clean clean) endif() - list(FIND TOOLCHAIN_TOOLS clang FOUND_CLANG) - if(FOUND_CLANG GREATER -1) + if(clang IN_LIST TOOLCHAIN_TOOLS) set(CLANG_IN_TOOLCHAIN On) endif() diff --git a/llvm/cmake/modules/LLVMProcessSources.cmake b/llvm/cmake/modules/LLVMProcessSources.cmake --- a/llvm/cmake/modules/LLVMProcessSources.cmake +++ b/llvm/cmake/modules/LLVMProcessSources.cmake @@ -102,10 +102,8 @@ # Don't reject hidden files. Some editors create backups in the # same directory as the file. if (NOT "${fn}" MATCHES "^\\.") - list(FIND LLVM_OPTIONAL_SOURCES ${entry} idx) - if( idx LESS 0 ) - list(FIND listed ${gp} idx) - if( idx LESS 0 ) + if(NOT ${entry} IN_LIST LLVM_OPTIONAL_SOURCES) + if(NOT ${gp} IN_LIST listed) if(ARG_SOURCE_DIR) set(fn_relative "${ARG_SOURCE_DIR}/${fn}") else() diff --git a/llvm/cmake/modules/TableGen.cmake b/llvm/cmake/modules/TableGen.cmake --- a/llvm/cmake/modules/TableGen.cmake +++ b/llvm/cmake/modules/TableGen.cmake @@ -42,24 +42,15 @@ set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}/${LLVM_TARGET_DEFINITIONS}) endif() - if (LLVM_ENABLE_DAGISEL_COV) - list(FIND ARGN "-gen-dag-isel" idx) - if( NOT idx EQUAL -1 ) - list(APPEND LLVM_TABLEGEN_FLAGS "-instrument-coverage") - endif() + if (LLVM_ENABLE_DAGISEL_COV AND "-gen-dag-isel" IN_LIST ARGN) + list(APPEND LLVM_TABLEGEN_FLAGS "-instrument-coverage") endif() - if (LLVM_ENABLE_GISEL_COV) - list(FIND ARGN "-gen-global-isel" idx) - if( NOT idx EQUAL -1 ) - list(APPEND LLVM_TABLEGEN_FLAGS "-instrument-gisel-coverage") - list(APPEND LLVM_TABLEGEN_FLAGS "-gisel-coverage-file=${LLVM_GISEL_COV_PREFIX}all") - endif() + if (LLVM_ENABLE_GISEL_COV AND "-gen-global-isel" IN_LIST ARGN) + list(APPEND LLVM_TABLEGEN_FLAGS "-instrument-gisel-coverage") + list(APPEND LLVM_TABLEGEN_FLAGS "-gisel-coverage-file=${LLVM_GISEL_COV_PREFIX}all") endif() - if (LLVM_OMIT_DAGISEL_COMMENTS) - list(FIND ARGN "-gen-dag-isel" idx) - if (NOT idx EQUAL -1) - list(APPEND LLVM_TABLEGEN_FLAGS "-omit-comments") - endif() + if (LLVM_OMIT_DAGISEL_COMMENTS AND "-gen-dag-isel" IN_LIST ARGN) + list(APPEND LLVM_TABLEGEN_FLAGS "-omit-comments") endif() # MSVC can't support long string literals ("long" > 65534 bytes)[1], so if there's