Function: flymake-cc--make-diagnostics

flymake-cc--make-diagnostics is a byte-compiled function defined in flymake-cc.el.gz.

Signature

(flymake-cc--make-diagnostics SOURCE)

Documentation

Parse GNU-compatible compilation messages in current buffer.

Return a list of Flymake diagnostic objects for the source buffer SOURCE.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/flymake-cc.el.gz
(defun flymake-cc--make-diagnostics (source)
  "Parse GNU-compatible compilation messages in current buffer.
Return a list of Flymake diagnostic objects for the source buffer
SOURCE."
  ;; TODO: if you can understand it, use `compilation-mode's regexps
  ;; or even some of its machinery here.
  ;;
  ;;    (setq-local compilation-locs
  ;;         (make-hash-table :test 'equal :weakness 'value))
  ;;    (compilation-parse-errors (point-min) (point-max)
  ;;                              'gnu 'gcc-include)
  ;;    (while (next-single-property-change 'compilation-message)
  ;;       ...)
  ;;
  ;; For now, this works minimally well.
  (cl-loop
   while
   (search-forward-regexp
    "^\\(In file included from \\)?\\([^ :]+\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?:\n?\\(.*\\): \\(.*\\)$"
    nil t)
   for msg = (match-string 6)
   for locus = (match-string 2)
   for line = (string-to-number (match-string 3))
   for col = (ignore-errors (string-to-number (match-string 4)))
   for source-buffer = (and (string= locus "<stdin>") source)
   for type = (if (match-string 1)
                  :error
                (save-match-data
                  (assoc-default
                   (match-string 5)
                   '(("error" . :error)
                     ("note" . :note)
                     ("warning" . :warning))
                   #'string-match
                   :error)))
   for diag =
   (cond (source-buffer
          (pcase-let ((`(,beg . ,end)
                       (flymake-diag-region source-buffer line col)))
            (flymake-make-diagnostic source-buffer beg end type msg)))
         (t (flymake-make-diagnostic locus (cons line col) nil type msg)))
   collect diag
   ;; If "In file included from..." matched, then move to end of that
   ;; line.  This helps us collect the diagnostic at its .h locus,
   ;; too.
   when (match-end 1) do (goto-char (match-end 2))))