cmake_format icon indicating copy to clipboard operation
cmake_format copied to clipboard

cmake-format hangs for particular input

Open lxbrz opened this issue 3 years ago • 0 comments

Hi,

when running cmake-format -i /tmp/test.cmake

on

test.cmake:

if(((NOT (IMAGE_NAME STREQUAL "foo1")) OR FOO)
        AND (NOT (BOARD MATCHES "foo2" AND (

            IMAGE_NAME STREQUAL "foo3"
        OR IMAGE_NAME STREQUAL "foo4"
        OR IMAGE_NAME STREQUAL "foo5")
    )))
    message(VERBOSE "foo6")
endif()

the formatting seems to hang, the CPU usage of one core is a 100%, whereas a slightly altered (foo4 removed) input test.cmake finishes:

if(((NOT (IMAGE_NAME STREQUAL "foo1")) OR FOO)
        AND (NOT (BOARD MATCHES "foo2" AND (

            IMAGE_NAME STREQUAL "foo3"
        OR IMAGE_NAME STREQUAL "foo5")
    )))
    message(VERBOSE "foo6")
endif()

becomes

if(((NOT (IMAGE_NAME STREQUAL "foo1")) OR FOO)
   AND (NOT (BOARD MATCHES "foo2" AND (IMAGE_NAME STREQUAL "foo3"
                                       OR IMAGE_NAME STREQUAL "foo5"))))
  message(VERBOSE "foo6")
endif()

in:

real    0m0,157s
user    0m0,132s
sys     0m0,024s

while the problematic input doesn't finish within a couple minutes.

cmake-format version is 0.6.13 on Ubuntu 22.04

lxbrz avatar May 13 '22 11:05 lxbrz