ch1bo / flycheck-clang-tidy

Flycheck syntax checker using clang-tidy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when checking .hpp files

Lesstat opened this issue · comments

Hi,
first of all, thanks for the great package. Unfortunately since installing it, I noticed that the flycheck-list-errors buffer does not show any errors for .hpp files and I get the following errors whenever I visit a .hpp file:

Error while checking syntax automatically: (wrong-type-argument arrayp nil)
Error running timer ‘flycheck-buffer’: (wrong-type-argument arrayp nil)

If I need to provide any more info to help please let me know.

This is the stack trace from toggle-debug-on-error for when I load an hpp file:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  signal(wrong-type-argument (arrayp nil))
  flycheck-buffer()
  flycheck-buffer-automatically()
  flycheck-perform-deferred-syntax-check()
  #<subr set-window-buffer>(nil #<buffer space_age.hpp> nil)
  ad-Advice-set-window-buffer(#<subr set-window-buffer> nil #<buffer space_age.hpp>)
  apply(ad-Advice-set-window-buffer #<subr set-window-buffer> (nil #<buffer space_age.hpp>))
  set-window-buffer(nil #<buffer space_age.hpp>)
  #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x47b9ed89>)) #<bytecode 0x4009174d>)(#<buffer space_age.hpp> nil nil)
  ad-Advice-switch-to-buffer(#f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x47b9eee5>)) #<bytecode 0x4009174d>) #<buffer space_age.hpp> nil nil)
  apply(ad-Advice-switch-to-buffer #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x47bae2c5>)) #<bytecode 0x4009174d>) (#<buffer space_age.hpp> nil nil))
  #f(advice-wrapper :around #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x47bae421>)) #<bytecode 0x4009174d>) ad-Advice-switch-to-buffer)(#<buffer space_age.hpp> nil nil)
  purpose-switch-to-buffer-advice(#f(advice-wrapper :around #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x47bae5d1>)) #<bytecode 0x4009174d>) ad-Advice-switch-to-buffer) #<buffer space_age.hpp> nil nil)
  apply(purpose-switch-to-buffer-advice #f(advice-wrapper :around #f(compiled-function (buffer-or-name &optional norecord force-same-window) "Display buffer BUFFER-OR-NAME in the selected window.\n\nWARNING: This is NOT the way to work on another buffer temporarily\nwithin a Lisp program!  Use `set-buffer' instead.  That avoids\nmessing with the window-buffer correspondences.\n\nIf the selected window cannot display the specified buffer\nbecause it is a minibuffer window or strongly dedicated to\nanother buffer, call `pop-to-buffer' to select the buffer in\nanother window.  In interactive use, if the selected window is\nstrongly dedicated to its buffer, the value of the option\n`switch-to-buffer-in-dedicated-window' specifies how to proceed.\n\nIf called interactively, read the buffer name using `read-buffer'.\nThe variable `confirm-nonexistent-file-or-buffer' determines\nwhether to request confirmation before creating a new buffer.\nSee `read-buffer' for features related to input and completion\nof buffer names.\n\nBUFFER-OR-NAME may be a buffer, a string (a buffer name), or nil.\nIf BUFFER-OR-NAME is a string that does not identify an existing\nbuffer, create a buffer with that name.  If BUFFER-OR-NAME is\nnil, switch to the buffer returned by `other-buffer'.\n\nIf optional argument NORECORD is non-nil, do not put the buffer\nat the front of the buffer list, and do not make the window\ndisplaying it the most recently selected one.\n\nIf optional argument FORCE-SAME-WINDOW is non-nil, the buffer\nmust be displayed in the selected window when called\nnon-interactively; if that is impossible, signal an error rather\nthan calling `pop-to-buffer'.\n\nThe option `switch-to-buffer-preserve-window-point' can be used\nto make the buffer appear at its last position in the selected\nwindow.\n\nReturn the buffer switched to." (interactive #f(compiled-function () #<bytecode 0x47bb1789>)) #<bytecode 0x4009174d>) ad-Advice-switch-to-buffer) (#<buffer space_age.hpp> nil nil))
  switch-to-buffer(#<buffer space_age.hpp> nil nil)
  persp-switch-to-buffer(#<buffer space_age.hpp>)
  #f(compiled-function (bon) #<bytecode 0x413542e5>)(#<buffer space_age.hpp>)
  mapc(#f(compiled-function (bon) #<bytecode 0x413542e5>) (#<buffer space_age.hpp>))
  persp-add-buffer(#<buffer space_age.hpp> nil t nil)
  persp-add-or-not-on-find-file()
  run-hooks(find-file-hook)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer space_age.hpp> "~/exercism/cpp/space-age/space_age.hpp" nil nil "~/exercism/cpp/space-age/space_age.hpp" (7948010 16777222))
  find-file-noselect("/Users/collen/exercism/cpp/space-age/space_age.hpp" nil nil nil)
  find-file("/Users/collen/exercism/cpp/space-age/space_age.hpp")
  #f(compiled-function (full-path &optional arg) #<bytecode 0x43fcc799>)("/Users/collen/exercism/cpp/space-age/space_age.hpp" 1)
  purpose-fix-neotree-open-file-advice(#f(compiled-function (full-path &optional arg) #<bytecode 0x43fcc799>) "/Users/collen/exercism/cpp/space-age/space_age.hpp" 1)
  apply(purpose-fix-neotree-open-file-advice #f(compiled-function (full-path &optional arg) #<bytecode 0x43fcc799>) ("/Users/collen/exercism/cpp/space-age/space_age.hpp" 1))
  neo-open-file("/Users/collen/exercism/cpp/space-age/space_age.hpp" 1)
  neo-buffer--execute(1 neo-open-file neo-open-dir)
  neotree-enter(1)
  apply(neotree-enter 1)
  (let ((mru-winum (winum-get-number (get-mru-window)))) (apply 'neotree-enter (list mru-winum)))
  (if arg (neotree-enter arg) (let ((mru-winum (winum-get-number (get-mru-window)))) (apply 'neotree-enter (list mru-winum))))
  (if (file-directory-p node) (progn (neo-buffer--set-expand node t) (neo-buffer--refresh t) (if neo-auto-indent-point (progn (next-line) (neo-point-auto-indent)))) (if arg (neotree-enter arg) (let ((mru-winum (winum-get-number (get-mru-window)))) (apply 'neotree-enter (list mru-winum)))))
  (progn (if (file-directory-p node) (progn (neo-buffer--set-expand node t) (neo-buffer--refresh t) (if neo-auto-indent-point (progn (next-line) (neo-point-auto-indent)))) (if arg (neotree-enter arg) (let ((mru-winum (winum-get-number (get-mru-window)))) (apply 'neotree-enter (list mru-winum))))))
  (if node (progn (if (file-directory-p node) (progn (neo-buffer--set-expand node t) (neo-buffer--refresh t) (if neo-auto-indent-point (progn (next-line) (neo-point-auto-indent)))) (if arg (neotree-enter arg) (let ((mru-winum (winum-get-number ...))) (apply 'neotree-enter (list mru-winum)))))))
  (let ((node (neo-buffer--get-filename-current-line))) (if node (progn (if (file-directory-p node) (progn (neo-buffer--set-expand node t) (neo-buffer--refresh t) (if neo-auto-indent-point (progn (next-line) (neo-point-auto-indent)))) (if arg (neotree-enter arg) (let ((mru-winum ...)) (apply 'neotree-enter (list mru-winum))))))))
  spacemacs/neotree-expand-or-open(nil)
  funcall-interactively(spacemacs/neotree-expand-or-open nil)
  call-interactively(spacemacs/neotree-expand-or-open nil nil)
  command-execute(spacemacs/neotree-expand-or-open)

Having the same issue. I tried putting custom signal statements, and have traced the error to (flycheck-checker-substituted-arguments checker) call, from inside flycheck-start-command-checker inside flycheck.el.
The above traceback (and emacs debug traceback in general) does not reveal this information, so I'm trying to step through manually.
Seems like it is tough to find the arguments for a header file, and this .el script doesn't know how to.

Okay so now I know what is happening. As I thought before, compile_commands doesn't contain any commands for header files. Softwares like cquery etc know how to deduce the compile commands for headers from cpp files around the header.

flycheck-clang-tidy doesn't do anything in that regard.
Thus, in the following snippet:

(defun flycheck-clang-tidy-temp-compile-command (file source)
  "Return compile command for FILE with source located in SOURCE."
  (let* ((cmd (flycheck-clang-tidy-compile-command file))

The value of cmd is nil for header files (verified).

My elisp isn't really great, so it would be great if someone with better knowledge of elisp could hack up a fix.

The error appears because the file to check is copied to a temporary directory. Reverting 4d7d33e fixes this issue and issue #6, but then flycheck-clang-tidy only works on files, not modified buffers.