cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
958 stars 105 forks source link

cmake-lint crashes when using `VERBATIM` in `add_custom_target` #163

Closed torfinnberset closed 4 years ago

torfinnberset commented 4 years ago

cmake-lint v0.6.7 crashes when trying to process the following snippet:

add_custom_target(
    verbatim_lint_crash
    COMMAND echo 1
    COMMENT "This crashes cmake-lint 0.6.5"
    VERBATIM
)

(does not crash unless VERBATIM is used)

with the following stack trace:

$ cmake-lint add_custom_target.cmake

WARNING The following configuration options were ignored:
  linter
WARNING While processing add_custom_target.cmake
Traceback (most recent call last):
  File "/Users/torfinn/Library/Python/3.7/bin/cmake-lint", line 8, in <module>
    sys.exit(main())
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/__main__.py", line 143, in main
    process_file(cfg, local_ctx, intext)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/__main__.py", line 44, in process_file
    basic_checker.check_tree(config, local_ctx, parse_tree)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 513, in check_tree
    check_body(cfg, local_ctx, node)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 357, in check_body
    check_tree(cfg, local_ctx, child)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 519, in check_tree
    check_statement(cfg, local_ctx, node)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 506, in check_statement
    check_tree(cfg, local_ctx, child)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 517, in check_tree
    check_arggroup(cfg, local_ctx, node)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 375, in check_arggroup
    check_tree(cfg, local_ctx, child)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 521, in check_tree
    check_positional_group(cfg, local_ctx, node)
  File "/Users/torfinn/Library/Python/3.7/lib/python/site-packages/cmake_lint/basic_checker.py", line 380, in check_positional_group
    min_npargs = get_min_npargs(node.spec.npargs)
AttributeError: 'NoneType' object has no attribute 'npargs'

Using Python 3.7.3 on macOS 10.15.2.