X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fir1report.lisp;h=25a7f57ee65578ba63300e615994dddc6b4e9a26;hb=4da7c01c1cd31a730308f1e610cf636569109aeb;hp=93dbf66e6bca2ab0d8ae0a4964a03db44d6c0868;hpb=9627f5a03e642fa950e1557fef17c506dfd386a6;p=sbcl.git diff --git a/src/compiler/ir1report.lisp b/src/compiler/ir1report.lisp index 93dbf66..25a7f57 100644 --- a/src/compiler/ir1report.lisp +++ b/src/compiler/ir1report.lisp @@ -85,10 +85,10 @@ Named form when it appears in the compiler input. Lambda-List is a DEFMACRO style lambda-list used to parse the arguments. The Body should return a list of subforms suitable for a \"~{~S ~}\" format string." - (let ((n-whole (gensym))) + (with-unique-names (whole) `(setf (gethash ',name *source-context-methods*) - (lambda (,n-whole) - (destructuring-bind ,lambda-list ,n-whole ,@body))))) + (lambda (,whole) + (destructuring-bind ,lambda-list ,whole ,@body))))) (define-source-context defstruct (name-or-options &rest slots) (declare (ignore slots)) @@ -174,49 +174,59 @@ ;;; list of things that are going to be printed out in the error ;;; message, and can thus be blown off when they appear in the source ;;; context. -(defun find-error-context (args) +;;; +;;; If OLD-CONTEXTS is passed in, and includes a context with the +;;; same original source path as the new context would have, the old +;;; context is reused instead, and a secondary value of T is returned. +(defun find-error-context (args &optional old-contexts) (let ((context *compiler-error-context*)) (if (compiler-error-context-p context) - context - (let ((path (or (and (boundp '*current-path*) *current-path*) - (if context - (node-source-path context) - nil)))) - (when (and *source-info* path) - (multiple-value-bind (form src-context) (find-original-source path) - (collect ((full nil cons) - (short nil cons)) - (let ((forms (source-path-forms path)) - (n 0)) - (dolist (src (if (member (first forms) args) - (rest forms) - forms)) - (if (>= n *enclosing-source-cutoff*) - (short (stringify-form (if (consp src) - (car src) - src) - nil)) - (full (stringify-form src))) - (incf n))) - - (let* ((tlf (source-path-tlf-number path)) - (file-info (source-info-file-info *source-info*))) - (make-compiler-error-context - :enclosing-source (short) - :source (full) - :original-source (stringify-form form) - :context src-context - :file-name (file-info-name file-info) - :file-position - (multiple-value-bind (ignore pos) - (find-source-root tlf *source-info*) - (declare (ignore ignore)) - pos) - :original-source-path - (source-path-original-source path) - :lexenv (if context - (node-lexenv context) - (if (boundp '*lexenv*) *lexenv* nil))))))))))) + (values context t) + (let* ((path (or (and (node-p context) (node-source-path context)) + (and (boundp '*current-path*) *current-path*))) + (old + (find (when path (source-path-original-source path)) + (remove-if #'null old-contexts) + :test #'equal + :key #'compiler-error-context-original-source-path))) + (if old + (values old t) + (when (and *source-info* path) + (multiple-value-bind (form src-context) (find-original-source path) + (collect ((full nil cons) + (short nil cons)) + (let ((forms (source-path-forms path)) + (n 0)) + (dolist (src (if (member (first forms) args) + (rest forms) + forms)) + (if (>= n *enclosing-source-cutoff*) + (short (stringify-form (if (consp src) + (car src) + src) + nil)) + (full (stringify-form src))) + (incf n))) + + (let* ((tlf (source-path-tlf-number path)) + (file-info (source-info-file-info *source-info*))) + (values + (make-compiler-error-context + :enclosing-source (short) + :source (full) + :original-source (stringify-form form) + :context src-context + :file-name (file-info-name file-info) + :file-position + (multiple-value-bind (ignore pos) + (find-source-root tlf *source-info*) + (declare (ignore ignore)) + pos) + :original-source-path (source-path-original-source path) + :lexenv (if context + (node-lexenv context) + (if (boundp '*lexenv*) *lexenv* nil))) + nil)))))))))) ;;;; printing error messages @@ -432,12 +442,13 @@ has written, having proved that it is unreachable.")) (let ((ep (first (block-succ (component-head component))))) (aver ep) ; else no entry points?? (multiple-value-bind (form context) - (find-original-source - (node-source-path (block-start-node ep))) + (find-original-source (node-source-path (block-start-node ep))) (declare (ignore form)) (let ((*print-level* 2) (*print-pretty* nil)) - (format nil "~{~{~S~^ ~}~^ => ~}" context))))) + (format nil "~{~{~S~^ ~}~^ => ~}" + #+sb-xc-host (list (list (caar context))) + #-sb-xc-host context))))) ;;;; condition system interface @@ -526,9 +537,11 @@ has written, having proved that it is unreachable.")) (res (or found (make-undefined-warning :name name :kind kind)))) (unless found (push res *undefined-warnings*)) - (when (or (not *undefined-warning-limit*) - (< (undefined-warning-count res) *undefined-warning-limit*)) - (push (find-error-context (list name)) - (undefined-warning-warnings res))) - (incf (undefined-warning-count res)))) + (multiple-value-bind (context old) + (find-error-context (list name) (undefined-warning-warnings res)) + (unless old + (when (or (not *undefined-warning-limit*) + (< (undefined-warning-count res) *undefined-warning-limit*)) + (push context (undefined-warning-warnings res))) + (incf (undefined-warning-count res)))))) (values))