Add a declaration
[sbcl.git] / src / code / early-source-location.lisp
blob58cb7012942ac23e82391e41a8d003e01dfb77b9
1 ;;;; Source location tracking macros.
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!C")
14 #| No calls to #'SOURCE-LOCATION must happen from this file because:
15 ;; - it would imply lack of location information for the definition,
16 ;; since deferring the call past compile-time means we've already lost.
17 ;; - it would be a style-warning to subsequently define the compiler-macro.
18 ;; (DEFINE-COMPILER-MACRO SOURCE-LOCATION) does not itself use SOURCE-LOCATION
19 ;; but this is possibly a mistake! Ordinary DEFMACRO supplies the location
20 ;; to %DEFMACRO. Compiler macros should too. This extra form will be needed:
21 (eval-when (#+sb-xc :compile-toplevel)
22 (setf (sb!int:info :function :compiler-macro-function 'source-location)
23 (lambda (form env)
24 (declare (ignore form env))
25 (make-definition-source-location)))) |#
27 #!+sb-source-locations
28 (progn
29 #-sb-xc-host
30 (define-compiler-macro source-location ()
31 (make-definition-source-location))
32 ;; We need a regular definition of SOURCE-LOCATION for calls processed
33 ;; during LOAD on a source file while *EVALUATOR-MODE* is :INTERPRET.
34 (defun source-location ()
35 #-sb-xc-host (make-definition-source-location)))
37 #!-sb-source-locations
38 (defun source-location () nil)
40 ;;; Used as the CDR of the code coverage instrumentation records
41 ;;; (instead of NIL) to ensure that any well-behaving user code will
42 ;;; not have constants EQUAL to that record. This avoids problems with
43 ;;; the records getting coalesced with non-record conses, which then
44 ;;; get mutated when the instrumentation runs. Note that it's
45 ;;; important for multiple records for the same location to be
46 ;;; coalesced. -- JES, 2008-01-02
47 (defconstant +code-coverage-unmarked+ '%code-coverage-unmarked%)
49 ;; FIXME: remove this obfuscatory macro
50 (defmacro with-source-location ((source-location) &body body)
51 `(when ,source-location
52 ,@body))