Добавлены автозамены для clazy

This commit is contained in:
Andrei Astafev 2020-04-18 23:31:40 +03:00
parent 8a09a61d52
commit b513e9b15b

View File

@ -15,19 +15,49 @@ function(add_clazy_check target)
add_dependencies(clazy-check-${target} ${target})
add_dependencies(clazy-check clazy-check-${target})
option(CMLIB_CLAZY_FIX_STRING_ALLOCATIONS "Clazy allocations" OFF)
option(CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT "Clazy old style connect" OFF)
option(CMLIB_CLAZY_FIX_QT_KEYWORDS "Fix Qt keywords" OFF)
option(CMLIB_CLAZY_FIX_RANGE_LOOP_ADD_REF "Fix range loop add reference" OFF)
option(CMLIB_CLAZY_FIX_RANGE_LOOP_ADD_QASCONST "Fix range loop add qAsConst" OFF)
option(CMLIB_CLAZY_FIX_FUNCTION_ARGS_BY_REF "Fix function args by reference" OFF)
option(CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT "Fix old style connect" OFF)
option(CMLIB_CLAZY_FIX_STRING_ALLOCATIONS "Fix string allocations" OFF)
if (CMLIB_CLAZY_FIX_STRING_ALLOCATIONS OR CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT)
if(CMLIB_CLAZY_FIX_QT_KEYWORDS OR
CMLIB_CLAZY_FIX_RANGE_LOOP_ADD_REF OR
CMLIB_CLAZY_FIX_RANGE_LOOP_ADD_QASCONST OR
CMLIB_CLAZY_FIX_FUNCTION_ARGS_BY_REF OR
CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT OR
CMLIB_CLAZY_FIX_STRING_ALLOCATIONS)
if(NOT TARGET clazy-fix)
add_custom_target(clazy-fix)
endif()
if(CMLIB_CLAZY_FIX_STRING_ALLOCATIONS)
add_custom_target(clazy-fix-string-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-qlatin1string-allocations"
if(CMLIB_CLAZY_FIX_QT_KEYWORDS)
add_custom_target(clazy-fix-qt-keywords-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-qt-keywords"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-string-${target} ${target})
add_dependencies(clazy-fix clazy-fix-string-${target})
add_dependencies(clazy-fix-qt-keywords-${target} ${target})
add_dependencies(clazy-fix clazy-fix-qt-keywords-${target})
endif()
if(CMLIB_CLAZY_FIX_RANGE_LOOP_ADD_REF)
add_custom_target(clazy-fix-range-loop-add-ref-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-range-loop-add-ref"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-range-loop-add-ref-${target} ${target})
add_dependencies(clazy-fix clazy-fix-range-loop-add-ref-${target})
endif()
if(CMLIB_CLAZY_FIX_RANGE_LOOP_ADD_QASCONST)
add_custom_target(clazy-fix-range-loop-add-qasconst-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-range-loop-add-qasconst"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-range-loop-add-qasconst-${target} ${target})
add_dependencies(clazy-fix clazy-fix-range-loop-add-qasconst-${target})
endif()
if(CMLIB_CLAZY_FIX_FUNCTION_ARGS_BY_REF)
add_custom_target(clazy-fix-function-args-by-ref-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-function-args-by-ref"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-function-args-by-ref-${target} ${target})
add_dependencies(clazy-fix clazy-fix-function-args-by-ref-${target})
endif()
if(CMLIB_CLAZY_FIX_OLD_STYLE_CONNECT)
add_custom_target(clazy-fix-old-style-connect-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@ -36,8 +66,17 @@ function(add_clazy_check target)
add_dependencies(clazy-fix-old-style-connect-${target} ${target})
add_dependencies(clazy-fix clazy-fix-old-style-connect-${target})
endif()
# "fix-qlatin1string-allocations", "qstring-allocations");
# "fix-fromLatin1_fromUtf8-allocations", "qstring-allocations");
# "fix-fromCharPtrAllocations", "qstring-allocations");
if(CMLIB_CLAZY_FIX_STRING_ALLOCATIONS)
add_custom_target(clazy-fix-string-${target} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E env "CLAZY_FIXIT=fix-qlatin1string-allocations"
${CLAZY_EXE} ${_args} -p ${CMAKE_BINARY_DIR} ${_sources})
add_dependencies(clazy-fix-string-${target} ${target})
add_dependencies(clazy-fix clazy-fix-string-${target})
endif()
endif()
else()
message(STATUS "CMLIB warning:")
message(STATUS " Clazy standalone analyzer is not found")