mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-23 14:10:28 -08:00
Improve accuracy of line/column numbers in byte compiler's warning messages.
* lisp/emacs-lisp/bytecomp.el (byte-compile-set-symbol-position): ensure new value of byte-compile-last-position is not lower than old value. (byte-compile-function-warn): call byte-compile-set-symbol-position.
This commit is contained in:
parent
aab079d1d2
commit
277e7b011d
1 changed files with 26 additions and 22 deletions
|
|
@ -1022,39 +1022,42 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
|
||||||
(setcdr list (cddr list)))
|
(setcdr list (cddr list)))
|
||||||
total)))
|
total)))
|
||||||
|
|
||||||
;; The purpose of this function is to iterate through the
|
;; The purpose of `byte-compile-set-symbol-position' is to attempt to
|
||||||
;; `read-symbol-positions-list'. Each time we process, say, a
|
;; set `byte-compile-last-position' to the "current position" in the
|
||||||
;; function definition (`defun') we remove `defun' from
|
;; raw source code. This is used for warning and error messages.
|
||||||
;; `read-symbol-positions-list', and set `byte-compile-last-position'
|
|
||||||
;; to that symbol's character position. Similarly, if we encounter a
|
|
||||||
;; variable reference, like in (1+ foo), we remove `foo' from the
|
|
||||||
;; list. If our current position is after the symbol's position, we
|
|
||||||
;; assume we've already passed that point, and look for the next
|
|
||||||
;; occurrence of the symbol.
|
|
||||||
;;
|
;;
|
||||||
;; This function should not be called twice for the same occurrence of
|
;; The function should be called for most occurrences of symbols in
|
||||||
;; a symbol, and it should not be called for symbols generated by the
|
;; the forms being compiled, strictly in the order they occur in the
|
||||||
;; byte compiler itself; because rather than just fail looking up the
|
;; source code. It should never be called twice for any single
|
||||||
;; symbol, we may find an occurrence of the symbol further ahead, and
|
;; occurrence, and should not be called for symbols generated by the
|
||||||
;; then `byte-compile-last-position' as advanced too far.
|
;; byte compiler itself.
|
||||||
;;
|
;;
|
||||||
;; So your're probably asking yourself: Isn't this function a
|
;; The function works by scanning the elements in the alist
|
||||||
;; gross hack? And the answer, of course, would be yes.
|
;; `read-symbol-positions-list' for the next match for the symbol
|
||||||
|
;; after the current value of `byte-compile-last-position', setting
|
||||||
|
;; that variable to the match's character position, then deleting the
|
||||||
|
;; matching element from the list. Thus the new value for
|
||||||
|
;; `byte-compile-last-position' is later than the old value unless,
|
||||||
|
;; perhaps, ALLOW-PREVIOUS is non-nil.
|
||||||
|
;;
|
||||||
|
;; So your're probably asking yourself: Isn't this function a gross
|
||||||
|
;; hack? And the answer, of course, would be yes.
|
||||||
(defun byte-compile-set-symbol-position (sym &optional allow-previous)
|
(defun byte-compile-set-symbol-position (sym &optional allow-previous)
|
||||||
(when byte-compile-read-position
|
(when byte-compile-read-position
|
||||||
(let (last entry)
|
(let ((last byte-compile-last-position)
|
||||||
|
entry)
|
||||||
(while (progn
|
(while (progn
|
||||||
(setq last byte-compile-last-position
|
(setq entry (assq sym read-symbol-positions-list))
|
||||||
entry (assq sym read-symbol-positions-list))
|
|
||||||
(when entry
|
(when entry
|
||||||
(setq byte-compile-last-position
|
(setq byte-compile-last-position
|
||||||
(+ byte-compile-read-position (cdr entry))
|
(+ byte-compile-read-position (cdr entry))
|
||||||
read-symbol-positions-list
|
read-symbol-positions-list
|
||||||
(byte-compile-delete-first
|
(byte-compile-delete-first
|
||||||
entry read-symbol-positions-list)))
|
entry read-symbol-positions-list)))
|
||||||
|
(and entry
|
||||||
(or (and allow-previous
|
(or (and allow-previous
|
||||||
(not (= last byte-compile-last-position)))
|
(not (= last byte-compile-last-position)))
|
||||||
(> last byte-compile-last-position)))))))
|
(> last byte-compile-last-position))))))))
|
||||||
|
|
||||||
(defvar byte-compile-last-warned-form nil)
|
(defvar byte-compile-last-warned-form nil)
|
||||||
(defvar byte-compile-last-logged-file nil)
|
(defvar byte-compile-last-logged-file nil)
|
||||||
|
|
@ -1284,6 +1287,7 @@ when printing the error message."
|
||||||
(t (format "%d-%d" (car signature) (cdr signature)))))
|
(t (format "%d-%d" (car signature) (cdr signature)))))
|
||||||
|
|
||||||
(defun byte-compile-function-warn (f nargs def)
|
(defun byte-compile-function-warn (f nargs def)
|
||||||
|
(byte-compile-set-symbol-position f)
|
||||||
(when (get f 'byte-obsolete-info)
|
(when (get f 'byte-obsolete-info)
|
||||||
(byte-compile-warn-obsolete f))
|
(byte-compile-warn-obsolete f))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue