summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
Commit message (Collapse)AuthorAgeFilesLines
* Allow inhibiting `not-unused' warningsLars Ingebrigtsen2021-10-131-1/+2
| | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-warning-types): Allow inhibiting the `not-unused' warning (bug#31641). (There has been some discussion about removing the `not-unused' warning, but it's still in there, so making it possible to inhibit it seems like the right thing to do.) * lisp/emacs-lisp/cconv.el (cconv--analyze-use): Don't warn about `not-unused'.
* ; Minor stylistic fixes found by checkdocStefan Kangas2021-10-051-3/+3
|
* Warn about overly long docstring in lambdaStefan Kangas2021-09-261-14/+8
| | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-docstring-length-warn): Warn about overly long docstring in lambda. (Bug#44858) (byte-compile--wide-docstring-p): Improve comment. * test/lisp/emacs-lisp/bytecomp-tests.el ("warn-wide-docstring-defun.el"): Update to test for the above new warning.
* Avoid false positives in bytecomp docstring width warningStefan Kangas2021-09-261-2/+10
| | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p): Ignore more function argument lists. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests-byte-compile--wide-docstring-p): New test.
* Renege on anonymous &rest (bug#50268, bug#50720)Mattias Engdegård2021-09-251-0/+2
| | | | | | | | | | | | | | | | Allowing &rest without a variable name following turned out not to be very useful, and it never worked properly. Disallow it. * lisp/emacs-lisp/bytecomp.el (byte-compile-check-lambda-list): * src/eval.c (funcall_lambda): Signal error for &rest without variable name. * doc/lispref/functions.texi (Argument List): Adjust manual. * etc/NEWS (file): Announce. * test/src/eval-tests.el (eval-tests--bugs-24912-and-24913): Extend test, also checking with and without lexical binding. (eval-tests-accept-empty-optional-rest): Reduce to... (eval-tests-accept-empty-optional): ...this, again checking with and without lexical binding.
* Don't quote nil and t in doc strings and commentsLars Ingebrigtsen2021-09-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/src/minibuf-tests.el (test-try-completion-ignore-case): * test/lisp/url/url-auth-tests.el (url-auth-test-digest-auth-retrieve-cache): * test/lisp/subr-tests.el (subr-tests-add-hook-depth): * test/lisp/so-long-tests/so-long-tests.el (so-long-tests-invisible-buffer-function): * test/lisp/emacs-lisp/tabulated-list-test.el (tabulated-list-sort): * src/xfaces.c: * src/process.c (Finterrupt_process): (syms_of_process): * src/minibuf.c (Fread_from_minibuffer): (Fcompleting_read): (syms_of_minibuf): * src/dispnew.c (syms_of_display): * src/data.c: * lisp/so-long.el (so-long--hack-local-variables): * lisp/progmodes/elisp-mode.el (elisp--xref-find-definitions): (elisp--xref-find-definitions): * lisp/org/ox-html.el (org-html-htmlize-output-type): * lisp/org/org-agenda.el (org-agenda-do-in-region): * lisp/net/tramp.el: * lisp/minibuffer.el (set-minibuffer-message): * lisp/isearch.el (isearch-wrap-pause): (isearch-repeat-on-direction-change): * lisp/emacs-lisp/timer.el (timer): * lisp/emacs-lisp/package.el (package-read-archive-contents): * lisp/emacs-lisp/faceup.el (faceup-next-property-change): * lisp/emacs-lisp/comp.el (comp-func): * lisp/emacs-lisp/comp-cstr.el (comp-cstr-empty-p): * lisp/emacs-lisp/cl-macs.el (cl-do): (cl-do*): (cl--self-tco): * lisp/emacs-lisp/bytecomp.el (byte-compile-unresolved-functions): (byte-compile-cond-jump-table): Don't quote t and nil.
* Improve doc strings of a recent commitEli Zaretskii2021-09-181-1/+1
| | | | | | | | * lisp/emacs-lisp/generator.el (iter-defun): * lisp/emacs-lisp/comp.el (comp-clean-up-stale-eln): * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): * lisp/emacs-lisp/autoload.el (autoload-insert-section-header): Include description of arguments in the doc string's first line.
* ; More stylistic docfixes in emacs-lisp/*.el found by checkdocStefan Kangas2021-09-181-2/+2
|
* ; More minor docfixes found by checkdocStefan Kangas2021-09-141-4/+4
|
* Add support for GCC compiler command-line optionsArthur Miller2021-09-101-0/+3
| | | | | | | | | * lisp/emacs-lisp/comp.el ('native-comp-compiler-options): New option. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Add support for new 'native-comp-compiler-options'. * src/comp.c (Fcomp_native_compiler_options_effective_p): New function. (add_compiler_options): New function. (Fcomp__compile_ctxt_to_file): Call 'add_compiler_options'.
* More robust optimisation of `ignore`Mattias Engdegård2021-09-061-0/+6
| | | | | | | | | | | | | | Treat `ignore` as any other function during source-level optimisation, to avoid having its warning-suppression effects cancelled by repeated passes. Instead, define a custom code generation function. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Don't treat `ignore' specially here. (side-effect-free-fns): Don't mark `ignore` as side-effect-free or error-free (although it is), since that would allow the optimiser to elide calls. * lisp/emacs-lisp/bytecomp.el (ignore, byte-compile-ignore): Define and register a code-gen function.
* Improve byte-compile-warnings doc stringLars Ingebrigtsen2021-08-231-2/+3
| | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-warnings): Mention 'byte-compile-docstring-max-column'.
* Single source optimiser entry pointMattias Engdegård2021-07-301-3/+3
| | | | | | | | | | | | Make the optimiser aware of lexical arguments. Otherwise we cannot know for sure whether a variable is lexical or dynamic during traversal. * lisp/emacs-lisp/byte-opt.el (byte-optimize-one-form): New optimiser entry point, replacing the recursive byte-optimize-form. * lisp/emacs-lisp/bytecomp.el (byte-optimize-one-form): Autoload. (byte-compile-keep-pending, byte-compile-top-level): Use byte-optimize-one-form.
* Make byte-recompile-directory less brittleLars Ingebrigtsen2021-07-281-2/+2
| | | | | * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): Don't interpret files named "~" as $HOME (bug#49758).
* Fix mistake in switch-case generation of `null` (bug#49746)Mattias Engdegård2021-07-271-1/+2
| | | | | | | | | Reported by Gregor Zattler. * lisp/emacs-lisp/bytecomp.el (byte-compile--cond-switch-prefix): Be more careful in the selection of equality. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases): Add test case.
* Warn about arity errors in inlining calls (bug#12299)Mattias Engdegård2021-07-231-10/+27
| | | | | | | | | | | | | | | Wrong number of arguments in inlining function calls (to `defsubst` or explicitly using `inline`) did not result in warnings, or in very cryptic ones. * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand): Add calls to `byte-compile--check-arity-bytecode`. * lisp/emacs-lisp/bytecomp.el (byte-compile-emit-callargs-warn) (byte-compile--check-arity-bytecode): New functions. (byte-compile-callargs-warn): Use factored-out function. * test/lisp/emacs-lisp/bytecomp-resources/warn-callargs-defsubst.el: * test/lisp/emacs-lisp/bytecomp-tests.el ("warn-callargs-defsubst.el"): New test case.
* Count (not X) as a switch conditionMattias Engdegård2021-07-201-0/+10
| | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--cond-switch-prefix): Treat (not VAR) and (null VAR) as (eq VAR nil) when computing the extent of switch ops.
* Avoid invalid regexp in wide docstring checkBasil L. Contovounesios2021-07-061-1/+1
| | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p): Avoid constructing an invalid regexp during byte-compilation by limiting the number of columns to the current RE_DUP_MAX of 65535. This protects against pathological values of fill-column, for example (bug#49426).
* Ignore .dir-locals-2.el files moreLars Ingebrigtsen2021-07-041-2/+1
| | | | | | * lisp/emacs-lisp/shadow.el (load-path-shadows-find): * lisp/emacs-lisp/bytecomp.el (byte-recompile-directory): Ignore .dir-locals-2.el, too (bug#23257).
* * Do not attempt to write .elc files when not necessary (bug#49118)Andrea Corallo2021-06-211-67/+67
| | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Do not attempt to write .elc files when not necessary.
* Fix false positives in docstring width warning with (fn...) constructs.Lars Ingebrigtsen2021-06-151-1/+4
| | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--wide-docstring-p): Don't consider the function signature when determining whether the doc string is too wide (bug#49007). (The signature is folded later when displaying help.)
* * Do not produce .elc temporary file when unnecessary (bug#48978)Andrea Corallo2021-06-141-15/+14
| | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-file): Produce .elc temporary files only when non native compiling or when native compiling but `byte+native-compile' is non nil.
* ;* lisp/emacs-lisp/bytecomp.el (byte-native-compiling): Typo fix.Andrea Corallo2021-06-141-1/+1
|
* * lisp/emacs-lisp/bytecomp.el (byte+native-compile): Update docstring.Andrea Corallo2021-06-141-5/+1
|
* Rename batch-byte-native-compile-for-bootstrap (bug#48743)Andrea Corallo2021-06-011-2/+2
| | | | | | | | | | | | | | | | * lisp/Makefile.in : Rename `batch-byte-native-compile-for-bootstrap' -> `batch-byte+native-compile. * lisp/emacs-lisp/bytecomp.el (byte+native-compile) (byte-compile-file): Rename `batch-byte-native-compile-for-bootstrap' -> `batch-byte+native-compile + `byte-native-for-bootstrap' -> `byte+native-compile'. * lisp/emacs-lisp/comp.el (comp-spill-lap-function, comp-final) (batch-native-compile, batch-byte+native-compile): Likewise. * lisp/emacs-lisp/bytecomp.el (byte+native-compile) (byte-compile-file): Likewise. * test/src/comp-tests.el (comp-tests-bootstrap): Rename `byte-native-for-bootstrap' -> `byte+native-compile'.
* Fix a few Edebug specifications where code is wrapped in lambdas.Philipp Stephani2021-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | As the Info node `(elisp) Specification List' explains, it is not correct to use `body' or t for a piece of code that the macro wraps in a `lambda' form. These should use `def-body' instead. * lisp/info-xref.el (info-xref-with-file): * lisp/subr.el (subr--with-wrapper-hook-no-warnings, track-mouse) (combine-change-calls, with-eval-after-load): * lisp/emacs-lisp/bytecomp.el (displaying-byte-compile-warnings): * lisp/emacs-lisp/cl-macs.el (cl-do-symbols, cl-progv): * lisp/emacs-lisp/ert-x.el (ert-with-test-buffer): * lisp/emacs-lisp/gv.el (gv-letplace): * lisp/emacs-lisp/nadvice.el (define-advice): * lisp/emacs-lisp/thunk.el (thunk-delay): * lisp/vc/vc-dispatcher.el (vc-run-delayed): Use 'def-body' instead of t or 'body' where applicable. * lisp/emacs-lisp/package.el (package--with-response-buffer): Remove evaluation of the body altogether. I have no idea how to write it correctly in this case.
* Rename comp-native-driver-options → native-comp-driver-optionsAndrea Corallo2021-05-061-2/+2
| | | | | | | | | * src/comp.c (add_driver_options, syms_of_comp): Rename comp-native-driver-options → native-comp-driver-options. * lisp/emacs-lisp/comp.el (native-comp-driver-options) (comp-ctxt, comp-spill-lap-function, comp-final) (comp-run-async-workers): Likewise. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Likewise.
* Rename comp-debug -> native-comp-debugAndrea Corallo2021-05-061-2/+2
| | | | | | | | | * src/comp.c (emit_ctxt_code, syms_of_comp): Rename comp-debug -> native-comp-debug. * lisp/emacs-lisp/comp.el (native-comp-debug, comp-ctxt) (comp-spill-lap-function, comp-run-async-workers): Likewise. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Likewise. * test/src/comp-tests.el (comp-tests-bootstrap): Likewise.
* Rename comp-speed -> native-comp-speedAndrea Corallo2021-05-061-2/+2
| | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Rename comp-speed -> native-comp-speed. * lisp/emacs-lisp/comp.el (native-comp-speed, comp-ctxt, comp-func, comp-spill-lap-function, comp-trampoline-compile, comp-run-async-workers): Likewise. * src/comp.c (emit_ctxt_code, load_comp_unit, syms_of_comp): Likewise. * test/src/comp-tests.el (comp-tests-tco, comp-tests-fw-prop-1) (comp-tests-check-ret-type-spec, comp-tests-pure): Likewise.
* Don't use pdumper-stats with unexecNikolay Kudryavtsev2021-05-021-1/+2
| | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-refresh-preloaded): Check if pdumper-stats is bound before using it.
* Merge remote-tracking branch 'savannah/master' into native-compAndrea Corallo2021-04-191-24/+39
|\
| * Add condition-case success handler (bug#47677)Mattias Engdegård2021-04-151-24/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow a condition-case handler on the form (:success BODY) to be specified as the success continuation of the protected form, with the specified variable bound to its result. * src/eval.c (Fcondition_case): Update the doc string. (internal_lisp_condition_case): Implement in interpreter. (syms_of_eval): Defsym :success. * lisp/emacs-lisp/bytecomp.el (byte-compile-condition-case): Implement in byte-compiler. * lisp/emacs-lisp/cl-macs.el (cl--self-tco): Allow self-TCO from success handler. * doc/lispref/control.texi (Handling Errors): Update manual. * etc/NEWS: Announce. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--test-cases) (bytecomp-condition-case-success): * test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs--labels): Add test cases.
* | Merge remote-tracking branch 'savannah/master' into native-compAndrea Corallo2021-03-251-51/+20
|\|
| * * lisp/emacs-lisp/bytecomp.el: Remember location of unresolved callsStefan Monnier2021-03-191-51/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've gotten tired of seeing the "function foo not known to be defined" warning without any line number information. So this patch adds as line number the position of the first use of that function in the file (well, approximately, as usual). (byte-compile-unresolved-functions): Add POSITIONs in the alist. (byte-compile-function-warn): Store the current position in `byte-compile-unresolved-functions`. (byte-compile-arglist-warn): Adjust accordingly. (byte-compile-print-syms): Delete unused function. (byte-compile-warn-about-unresolved-functions): Use the stored position to give more precise warnings.
* | Fix `no-byte-compile' native compilation interaction (bug#47169)Andrea Corallo2021-03-161-2/+1
| | | | | | | | | | | | | | * lisp/emacs-lisp/comp.el (comp-spill-lap-function): Throw no-native-compile when `byte-native-qualities' are null. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): No need to consider `no-byte-compile'.
* | Have `no-byte-compile' implies also `no-native-compile'.Andrea Corallo2021-03-161-1/+2
| | | | | | | | | | | | * lisp/emacs-lisp/comp.el (no-native-compile): Update doctring. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): when `no-byte-compile' is set to non-nil it overrides this.
* | * lisp/emacs-lisp/bytecomp.el: Fix native re-compilation (bug#47161).Andrea Corallo2021-03-151-0/+1
| |
* | Merge remote-tracking branch 'savannah/master' into native-compAndrea Corallo2021-03-121-4/+12
|\|
| * * lisp/emacs-lisp/bytecomp.el: Warn about unprefixed vars in `boundp`Stefan Monnier2021-03-071-4/+12
| | | | | | | | | | | | | | (byte-compile--check-prefixed-var): New fun, extracted from `byte-compile--declare-var`. (byte-compile--declare-var): Use it. (byte-compile-maybe-guarded): Use it as well.
* | Implement `no-native-compile' (bug#46983)Andrea Corallo2021-03-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Capture `no-native-compile'. * lisp/emacs-lisp/comp.el (no-native-compile): Define new variable. (comp-spill-lap-function): Throw when `no-native-compile' was captured non-nil. (comp--native-compile): Catch `no-native-compile' if necessary and return nil in case.
* | Merge commit '9cbdf20316' into native-compAndrea Corallo2021-03-091-28/+26
|\|
| * Compile closures that modify their bound vars correctly (Bug#46834)Pip Cet2021-03-021-23/+23
| | | | | | | | | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile--reify-function): Don't move let bindings into the lambda. Don't reverse list of bindings. (byte-compile): Evaluate the return value if it was previously reified. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-reify-function): Add tests.
| * * lisp/emacs-lisp/bytecomp.el: Fix minor regression introduced by pdumpStefan Monnier2021-02-271-2/+3
| | | | | | | | | | | | | | | | After `rm **/*.elc; make` we'd sometimes get loads and loads of unnecessary "Reloading ...". (byte-compile-refresh-preloaded): Don't reload files that are more recent than `temacs` but older than the `.pdmp` file.
| * * lisp/emacs-lisp/cconv.el: Improve line-nb info of unused var warningsStefan Monnier2021-02-261-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of warning about unused vars during the analysis phase of closure conversion, do it in the actual closure conversion by annotating the code with "unused" warnings, so that the warnings get emitted later by the bytecomp phase, like all other warnings, at which point the line-number info is a bit less imprecise. Take advantage of this change to wrap the expressions of unused let-bound vars inside (ignore ...) so the byte-compiler can better optimize them away. Finally, promote `macroexp--warn-and-return` to "official" status by removing its "--" marker. (cconv-captured+mutated, cconv-lambda-candidates): Remove vars. (cconv-var-classification): New var to replace them. (cconv-warnings-only): Delete function. (cconv--warn-unused-msg, cconv--var-classification): New functions. (cconv--convert-funcbody): Add warnings for unused args. (cconv-convert): Add warnings for unused vars in `let` and `condition-case`. (cconv--analyze-use): Don't emit an "unused var" warning any more, but instead remember the fact in `cconv-var-classification`. * lisp/emacs-lisp/bytecomp.el (byte-compile-force-lexical-warnings): Remove variable. (byte-compile-preprocess): Remove corresponding case. * lisp/emacs-lisp/pcase.el (pcase--if): Don't throw away `test` effects. (\`): * lisp/emacs-lisp/cl-macs.el (cl--do-arglist): Use `car-safe` instead of `car`, so it can more easily be removed by the optimizer if the result is not used. * lisp/emacs-lisp/macroexp.el (macroexp--warn-wrap): New function. (macroexp-warn-and-return): Rename from `macroexp--warn-and-return`.
* | Allow for `comp-native-driver-options' to work as a file-local variable.Andrea Corallo2021-03-071-1/+4
| |
* | Merge remote-tracking branch 'savannah/master' into native-compAndrea Corallo2021-02-261-14/+36
|\|
| * * lisp/emacs-lisp/macroexp.el (macroexp-file-name): Work in `eval-buffer`Stefan Monnier2021-02-241-1/+1
| | | | | | | | | | | | | | Rely on `current-load-list` instead of `load-file-name`. * lisp/emacs-lisp/bytecomp.el (byte-compile-close-variables): Change the var we override accordingly.
| * * lisp/emacs-lisp/macroexp.el (macroexp-file-name): New function.Stefan Monnier2021-02-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Yes, finally: a function that tells you the name of the file where the code is located. Finding this name is non-trivial in practice, as evidenced by the "4 shift/reduce conflicts" warning when compiling CEDET's python.el, because its `wisent-source` got it wrong in that case, thinking the grammar came from `python.el` instead of `python-wy.el`. While at it, also made `macroexp-compiling-p` public, since it's useful at various places. (macroexp-compiling-p): Rename from `macroexp--compiling-p`. * lisp/emacs-lisp/bytecomp.el (byte-compile-close-variables): Bind `load-file-name` to nil so we can distinguish a load that calls the byte compiler from a byte compilation which causes a load. * lisp/cedet/semantic/wisent/python.el (wisent-python--expected-conflicts): Remove; it was just a workaround. * lisp/subr.el (do-after-load-evaluation): Avoid `byte-compile--` vars. * lisp/cedet/semantic/fw.el (semantic-alias-obsolete): Use `macroexp-compiling-p` and `macroexp-file-name`. * lisp/cedet/semantic/wisent/comp.el (wisent-source): Use `macroexp-file-name` (wisent-total-conflicts): Tighten regexp. * lisp/emacs-lisp/cl-lib.el (cl--compiling-file): Delete function and variable. Use `macroexp-compiling-p` instead. * lisp/progmodes/flymake.el (flymake-log): * lisp/emacs-lisp/package.el (package-get-version): * lisp/emacs-lisp/ert-x.el (ert-resource-directory): Use `macroexp-file-name`.
| * Fix compilation of closures with nontrivial doc stringsMattias Engdegård2021-02-221-14/+31
| | | | | | | | | | | | * lisp/emacs-lisp/bytecomp.el (byte-compile-make-closure): Use the supplied doc string if it's a literal; fall back to the old slow way of building a closure otherwise.
* | Merge remote-tracking branch 'savannah/master' into HEADAndrea Corallo2021-02-211-10/+18
|\|