diff options
| author | Glenn Morris | 2009-10-31 02:10:43 +0000 |
|---|---|---|
| committer | Glenn Morris | 2009-10-31 02:10:43 +0000 |
| commit | 416d35886fa893252a62b21238ca84c0a01dce91 (patch) | |
| tree | 34ab870db03a05ba4eb2fe1a6c3075d10f3da5cf | |
| parent | 8aedfd3b5d1463c6d65602d15b251a717c5ffe27 (diff) | |
| download | emacs-416d35886fa893252a62b21238ca84c0a01dce91.tar.gz emacs-416d35886fa893252a62b21238ca84c0a01dce91.zip | |
(byte-compile-warning-types, byte-compile-warnings): Add `constants'
as an option.
(byte-compile-callargs-warn, byte-compile-arglist-warn)
(display-call-tree): Update for byte-compile-fdefinition possibly
returning `(macro lambda ...)'. (Bug#4778)
(byte-compile-variable-ref, byte-compile-setq-default):
Respect `constants' member of byte-compile-warnings.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 149 |
2 files changed, 72 insertions, 85 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e7cc04dd785..674170972f3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2009-10-31 Glenn Morris <rgm@gnu.org> | 1 | 2009-10-31 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * emacs-lisp/bytecomp.el (byte-compile-warning-types) | ||
| 4 | (byte-compile-warnings): Add `constants' as an option. | ||
| 5 | (byte-compile-callargs-warn, byte-compile-arglist-warn) | ||
| 6 | (display-call-tree): Update for byte-compile-fdefinition possibly | ||
| 7 | returning `(macro lambda ...)'. (Bug#4778) | ||
| 8 | (byte-compile-variable-ref, byte-compile-setq-default): | ||
| 9 | Respect `constants' member of byte-compile-warnings. | ||
| 10 | |||
| 3 | * cedet/semantic/tag.el (semantic--tag-link-list-to-buffer): | 11 | * cedet/semantic/tag.el (semantic--tag-link-list-to-buffer): |
| 4 | Use mapc rather than mapcar because the return value is never used. | 12 | Use mapc rather than mapcar because the return value is never used. |
| 5 | 13 | ||
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 1262264e9ec..43a421ca9e6 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -66,47 +66,7 @@ | |||
| 66 | ;; + correct compilation of top-level uses of macros; | 66 | ;; + correct compilation of top-level uses of macros; |
| 67 | ;; + the ability to generate a histogram of functions called. | 67 | ;; + the ability to generate a histogram of functions called. |
| 68 | 68 | ||
| 69 | ;; User customization variables: | 69 | ;; User customization variables: M-x customize-group bytecomp |
| 70 | ;; | ||
| 71 | ;; byte-compile-verbose Whether to report the function currently being | ||
| 72 | ;; compiled in the echo area; | ||
| 73 | ;; byte-optimize Whether to do optimizations; this may be | ||
| 74 | ;; t, nil, 'source, or 'byte; | ||
| 75 | ;; byte-optimize-log Whether to report (in excruciating detail) | ||
| 76 | ;; exactly which optimizations have been made. | ||
| 77 | ;; This may be t, nil, 'source, or 'byte; | ||
| 78 | ;; byte-compile-error-on-warn Whether to stop compilation when a warning is | ||
| 79 | ;; produced; | ||
| 80 | ;; byte-compile-delete-errors Whether the optimizer may delete calls or | ||
| 81 | ;; variable references that are side-effect-free | ||
| 82 | ;; except that they may return an error. | ||
| 83 | ;; byte-compile-generate-call-tree Whether to generate a histogram of | ||
| 84 | ;; function calls. This can be useful for | ||
| 85 | ;; finding unused functions, as well as simple | ||
| 86 | ;; performance metering. | ||
| 87 | ;; byte-compile-warnings List of warnings to issue, or t. May contain | ||
| 88 | ;; `free-vars' (references to variables not in the | ||
| 89 | ;; current lexical scope) | ||
| 90 | ;; `unresolved' (calls to unknown functions) | ||
| 91 | ;; `callargs' (lambda calls with args that don't | ||
| 92 | ;; match the lambda's definition) | ||
| 93 | ;; `redefine' (function cell redefined from | ||
| 94 | ;; a macro to a lambda or vice versa, | ||
| 95 | ;; or redefined to take other args) | ||
| 96 | ;; `obsolete' (obsolete variables and functions) | ||
| 97 | ;; `noruntime' (calls to functions only defined | ||
| 98 | ;; within `eval-when-compile') | ||
| 99 | ;; `cl-functions' (calls to CL functions) | ||
| 100 | ;; `interactive-only' (calls to commands that are | ||
| 101 | ;; not good to call from Lisp) | ||
| 102 | ;; `make-local' (dubious calls to | ||
| 103 | ;; `make-variable-buffer-local') | ||
| 104 | ;; `mapcar' (mapcar called for effect) | ||
| 105 | ;; byte-compile-compatibility Whether the compiler should | ||
| 106 | ;; generate .elc files which can be loaded into | ||
| 107 | ;; generic emacs 18. | ||
| 108 | ;; emacs-lisp-file-regexp Regexp for the extension of source-files; | ||
| 109 | ;; see also the function byte-compile-dest-file. | ||
| 110 | 70 | ||
| 111 | ;; New Features: | 71 | ;; New Features: |
| 112 | ;; | 72 | ;; |
| @@ -349,7 +309,7 @@ If it is 'byte, then only byte-level optimizations will be logged." | |||
| 349 | (defconst byte-compile-warning-types | 309 | (defconst byte-compile-warning-types |
| 350 | '(redefine callargs free-vars unresolved | 310 | '(redefine callargs free-vars unresolved |
| 351 | obsolete noruntime cl-functions interactive-only | 311 | obsolete noruntime cl-functions interactive-only |
| 352 | make-local mapcar) | 312 | make-local mapcar constants) |
| 353 | "The list of warning types used when `byte-compile-warnings' is t.") | 313 | "The list of warning types used when `byte-compile-warnings' is t.") |
| 354 | (defcustom byte-compile-warnings t | 314 | (defcustom byte-compile-warnings t |
| 355 | "List of warnings that the byte-compiler should issue (t for all). | 315 | "List of warnings that the byte-compiler should issue (t for all). |
| @@ -370,6 +330,7 @@ Elements of the list may be: | |||
| 370 | commands that normally shouldn't be called from Lisp code. | 330 | commands that normally shouldn't be called from Lisp code. |
| 371 | make-local calls to make-variable-buffer-local that may be incorrect. | 331 | make-local calls to make-variable-buffer-local that may be incorrect. |
| 372 | mapcar mapcar called for effect. | 332 | mapcar mapcar called for effect. |
| 333 | constants let-binding of, or assignment to, constants/nonvariables. | ||
| 373 | 334 | ||
| 374 | If the list begins with `not', then the remaining elements specify warnings to | 335 | If the list begins with `not', then the remaining elements specify warnings to |
| 375 | suppress. For example, (not mapcar) will suppress warnings about mapcar." | 336 | suppress. For example, (not mapcar) will suppress warnings about mapcar." |
| @@ -380,7 +341,7 @@ suppress. For example, (not mapcar) will suppress warnings about mapcar." | |||
| 380 | (const callargs) (const redefine) | 341 | (const callargs) (const redefine) |
| 381 | (const obsolete) (const noruntime) | 342 | (const obsolete) (const noruntime) |
| 382 | (const cl-functions) (const interactive-only) | 343 | (const cl-functions) (const interactive-only) |
| 383 | (const make-local) (const mapcar)))) | 344 | (const make-local) (const mapcar) (const constants)))) |
| 384 | ;;;###autoload(put 'byte-compile-warnings 'safe-local-variable 'byte-compile-warnings-safe-p) | 345 | ;;;###autoload(put 'byte-compile-warnings 'safe-local-variable 'byte-compile-warnings-safe-p) |
| 385 | 346 | ||
| 386 | ;;;###autoload | 347 | ;;;###autoload |
| @@ -1306,12 +1267,16 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'." | |||
| 1306 | (let* ((def (or (byte-compile-fdefinition (car form) nil) | 1267 | (let* ((def (or (byte-compile-fdefinition (car form) nil) |
| 1307 | (byte-compile-fdefinition (car form) t))) | 1268 | (byte-compile-fdefinition (car form) t))) |
| 1308 | (sig (if (and def (not (eq def t))) | 1269 | (sig (if (and def (not (eq def t))) |
| 1309 | (byte-compile-arglist-signature | 1270 | (progn |
| 1310 | (if (memq (car-safe def) '(declared lambda)) | 1271 | (and (eq (car-safe def) 'macro) |
| 1311 | (nth 1 def) | 1272 | (eq (car-safe (cdr-safe def)) 'lambda) |
| 1312 | (if (byte-code-function-p def) | 1273 | (setq def (cdr def))) |
| 1313 | (aref def 0) | 1274 | (byte-compile-arglist-signature |
| 1314 | '(&rest def)))) | 1275 | (if (memq (car-safe def) '(declared lambda)) |
| 1276 | (nth 1 def) | ||
| 1277 | (if (byte-code-function-p def) | ||
| 1278 | (aref def 0) | ||
| 1279 | '(&rest def))))) | ||
| 1315 | (if (and (fboundp (car form)) | 1280 | (if (and (fboundp (car form)) |
| 1316 | (subrp (symbol-function (car form)))) | 1281 | (subrp (symbol-function (car form)))) |
| 1317 | (subr-arity (symbol-function (car form)))))) | 1282 | (subr-arity (symbol-function (car form)))))) |
| @@ -1406,22 +1371,26 @@ extra args." | |||
| 1406 | (defun byte-compile-arglist-warn (form macrop) | 1371 | (defun byte-compile-arglist-warn (form macrop) |
| 1407 | (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) | 1372 | (let ((old (byte-compile-fdefinition (nth 1 form) macrop))) |
| 1408 | (if (and old (not (eq old t))) | 1373 | (if (and old (not (eq old t))) |
| 1409 | (let ((sig1 (byte-compile-arglist-signature | 1374 | (progn |
| 1410 | (if (eq 'lambda (car-safe old)) | 1375 | (and (eq 'macro (car-safe old)) |
| 1411 | (nth 1 old) | 1376 | (eq 'lambda (car-safe (cdr-safe old))) |
| 1412 | (if (byte-code-function-p old) | 1377 | (setq old (cdr old))) |
| 1413 | (aref old 0) | 1378 | (let ((sig1 (byte-compile-arglist-signature |
| 1414 | '(&rest def))))) | 1379 | (if (eq 'lambda (car-safe old)) |
| 1415 | (sig2 (byte-compile-arglist-signature (nth 2 form)))) | 1380 | (nth 1 old) |
| 1416 | (unless (byte-compile-arglist-signatures-congruent-p sig1 sig2) | 1381 | (if (byte-code-function-p old) |
| 1417 | (byte-compile-set-symbol-position (nth 1 form)) | 1382 | (aref old 0) |
| 1418 | (byte-compile-warn | 1383 | '(&rest def))))) |
| 1419 | "%s %s used to take %s %s, now takes %s" | 1384 | (sig2 (byte-compile-arglist-signature (nth 2 form)))) |
| 1420 | (if (eq (car form) 'defun) "function" "macro") | 1385 | (unless (byte-compile-arglist-signatures-congruent-p sig1 sig2) |
| 1421 | (nth 1 form) | 1386 | (byte-compile-set-symbol-position (nth 1 form)) |
| 1422 | (byte-compile-arglist-signature-string sig1) | 1387 | (byte-compile-warn |
| 1423 | (if (equal sig1 '(1 . 1)) "argument" "arguments") | 1388 | "%s %s used to take %s %s, now takes %s" |
| 1424 | (byte-compile-arglist-signature-string sig2)))) | 1389 | (if (eq (car form) 'defun) "function" "macro") |
| 1390 | (nth 1 form) | ||
| 1391 | (byte-compile-arglist-signature-string sig1) | ||
| 1392 | (if (equal sig1 '(1 . 1)) "argument" "arguments") | ||
| 1393 | (byte-compile-arglist-signature-string sig2))))) | ||
| 1425 | ;; This is the first definition. See if previous calls are compatible. | 1394 | ;; This is the first definition. See if previous calls are compatible. |
| 1426 | (let ((calls (assq (nth 1 form) byte-compile-unresolved-functions)) | 1395 | (let ((calls (assq (nth 1 form) byte-compile-unresolved-functions)) |
| 1427 | nums sig min max) | 1396 | nums sig min max) |
| @@ -3046,12 +3015,13 @@ That command is designed for interactive use only" bytecomp-fn)) | |||
| 3046 | (if (or (not (symbolp bytecomp-var)) | 3015 | (if (or (not (symbolp bytecomp-var)) |
| 3047 | (byte-compile-const-symbol-p bytecomp-var | 3016 | (byte-compile-const-symbol-p bytecomp-var |
| 3048 | (not (eq base-op 'byte-varref)))) | 3017 | (not (eq base-op 'byte-varref)))) |
| 3049 | (byte-compile-warn | 3018 | (if (byte-compile-warning-enabled-p 'constants) |
| 3050 | (cond ((eq base-op 'byte-varbind) "attempt to let-bind %s `%s'") | 3019 | (byte-compile-warn |
| 3051 | ((eq base-op 'byte-varset) "variable assignment to %s `%s'") | 3020 | (cond ((eq base-op 'byte-varbind) "attempt to let-bind %s `%s'") |
| 3052 | (t "variable reference to %s `%s'")) | 3021 | ((eq base-op 'byte-varset) "variable assignment to %s `%s'") |
| 3053 | (if (symbolp bytecomp-var) "constant" "nonvariable") | 3022 | (t "variable reference to %s `%s'")) |
| 3054 | (prin1-to-string bytecomp-var)) | 3023 | (if (symbolp bytecomp-var) "constant" "nonvariable") |
| 3024 | (prin1-to-string bytecomp-var))) | ||
| 3055 | (and (get bytecomp-var 'byte-obsolete-variable) | 3025 | (and (get bytecomp-var 'byte-obsolete-variable) |
| 3056 | (not (memq bytecomp-var byte-compile-not-obsolete-vars)) | 3026 | (not (memq bytecomp-var byte-compile-not-obsolete-vars)) |
| 3057 | (byte-compile-warn-obsolete bytecomp-var)) | 3027 | (byte-compile-warn-obsolete bytecomp-var)) |
| @@ -3582,12 +3552,13 @@ If it is nil, then the handler is \"byte-compile-SYMBOL.\"" | |||
| 3582 | setters) | 3552 | setters) |
| 3583 | (while bytecomp-args | 3553 | (while bytecomp-args |
| 3584 | (let ((var (car bytecomp-args))) | 3554 | (let ((var (car bytecomp-args))) |
| 3585 | (if (or (not (symbolp var)) | 3555 | (and (or (not (symbolp var)) |
| 3586 | (byte-compile-const-symbol-p var t)) | 3556 | (byte-compile-const-symbol-p var t)) |
| 3587 | (byte-compile-warn | 3557 | (byte-compile-warning-enabled-p 'constants) |
| 3588 | "variable assignment to %s `%s'" | 3558 | (byte-compile-warn |
| 3589 | (if (symbolp var) "constant" "nonvariable") | 3559 | "variable assignment to %s `%s'" |
| 3590 | (prin1-to-string var))) | 3560 | (if (symbolp var) "constant" "nonvariable") |
| 3561 | (prin1-to-string var))) | ||
| 3591 | (push (list 'set-default (list 'quote var) (car (cdr bytecomp-args))) | 3562 | (push (list 'set-default (list 'quote var) (car (cdr bytecomp-args))) |
| 3592 | setters)) | 3563 | setters)) |
| 3593 | (setq bytecomp-args (cdr (cdr bytecomp-args)))) | 3564 | (setq bytecomp-args (cdr (cdr bytecomp-args)))) |
| @@ -4329,12 +4300,22 @@ invoked interactively." | |||
| 4329 | 4300 | ||
| 4330 | (message "Generating call tree...(finding uncalled functions...)") | 4301 | (message "Generating call tree...(finding uncalled functions...)") |
| 4331 | (setq rest byte-compile-call-tree) | 4302 | (setq rest byte-compile-call-tree) |
| 4332 | (let ((uncalled nil)) | 4303 | (let (uncalled def) |
| 4333 | (while rest | 4304 | (while rest |
| 4334 | (or (nth 1 (car rest)) | 4305 | (or (nth 1 (car rest)) |
| 4335 | (null (setq f (car (car rest)))) | 4306 | (null (setq f (caar rest))) |
| 4336 | (functionp (byte-compile-fdefinition f t)) | 4307 | (progn |
| 4337 | (commandp (byte-compile-fdefinition f nil)) | 4308 | (setq def (byte-compile-fdefinition f t)) |
| 4309 | (and (eq (car-safe def) 'macro) | ||
| 4310 | (eq (car-safe (cdr-safe def)) 'lambda) | ||
| 4311 | (setq def (cdr def))) | ||
| 4312 | (functionp def)) | ||
| 4313 | (progn | ||
| 4314 | (setq def (byte-compile-fdefinition f nil)) | ||
| 4315 | (and (eq (car-safe def) 'macro) | ||
| 4316 | (eq (car-safe (cdr-safe def)) 'lambda) | ||
| 4317 | (setq def (cdr def))) | ||
| 4318 | (commandp def)) | ||
| 4338 | (setq uncalled (cons f uncalled))) | 4319 | (setq uncalled (cons f uncalled))) |
| 4339 | (setq rest (cdr rest))) | 4320 | (setq rest (cdr rest))) |
| 4340 | (if uncalled | 4321 | (if uncalled |
| @@ -4342,10 +4323,8 @@ invoked interactively." | |||
| 4342 | (insert "Noninteractive functions not known to be called:\n ") | 4323 | (insert "Noninteractive functions not known to be called:\n ") |
| 4343 | (setq p (point)) | 4324 | (setq p (point)) |
| 4344 | (insert (mapconcat 'symbol-name (nreverse uncalled) ", ")) | 4325 | (insert (mapconcat 'symbol-name (nreverse uncalled) ", ")) |
| 4345 | (fill-region-as-paragraph p (point))))) | 4326 | (fill-region-as-paragraph p (point)))))) |
| 4346 | ) | 4327 | (message "Generating call tree...done."))) |
| 4347 | (message "Generating call tree...done.") | ||
| 4348 | )) | ||
| 4349 | 4328 | ||
| 4350 | 4329 | ||
| 4351 | ;;;###autoload | 4330 | ;;;###autoload |