flycheck-clang-tidy icon indicating copy to clipboard operation
flycheck-clang-tidy copied to clipboard

Replaced "source" to "source-original"

Open emacs18 opened this issue 3 years ago • 4 comments

This is so that clang-tidy would use the original C++ file as input rather than a copy of it under temporary directory.

Even on ubuntu 20.04 I don't think flycheck-clang-tidy was working correctly, because compilation database file was not being located. With this change flycheck-list-errors now works correctly on CentOS 7.

emacs18 avatar Jan 14 '22 05:01 emacs18

The problem with using the the original file is that it will not work on content that is not yet saved. That's why we use use source in the first place. 😊

Did you try setting flycheck-clang-tidy-build-path to the path (relative to the repos root directory) that contains the compilation database?

tastytea avatar Jan 14 '22 05:01 tastytea

Yes. I tried not setting it, as well as to "." since compile_commands.json is at the project root directory. Nothing I tried worked. I also tried setting it to absolute path of project root.

emacs18 avatar Jan 14 '22 05:01 emacs18

clang-tidy takes up to a minute or more to run on my code, so I have no plans to have run it on code of an unsaved buffer.

emacs18 avatar Jan 14 '22 05:01 emacs18

By adding debug code shown below to flycheck, I learned that compilation database was not being found even on Ubuntu 20.04.

diff --git a/flycheck.el b/flycheck.el
index b88335b5..07ce64bd 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -82,6 +82,13 @@
 (require 'json)                  ; `flycheck-parse-tslint'
 (require 'ansi-color)            ; `flycheck-parse-with-patterns-without-color'
 
+(defun my-flycheck-debug-log (&rest msgs)
+  (let ((buffer (get-buffer-create "*flycheck-debug*")))
+    (save-excursion
+      (set-buffer buffer)
+      (goto-char (point-max))
+      (insert (mapconcat #'identity msgs "\n"))
+      (insert "\n"))))
 
 ;; Declare a bunch of dynamic variables that we need from other modes
 (defvar sh-shell)                       ; For shell script checker predicates
@@ -6203,6 +6210,7 @@ and rely on Emacs' own buffering and chunking."
           ;;
           ;; See https://github.com/flycheck/flycheck/issues/298 for an
           ;; example for such a conflict.
+          (my-flycheck-debug-log (mapconcat #'identity command " "))
           (setq process (apply 'start-process (format "flycheck-%s" checker)
                                nil command))
           ;; Process sentinels can be called while sending input to the process.
@@ -6318,6 +6326,7 @@ CHECKER."
 ;;; Process management for command syntax checkers
 (defun flycheck-receive-checker-output (process output)
   "Receive a syntax checking PROCESS OUTPUT."
+  (my-flycheck-debug-log output)
   (push output (process-get process 'flycheck-pending-output)))
 
 (defun flycheck-get-output (process)

emacs18 avatar Jan 14 '22 05:01 emacs18