Function: flymake-cc
flymake-cc is an autoloaded and byte-compiled function defined in
flymake-cc.el.gz.
Signature
(flymake-cc REPORT-FN &rest ARGS)
Documentation
Flymake backend for GNU-style C compilers.
This backend uses flymake-cc-command (which see) to launch a
process that is passed the current buffer's contents via stdin.
REPORT-FN is Flymake's callback.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/flymake-cc.el.gz
;;;###autoload
(defun flymake-cc (report-fn &rest _args)
"Flymake backend for GNU-style C compilers.
This backend uses `flymake-cc-command' (which see) to launch a
process that is passed the current buffer's contents via stdin.
REPORT-FN is Flymake's callback."
;; HACK: XXX: Assuming this backend function is run before it in
;; `flymake-diagnostic-functions', very hackingly convince the other
;; backend `flymake-proc-legacy-flymake', which is on by default, to
;; disable itself.
;;
(setq-local flymake-proc-allowed-file-name-masks nil)
(when (process-live-p flymake-cc--proc)
(kill-process flymake-cc--proc))
(let ((source (current-buffer)))
(save-restriction
(widen)
(setq
flymake-cc--proc
(make-process
:name "gcc-flymake"
:buffer (generate-new-buffer "*gcc-flymake*")
:command (if (functionp flymake-cc-command)
(funcall flymake-cc-command)
flymake-cc-command)
:noquery t :connection-type 'pipe
:sentinel
(lambda (p _ev)
(unwind-protect
(when (eq 'exit (process-status p))
(when (with-current-buffer source (eq p flymake-cc--proc))
(with-current-buffer (process-buffer p)
(goto-char (point-min))
(let ((diags
(flymake-cc--make-diagnostics source)))
(if (or diags (zerop (process-exit-status p)))
(funcall report-fn diags)
;; non-zero exit with no diags is cause
;; for alarm
(funcall report-fn
:panic :explanation
(buffer-substring
(point-min) (progn (goto-char (point-min))
(line-end-position)))))))))
(unless (process-live-p p)
;; (display-buffer (process-buffer p)) ; uncomment to debug
(kill-buffer (process-buffer p)))))))
(process-send-region flymake-cc--proc (point-min) (point-max))
(process-send-eof flymake-cc--proc))))